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

yurys at chromium.org yurys at chromium.org
Thu Apr 8 00:52:10 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 03b64c8ed14a1d34ee12facfb2861c284b03782b
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Dec 30 12:34:40 2009 +0000

    2009-12-30  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Dimitri Glazkov.
    
            [v8] Use current isolated world's context for ScriptCallStack.
    
            https://bugs.webkit.org/show_bug.cgi?id=33016
    
            * bindings/v8/ScriptCallStack.cpp:
            (WebCore::ScriptCallStack::ScriptCallStack):
            * bindings/v8/ScriptCallStack.h:
            (WebCore::ScriptCallStack::state):
            * bindings/v8/ScriptController.cpp:
            (WebCore::ScriptController::mainWorldScriptState):
            (WebCore::ScriptController::currentScriptState):
            (WebCore::ScriptController::clearWindowShell):
            * bindings/v8/ScriptController.h:
            * bindings/v8/V8IsolatedWorld.cpp:
            (WebCore::V8IsolatedWorld::scriptState):
            * bindings/v8/V8IsolatedWorld.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52653 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 53bb47c..ff6e007 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,24 @@
+2009-12-30  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Dimitri Glazkov.
+
+        [v8] Use current isolated world's context for ScriptCallStack.
+
+        https://bugs.webkit.org/show_bug.cgi?id=33016
+
+        * bindings/v8/ScriptCallStack.cpp:
+        (WebCore::ScriptCallStack::ScriptCallStack):
+        * bindings/v8/ScriptCallStack.h:
+        (WebCore::ScriptCallStack::state):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::mainWorldScriptState):
+        (WebCore::ScriptController::currentScriptState):
+        (WebCore::ScriptController::clearWindowShell):
+        * bindings/v8/ScriptController.h:
+        * bindings/v8/V8IsolatedWorld.cpp:
+        (WebCore::V8IsolatedWorld::scriptState):
+        * bindings/v8/V8IsolatedWorld.h:
+
 2009-12-30  Laszlo Gombos  <laszlo.1.gombos at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp
index d9b2fcf..a0eeccb 100644
--- a/WebCore/bindings/v8/ScriptCallStack.cpp
+++ b/WebCore/bindings/v8/ScriptCallStack.cpp
@@ -31,6 +31,8 @@
 #include "config.h"
 #include "ScriptCallStack.h"
 
+#include "ScriptController.h"
+
 #include <v8.h>
 
 #include "V8Binding.h"
@@ -53,7 +55,7 @@ ScriptCallStack* ScriptCallStack::create(const v8::Arguments& arguments, unsigne
 
 ScriptCallStack::ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber)
     : m_lastCaller(String(), sourceName, sourceLineNumber, arguments, skipArgumentCount)
-    , m_scriptState(new ScriptState(V8Proxy::retrieveFrameForCurrentContext()))
+    , m_scriptState(ScriptController::currentScriptState())
 {
 }
 
diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h
index f6a7e39..aa04362 100644
--- a/WebCore/bindings/v8/ScriptCallStack.h
+++ b/WebCore/bindings/v8/ScriptCallStack.h
@@ -35,7 +35,6 @@
 #include "ScriptState.h"
 #include "ScriptValue.h"
 #include <wtf/Noncopyable.h>
-#include <wtf/OwnPtr.h>
 
 namespace v8 {
     class Arguments;
@@ -52,13 +51,13 @@ namespace WebCore {
         // FIXME: implement retrieving and storing call stack trace
         unsigned size() const { return 1; }
 
-        ScriptState* state() const { return m_scriptState.get(); }
+        ScriptState* state() const { return m_scriptState; }
 
     private:
         ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber);
     
         ScriptCallFrame m_lastCaller;
-        OwnPtr<ScriptState> m_scriptState;
+        ScriptState* m_scriptState;
     };
 
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index da20939..f9e268f 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -51,6 +51,7 @@
 #include "Settings.h"
 #include "V8Binding.h"
 #include "V8BindingState.h"
+#include "V8IsolatedWorld.h"
 #include "V8NPObject.h"
 #include "V8Proxy.h"
 #include "Widget.h"
@@ -364,11 +365,22 @@ void ScriptController::getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
 
 ScriptState* ScriptController::mainWorldScriptState()
 {
-    if (!m_mainWorldScriptState)
+    if (!m_mainWorldScriptState) {
+        v8::HandleScope handleScope;
         m_mainWorldScriptState.set(new ScriptState(m_frame, V8Proxy::mainWorldContext(m_frame)));
+    }
     return m_mainWorldScriptState.get();
 }
 
+ScriptState* ScriptController::currentScriptState()
+{
+    if (V8IsolatedWorld* world = V8IsolatedWorld::getEntered())
+        return world->scriptState();
+    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+    ASSERT(frame);
+    return frame->script()->mainWorldScriptState();
+}
+
 static NPObject* createNoScriptObject()
 {
     notImplemented();
@@ -431,6 +443,8 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
 
 void ScriptController::clearWindowShell()
 {
+    m_mainWorldScriptState.clear();
+
     // V8 binding expects ScriptController::clearWindowShell only be called
     // when a frame is loading a new page. V8Proxy::clearForNavigation
     // creates a new context for the new page.
diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h
index 298ffe0..58f19bc 100644
--- a/WebCore/bindings/v8/ScriptController.h
+++ b/WebCore/bindings/v8/ScriptController.h
@@ -175,6 +175,9 @@ namespace WebCore {
         // Script state for the main world context.
         ScriptState* mainWorldScriptState();
 
+        // Returns ScriptState for current context.
+        static ScriptState* currentScriptState();
+
     private:
         Frame* m_frame;
         const String* m_sourceURL;
diff --git a/WebCore/bindings/v8/V8IsolatedWorld.cpp b/WebCore/bindings/v8/V8IsolatedWorld.cpp
index cb65097..de1292d 100644
--- a/WebCore/bindings/v8/V8IsolatedWorld.cpp
+++ b/WebCore/bindings/v8/V8IsolatedWorld.cpp
@@ -91,4 +91,14 @@ V8IsolatedWorld::~V8IsolatedWorld()
     m_context->disposeHandle();
 }
 
+ScriptState* V8IsolatedWorld::scriptState()
+{
+    if (!m_scriptState) {
+        v8::HandleScope scope;
+        v8::Handle<v8::Context> context = m_context.get()->get();
+        m_scriptState.set(new ScriptState(V8Proxy::retrieveFrame(context), context));
+    }
+    return m_scriptState.get();
+}
+
 } // namespace WebCore
diff --git a/WebCore/bindings/v8/V8IsolatedWorld.h b/WebCore/bindings/v8/V8IsolatedWorld.h
index 6313da8..c3c18fe 100644
--- a/WebCore/bindings/v8/V8IsolatedWorld.h
+++ b/WebCore/bindings/v8/V8IsolatedWorld.h
@@ -95,6 +95,8 @@ namespace WebCore {
 
         DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore(); }
 
+        ScriptState* scriptState();
+
     private:
         static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> context)
         {
@@ -114,6 +116,9 @@ namespace WebCore {
         // manage their lifetime.
         DOMDataStoreHandle m_domDataStore;
 
+        // FIXME: get rid of redundant m_context field. The context can be retrieved from the ScriptState.
+        OwnPtr<ScriptState> m_scriptState;
+
         static int isolatedWorldCount;
     };
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list