[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

abarth at webkit.org abarth at webkit.org
Thu Apr 8 00:56:13 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 7f7bf604908393f0ccf9b14a80869b6d57904fae
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 7 00:47:00 2010 +0000

    2010-01-06  Adam Barth  <abarth at webkit.org>
    
            No review, rolling out r52877.
            http://trac.webkit.org/changeset/52877
            https://bugs.webkit.org/show_bug.cgi?id=33243
    
            I screwedd up landing this patch and only partially applied the patch I
            was trying to land.
    
            * bindings/ScriptControllerBase.cpp:
            * bindings/js/ScriptController.cpp:
            (WebCore::ScriptController::executeScriptInWorld):
            * bindings/v8/ScriptController.cpp:
            (WebCore::ScriptController::ScriptController):
            (WebCore::ScriptController::~ScriptController):
            (WebCore::ScriptController::updateSecurityOrigin):
            (WebCore::ScriptController::evaluateInIsolatedWorld):
            (WebCore::ScriptController::haveInterpreter):
            (WebCore::ScriptController::mainWorldWindowShell):
            (WebCore::ScriptController::clearWindowShell):
            (WebCore::ScriptController::clearForClose):
            (WebCore::ScriptController::destroyWindowShell):
            (WebCore::ScriptController::updateDocument):
            * bindings/v8/ScriptController.h:
            (WebCore::ScriptController::proxy):
            (WebCore::ScriptController::windowShell):
            (WebCore::ScriptController::existingWindowShell):
            (WebCore::ScriptController::evaluateInWorld):
            * bindings/v8/V8DOMWindowShell.cpp:
            (WebCore::V8DOMWindowShell::create):
            (WebCore::V8DOMWindowShell::V8DOMWindowShell):
            (WebCore::V8DOMWindowShell::initContextIfNeeded):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52882 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 53a02f2..e08ead4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,36 @@
+2010-01-06  Adam Barth  <abarth at webkit.org>
+
+        No review, rolling out r52877.
+        http://trac.webkit.org/changeset/52877
+        https://bugs.webkit.org/show_bug.cgi?id=33243
+
+        I screwedd up landing this patch and only partially applied the patch I
+        was trying to land.
+
+        * bindings/ScriptControllerBase.cpp:
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::executeScriptInWorld):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::ScriptController):
+        (WebCore::ScriptController::~ScriptController):
+        (WebCore::ScriptController::updateSecurityOrigin):
+        (WebCore::ScriptController::evaluateInIsolatedWorld):
+        (WebCore::ScriptController::haveInterpreter):
+        (WebCore::ScriptController::mainWorldWindowShell):
+        (WebCore::ScriptController::clearWindowShell):
+        (WebCore::ScriptController::clearForClose):
+        (WebCore::ScriptController::destroyWindowShell):
+        (WebCore::ScriptController::updateDocument):
+        * bindings/v8/ScriptController.h:
+        (WebCore::ScriptController::proxy):
+        (WebCore::ScriptController::windowShell):
+        (WebCore::ScriptController::existingWindowShell):
+        (WebCore::ScriptController::evaluateInWorld):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::V8DOMWindowShell::create):
+        (WebCore::V8DOMWindowShell::V8DOMWindowShell):
+        (WebCore::V8DOMWindowShell::initContextIfNeeded):
+
 2010-01-06  Eric Seidel  <eric at webkit.org>
 
         Unreviewed.  Rolling back in a change I should not have rolled out.
diff --git a/WebCore/bindings/ScriptControllerBase.cpp b/WebCore/bindings/ScriptControllerBase.cpp
index 59b2a1b..72c9f45 100644
--- a/WebCore/bindings/ScriptControllerBase.cpp
+++ b/WebCore/bindings/ScriptControllerBase.cpp
@@ -53,25 +53,6 @@ ScriptValue ScriptController::executeScript(const ScriptSourceCode& sourceCode)
     return result;
 }
 
-ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
-{
-    ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
-
-    if (!isEnabled() || isPaused())
-        return ScriptValue();
-
-    bool wasInExecuteScript = m_inExecuteScript;
-    m_inExecuteScript = true;
-
-    ScriptValue result = evaluateInWorld(sourceCode, world);
-
-    if (!wasInExecuteScript) {
-        m_inExecuteScript = false;
-        Document::updateStyleForAllDocuments();
-    }
-
-    return result;
-}
 
 bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument)
 {
diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp
index d778122..3c440db 100644
--- a/WebCore/bindings/js/ScriptController.cpp
+++ b/WebCore/bindings/js/ScriptController.cpp
@@ -446,4 +446,24 @@ void ScriptController::clearScriptObjects()
 #endif
 }
 
+ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture)
+{
+    ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->loader()->url());
+
+    if (!isEnabled() || isPaused())
+        return ScriptValue();
+
+    bool wasInExecuteScript = m_inExecuteScript;
+    m_inExecuteScript = true;
+
+    ScriptValue result = evaluateInWorld(sourceCode, world);
+
+    if (!wasInExecuteScript) {
+        m_inExecuteScript = false;
+        Document::updateStyleForAllDocuments();
+    }
+
+    return result;
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 61923b8..456a038 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -60,25 +60,6 @@
 
 namespace WebCore {
 
-PassRefPtr<DOMWrapperWorld> ScriptController::createWorld()
-{
-    return IsolatedWorld::create();
-}
-
-V8DOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world)
-{
-    ASSERT(!m_windowShells.contains(world));
-
-    RefPtr<V8DOMWindowShell> windowShell = V8DOMWindowShell::create(m_frame, world);
-    m_windowShells.add(world, windowShell);
-    windowShell->initContextIfNeeded();
-    windowShell->updateDocument();
-
-    m_frame->loader()->dispatchDidClearWindowObjectInWorld(world);
-
-    return windowShell.get();
-}
-
 void ScriptController::initializeThreading()
 {
     static bool initializedThreading = false;
@@ -125,6 +106,7 @@ ScriptController::ScriptController(Frame* frame)
     , m_processingTimerCallback(false)
     , m_paused(false)
     , m_proxy(new V8Proxy(frame))
+    , m_windowShell(V8DOMWindowShell::create(frame))
 #if ENABLE(NETSCAPE_PLUGIN_API)
     , m_windowScriptNPObject(0)
 #endif
@@ -135,12 +117,7 @@ ScriptController::ScriptController(Frame* frame)
 ScriptController::~ScriptController()
 {
     m_proxy->disconnectFrame();
-
-    if (!m_windowShells.isEmpty()) {
-        m_windowShells.clear();
-        m_mainWorldWindowShell = 0;
-        // JSC triggers a GC here, but we haven't historically.
-    }
+    m_windowShell.clear();
 }
 
 void ScriptController::clearScriptObjects()
@@ -165,8 +142,7 @@ void ScriptController::clearScriptObjects()
 
 void ScriptController::updateSecurityOrigin()
 {
-    for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
-        iter->second->updateSecurityOrigin();
+    m_windowShell->updateSecurityOrigin();
 }
 
 void ScriptController::updatePlatformScriptObjects()
@@ -232,9 +208,7 @@ bool ScriptController::anyPageIsProcessingUserGesture() const
 void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>& sources)
 {
     // FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
-    
-    // Force the mainWindowShell to exist.
-    windowShell(mainThreadNormalWorld());
+    m_windowShell->initContextIfNeeded();
     m_proxy->evaluateInIsolatedWorld(worldID, sources, 0);
 }
 
@@ -274,13 +248,6 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
     return ScriptValue(object);
 }
 
-ScriptValue ScriptController::evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*)
-{
-    // FIXME: Move isolated world execution to here!
-    notImplemented();
-    return ScriptValue();
-}
-
 void ScriptController::setEventHandlerLineNumber(int lineNumber)
 {
     m_proxy->setEventHandlerLineNumber(lineNumber);
@@ -326,6 +293,11 @@ void ScriptController::lowMemoryNotification()
     v8::V8::LowMemoryNotification();
 }
 
+bool ScriptController::haveInterpreter() const
+{
+    return m_windowShell->isContextInitialized();
+}
+
 bool ScriptController::isEnabled() const
 {
     Settings* settings = m_proxy->frame()->settings();
@@ -467,11 +439,10 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
     return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(v8plugin), window);
 }
 
-V8DOMWindowShell* ScriptController::mainWorldWindowShell()
+V8DOMWindowShell* ScriptController::mainWorldWindowShell() const
 {
-    if (!m_mainWorldWindowShell)
-        m_mainWorldWindowShell = windowShell(mainThreadNormalWorld());
-    return m_mainWorldWindowShell.get();
+    m_windowShell->initContextIfNeeded();
+    return m_windowShell.get();
 }
 
 void ScriptController::clearWindowShell()
@@ -482,20 +453,18 @@ void ScriptController::clearWindowShell()
     // V8 binding expects ScriptController::clearWindowShell only be called
     // when a frame is loading a new page. V8DOMWindowShell::clearForNavigation
     // creates a new context for the new page.
-    for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
-        iter->second->clearForNavigation();
+    m_windowShell->clearForNavigation();
 }
 
 void ScriptController::clearForClose()
 {
-    for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
-        iter->second->clearForClose();
+    m_windowShell->clearForClose();
 }
 
 void ScriptController::destroyWindowShell()
 {
-    m_windowShells.clear();
-    m_mainWorldWindowShell = 0;
+    m_windowShell->clearForClose();
+    m_windowShell->destroyGlobal();
 }
 
 void ScriptController::attachDebugger(void*)
@@ -505,12 +474,7 @@ void ScriptController::attachDebugger(void*)
 
 void ScriptController::updateDocument()
 {
-    // This seems redudant, but JSC does it.
-    if (!m_frame->document())
-        return;
-
-    for (ShellMap::iterator iter = m_windowShells.begin(); iter != m_windowShells.end(); ++iter)
-        iter->second->updateDocument();
+    m_windowShell->updateDocument();
 }
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index 25a4811..958ebfb 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -51,40 +51,22 @@ class HTMLPlugInElement;
 class ScriptSourceCode;
 class ScriptState;
 class String;
-class V8DOMWindow;
 class Widget;
 class XSSAuditor;
 
 class ScriptController {
-    typedef WTF::HashMap< RefPtr<DOMWrapperWorld>, RefPtr<V8DOMWindowShell> > ShellMap;
-
 public:
     ScriptController(Frame*);
     ~ScriptController();
 
-    static PassRefPtr<DOMWrapperWorld> createWorld();
-
-    V8DOMWindowShell* windowShell(DOMWrapperWorld* world)
-    {
-        ShellMap::iterator iter = m_windowShells.find(world);
-        return (iter != m_windowShells.end()) ? iter->second.get() : initScript(world);
-    }
-    V8DOMWindowShell* existingWindowShell(DOMWrapperWorld* world) const
-    {
-        ShellMap::const_iterator iter = m_windowShells.find(world);
-        return (iter != m_windowShells.end()) ? iter->second.get() : 0;
-    }
-    V8DOMWindow* globalObject(DOMWrapperWorld* world)
-    {
-        notImplemented();
-        return 0;
-    }
-
-    static void getAllWorlds(Vector<DOMWrapperWorld*>&);
+    // FIXME: V8Proxy should either be folded into ScriptController
+    // or this accessor should be made JSProxy*
+    V8Proxy* proxy() { return m_proxy.get(); }
+
+    V8DOMWindowShell* mainWorldWindowShell() const;
 
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);
-    ScriptValue executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture = false);
 
     // Returns true if argument is a JavaScript URL.
     bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true);
@@ -92,18 +74,10 @@ public:
     // This function must be called from the main thread. It is safe to call it repeatedly.
     static void initializeThreading();
 
+    // Evaluate a script file in the environment of this proxy.
+    // If succeeded, 'succ' is set to true and result is returned
+    // as a string.
     ScriptValue evaluate(const ScriptSourceCode&);
-    ScriptValue evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*);
-
-    // ==== End identical match with JSC's ScriptController === //
-
-    // FIXME: V8Proxy should either be folded into ScriptController
-    // or this accessor should be made JSProxy*
-    V8Proxy* proxy() { return m_proxy.get(); }
-
-    // FIXME: We should eventually remove all clients of this method. The
-    // problem is that some of them are in very hot code paths.
-    V8DOMWindowShell* mainWorldWindowShell();
 
     void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&);
 
@@ -119,6 +93,12 @@ public:
     // FIXME: Get rid of extensionGroup here.
     void evaluateInIsolatedWorld(unsigned worldID, const Vector<ScriptSourceCode>&, int extensionGroup);
 
+    // Masquerade 'this' as the windowShell.
+    // This is a bit of a hack, but provides reasonable compatibility
+    // with what JSC does as well.
+    ScriptController* windowShell(DOMWrapperWorld*) { return this; }
+    ScriptController* existingWindowShell(DOMWrapperWorld*) { return this; }
+
     XSSAuditor* xssAuditor() { return m_XSSAuditor.get(); }
 
     void collectGarbage();
@@ -131,6 +111,9 @@ public:
 
     PassScriptInstance createScriptInstanceForWidget(Widget*);
 
+    // Check if the javascript engine has been initialized.
+    bool haveInterpreter() const;
+
     bool isEnabled() const;
 
     // FIXME: void* is a compile hack.
@@ -187,6 +170,10 @@ public:
     NPObject* windowScriptNPObject();
 #endif
 
+    // Dummy method to avoid a bunch of ifdef's in WebCore.
+    void evaluateInWorld(const ScriptSourceCode&, DOMWrapperWorld*) { }
+    static void getAllWorlds(Vector<DOMWrapperWorld*>& worlds);
+
     // Script state for the main world context.
     ScriptState* mainWorldScriptState();
 
@@ -194,17 +181,7 @@ public:
     static ScriptState* currentScriptState();
 
 private:
-    V8DOMWindowShell* initScript(DOMWrapperWorld*);
-
-    ShellMap m_windowShells;
     Frame* m_frame;
-
-    // This is a cache of the main world's windowShell.  We have this
-    // because we need access to it during some wrapper operations that
-    // are performance sensitive.  Those call sites are wrong, but I'm
-    // waiting to remove them until the next patch.
-    RefPtr<V8DOMWindowShell> m_mainWorldWindowShell;
-
     const String* m_sourceURL;
 
     bool m_inExecuteScript;
@@ -215,6 +192,9 @@ private:
     // FIXME: V8Proxy should eventually be removed.
     OwnPtr<V8Proxy> m_proxy;
 
+    // For the moment, we have one of these.  Soon we will have one per DOMWrapperWorld.
+    RefPtr<V8DOMWindowShell> m_windowShell;
+
     typedef HashMap<Widget*, NPObject*> PluginObjectMap;
 
     // A mapping between Widgets and their corresponding script object.
diff --git a/WebCore/bindings/v8/V8DOMWindowShell.cpp b/WebCore/bindings/v8/V8DOMWindowShell.cpp
index c89fa31..7e1491f 100644
--- a/WebCore/bindings/v8/V8DOMWindowShell.cpp
+++ b/WebCore/bindings/v8/V8DOMWindowShell.cpp
@@ -36,7 +36,6 @@
 #include "DateExtension.h"
 #include "DocumentLoader.h"
 #include "DOMObjectsInclude.h"
-#include "DOMWrapperWorld.h"
 #include "Frame.h"
 #include "FrameLoaderClient.h"
 #include "InspectorTimelineAgent.h"
@@ -123,14 +122,13 @@ static void reportUnsafeJavaScriptAccess(v8::Local<v8::Object> host, v8::AccessT
         V8Proxy::reportUnsafeAccessTo(target, V8Proxy::ReportLater);
 }
 
-PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame, DOMWrapperWorld* world)
+PassRefPtr<V8DOMWindowShell> V8DOMWindowShell::create(Frame* frame)
 {
-    return adoptRef(new V8DOMWindowShell(frame, world));
+    return adoptRef(new V8DOMWindowShell(frame));
 }
 
-V8DOMWindowShell::V8DOMWindowShell(Frame* frame, DOMWrapperWorld* world)
+V8DOMWindowShell::V8DOMWindowShell(Frame* frame)
     : m_frame(frame)
-    , m_world(world)
 {
 }
 
@@ -313,8 +311,11 @@ void V8DOMWindowShell::initContextIfNeeded()
 
     setSecurityToken();
 
-    // FIXME: JSC doesn't seem to make this callback.
     m_frame->loader()->client()->didCreateScriptContextForFrame();
+
+    // FIXME: This is wrong. We should actually do this for the proper world once
+    // we do isolated worlds the WebCore way.
+    m_frame->loader()->dispatchDidClearWindowObjectInWorld(0);
 }
 
 v8::Persistent<v8::Context> V8DOMWindowShell::createNewContext(v8::Handle<v8::Object> global, int extensionGroup)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list