Skip to content

Commit 7a44021

Browse files
JosephPecorarowebkit-commit-queue
authored andcommitted
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: Canonical link: https://commits.webkit.org/169146@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192064 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 24e27af commit 7a44021

16 files changed

Lines changed: 56 additions & 32 deletions

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
2015-11-05 Joseph Pecoraro <pecoraro@apple.com>
2+
3+
Web Inspector: Clean up InjectedScript uses
4+
https://bugs.webkit.org/show_bug.cgi?id=150921
5+
6+
Reviewed by Timothy Hatcher.
7+
8+
* inspector/InjectedScript.cpp:
9+
(Inspector::InjectedScript::wrapCallFrames):
10+
* inspector/InjectedScript.h:
11+
* inspector/InjectedScriptBase.cpp:
12+
(Inspector::InjectedScriptBase::initialize): Deleted.
13+
* inspector/InjectedScriptBase.h:
14+
* inspector/InjectedScriptManager.cpp:
15+
(Inspector::InjectedScriptManager::didCreateInjectedScript):
16+
* inspector/InjectedScriptManager.h:
17+
* inspector/InjectedScriptModule.cpp:
18+
(Inspector::InjectedScriptModule::ensureInjected):
19+
* inspector/InjectedScriptModule.h:
20+
* inspector/agents/InspectorDebuggerAgent.cpp:
21+
(Inspector::InspectorDebuggerAgent::currentCallFrames):
22+
* inspector/agents/InspectorDebuggerAgent.h:
23+
124
2015-11-05 Joseph Pecoraro <pecoraro@apple.com>
225

326
Web Inspector: Put ScriptDebugServer into InspectorEnvironment and cleanup duplicate references

‎Source/JavaScriptCore/inspector/InjectedScript.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void InjectedScript::saveResult(ErrorString& errorString, const String& callArgu
194194
*savedResultIndex = savedResultIndexInt;
195195
}
196196

197-
Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames)
197+
Ref<Array<Inspector::Protocol::Debugger::CallFrame>> InjectedScript::wrapCallFrames(const Deprecated::ScriptValue& callFrames) const
198198
{
199199
ASSERT(!hasNoValue());
200200
Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("wrapCallFrames"), inspectorEnvironment()->functionCallHandler());

‎Source/JavaScriptCore/inspector/InjectedScript.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class JS_EXPORT_PRIVATE InjectedScript : public InjectedScriptBase {
6262
void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries);
6363
void saveResult(ErrorString&, const String& callArgumentJSON, Inspector::Protocol::OptOutput<int>* savedResultIndex);
6464

65-
Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
65+
Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&) const;
6666
RefPtr<Protocol::Runtime::RemoteObject> wrapObject(const Deprecated::ScriptValue&, const String& groupName, bool generatePreview = false) const;
6767
RefPtr<Protocol::Runtime::RemoteObject> wrapTable(const Deprecated::ScriptValue& table, const Deprecated::ScriptValue& columns) const;
6868

‎Source/JavaScriptCore/inspector/InjectedScriptBase.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ InjectedScriptBase::~InjectedScriptBase()
5858
{
5959
}
6060

61-
void InjectedScriptBase::initialize(Deprecated::ScriptObject injectedScriptObject, InspectorEnvironment* environment)
62-
{
63-
m_injectedScriptObject = injectedScriptObject;
64-
m_environment = environment;
65-
}
66-
6761
bool InjectedScriptBase::hasAccessToInspectedScriptState() const
6862
{
6963
return m_environment && m_environment->canAccessInspectedScriptState(m_injectedScriptObject.scriptState());

‎Source/JavaScriptCore/inspector/InjectedScriptBase.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class JS_EXPORT_PRIVATE InjectedScriptBase {
6060

6161
InspectorEnvironment* inspectorEnvironment() const { return m_environment; }
6262

63-
void initialize(Deprecated::ScriptObject, InspectorEnvironment*);
6463
bool hasAccessToInspectedScriptState() const;
6564

6665
const Deprecated::ScriptObject& injectedScriptObject() const;

‎Source/JavaScriptCore/inspector/InjectedScriptManager.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ InjectedScript InjectedScriptManager::injectedScriptFor(ExecState* inspectedExec
189189
return result;
190190
}
191191

192-
void InjectedScriptManager::didCreateInjectedScript(InjectedScript)
192+
void InjectedScriptManager::didCreateInjectedScript(const InjectedScript&)
193193
{
194194
// Intentionally empty. This allows for subclasses to inject additional scripts.
195195
}

‎Source/JavaScriptCore/inspector/InjectedScriptManager.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class JS_EXPORT_PRIVATE InjectedScriptManager {
6767
void clearExceptionValue();
6868

6969
protected:
70-
virtual void didCreateInjectedScript(InjectedScript);
70+
virtual void didCreateInjectedScript(const InjectedScript&);
7171

7272
HashMap<int, InjectedScript> m_idToInjectedScript;
7373
HashMap<JSC::ExecState*, int> m_scriptStateToId;

‎Source/JavaScriptCore/inspector/InjectedScriptModule.cpp‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
5454
ensureInjected(injectedScriptManager, injectedScript);
5555
}
5656

57-
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, InjectedScript injectedScript)
57+
void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptManager, const InjectedScript& injectedScript)
5858
{
5959
ASSERT(!injectedScript.hasNoValue());
6060
if (injectedScript.hasNoValue())
@@ -73,16 +73,11 @@ void InjectedScriptModule::ensureInjected(InjectedScriptManager* injectedScriptM
7373
function.appendArgument(source());
7474
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
7575
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
76-
if (hadException || (returnsObject() && (resultValue.hasNoValue() || !resultValue.isObject()))) {
76+
if (hadException) {
7777
ASSERT_NOT_REACHED();
7878
return;
7979
}
8080
}
81-
82-
if (returnsObject()) {
83-
Deprecated::ScriptObject moduleObject(injectedScript.scriptState(), resultValue);
84-
initialize(moduleObject, &injectedScriptManager->inspectorEnvironment());
85-
}
8681
}
8782

8883
} // namespace Inspector

‎Source/JavaScriptCore/inspector/InjectedScriptModule.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ class JS_EXPORT_PRIVATE InjectedScriptModule : public InjectedScriptBase {
4949
virtual ~InjectedScriptModule();
5050
virtual String source() const = 0;
5151
virtual JSC::JSValue host(InjectedScriptManager*, JSC::ExecState*) const = 0;
52-
virtual bool returnsObject() const = 0;
5352

5453
protected:
5554
// Do not expose constructor in the child classes as well. Instead provide
5655
// a static factory method that would create a new instance of the class
5756
// and call its ensureInjected() method immediately.
58-
InjectedScriptModule(const String& name);
57+
explicit InjectedScriptModule(const String& name);
5958
void ensureInjected(InjectedScriptManager*, JSC::ExecState*);
60-
void ensureInjected(InjectedScriptManager*, InjectedScript);
59+
void ensureInjected(InjectedScriptManager*, const InjectedScript&);
6160
};
6261

6362
} // namespace Inspector

‎Source/JavaScriptCore/inspector/agents/InspectorDebuggerAgent.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directive
594594
breakProgram(DebuggerFrontendDispatcher::Reason::CSPViolation, buildCSPViolationPauseReason(directiveText));
595595
}
596596

597-
Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> InspectorDebuggerAgent::currentCallFrames(InjectedScript injectedScript)
597+
Ref<Inspector::Protocol::Array<Inspector::Protocol::Debugger::CallFrame>> InspectorDebuggerAgent::currentCallFrames(const InjectedScript& injectedScript)
598598
{
599599
ASSERT(!injectedScript.hasNoValue());
600600
if (injectedScript.hasNoValue())

0 commit comments

Comments
 (0)