DOMWindowExtension.cpp [plain text]
#include "config.h"
#include "DOMWindowExtension.h"
#include "DOMWindow.h"
#include "DOMWrapperWorld.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClient.h"
#include <wtf/Ref.h>
namespace WebCore {
DOMWindowExtension::DOMWindowExtension(Frame* frame, DOMWrapperWorld& world)
: DOMWindowProperty(frame)
, m_world(&world)
, m_wasDetached(false)
{
ASSERT(this->frame());
}
void DOMWindowExtension::disconnectFrameForPageCache()
{
Ref<DOMWindowExtension> protect(*this);
Frame* frame = this->frame();
frame->loader().client().dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(this);
m_disconnectedFrame = frame;
DOMWindowProperty::disconnectFrameForPageCache();
}
void DOMWindowExtension::reconnectFrameFromPageCache(Frame* frame)
{
ASSERT(m_disconnectedFrame == frame);
DOMWindowProperty::reconnectFrameFromPageCache(frame);
m_disconnectedFrame = 0;
this->frame()->loader().client().dispatchDidReconnectDOMWindowExtensionToGlobalObject(this);
}
void DOMWindowExtension::willDestroyGlobalObjectInCachedFrame()
{
ASSERT(m_disconnectedFrame);
Ref<DOMWindowExtension> protect(*this);
m_disconnectedFrame->loader().client().dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
m_disconnectedFrame = 0;
DOMWindowProperty::willDestroyGlobalObjectInCachedFrame();
}
void DOMWindowExtension::willDestroyGlobalObjectInFrame()
{
ASSERT(!m_disconnectedFrame);
Ref<DOMWindowExtension> protect(*this);
if (!m_wasDetached) {
Frame* frame = this->frame();
ASSERT(frame);
frame->loader().client().dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
}
DOMWindowProperty::willDestroyGlobalObjectInFrame();
}
void DOMWindowExtension::willDetachGlobalObjectFromFrame()
{
ASSERT(!m_disconnectedFrame);
ASSERT(!m_wasDetached);
Ref<DOMWindowExtension> protect(*this);
Frame* frame = this->frame();
ASSERT(frame);
frame->loader().client().dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
m_wasDetached = true;
DOMWindowProperty::willDetachGlobalObjectFromFrame();
}
}