DOMWrapperWorld.cpp [plain text]
#include "config.h"
#include "DOMWrapperWorld.h"
#include "JSDOMWindow.h"
#include "ScriptController.h"
#include "WebCoreJSClientData.h"
#include <wtf/MainThread.h>
using namespace JSC;
namespace WebCore {
DOMWrapperWorld::DOMWrapperWorld(JSC::VM* vm, bool isNormal)
: m_vm(vm)
, m_isNormal(isNormal)
{
VM::ClientData* clientData = m_vm->clientData;
ASSERT(clientData);
static_cast<WebCoreJSClientData*>(clientData)->rememberWorld(this);
}
DOMWrapperWorld::~DOMWrapperWorld()
{
VM::ClientData* clientData = m_vm->clientData;
ASSERT(clientData);
static_cast<WebCoreJSClientData*>(clientData)->forgetWorld(this);
while (!m_scriptControllersWithWindowShells.isEmpty())
(*m_scriptControllersWithWindowShells.begin())->destroyWindowShell(this);
}
void DOMWrapperWorld::clearWrappers()
{
m_wrappers.clear();
m_stringCache.clear();
while (!m_scriptControllersWithWindowShells.isEmpty())
(*m_scriptControllersWithWindowShells.begin())->destroyWindowShell(this);
}
DOMWrapperWorld* normalWorld(JSC::VM& vm)
{
VM::ClientData* clientData = vm.clientData;
ASSERT(clientData);
return static_cast<WebCoreJSClientData*>(clientData)->normalWorld();
}
DOMWrapperWorld* mainThreadNormalWorld()
{
ASSERT(isMainThread());
static DOMWrapperWorld* cachedNormalWorld = normalWorld(*JSDOMWindow::commonVM());
return cachedNormalWorld;
}
}