Title: [134089] trunk/Source/WebCore
Revision
134089
Author
commit-qu...@webkit.org
Date
2012-11-09 11:10:54 -0800 (Fri, 09 Nov 2012)

Log Message

[V8] Remove ScriptController::windowShell()
https://bugs.webkit.org/show_bug.cgi?id=100235

Patch by Dan Carney <dcar...@google.com> on 2012-11-09
Reviewed by Adam Barth.

Refactored windowShell(DOMWrapperWorld*) and
existingWindowShell(DOMWrapperWorld*) to be like JSC.

No new tests. No change in functionality.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateToV8Converters):
* bindings/v8/DOMWrapperWorld.cpp:
(WebCore::isolatedWorldMap):
(WebCore::DOMWrapperWorld::getAllWorlds):
(WebCore):
* bindings/v8/DOMWrapperWorld.h:
(DOMWrapperWorld):
* bindings/v8/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::addListener):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::~ScriptController):
(WebCore::ScriptController::clearForOutOfMemory):
(WebCore):
(WebCore::ScriptController::clearForClose):
(WebCore::ScriptController::updateSecurityOrigin):
(WebCore::ScriptController::initializeMainWorld): Returns true if the main world was initialized.
(WebCore::existingWindowShellWorkaroundWorld):
(WebCore::ScriptController::existingWindowShell):
(WebCore::ScriptController::windowShell):
(WebCore::ScriptController::evaluateInIsolatedWorld):
(WebCore::ScriptController::currentWorldContext):
(WebCore::ScriptController::mainWorldContext):
(WebCore::ScriptController::haveInterpreter):
(WebCore::ScriptController::enableEval):
(WebCore::ScriptController::disableEval):
(WebCore::ScriptController::clearWindowShell):
(WebCore::ScriptController::setContextDebugId):
(WebCore::ScriptController::updateDocument):
(WebCore::ScriptController::namedItemAdded):
(WebCore::ScriptController::namedItemRemoved):
* bindings/v8/ScriptController.h:
(ScriptController):
(WebCore::ScriptController::getAllWorlds):
* bindings/v8/V8Binding.cpp:
(WebCore::perContextDataForCurrentWorld):
(WebCore::handleOutOfMemory):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::initializeIfNeeded):
(WebCore::V8DOMWindowShell::updateDocument):
(WebCore::V8DOMWindowShell::namedItemAdded):
(WebCore::V8DOMWindowShell::namedItemRemoved):
* bindings/v8/V8DOMWindowShell.h:
(WebCore::V8DOMWindowShell::isContextInitialized):
(WebCore::V8DOMWindowShell::isGlobalInitialized):
* bindings/v8/custom/V8DocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8SVGDocumentCustom.cpp:
(WebCore::toV8):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134088 => 134089)


--- trunk/Source/WebCore/ChangeLog	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/ChangeLog	2012-11-09 19:10:54 UTC (rev 134089)
@@ -1,3 +1,67 @@
+2012-11-09  Dan Carney  <dcar...@google.com>
+
+        [V8] Remove ScriptController::windowShell()
+        https://bugs.webkit.org/show_bug.cgi?id=100235
+
+        Reviewed by Adam Barth.
+
+        Refactored windowShell(DOMWrapperWorld*) and
+        existingWindowShell(DOMWrapperWorld*) to be like JSC.
+
+        No new tests. No change in functionality.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateToV8Converters):
+        * bindings/v8/DOMWrapperWorld.cpp:
+        (WebCore::isolatedWorldMap):
+        (WebCore::DOMWrapperWorld::getAllWorlds):
+        (WebCore):
+        * bindings/v8/DOMWrapperWorld.h:
+        (DOMWrapperWorld):
+        * bindings/v8/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::addListener):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::~ScriptController):
+        (WebCore::ScriptController::clearForOutOfMemory):
+        (WebCore):
+        (WebCore::ScriptController::clearForClose):
+        (WebCore::ScriptController::updateSecurityOrigin):
+        (WebCore::ScriptController::initializeMainWorld): Returns true if the main world was initialized.
+        (WebCore::existingWindowShellWorkaroundWorld):
+        (WebCore::ScriptController::existingWindowShell):
+        (WebCore::ScriptController::windowShell):
+        (WebCore::ScriptController::evaluateInIsolatedWorld):
+        (WebCore::ScriptController::currentWorldContext):
+        (WebCore::ScriptController::mainWorldContext):
+        (WebCore::ScriptController::haveInterpreter):
+        (WebCore::ScriptController::enableEval):
+        (WebCore::ScriptController::disableEval):
+        (WebCore::ScriptController::clearWindowShell):
+        (WebCore::ScriptController::setContextDebugId):
+        (WebCore::ScriptController::updateDocument):
+        (WebCore::ScriptController::namedItemAdded):
+        (WebCore::ScriptController::namedItemRemoved):
+        * bindings/v8/ScriptController.h:
+        (ScriptController):
+        (WebCore::ScriptController::getAllWorlds):
+        * bindings/v8/V8Binding.cpp:
+        (WebCore::perContextDataForCurrentWorld):
+        (WebCore::handleOutOfMemory):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::V8DOMWindowShell::initializeIfNeeded):
+        (WebCore::V8DOMWindowShell::updateDocument):
+        (WebCore::V8DOMWindowShell::namedItemAdded):
+        (WebCore::V8DOMWindowShell::namedItemRemoved):
+        * bindings/v8/V8DOMWindowShell.h:
+        (WebCore::V8DOMWindowShell::isContextInitialized):
+        (WebCore::V8DOMWindowShell::isGlobalInitialized):
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8SVGDocumentCustom.cpp:
+        (WebCore::toV8):
+
 2012-11-09  Adam Barth  <aba...@webkit.org>
 
         [V8] Remove a level of indirection in DOMDataStore

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (134088 => 134089)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-09 19:10:54 UTC (rev 134089)
@@ -3406,8 +3406,8 @@
     if (IsSubType($dataNode, "Document")) {
         push(@implContent, <<END);
     if (Frame* frame = impl->frame()) {
-        if (frame->script()->windowShell()->context().IsEmpty() && frame->script()->windowShell()->initializeIfNeeded()) {
-            // initializeIfNeeded may have created a wrapper for the object, retry from the start.
+        if (frame->script()->initializeMainWorld()) {
+            // initializeMainWorld may have created a wrapper for the object, retry from the start.
             return ${className}::wrap(impl.get(), creationContext, isolate);
         }
     }

Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -55,14 +55,22 @@
     return cachedNormalWorld.get();
 }
 
-// FIXME: This should probably go to PerIsolateData.
 typedef HashMap<int, DOMWrapperWorld*> WorldMap;
 static WorldMap& isolatedWorldMap()
 {
+    ASSERT(isMainThread());
     DEFINE_STATIC_LOCAL(WorldMap, map, ());
     return map;
 }
 
+void DOMWrapperWorld::getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds)
+{
+    worlds.append(mainThreadNormalWorld());
+    WorldMap& isolatedWorlds = isolatedWorldMap();
+    for (WorldMap::iterator it = isolatedWorlds.begin(); it != isolatedWorlds.end(); ++it)
+        worlds.append(it->value);
+}
+
 void DOMWrapperWorld::deallocate(DOMWrapperWorld* world)
 {
     int worldId = world->worldId();

Modified: trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/DOMWrapperWorld.h	2012-11-09 19:10:54 UTC (rev 134089)
@@ -51,6 +51,7 @@
     static PassRefPtr<DOMWrapperWorld> ensureIsolatedWorld(int worldId, int extensionGroup);
     static bool isolatedWorldsExist() { return isolatedWorldCount; }
     static bool isIsolatedWorldId(int worldId) { return worldId != mainWorldId && worldId != uninitializedWorldId; }
+    static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds);
     // Associates an isolated world (see above for description) with a security
     // origin. XMLHttpRequest instances used in that world will be considered
     // to come from that origin, not the frame's.

Modified: trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -92,8 +92,8 @@
     }
     m_listenersMap.set(page, listener);
 
-    V8DOMWindowShell* shell = scriptController->windowShell();
-    if (!shell->isContextInitialized())
+    V8DOMWindowShell* shell = scriptController->existingWindowShell(mainThreadNormalWorld());
+    if (!shell || !shell->isContextInitialized())
         return;
     v8::Handle<v8::Context> context = shell->context();
     v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts")));

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -33,6 +33,7 @@
 #include "ScriptController.h"
 
 #include "BindingState.h"
+#include "ContentSecurityPolicy.h"
 #include "DOMWindow.h"
 #include "Document.h"
 #include "Event.h"
@@ -111,7 +112,7 @@
 
 ScriptController::~ScriptController()
 {
-    windowShell()->destroyGlobal();
+    m_windowShell->destroyGlobal();
     clearForClose();
 }
 
@@ -154,17 +155,23 @@
     V8GCController::hintForCollectGarbage();
 }
 
+void ScriptController::clearForOutOfMemory()
+{
+    clearForClose();
+    m_windowShell->destroyGlobal();
+}
+
 void ScriptController::clearForClose()
 {
     double start = currentTime();
     reset();
-    windowShell()->clearForClose();
+    m_windowShell->clearForClose();
     HistogramSupport::histogramCustomCounts("WebCore.ScriptController.clearForClose", (currentTime() - start) * 1000, 0, 10000, 50);
 }
 
 void ScriptController::updateSecurityOrigin()
 {
-    windowShell()->updateSecurityOrigin();
+    m_windowShell->updateSecurityOrigin();
 }
 
 void ScriptController::updatePlatformScriptObjects()
@@ -310,46 +317,64 @@
     return ScriptValue(object);
 }
 
-V8DOMWindowShell* ScriptController::ensureIsolatedWorldContext(int worldId, int extensionGroup)
+bool ScriptController::initializeMainWorld()
 {
-    ASSERT(worldId != DOMWrapperWorld::mainWorldId);
+    if (m_windowShell->isContextInitialized())
+        return false;
+    return windowShell(mainThreadNormalWorld())->isContextInitialized();
+}
 
-    // Check the map for non-temporary worlds.
-    if (worldId != DOMWrapperWorld::uninitializedWorldId) {
-        IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);
-        if (iter != m_isolatedWorlds.end()) {
-            ASSERT(iter->value->world()->worldId() == worldId);
-            ASSERT(iter->value->world()->extensionGroup() == extensionGroup);
-            return iter->value;
-        }
-    }
-
-    RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(worldId, extensionGroup);
-    OwnPtr<V8DOMWindowShell> isolatedWorldShell = V8DOMWindowShell::create(m_frame, world);
-    m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.get());
-    return isolatedWorldShell.leakPtr();
+// FIXME: Remove this function. There is currently an issue with the inspector related to the call to dispatchDidClearWindowObjectInWorld in ScriptController::windowShell.
+static DOMWrapperWorld* existingWindowShellWorkaroundWorld()
+{
+    DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, world, (DOMWrapperWorld::createUninitializedWorld()));
+    return world.get();
 }
 
-V8DOMWindowShell* ScriptController::existingWindowShellInternal(DOMWrapperWorld* world)
+V8DOMWindowShell* ScriptController::existingWindowShell(DOMWrapperWorld* world)
 {
     ASSERT(world);
 
-    if (LIKELY(world->isMainWorld()))
+    if (world->isMainWorld())
+        return m_windowShell->isContextInitialized() ? m_windowShell.get() : 0;
+
+    // FIXME: Remove this block. See comment with existingWindowShellWorkaroundWorld().
+    if (world->worldId() == DOMWrapperWorld::uninitializedWorldId) {
+        ASSERT(world == existingWindowShellWorkaroundWorld());
         return m_windowShell.get();
+    }
 
     IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world->worldId());
-    return iter == m_isolatedWorlds.end() ? 0 : iter->value;
+    if (iter == m_isolatedWorlds.end())
+        return 0;
+    return iter->value->isContextInitialized() ? iter->value : 0;
 }
 
 V8DOMWindowShell* ScriptController::windowShell(DOMWrapperWorld* world)
 {
-    V8DOMWindowShell* shell = existingWindowShellInternal(world);
-    if (LIKELY(!!shell))
-        return shell;
+    ASSERT(world);
 
-    OwnPtr<V8DOMWindowShell> isolatedWorldShell = V8DOMWindowShell::create(m_frame, world);
-    m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.get());
-    return isolatedWorldShell.leakPtr();
+    V8DOMWindowShell* shell = 0;
+    if (world->isMainWorld())
+        shell = m_windowShell.get();
+    else {
+        IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(world->worldId());
+        if (iter != m_isolatedWorlds.end())
+            shell = iter->value;
+        else {
+            OwnPtr<V8DOMWindowShell> isolatedWorldShell = V8DOMWindowShell::create(m_frame, world);
+            shell = isolatedWorldShell.get();
+            m_isolatedWorlds.set(world->worldId(), isolatedWorldShell.leakPtr());
+        }
+    }
+    if (!shell->isContextInitialized() && shell->initializeIfNeeded()) {
+        if (world->isMainWorld()) {
+            // FIXME: Remove this if clause. See comment with existingWindowShellWorkaroundWorld().
+            m_frame->loader()->dispatchDidClearWindowObjectInWorld(existingWindowShellWorkaroundWorld());
+        } else
+            m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);
+    }
+    return shell;
 }
 
 void ScriptController::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup, Vector<ScriptValue>* results)
@@ -363,10 +388,10 @@
     v8::Local<v8::Array> v8Results;
     {
         v8::HandleScope evaluateHandleScope;
-        V8DOMWindowShell* isolatedWorldShell = ensureIsolatedWorldContext(worldID, extensionGroup);
+        RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(worldID, extensionGroup);
+        V8DOMWindowShell* isolatedWorldShell = windowShell(world.get());
 
-        isolatedWorldShell->initializeIfNeeded();
-        if (isolatedWorldShell->context().IsEmpty())
+        if (!isolatedWorldShell->isContextInitialized())
             return;
 
         v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedWorldShell->context());
@@ -423,14 +448,12 @@
             return v8::Local<v8::Context>();
         return v8::Local<v8::Context>::New(context);
     }
-    windowShell()->initializeIfNeeded();
-    return v8::Local<v8::Context>::New(windowShell()->context());
+    return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
 }
 
 v8::Local<v8::Context> ScriptController::mainWorldContext()
 {
-    windowShell()->initializeIfNeeded();
-    return v8::Local<v8::Context>::New(windowShell()->context());
+    return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
 }
 
 v8::Local<v8::Context> ScriptController::mainWorldContext(Frame* frame)
@@ -461,26 +484,23 @@
 
 bool ScriptController::haveInterpreter() const
 {
-    return windowShell()->isContextInitialized();
+    return m_windowShell->isContextInitialized();
 }
 
 void ScriptController::enableEval()
 {
+    if (!m_windowShell->isContextInitialized())
+        return;
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> v8Context = windowShell()->context();
-    if (v8Context.IsEmpty())
-        return;
-
-    v8Context->AllowCodeGenerationFromStrings(true);
+    m_windowShell->context()->AllowCodeGenerationFromStrings(true);
 }
 
 void ScriptController::disableEval(const String& errorMessage)
 {
+    if (!m_windowShell->isContextInitialized())
+        return;
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> v8Context = windowShell()->context();
-    if (v8Context.IsEmpty())
-        return;
-
+    v8::Handle<v8::Context> v8Context = m_windowShell->context();
     v8Context->AllowCodeGenerationFromStrings(false);
     v8Context->SetErrorMessageForCodeGenerationFromStrings(v8String(errorMessage));
 }
@@ -539,11 +559,6 @@
     m_pluginObjects.remove(it);
 }
 
-void ScriptController::getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds)
-{
-    worlds.append(mainThreadNormalWorld());
-}
-
 void ScriptController::evaluateInWorld(const ScriptSourceCode& source,
                                        DOMWrapperWorld* world)
 {
@@ -642,7 +657,7 @@
     reset();
     // V8 binding expects ScriptController::clearWindowShell only be called
     // when a frame is loading a new page. This creates a new context for the new page.
-    windowShell()->clearForNavigation();
+    m_windowShell->clearForNavigation();
     HistogramSupport::histogramCustomCounts("WebCore.ScriptController.clearWindowShell", (currentTime() - start) * 1000, 0, 10000, 50);
 }
 
@@ -672,10 +687,10 @@
 bool ScriptController::setContextDebugId(int debugId)
 {
     ASSERT(debugId > 0);
+    if (!m_windowShell->isContextInitialized())
+        return false;
     v8::HandleScope scope;
-    v8::Handle<v8::Context> context = windowShell()->context();
-    if (context.IsEmpty())
-        return false;
+    v8::Handle<v8::Context> context = m_windowShell->context();
     if (!context->GetData()->IsUndefined())
         return false;
 
@@ -708,17 +723,22 @@
 
 void ScriptController::updateDocument()
 {
-    windowShell()->updateDocument();
+    // For an uninitialized main window shell, do not incur the cost of context initialization during FrameLoader::init().
+    if ((!m_windowShell->isContextInitialized() || !m_windowShell->isGlobalInitialized()) && m_frame->loader()->stateMachine()->creatingInitialEmptyDocument())
+        return;
+
+    if (!initializeMainWorld())
+        windowShell(mainThreadNormalWorld())->updateDocument();
 }
 
 void ScriptController::namedItemAdded(HTMLDocument* doc, const AtomicString& name)
 {
-    windowShell()->namedItemAdded(doc, name);
+    windowShell(mainThreadNormalWorld())->namedItemAdded(doc, name);
 }
 
 void ScriptController::namedItemRemoved(HTMLDocument* doc, const AtomicString& name)
 {
-    windowShell()->namedItemRemoved(doc, name);
+    windowShell(mainThreadNormalWorld())->namedItemRemoved(doc, name);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-11-09 19:10:54 UTC (rev 134089)
@@ -66,11 +66,9 @@
     ScriptController(Frame*);
     ~ScriptController();
 
-    V8DOMWindowShell* windowShell() const { return m_windowShell.get(); }
+    bool initializeMainWorld();
     V8DOMWindowShell* windowShell(DOMWrapperWorld*);
-    // FIXME: Replace existingWindowShell with existingWindowShellInternal see comment in V8DOMWindowShell::initializeIfNeeded.
-    ScriptController* existingWindowShell(DOMWrapperWorld*) { return this; }
-    V8DOMWindowShell* existingWindowShellInternal(DOMWrapperWorld*);
+    V8DOMWindowShell* existingWindowShell(DOMWrapperWorld*);
 
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
@@ -173,13 +171,17 @@
     void cleanupScriptObjectsForPlugin(Widget*);
 
     void clearForClose();
+    void clearForOutOfMemory();
 
+
     NPObject* createScriptObjectForPluginElement(HTMLPlugInElement*);
     NPObject* windowScriptNPObject();
 
-    // Dummy method to avoid a bunch of ifdef's in WebCore.
     void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
-    static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds);
+    static void getAllWorlds(Vector<RefPtr<DOMWrapperWorld> >& worlds)
+    {
+        DOMWrapperWorld::getAllWorlds(worlds);
+    }
 
     // Registers a v8 extension to be available on webpages. Will only
     // affect v8 contexts initialized after this call. Takes ownership of
@@ -201,7 +203,6 @@
     Frame* m_frame;
     const String* m_sourceURL;
 
-    V8DOMWindowShell* ensureIsolatedWorldContext(int worldId, int extensionGroup);
     OwnPtr<V8DOMWindowShell> m_windowShell;
 
     // The isolated worlds we are tracking for this frame. We hold them alive

Modified: trunk/Source/WebCore/bindings/v8/V8Binding.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/V8Binding.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -323,7 +323,8 @@
     V8DOMWindowShell* isolatedShell;
     if (UNLIKELY(!!(isolatedShell = V8DOMWindowShell::getEntered())))
         return isolatedShell->perContextData();
-    return frame->script()->windowShell()->perContextData();
+    V8DOMWindowShell* mainShell = frame->script()->existingWindowShell(mainThreadNormalWorld());
+    return mainShell ? mainShell->perContextData() : 0;
 }
 
 bool handleOutOfMemory()
@@ -338,8 +339,7 @@
     if (!frame)
         return true;
 
-    frame->script()->clearForClose();
-    frame->script()->windowShell()->destroyGlobal();
+    frame->script()->clearForOutOfMemory();
 
 #if PLATFORM(CHROMIUM)
     frame->loader()->client()->didExhaustMemoryAvailableForScript();

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -200,12 +200,6 @@
 {
 }
 
-bool V8DOMWindowShell::isContextInitialized()
-{
-    ASSERT(m_context.isEmpty() || !m_global.isEmpty());
-    return !m_context.isEmpty();
-}
-
 void V8DOMWindowShell::destroyIsolatedShell()
 {
     disposeContext(true);
@@ -346,9 +340,8 @@
 
     // Flag context as isolated.
     if (!isMainWorld) {
-        V8DOMWindowShell* mainWindow = m_frame->script()->windowShell();
-        mainWindow->initializeIfNeeded();
-        if (!mainWindow->context().IsEmpty())
+        V8DOMWindowShell* mainWindow = m_frame->script()->existingWindowShell(mainThreadNormalWorld());
+        if (mainWindow && !mainWindow->context().IsEmpty())
             setInjectedScriptContextDebugId(m_context.get(), m_frame->script()->contextDebugId(mainWindow->context()));
         setIsolatedWorldField(this, context);
     }
@@ -388,13 +381,6 @@
         }
     }
     m_frame->loader()->client()->didCreateScriptContext(m_context.get(), m_world->extensionGroup(), m_world->worldId());
-
-    if (isMainWorld) {
-        // FIXME: This call is probably in the wrong spot, but causes a test timeout for http/tests/misc/window-open-then-write.html when removed.
-        // Additionally, ScriptController::existingWindowShell cannot be correctly implemented until this call is gone.
-        m_frame->loader()->dispatchDidClearWindowObjectInWorld(0);
-    }
-
     return true;
 }
 
@@ -552,7 +538,7 @@
     ASSERT(m_world->isMainWorld());
     if (m_global.isEmpty())
         return;
-    if (!initializeIfNeeded())
+    if (m_context.isEmpty())
         return;
     updateDocumentProperty();
     updateSecurityOrigin();
@@ -577,7 +563,7 @@
 {
     ASSERT(m_world->isMainWorld());
 
-    if (!initializeIfNeeded())
+    if (m_context.isEmpty())
         return;
 
     v8::HandleScope handleScope;
@@ -592,10 +578,10 @@
 {
     ASSERT(m_world->isMainWorld());
 
-    if (document->hasNamedItem(name.impl()) || document->hasExtraNamedItem(name.impl()))
+    if (m_context.isEmpty())
         return;
 
-    if (!initializeIfNeeded())
+    if (document->hasNamedItem(name.impl()) || document->hasExtraNamedItem(name.impl()))
         return;
 
     v8::HandleScope handleScope;

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h	2012-11-09 19:10:54 UTC (rev 134089)
@@ -67,7 +67,8 @@
     // (e.g., after setting docoument.domain).
     void updateSecurityOrigin();
 
-    bool isContextInitialized();
+    bool isContextInitialized() { return !m_context.isEmpty(); }
+    bool isGlobalInitialized() { return !m_global.isEmpty(); }
 
     v8::Persistent<v8::Context> createNewContext(v8::Handle<v8::Object> global, int extensionGroup, int worldId);
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -110,7 +110,7 @@
         return wrapper;
     if (!V8DOMWindowShell::getEntered()) {
         if (Frame* frame = impl->frame())
-            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
+            frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -185,7 +185,7 @@
         return wrapper;
     if (!V8DOMWindowShell::getEntered()) {
         if (Frame* frame = impl->frame())
-            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
+            frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp (134088 => 134089)


--- trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-11-09 19:07:22 UTC (rev 134088)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-11-09 19:10:54 UTC (rev 134089)
@@ -47,7 +47,7 @@
         return wrapper;
     if (!V8DOMWindowShell::getEntered()) {
         if (Frame* frame = impl->frame())
-            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
+            frame->script()->windowShell(mainThreadNormalWorld())->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to