Title: [160955] trunk/Source/WebCore
Revision
160955
Author
commit-qu...@webkit.org
Date
2013-12-20 18:47:10 -0800 (Fri, 20 Dec 2013)

Log Message

Web Inspector: Remove the references to Node in InjectedScript
https://bugs.webkit.org/show_bug.cgi?id=126091

Patch by Joseph Pecoraro <pecor...@apple.com> on 2013-12-20
Reviewed by Timothy Hatcher.

Remove the last DOM references from InjectedScript so that
InjectedScript can move down into _javascript_Core. The only
remaining references were to Nodes, which are all just thin
wrappers around existing functions. Move Node / JSNode (JSValue)
conversion into InspectorDOMAgent, where it was used.

No new tests, no observable change in functionality.

* bindings/js/JSInjectedScriptHostCustom.cpp:
* inspector/InjectedScript.cpp:
(WebCore::InjectedScript::inspectObject):
(WebCore::InjectedScript::releaseObject):
* inspector/InjectedScript.h:
* inspector/InjectedScriptHost.h:
* inspector/InjectedScriptSource.js:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::focusNode):
(WebCore::InspectorDOMAgent::highlightNode):
(WebCore::InspectorDOMAgent::requestNode):
(WebCore::InspectorDOMAgent::nodeForObjectId):
(WebCore::InspectorDOMAgent::resolveNode):
(WebCore::InspectorDOMAgent::scriptValueAsNode):
(WebCore::InspectorDOMAgent::nodeAsScriptValue):
* inspector/InspectorDOMAgent.h:
* inspector/PageConsoleAgent.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (160954 => 160955)


--- trunk/Source/WebCore/ChangeLog	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/ChangeLog	2013-12-21 02:47:10 UTC (rev 160955)
@@ -1,3 +1,36 @@
+2013-12-20  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Remove the references to Node in InjectedScript
+        https://bugs.webkit.org/show_bug.cgi?id=126091
+
+        Reviewed by Timothy Hatcher.
+
+        Remove the last DOM references from InjectedScript so that
+        InjectedScript can move down into _javascript_Core. The only
+        remaining references were to Nodes, which are all just thin
+        wrappers around existing functions. Move Node / JSNode (JSValue)
+        conversion into InspectorDOMAgent, where it was used.
+
+        No new tests, no observable change in functionality.
+
+        * bindings/js/JSInjectedScriptHostCustom.cpp:
+        * inspector/InjectedScript.cpp:
+        (WebCore::InjectedScript::inspectObject):
+        (WebCore::InjectedScript::releaseObject):
+        * inspector/InjectedScript.h:
+        * inspector/InjectedScriptHost.h:
+        * inspector/InjectedScriptSource.js:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::focusNode):
+        (WebCore::InspectorDOMAgent::highlightNode):
+        (WebCore::InspectorDOMAgent::requestNode):
+        (WebCore::InspectorDOMAgent::nodeForObjectId):
+        (WebCore::InspectorDOMAgent::resolveNode):
+        (WebCore::InspectorDOMAgent::scriptValueAsNode):
+        (WebCore::InspectorDOMAgent::nodeAsScriptValue):
+        * inspector/InspectorDOMAgent.h:
+        * inspector/PageConsoleAgent.cpp:
+
 2013-12-20  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Faster implementation of text-decoration-skip: ink

Modified: trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp (160954 => 160955)


--- trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp	2013-12-21 02:47:10 UTC (rev 160955)
@@ -59,22 +59,6 @@
 
 namespace WebCore {
 
-Node* InjectedScriptHost::scriptValueAsNode(Deprecated::ScriptValue value)
-{
-    if (!value.isObject() || value.isNull())
-        return 0;
-    return toNode(value.jsValue());
-}
-
-Deprecated::ScriptValue InjectedScriptHost::nodeAsScriptValue(JSC::ExecState* state, Node* node)
-{
-    if (!shouldAllowAccessToNode(state, node))
-        return Deprecated::ScriptValue(state->vm(), jsNull());
-
-    JSLockHolder lock(state);
-    return Deprecated::ScriptValue(state->vm(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
-}
-
 JSValue JSInjectedScriptHost::internalConstructorName(ExecState* exec)
 {
     if (exec->argumentCount() < 1)

Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (160954 => 160955)


--- trunk/Source/WebCore/inspector/InjectedScript.cpp	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp	2013-12-21 02:47:10 UTC (rev 160955)
@@ -144,29 +144,6 @@
         *properties = array;
 }
 
-Node* InjectedScript::nodeForObjectId(const String& objectId)
-{
-    if (hasNoValue() || !canAccessInspectedWindow())
-        return 0;
-
-    Deprecated::ScriptFunctionCall function(injectedScriptObject(), "nodeForObjectId", WebCore::functionCallHandlerFromAnyThread);
-    function.appendArgument(objectId);
-
-    bool hadException = false;
-    Deprecated::ScriptValue resultValue = callFunctionWithEvalEnabled(function, hadException);
-    ASSERT(!hadException);
-
-    return InjectedScriptHost::scriptValueAsNode(resultValue);
-}
-
-void InjectedScript::releaseObject(const String& objectId)
-{
-    Deprecated::ScriptFunctionCall function(injectedScriptObject(), "releaseObject", WebCore::functionCallHandlerFromAnyThread);
-    function.appendArgument(objectId);
-    RefPtr<InspectorValue> result;
-    makeCall(function, &result);
-}
-
 #if ENABLE(_javascript__DEBUGGER)
 PassRefPtr<Array<CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
 {
@@ -217,11 +194,6 @@
     return Inspector::TypeBuilder::Runtime::RemoteObject::runtimeCast(rawResult);
 }
 
-PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> InjectedScript::wrapNode(Node* node, const String& groupName)
-{
-    return wrapObject(nodeAsScriptValue(node), groupName);
-}
-
 Deprecated::ScriptValue InjectedScript::findObjectById(const String& objectId) const
 {
     ASSERT(!hasNoValue());
@@ -234,15 +206,23 @@
     return resultValue;
 }
 
-void InjectedScript::inspectNode(Node* node)
+void InjectedScript::inspectObject(Deprecated::ScriptValue value)
 {
     ASSERT(!hasNoValue());
-    Deprecated::ScriptFunctionCall function(injectedScriptObject(), "inspectNode", WebCore::functionCallHandlerFromAnyThread);
-    function.appendArgument(nodeAsScriptValue(node));
+    Deprecated::ScriptFunctionCall function(injectedScriptObject(), "inspectObject", WebCore::functionCallHandlerFromAnyThread);
+    function.appendArgument(value);
     RefPtr<InspectorValue> result;
     makeCall(function, &result);
 }
 
+void InjectedScript::releaseObject(const String& objectId)
+{
+    Deprecated::ScriptFunctionCall function(injectedScriptObject(), "releaseObject", WebCore::functionCallHandlerFromAnyThread);
+    function.appendArgument(objectId);
+    RefPtr<InspectorValue> result;
+    makeCall(function, &result);
+}
+
 void InjectedScript::releaseObjectGroup(const String& objectGroup)
 {
     ASSERT(!hasNoValue());
@@ -253,11 +233,6 @@
     ASSERT(!hadException);
 }
 
-Deprecated::ScriptValue InjectedScript::nodeAsScriptValue(Node* node)
-{
-    return InjectedScriptHost::nodeAsScriptValue(scriptState(), node);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/InjectedScript.h (160954 => 160955)


--- trunk/Source/WebCore/inspector/InjectedScript.h	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InjectedScript.h	2013-12-21 02:47:10 UTC (rev 160955)
@@ -85,27 +85,23 @@
     void getFunctionDetails(ErrorString*, const String& functionId, RefPtr<Inspector::TypeBuilder::Debugger::FunctionDetails>* result);
     void getProperties(ErrorString*, const String& objectId, bool ownProperties, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::PropertyDescriptor>>* result);
     void getInternalProperties(ErrorString*, const String& objectId, RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Runtime::InternalPropertyDescriptor>>* result);
-    Node* nodeForObjectId(const String& objectId);
-    void releaseObject(const String& objectId);
 
 #if ENABLE(_javascript__DEBUGGER)
     PassRefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
 #endif
-
     PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> wrapObject(const Deprecated::ScriptValue&, const String& groupName, bool generatePreview = false) const;
     PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const;
-    PassRefPtr<Inspector::TypeBuilder::Runtime::RemoteObject> wrapNode(Node*, const String& groupName);
+
     Deprecated::ScriptValue findObjectById(const String& objectId) const;
+    void inspectObject(Deprecated::ScriptValue);
 
-    void inspectNode(Node*);
-    void releaseObjectGroup(const String&);
+    void releaseObject(const String& objectId);
+    void releaseObjectGroup(const String& objectGroup);
 
 private:
     friend class InjectedScriptModule;
     friend InjectedScript InjectedScriptManager::injectedScriptFor(JSC::ExecState*);
     InjectedScript(Deprecated::ScriptObject, InspectedStateAccessCheck);
-
-    Deprecated::ScriptValue nodeAsScriptValue(Node*);
 };
 
 #endif

Modified: trunk/Source/WebCore/inspector/InjectedScriptHost.h (160954 => 160955)


--- trunk/Source/WebCore/inspector/InjectedScriptHost.h	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InjectedScriptHost.h	2013-12-21 02:47:10 UTC (rev 160955)
@@ -47,9 +47,6 @@
     static PassRefPtr<InjectedScriptHost> create();
     ~InjectedScriptHost() { }
 
-    static Node* scriptValueAsNode(Deprecated::ScriptValue);
-    static Deprecated::ScriptValue nodeAsScriptValue(JSC::ExecState*, Node*);
-
 private:
     InjectedScriptHost() { }
 };

Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (160954 => 160955)


--- trunk/Source/WebCore/inspector/InjectedScriptSource.js	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js	2013-12-21 02:47:10 UTC (rev 160955)
@@ -125,7 +125,7 @@
     /**
      * @param {*} object
      */
-    inspectNode: function(object)
+    inspectObject: function(object)
     {
         if (this._commandLineAPIImpl)
             this._commandLineAPIImpl.inspect(object);
@@ -642,18 +642,6 @@
     },
 
     /**
-     * @param {string} objectId
-     * @return {Node}
-     */
-    nodeForObjectId: function(objectId)
-    {
-        var object = this.findObjectById(objectId);
-        if (!object || this._subtype(object) !== "node")
-            return null;
-        return /** @type {Node} */ (object);
-    },
-
-    /**
      * @param {string} name
      * @return {Object}
      */

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp (160954 => 160955)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp	2013-12-21 02:47:10 UTC (rev 160955)
@@ -77,11 +77,13 @@
 #include "InstrumentingAgents.h"
 #include "IntRect.h"
 #include "JSEventListener.h"
+#include "JSNode.h"
 #include "MainFrame.h"
 #include "MutationEvent.h"
 #include "Node.h"
 #include "NodeList.h"
 #include "Page.h"
+#include "PageInjectedScriptManager.h"
 #include "Pasteboard.h"
 #include "RenderStyle.h"
 #include "RenderStyleConstants.h"
@@ -998,11 +1000,12 @@
     if (!frame)
         return;
 
-    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldExecState(frame));
+    JSC::ExecState* scriptState = mainWorldExecState(frame);
+    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
     if (injectedScript.hasNoValue())
         return;
 
-    injectedScript.inspectNode(node.get());
+    injectedScript.inspectObject(InspectorDOMAgent::nodeAsScriptValue(scriptState, node.get()));
 }
 
 void InspectorDOMAgent::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
@@ -1090,8 +1093,7 @@
     if (nodeId) {
         node = assertNode(errorString, *nodeId);
     } else if (objectId) {
-        InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(*objectId);
-        node = injectedScript.nodeForObjectId(*objectId);
+        node = nodeForObjectId(*objectId);
         if (!node)
             *errorString = "Node for given objectId not found";
     } else
@@ -1241,8 +1243,7 @@
 
 void InspectorDOMAgent::requestNode(ErrorString*, const String& objectId, int* nodeId)
 {
-    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
-    Node* node = injectedScript.nodeForObjectId(objectId);
+    Node* node = nodeForObjectId(objectId);
     if (node)
         *nodeId = pushNodePathToFrontend(node);
     else
@@ -1706,6 +1707,13 @@
     return node;
 }
 
+Node* InspectorDOMAgent::nodeForObjectId(const String& objectId)
+{
+    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
+    Deprecated::ScriptValue value = injectedScript.findObjectById(objectId);
+    return InspectorDOMAgent::scriptValueAsNode(value);
+}
+
 void InspectorDOMAgent::pushNodeByPathToFrontend(ErrorString* errorString, const String& path, int* nodeId)
 {
     if (Node* node = nodeForPath(path))
@@ -1737,13 +1745,31 @@
     if (!frame)
         return 0;
 
-    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldExecState(frame));
+    JSC::ExecState* scriptState = mainWorldExecState(frame);
+    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
     if (injectedScript.hasNoValue())
         return 0;
 
-    return injectedScript.wrapNode(node, objectGroup);
+    return injectedScript.wrapObject(InspectorDOMAgent::nodeAsScriptValue(scriptState, node), objectGroup);
 }
 
+Node* InspectorDOMAgent::scriptValueAsNode(Deprecated::ScriptValue value)
+{
+    if (!value.isObject() || value.isNull())
+        return nullptr;
+
+    return toNode(value.jsValue());
+}
+
+Deprecated::ScriptValue InspectorDOMAgent::nodeAsScriptValue(JSC::ExecState* state, Node* node)
+{
+    if (!shouldAllowAccessToNode(state, node))
+        return Deprecated::ScriptValue(state->vm(), JSC::jsNull());
+
+    JSC::JSLockHolder lock(state);
+    return Deprecated::ScriptValue(state->vm(), toJS(state, deprecatedGlobalObjectForPrototype(state), node));
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/InspectorDOMAgent.h (160954 => 160955)


--- trunk/Source/WebCore/inspector/InspectorDOMAgent.h	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/InspectorDOMAgent.h	2013-12-21 02:47:10 UTC (rev 160955)
@@ -208,6 +208,9 @@
     Element* assertElement(ErrorString*, int nodeId);
     Document* assertDocument(ErrorString*, int nodeId);
 
+    static Node* scriptValueAsNode(Deprecated::ScriptValue);
+    static Deprecated::ScriptValue nodeAsScriptValue(JSC::ExecState*, Node*);
+
     // Methods called from other agents.
     InspectorPageAgent* pageAgent() { return m_pageAgent; }
 
@@ -238,6 +241,7 @@
     PassRefPtr<Inspector::TypeBuilder::DOM::EventListener> buildObjectForEventListener(const RegisteredEventListener&, const AtomicString& eventType, Node*, const String* objectGroupId);
 
     Node* nodeForPath(const String& path);
+    Node* nodeForObjectId(const String& objectId);
 
     void discardBindings();
 

Modified: trunk/Source/WebCore/inspector/PageConsoleAgent.cpp (160954 => 160955)


--- trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2013-12-21 02:25:19 UTC (rev 160954)
+++ trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2013-12-21 02:47:10 UTC (rev 160955)
@@ -70,7 +70,7 @@
     explicit InspectableNode(Node* node) : m_node(node) { }
     virtual Deprecated::ScriptValue get(JSC::ExecState* state) OVERRIDE
     {
-        return InjectedScriptHost::nodeAsScriptValue(state, m_node);
+        return InspectorDOMAgent::nodeAsScriptValue(state, m_node);
     }
 private:
     Node* m_node;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to