DOMWindowExtension.cpp [plain text]
#include "config.h"
#include "DOMWindowExtension.h"
#include "DOMWindow.h"
#include "DOMWrapperWorld.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
namespace WebCore {
DOMWindowExtension::DOMWindowExtension(Frame* frame, DOMWrapperWorld* world)
: DOMWindowProperty(frame)
, m_world(world)
, m_wasDetached(false)
{
ASSERT(this->frame());
ASSERT(m_world);
}
void DOMWindowExtension::disconnectFrameForPageCache()
{
RefPtr<DOMWindowExtension> protector = 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);
RefPtr<DOMWindowExtension> protector = this;
m_disconnectedFrame->loader()->client()->dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
m_disconnectedFrame = 0;
DOMWindowProperty::willDestroyGlobalObjectInCachedFrame();
}
void DOMWindowExtension::willDestroyGlobalObjectInFrame()
{
ASSERT(!m_disconnectedFrame);
RefPtr<DOMWindowExtension> protector = 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);
RefPtr<DOMWindowExtension> protector = this;
Frame* frame = this->frame();
ASSERT(frame);
frame->loader()->client()->dispatchWillDestroyGlobalObjectForDOMWindowExtension(this);
m_wasDetached = true;
DOMWindowProperty::willDetachGlobalObjectFromFrame();
}
}