[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

yurys at chromium.org yurys at chromium.org
Wed Dec 22 12:22:28 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit f4b120288bc16aea845b420fe5222c940db46913
Author: yurys at chromium.org <yurys at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 20 11:34:16 2010 +0000

    2010-08-20  Yury Semikhatsky  <yurys at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: discard InjectedScript reference on ScriptState when clearing injected scripts
            https://bugs.webkit.org/show_bug.cgi?id=44328
    
            Otherwise if the reference is not cleared we may remove InjectedScript from the
            map on InjectedScriptHost but keep it on ScriptState and try to reuse it later.
    
            * bindings/js/JSInjectedScriptHostCustom.cpp:
            (WebCore::InjectedScriptHost::discardInjectedScript):
            * bindings/v8/V8HiddenPropertyName.h:
            * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
            (WebCore::InjectedScriptHost::discardInjectedScript):
            (WebCore::InjectedScriptHost::injectedScriptFor):
            * inspector/InjectedScript.h:
            (WebCore::InjectedScript::scriptState):
            * inspector/InjectedScriptHost.cpp:
            (WebCore::InjectedScriptHost::discardInjectedScripts):
            * inspector/InjectedScriptHost.h:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65730 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6c5389c..28df9aa 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-08-20  Yury Semikhatsky  <yurys at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: discard InjectedScript reference on ScriptState when clearing injected scripts
+        https://bugs.webkit.org/show_bug.cgi?id=44328
+
+        Otherwise if the reference is not cleared we may remove InjectedScript from the
+        map on InjectedScriptHost but keep it on ScriptState and try to reuse it later.
+
+        * bindings/js/JSInjectedScriptHostCustom.cpp:
+        (WebCore::InjectedScriptHost::discardInjectedScript):
+        * bindings/v8/V8HiddenPropertyName.h:
+        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+        (WebCore::InjectedScriptHost::discardInjectedScript):
+        (WebCore::InjectedScriptHost::injectedScriptFor):
+        * inspector/InjectedScript.h:
+        (WebCore::InjectedScript::scriptState):
+        * inspector/InjectedScriptHost.cpp:
+        (WebCore::InjectedScriptHost::discardInjectedScripts):
+        * inspector/InjectedScriptHost.h:
+
 2010-08-20  Nikolas Zimmermann  <nzimmermann at rim.com>
 
         Reviewed by Dirk Schulze.
diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
index 06360fb..ac5225e 100644
--- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp
@@ -103,6 +103,12 @@ ScriptObject InjectedScriptHost::createInjectedScript(const String& source, Scri
     return ScriptObject();
 }
 
+void InjectedScriptHost::discardInjectedScript(ScriptState* scriptState)
+{
+    JSDOMGlobalObject* globalObject = static_cast<JSDOMGlobalObject*>(scriptState->lexicalGlobalObject());
+    globalObject->setInjectedScript(0);
+}
+
 #if ENABLE(JAVASCRIPT_DEBUGGER)
 JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec)
 {
diff --git a/WebCore/bindings/v8/V8HiddenPropertyName.h b/WebCore/bindings/v8/V8HiddenPropertyName.h
index 2d0e8d6..7867b36 100644
--- a/WebCore/bindings/v8/V8HiddenPropertyName.h
+++ b/WebCore/bindings/v8/V8HiddenPropertyName.h
@@ -40,10 +40,12 @@ namespace WebCore {
     V(listener) \
     V(attributeListener) \
     V(scriptState) \
+    V(devtoolsInjectedScript) \
     V(sleepFunction) \
     V(toStringString) \
     V(event)
 
+
     class V8HiddenPropertyName {
     public:
 #define V8_DECLARE_PROPERTY(name) static v8::Handle<v8::String> name();
diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
index 1b069cf..b3007a4 100644
--- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp
@@ -46,6 +46,7 @@
 #include "V8BindingState.h"
 #include "V8DOMWindow.h"
 #include "V8Database.h"
+#include "V8HiddenPropertyName.h"
 #include "V8JavaScriptCallFrame.h"
 #include "V8Node.h"
 #include "V8Proxy.h"
@@ -120,6 +121,21 @@ ScriptObject InjectedScriptHost::createInjectedScript(const String& scriptSource
     return ScriptObject(inspectedScriptState, injectedScript);
 }
 
+void InjectedScriptHost::discardInjectedScript(ScriptState* inspectedScriptState)
+{
+    v8::HandleScope handleScope;
+    v8::Local<v8::Context> context = inspectedScriptState->context();
+    v8::Context::Scope contextScope(context);
+
+    v8::Local<v8::Object> global = context->Global();
+    // Skip proxy object. The proxy object will survive page navigation while we need
+    // an object whose lifetime consides with that of the inspected context.
+    global = v8::Local<v8::Object>::Cast(global->GetPrototype());
+
+    v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
+    global->DeleteHiddenValue(key);
+}
+
 v8::Handle<v8::Value> V8InjectedScriptHost::nodeForIdCallback(const v8::Arguments& args)
 {
     INC_STATS("InjectedScriptHost.nodeForId()");
@@ -206,7 +222,7 @@ InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScrip
     // an object whose lifetime consides with that of the inspected context.
     global = v8::Local<v8::Object>::Cast(global->GetPrototype());
 
-    v8::Local<v8::String> key = v8::String::New("Devtools_InjectedScript");
+    v8::Handle<v8::String> key = V8HiddenPropertyName::devtoolsInjectedScript();
     v8::Local<v8::Value> val = global->GetHiddenValue(key);
     if (!val.IsEmpty() && val->IsObject())
         return InjectedScript(ScriptObject(inspectedScriptState, v8::Local<v8::Object>::Cast(val)));
diff --git a/WebCore/inspector/InjectedScript.h b/WebCore/inspector/InjectedScript.h
index 17389ba..f80cfb4 100644
--- a/WebCore/inspector/InjectedScript.h
+++ b/WebCore/inspector/InjectedScript.h
@@ -54,6 +54,7 @@ public:
 #endif
     PassRefPtr<InspectorValue> wrapForConsole(ScriptValue);
     void releaseWrapperObjectGroup(const String&);
+    ScriptState* scriptState() const { return m_injectedScriptObject.scriptState(); }
 
 private:
     friend InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState*);
diff --git a/WebCore/inspector/InjectedScriptHost.cpp b/WebCore/inspector/InjectedScriptHost.cpp
index 37512be..9833c03 100644
--- a/WebCore/inspector/InjectedScriptHost.cpp
+++ b/WebCore/inspector/InjectedScriptHost.cpp
@@ -149,6 +149,9 @@ InjectedScript InjectedScriptHost::injectedScriptForId(long id)
 
 void InjectedScriptHost::discardInjectedScripts()
 {
+    IdToInjectedScriptMap::iterator end = m_idToInjectedScript.end();
+    for (IdToInjectedScriptMap::iterator it = m_idToInjectedScript.begin(); it != end; ++it)
+        discardInjectedScript(it->second.scriptState());
     m_idToInjectedScript.clear();
 }
 
diff --git a/WebCore/inspector/InjectedScriptHost.h b/WebCore/inspector/InjectedScriptHost.h
index a670db0..32797d1 100644
--- a/WebCore/inspector/InjectedScriptHost.h
+++ b/WebCore/inspector/InjectedScriptHost.h
@@ -97,6 +97,7 @@ private:
     InspectorDOMAgent* inspectorDOMAgent();
     RemoteInspectorFrontend* remoteFrontend();
     ScriptObject createInjectedScript(const String& source, ScriptState* scriptState, long id);
+    void discardInjectedScript(ScriptState*);
 
     InspectorController* m_inspectorController;
     String m_injectedScriptSource;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list