Web Inspector: Clean up InjectedScript uses
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 19:31:35 +0000 (19:31 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Nov 2015 19:31:35 +0000 (19:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150921

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-11-05
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::wrapCallFrames):
* inspector/InjectedScript.h:
* inspector/InjectedScriptBase.cpp:
(Inspector::InjectedScriptBase::initialize): Deleted.
* inspector/InjectedScriptBase.h:
* inspector/InjectedScriptManager.cpp:
(Inspector::InjectedScriptManager::didCreateInjectedScript):
* inspector/InjectedScriptManager.h:
* inspector/InjectedScriptModule.cpp:
(Inspector::InjectedScriptModule::ensureInjected):
* inspector/InjectedScriptModule.h:
* inspector/agents/InspectorDebuggerAgent.cpp:
(Inspector::InspectorDebuggerAgent::currentCallFrames):
* inspector/agents/InspectorDebuggerAgent.h:

Source/WebCore:

* inspector/CommandLineAPIModule.cpp:
(WebCore::CommandLineAPIModule::injectIfNeeded):
(WebCore::CommandLineAPIModule::CommandLineAPIModule):
* inspector/CommandLineAPIModule.h:
* inspector/WebInjectedScriptManager.cpp:
(WebCore::WebInjectedScriptManager::didCreateInjectedScript):
* inspector/WebInjectedScriptManager.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192064 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InjectedScript.cpp
Source/JavaScriptCore/inspector/InjectedScript.h
Source/JavaScriptCore/inspector/InjectedScriptBase.cpp
Source/JavaScriptCore/inspector/InjectedScriptBase.h
Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
Source/JavaScriptCore/inspector/InjectedScriptManager.h
Source/JavaScriptCore/inspector/InjectedScriptModule.cpp
Source/JavaScriptCore/inspector/InjectedScriptModule.h
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/CommandLineAPIModule.cpp
Source/WebCore/inspector/CommandLineAPIModule.h
Source/WebCore/inspector/WebInjectedScriptManager.cpp
Source/WebCore/inspector/WebInjectedScriptManager.h

index c049098d433b60df4b5b4d379130b573c1954d2e..6be0f1a615693d232262743aa0d55e91648111c5 100644 (file)
@@ -1,3 +1,26 @@
+2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Clean up InjectedScript uses
+        https://bugs.webkit.org/show_bug.cgi?id=150921
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/InjectedScript.cpp:
+        (Inspector::InjectedScript::wrapCallFrames):
+        * inspector/InjectedScript.h:
+        * inspector/InjectedScriptBase.cpp:
+        (Inspector::InjectedScriptBase::initialize): Deleted.
+        * inspector/InjectedScriptBase.h:
+        * inspector/InjectedScriptManager.cpp:
+        (Inspector::InjectedScriptManager::didCreateInjectedScript):
+        * inspector/InjectedScriptManager.h:
+        * inspector/InjectedScriptModule.cpp:
+        (Inspector::InjectedScriptModule::ensureInjected):
+        * inspector/InjectedScriptModule.h:
+        * inspector/agents/InspectorDebuggerAgent.cpp:
+        (Inspector::InspectorDebuggerAgent::currentCallFrames):
+        * inspector/agents/InspectorDebuggerAgent.h:
+
 2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate references
index 492060e68ecd93813c6253a2434f8dcf0042bbd6..72d07592aa3a1776b6c3a50dd7185b79449bc98f 100644 (file)
@@ -194,7 +194,7 @@ void InjectedScript::saveResult(ErrorString& errorString, const String& callArgu
         *savedResultIndex = savedResultIndexInt;
 }
 
-Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
+Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames) const
 {
     ASSERT(!hasNoValue());
     Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());
index bd43f720ce41a4064e0a5ddcf79ee6e85b6f3353..509cd58d405a731cebd982a648e6022cb70aea10 100644 (file)
@@ -62,7 +62,7 @@ public:
     void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries);
     void saveResult(ErrorString&, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex);
 
-    Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
+    Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&) const;
     RefPtr<Protocol::Runtime::RemoteObject> wrapObject(const Deprecated::ScriptValue&, const String& groupName, bool generatePreview = false) const;
     RefPtr<Protocol::Runtime::RemoteObject> wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const;
 
index 2dd5643dea49ab64e16575bb6bd071e68b33b35d..9280a58392b0c7e234e8d0e7283d70df35a6ad56 100644 (file)
@@ -58,12 +58,6 @@ InjectedScriptBase::~InjectedScriptBase()
 {
 }
 
-void InjectedScriptBase::initialize(Deprecated::ScriptObject injectedScriptObject, InspectorEnvironment* environment)
-{
-    m_injectedScriptObject = injectedScriptObject;
-    m_environment = environment;
-}
-
 bool InjectedScriptBase::hasAccessToInspectedScriptState() const
 {
     return m_environment && m_environment->canAccessInspectedScriptState(m_injectedScriptObject.scriptState());
index 06c3f5664a549900592a8b208c2d97dd94e79fd4..fd01fabd7fff3c7649ffe336b6bdae7f24223ddf 100644 (file)
@@ -60,7 +60,6 @@ protected:
 
     InspectorEnvironment* inspectorEnvironment() const { return m_environment; }
 
-    void initialize(Deprecated::ScriptObject, InspectorEnvironment*);
     bool hasAccessToInspectedScriptState() const;
 
     const Deprecated::ScriptObject& injectedScriptObject() const;
index 0a7734978eb0e323acb3f470bc1f618acb44d50e..e25f9e3d116094f1dc4751523d81e4355a43d41b 100644 (file)
@@ -189,7 +189,7 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExec
     return result;
 }
 
-void InjectedScriptManager::didCreateInjectedScript(InjectedScript)
+void InjectedScriptManager::didCreateInjectedScript(const InjectedScript&)
 {
     // Intentionally empty. This allows for subclasses to inject additional scripts.
 }
index cb6c9b3b98c54b531341f5a7c0d757bc3191b215..4a39db3c27d875086fc76ddc3bfc2abca8275b6a 100644 (file)
@@ -67,7 +67,7 @@ public:
     void clearExceptionValue();
 
 protected:
-    virtual void didCreateInjectedScript(InjectedScript);
+    virtual void didCreateInjectedScript(const InjectedScript&);
 
     HashMap<int, InjectedScript> m_idToInjectedScript;
     HashMap<JSC::ExecState*, int> m_scriptStateToId;
index 5ba27e08023b5af7acd6a4e3e6ae912b851b39f8..52bdb46b901a6733e05ed00eabed3df73a3ea514 100644 (file)
@@ -54,7 +54,7 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
     ensureInjected(injectedScriptManager, injectedScript);
 }
 
-void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
+void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, const InjectedScript& injectedScript)
 {
     ASSERT(!injectedScript.hasNoValue());
     if (injectedScript.hasNoValue())
@@ -73,16 +73,11 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
         function.appendArgument(source());
         function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
         resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
-        if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
+        if (hadException) {
             ASSERT_NOT_REACHED();
             return;
         }
     }
-
-    if (returnsObject()) {
-        Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
-        initialize(moduleObject, &injectedScriptManager->inspectorEnvironment());
-    }
 }
 
 } // namespace Inspector
index e8881b9ec626c9dcbca69434cb3eb85e885b84f2..a96e618b233cac45ebc842b6ac2dcd0f07bc97d4 100644 (file)
@@ -49,15 +49,14 @@ public:
     virtual ~InjectedScriptModule();
     virtual String source() const = 0;
     virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const = 0;
-    virtual bool returnsObject() const = 0;
 
 protected:
     // Do not expose constructor in the child classes as well. Instead provide
     // a static factory method that would create a new instance of the class
     // and call its ensureInjected() method immediately.
-    InjectedScriptModule(const String& name);
+    explicit InjectedScriptModule(const String& name);
     void ensureInjected(InjectedScriptManager*, JSC::ExecState*);
-    void ensureInjected(InjectedScriptManager*, InjectedScript);
+    void ensureInjected(InjectedScriptManager*, const InjectedScript&);
 };
 
 } // namespace Inspector
index aafdc58584c8033320fc21b29354fd1cf18e0d0f..fa98a8357a11e14a75393e0e75413304f1f68036 100644 (file)
@@ -594,7 +594,7 @@ void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
         breakProgram(DebuggerFrontendDispatcher::Reason::CSPViolation, buildCSPViolationPauseReason(directiveText));
 }
 
-Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> InspectorDebuggerAgent::currentCallFrames(InjectedScript injectedScript)
+Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> InspectorDebuggerAgent::currentCallFrames(const InjectedScript& injectedScript)
 {
     ASSERT(!injectedScript.hasNoValue());
     if (injectedScript.hasNoValue())
index 2064963c6f537b07f7bc8764bd7f50fa914f7b16..c09332cf03a472773b0eb49174ff1b666b5ba879 100644 (file)
@@ -125,7 +125,7 @@ protected:
     void didClearGlobalObject();
 
 private:
-    Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> currentCallFrames(InjectedScript);
+    Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> currentCallFrames(const InjectedScript&);
 
     virtual void didParseSource(JSC::SourceID, const Script&) override final;
     virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) override final;
index ccbad3fc7fdd5cb12db1b6598fe36d1236a242ac..24681f8124b2eb6051ef703001bee26cf6682d52 100644 (file)
@@ -1,3 +1,18 @@
+2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Clean up InjectedScript uses
+        https://bugs.webkit.org/show_bug.cgi?id=150921
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/CommandLineAPIModule.cpp:
+        (WebCore::CommandLineAPIModule::injectIfNeeded):
+        (WebCore::CommandLineAPIModule::CommandLineAPIModule):
+        * inspector/CommandLineAPIModule.h:
+        * inspector/WebInjectedScriptManager.cpp:
+        (WebCore::WebInjectedScriptManager::didCreateInjectedScript):
+        * inspector/WebInjectedScriptManager.h:
+
 2015-11-05  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate references
index 9e561d15f4d3c3c692fcf0d8db4a8cd165ace4c1..a9d621d5f9423d9700a0167a5141e13f2918a521 100644 (file)
@@ -37,15 +37,15 @@ using namespace Inspector;
 
 namespace WebCore {
 
-CommandLineAPIModule::CommandLineAPIModule()
-    : InjectedScriptModule(ASCIILiteral("CommandLineAPI"))
+void CommandLineAPIModule::injectIfNeeded(InjectedScriptManager* injectedScriptManager, const InjectedScript& injectedScript)
 {
+    CommandLineAPIModule module;
+    module.ensureInjected(injectedScriptManager, injectedScript);
 }
 
-void CommandLineAPIModule::injectIfNeeded(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
+CommandLineAPIModule::CommandLineAPIModule()
+    : InjectedScriptModule(ASCIILiteral("CommandLineAPI"))
 {
-    CommandLineAPIModule module;
-    module.ensureInjected(injectedScriptManager, injectedScript);
 }
 
 String CommandLineAPIModule::source() const
index 65c9209c210475159bf95e98a2dd43aaf844369a..c275968999ed14b33ee276eed1c4aec312333215 100644 (file)
@@ -36,9 +36,8 @@ public:
 
     virtual String source() const override;
     virtual JSC::JSValue host(Inspector::InjectedScriptManager*, JSC::ExecState*) const override;
-    virtual bool returnsObject() const override { return false; }
 
-    static void injectIfNeeded(Inspector::InjectedScriptManager*, Inspector::InjectedScript);
+    static void injectIfNeeded(Inspector::InjectedScriptManager*, const Inspector::InjectedScript&);
 };
 
 } // namespace WebCore
index 8fb252bbdb7def5b8d7c4b2886f4c504af4da862..1813756638357f6e9cafe08f0f1c12a647d6a5cf 100644 (file)
@@ -47,7 +47,7 @@ void WebInjectedScriptManager::disconnect()
     m_commandLineAPIHost = nullptr;
 }
 
-void WebInjectedScriptManager::didCreateInjectedScript(InjectedScript injectedScript)
+void WebInjectedScriptManager::didCreateInjectedScript(const Inspector::InjectedScript& injectedScript)
 {
     CommandLineAPIModule::injectIfNeeded(this, injectedScript);
 }
index fcd45d715758424809777e6f14bf47ce90309b6e..2b5f077e5e22d31a1c5efe39ec1fb96cff19f791 100644 (file)
@@ -46,7 +46,7 @@ public:
     void discardInjectedScriptsFor(DOMWindow*);
 
 protected:
-    virtual void didCreateInjectedScript(Inspector::InjectedScript) override;
+    virtual void didCreateInjectedScript(const Inspector::InjectedScript&) override;
 
 private:
     RefPtr<CommandLineAPIHost> m_commandLineAPIHost;