Web Inspector: Move InjectedScript classes into JavaScriptCore
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jan 2014 19:00:48 +0000 (19:00 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Jan 2014 19:00:48 +0000 (19:00 +0000)
commitc75a28e38a81b5d90770cf866ec5fd3414920621
treecb381aa20adcf7633a590b5c532dde00e388f4c7
parent1a25b1e85a6821483ce038b383b44fd817e419e8
Web Inspector: Move InjectedScript classes into JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=126598

Source/JavaScriptCore:

Reviewed by Timothy Hatcher.

Part 1: Extract InspectorInstrumentationCookie class from InspectorInstrumentation.
Part 2: Move InjectedScriptSource and generation into JavaScriptCore.
Part 3: Update CodeGeneratorInspector to avoid inlining virtual destructors.
Part 4: Move all inspector scripts into JavaScriptCore and update generators.
Part 5: Move InjectedScript classes into JavaScriptCore
Part 6: Put it all together. Make WebCore use the JavaScriptCore InjectedScript files.

There are pieces of logic that WebCore wants to hook into in the InjectedScript
execution (e.g. for CommandLineAPIModule and InspectorInstrumentation). Create
hooks for those in a base class called InspectorEnvironment. For now, the
InspectorControllers (Page, JSGlobalObject, Worker) will be the InspectorEnvironments
and provide answers to its hooks.

* inspector/InspectorEnvironment.h: Added.
New hooks needed by WebCore in various places. Mostly stubbed in JavaScriptCore.

* inspector/InjectedScript.cpp: Renamed from Source/WebCore/inspector/InjectedScript.cpp.
* inspector/InjectedScript.h: Added.
* inspector/InjectedScriptBase.cpp: Renamed from Source/WebCore/inspector/InjectedScriptBase.cpp.
* inspector/InjectedScriptBase.h: Renamed from Source/WebCore/inspector/InjectedScriptBase.h.
* inspector/InjectedScriptModule.cpp: Renamed from Source/WebCore/inspector/InjectedScriptModule.cpp.
* inspector/InjectedScriptModule.h: Renamed from Source/WebCore/inspector/InjectedScriptModule.h.
Cleanup the style of these files (nullptr, formatting, whitespace, etc).
Use the InspectorEnvironments call/evaluate function for ScriptFunctionCalls and checking access

* inspector/InjectedScriptManager.cpp: Renamed from Source/WebCore/inspector/InjectedScriptManager.cpp.
* inspector/InjectedScriptManager.h: Renamed from Source/WebCore/inspector/InjectedScriptManager.h.
Take an InspectorEnvironment with multiple hooks, instead of a single hook function.

* inspector/InjectedScriptHost.cpp: Added.
* inspector/InjectedScriptHost.h: Added.
* inspector/JSInjectedScriptHost.cpp: Renamed from Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp.
* inspector/JSInjectedScriptHost.h: Added.
* inspector/JSInjectedScriptHostPrototype.cpp: Added.
* inspector/JSInjectedScriptHostPrototype.h: Added.
Implementation of InjectedScriptHost which is passed into the script (InjectedScriptSource.js)
that we inject into the page. This is mostly copied from the original autogenerated code,
then simplified and cleaned up. InjectedScriptHost can be subclasses to provide specialized
implementations of isHTMLAllCollection and type for Web/DOM types unknown to a pure JS context.

For OS X be sure to export the scripts as if they are private headers.

* GNUmakefile.am:
* JavaScriptCore.xcodeproj/project.pbxproj:
* inspector/scripts/cssmin.py: Renamed from Source/WebCore/inspector/Scripts/cssmin.py.
* inspector/scripts/inline-and-minify-stylesheets-and-scripts.py: Renamed from Source/WebCore/inspector/Scripts/inline-and-minify-stylesheets-and-scripts.py.
* inspector/scripts/jsmin.py: Renamed from Source/WebCore/inspector/Scripts/jsmin.py.
* inspector/scripts/xxd.pl: Renamed from Source/WebCore/inspector/xxd.pl.

This avoids build errors about duplicate exported virtual inlined methods
are included from multiple places. Just put empty destructors in the
implementation file instead of inlined.

* inspector/scripts/CodeGeneratorInspector.py:
(Generator):
(Generator.go):
* inspector/scripts/CodeGeneratorInspectorStrings.py:

Move InjectedScriptSource.js and derived sources generation.

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* inspector/InjectedScriptSource.js: Renamed from Source/WebCore/inspector/InjectedScriptSource.js.

Source/WebCore:

Reviewed by Timothy Hatcher.

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* GNUmakefile.list.am:
* UseJSC.cmake:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
Remove old InjectedScript files.

* ForwardingHeaders/inspector/InjectedScript.h: Added.
* ForwardingHeaders/inspector/InjectedScriptBase.h: Added.
* ForwardingHeaders/inspector/InjectedScriptHost.h: Added.
* ForwardingHeaders/inspector/InjectedScriptManager.h: Added.
* ForwardingHeaders/inspector/InjectedScriptModule.h: Added.
* ForwardingHeaders/inspector/InspectorEnvironment.h: Added.
Expose headers to WebCore.

* inspector/InspectorController.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::developerExtrasEnabled):
(WebCore::InspectorController::canAccessInspectedScriptState):
(WebCore::InspectorController::functionCallHandler):
(WebCore::InspectorController::evaluateHandler):
(WebCore::InspectorController::willCallInjectedScriptFunction):
(WebCore::InspectorController::didCallInjectedScriptFunction):
* inspector/WorkerInspectorController.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
(WebCore::WorkerInspectorController::functionCallHandler):
(WebCore::WorkerInspectorController::evaluateHandler):
(WebCore::WorkerInspectorController::willCallInjectedScriptFunction):
(WebCore::WorkerInspectorController::didCallInjectedScriptFunction):
Make both InspectorControllers in WebCore be InspectorEnvironments.

* bindings/js/JSMainThreadExecState.h:
* bindings/js/JSMainThreadExecState.cpp:
(WebCore::evaluateHandlerFromAnyThread):
Make JSC::evaluate wrapper like the existing JSC::call wrapper.
These will be the ScriptFunctionCall implementations when debugging
a WebCore::Page or worker, instead of the pure JSC versions.

* inspector/PageInjectedScriptHost.h: Copied from Source/WebCore/inspector/CommandLineAPIModule.h.
* inspector/PageInjectedScriptHost.cpp: Copied from Source/WebCore/inspector/PageInjectedScriptManager.cpp.
(WebCore::PageInjectedScriptHost::type):
(WebCore::PageInjectedScriptHost::isHTMLAllCollection):
WebCore InjectedScriptHost implementation for DOM type handling.

* inspector/PageInjectedScriptManager.h:
* inspector/PageInjectedScriptManager.cpp:
(WebCore::PageInjectedScriptManager::PageInjectedScriptManager):
(WebCore::PageInjectedScriptManager::discardInjectedScriptsFor):
WebCore InjectedScriptManager implementation for CommandLineAPI and
specialized DOMWindow injected script management.

* bindings/js/JSBindingsAllInOne.cpp:
* inspector/CommandLineAPIHost.cpp:
* inspector/CommandLineAPIHost.h:
* inspector/CommandLineAPIModule.cpp:
(WebCore::CommandLineAPIModule::host):
* inspector/CommandLineAPIModule.h:
* inspector/ConsoleMessage.cpp:
(WebCore::ConsoleMessage::addToFrontend):
* inspector/ConsoleMessage.h:
* inspector/InjectedScriptCanvasModule.cpp:
(WebCore::InjectedScriptCanvasModule::InjectedScriptCanvasModule):
* inspector/InjectedScriptCanvasModule.h:
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorCanvasAgent.cpp:
* inspector/InspectorCanvasAgent.h:
(WebCore::InspectorCanvasAgent::create):
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorDOMAgent.cpp:
* inspector/InspectorDOMAgent.h:
(WebCore::InspectorDOMAgent::create):
* inspector/InspectorDebuggerAgent.cpp:
* inspector/InspectorDebuggerAgent.h:
(WebCore::InspectorDebuggerAgent::injectedScriptManager):
* inspector/InspectorHeapProfilerAgent.cpp:
(WebCore::InspectorHeapProfilerAgent::create):
(WebCore::InspectorHeapProfilerAgent::InspectorHeapProfilerAgent):
* inspector/InspectorHeapProfilerAgent.h:
* inspector/InspectorIndexedDBAgent.cpp:
* inspector/InspectorIndexedDBAgent.h:
(WebCore::InspectorIndexedDBAgent::create):
* inspector/InspectorPageAgent.cpp:
* inspector/InspectorPageAgent.h:
* inspector/InspectorProfilerAgent.cpp:
(WebCore::PageProfilerAgent::PageProfilerAgent):
(WebCore::InspectorProfilerAgent::create):
(WebCore::WorkerProfilerAgent::WorkerProfilerAgent):
(WebCore::InspectorProfilerAgent::InspectorProfilerAgent):
* inspector/InspectorProfilerAgent.h:
* inspector/InspectorRuntimeAgent.cpp:
* inspector/InspectorRuntimeAgent.h:
(WebCore::InspectorRuntimeAgent::injectedScriptManager):
* inspector/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::PageConsoleAgent):
* inspector/PageConsoleAgent.h:
(WebCore::PageConsoleAgent::create):
* inspector/PageDebuggerAgent.cpp:
* inspector/PageDebuggerAgent.h:
* inspector/PageRuntimeAgent.cpp:
* inspector/PageRuntimeAgent.h:
(WebCore::PageRuntimeAgent::create):
* inspector/WorkerConsoleAgent.cpp:
(WebCore::WorkerConsoleAgent::WorkerConsoleAgent):
* inspector/WorkerConsoleAgent.h:
(WebCore::WorkerConsoleAgent::create):
* inspector/WorkerDebuggerAgent.cpp:
* inspector/WorkerDebuggerAgent.h:
* inspector/WorkerRuntimeAgent.cpp:
* inspector/WorkerRuntimeAgent.h:
(WebCore::WorkerRuntimeAgent::create):
Switch to using the Inspector namespace and JSC InjectedScript files.

* bindings/js/JSInjectedScriptManager.cpp: Removed.
* inspector/InjectedScript.h: Removed.
* inspector/InjectedScriptHost.cpp: Removed.
* inspector/InjectedScriptHost.h: Removed.
* inspector/InjectedScriptHost.idl: Removed.

With the updated location switch to using the appropriate INSPECTOR_SCRIPTS_DIR
variable which defines where the scripts are.

* CMakeLists.txt:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:

Currently InjectedScriptBase uses InspectorInstrumentation directly
to track calling into JavaScript for timeline purposes. We will remove
the direct call from InjectedScriptBase and extracting the Cookie class
will make that easier.

* CMakeLists.txt:
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
* inspector/InspectorInstrumentation.cpp:
* inspector/InspectorInstrumentation.h:
* inspector/InspectorInstrumentationCookie.cpp: Added.
(WebCore::InspectorInstrumentationCookie::InspectorInstrumentationCookie):
(WebCore::InspectorInstrumentationCookie::operator=):
(WebCore::InspectorInstrumentationCookie::~InspectorInstrumentationCookie):
* inspector/InspectorInstrumentationCookie.h: Added.
(WebCore::InspectorInstrumentationCookie::isValid):
(WebCore::InspectorInstrumentationCookie::instrumentingAgents):
(WebCore::InspectorInstrumentationCookie::hasMatchingTimelineAgentId):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161563 268f45cc-cd09-0410-ab3c-d52691b4dbfc
104 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/GNUmakefile.am
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/inspector/InjectedScript.cpp [moved from Source/WebCore/inspector/InjectedScript.cpp with 77% similarity]
Source/JavaScriptCore/inspector/InjectedScript.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/InjectedScriptBase.cpp [moved from Source/WebCore/inspector/InjectedScriptBase.cpp with 69% similarity]
Source/JavaScriptCore/inspector/InjectedScriptBase.h [moved from Source/WebCore/inspector/InjectedScriptBase.h with 78% similarity]
Source/JavaScriptCore/inspector/InjectedScriptHost.cpp [new file with mode: 0644]
Source/JavaScriptCore/inspector/InjectedScriptHost.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/InjectedScriptManager.cpp [moved from Source/WebCore/inspector/InjectedScriptManager.cpp with 55% similarity]
Source/JavaScriptCore/inspector/InjectedScriptManager.h [moved from Source/WebCore/inspector/InjectedScriptManager.h with 70% similarity]
Source/JavaScriptCore/inspector/InjectedScriptModule.cpp [moved from Source/WebCore/inspector/InjectedScriptModule.cpp with 86% similarity]
Source/JavaScriptCore/inspector/InjectedScriptModule.h [moved from Source/WebCore/inspector/InjectedScriptModule.h with 89% similarity]
Source/JavaScriptCore/inspector/InjectedScriptSource.js [moved from Source/WebCore/inspector/InjectedScriptSource.js with 100% similarity]
Source/JavaScriptCore/inspector/InspectorEnvironment.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/JSInjectedScriptHost.cpp [moved from Source/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp with 53% similarity]
Source/JavaScriptCore/inspector/JSInjectedScriptHost.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.cpp [new file with mode: 0644]
Source/JavaScriptCore/inspector/JSInjectedScriptHostPrototype.h [new file with mode: 0644]
Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspector.py
Source/JavaScriptCore/inspector/scripts/CodeGeneratorInspectorStrings.py
Source/JavaScriptCore/inspector/scripts/cssmin.py [moved from Source/WebCore/inspector/Scripts/cssmin.py with 100% similarity]
Source/JavaScriptCore/inspector/scripts/inline-and-minify-stylesheets-and-scripts.py [moved from Source/WebCore/inspector/Scripts/inline-and-minify-stylesheets-and-scripts.py with 100% similarity]
Source/JavaScriptCore/inspector/scripts/jsmin.py [moved from Source/WebCore/inspector/Scripts/jsmin.py with 100% similarity]
Source/JavaScriptCore/inspector/scripts/xxd.pl [moved from Source/WebCore/inspector/xxd.pl with 100% similarity]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.cpp
Source/WebCore/DerivedSources.make
Source/WebCore/ForwardingHeaders/inspector/InjectedScript.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/InjectedScriptBase.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/InjectedScriptHost.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/InjectedScriptManager.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/InjectedScriptModule.h [new file with mode: 0644]
Source/WebCore/ForwardingHeaders/inspector/InspectorEnvironment.h [new file with mode: 0644]
Source/WebCore/GNUmakefile.am
Source/WebCore/GNUmakefile.list.am
Source/WebCore/UseJSC.cmake
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSInjectedScriptManager.cpp [deleted file]
Source/WebCore/bindings/js/JSMainThreadExecState.cpp
Source/WebCore/bindings/js/JSMainThreadExecState.h
Source/WebCore/inspector/CommandLineAPIHost.cpp
Source/WebCore/inspector/CommandLineAPIHost.h
Source/WebCore/inspector/CommandLineAPIModule.cpp
Source/WebCore/inspector/CommandLineAPIModule.h
Source/WebCore/inspector/ConsoleMessage.cpp
Source/WebCore/inspector/ConsoleMessage.h
Source/WebCore/inspector/InjectedScript.h [deleted file]
Source/WebCore/inspector/InjectedScriptCanvasModule.cpp
Source/WebCore/inspector/InjectedScriptCanvasModule.h
Source/WebCore/inspector/InjectedScriptHost.cpp [deleted file]
Source/WebCore/inspector/InjectedScriptHost.h [deleted file]
Source/WebCore/inspector/InjectedScriptHost.idl [deleted file]
Source/WebCore/inspector/InspectorAllInOne.cpp
Source/WebCore/inspector/InspectorCanvasAgent.cpp
Source/WebCore/inspector/InspectorCanvasAgent.h
Source/WebCore/inspector/InspectorConsoleAgent.cpp
Source/WebCore/inspector/InspectorConsoleAgent.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorDebuggerAgent.cpp
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorHeapProfilerAgent.cpp
Source/WebCore/inspector/InspectorHeapProfilerAgent.h
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorInstrumentationCookie.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorInstrumentationCookie.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/InspectorProfilerAgent.cpp
Source/WebCore/inspector/InspectorProfilerAgent.h
Source/WebCore/inspector/InspectorRuntimeAgent.cpp
Source/WebCore/inspector/InspectorRuntimeAgent.h
Source/WebCore/inspector/PageConsoleAgent.cpp
Source/WebCore/inspector/PageConsoleAgent.h
Source/WebCore/inspector/PageDebuggerAgent.cpp
Source/WebCore/inspector/PageDebuggerAgent.h
Source/WebCore/inspector/PageInjectedScriptHost.cpp [new file with mode: 0644]
Source/WebCore/inspector/PageInjectedScriptHost.h [new file with mode: 0644]
Source/WebCore/inspector/PageInjectedScriptManager.cpp
Source/WebCore/inspector/PageInjectedScriptManager.h
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerConsoleAgent.cpp
Source/WebCore/inspector/WorkerConsoleAgent.h
Source/WebCore/inspector/WorkerDebuggerAgent.cpp
Source/WebCore/inspector/WorkerDebuggerAgent.h
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/inspector/WorkerInspectorController.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h