Web Inspector: Clean up InjectedScript uses
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: http://svn.webkit.org/repository/webkit/trunk@192064 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/inspector/InjectedScript.cpp b/Source/JavaScriptCore/inspector/InjectedScript.cpp
index 492060e..72d0759 100644
--- a/Source/JavaScriptCore/inspector/InjectedScript.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScript.cpp
@@ -194,7 +194,7 @@
*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());
diff --git a/Source/JavaScriptCore/inspector/InjectedScript.h b/Source/JavaScriptCore/inspector/InjectedScript.h
index bd43f72..509cd58 100644
--- a/Source/JavaScriptCore/inspector/InjectedScript.h
+++ b/Source/JavaScriptCore/inspector/InjectedScript.h
@@ -62,7 +62,7 @@
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;
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp
index 2dd5643..9280a58 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScriptBase.cpp
@@ -58,12 +58,6 @@
{
}
-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());
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptBase.h b/Source/JavaScriptCore/inspector/InjectedScriptBase.h
index 06c3f56..fd01fab 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptBase.h
+++ b/Source/JavaScriptCore/inspector/InjectedScriptBase.h
@@ -60,7 +60,6 @@
InspectorEnvironment* inspectorEnvironment() const { return m_environment; }
- void initialize(Deprecated::ScriptObject, InspectorEnvironment*);
bool hasAccessToInspectedScriptState() const;
const Deprecated::ScriptObject& injectedScriptObject() const;
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
index 0a77349..e25f9e3 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.cpp
@@ -189,7 +189,7 @@
return result;
}
-void InjectedScriptManager::didCreateInjectedScript(InjectedScript)
+void InjectedScriptManager::didCreateInjectedScript(const InjectedScript&)
{
// Intentionally empty. This allows for subclasses to inject additional scripts.
}
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptManager.h b/Source/JavaScriptCore/inspector/InjectedScriptManager.h
index cb6c9b3..4a39db3 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptManager.h
+++ b/Source/JavaScriptCore/inspector/InjectedScriptManager.h
@@ -67,7 +67,7 @@
void clearExceptionValue();
protected:
- virtual void didCreateInjectedScript(InjectedScript);
+ virtual void didCreateInjectedScript(const InjectedScript&);
HashMap<int, InjectedScript> m_idToInjectedScript;
HashMap<JSC::ExecState*, int> m_scriptStateToId;
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp b/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp
index 5ba27e0..52bdb46 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp
+++ b/Source/JavaScriptCore/inspector/InjectedScriptModule.cpp
@@ -54,7 +54,7 @@
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 @@
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
diff --git a/Source/JavaScriptCore/inspector/InjectedScriptModule.h b/Source/JavaScriptCore/inspector/InjectedScriptModule.h
index e8881b9..a96e618 100644
--- a/Source/JavaScriptCore/inspector/InjectedScriptModule.h
+++ b/Source/JavaScriptCore/inspector/InjectedScriptModule.h
@@ -49,15 +49,14 @@
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
diff --git a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
index aafdc58..fa98a83 100644
--- a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
+++ b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp
@@ -594,7 +594,7 @@
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())
diff --git a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
index 2064963..c09332c 100644
--- a/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
+++ b/Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.h
@@ -125,7 +125,7 @@
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;