Make the Web Inspector use a separate web process.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Sep 2014 19:58:08 +0000 (19:58 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Sep 2014 19:58:08 +0000 (19:58 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135120

Reviewed by Anders Carlsson.

Source/WebCore:

* English.lproj/Localizable.strings: Updated.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ScriptGlobalObject.h:
* bindings/js/ScriptState.h:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorPageAgent.h:
* page/Chrome.h:
Exported a few functions and private headers.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::setInspectorFrontendClient):
(WebCore::InspectorController::hasInspectorFrontendClient):
(WebCore::InspectorController::show):
* inspector/InspectorController.h:
Make InspectorFrontendClient a pointer instead of a std::unique_ptr.
This makes it easier to implement InspectorFrontendClient as
part of an existing object that is externally owned.

* testing/Internals.cpp:
(WebCore::Internals::openDummyInspectorFrontend):
(WebCore::Internals::closeDummyInspectorFrontend):
* testing/Internals.h:
Change InspectorFrontendClientDummy from being moved to owned.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js: Updated.

* UserInterface/Base/Main.js:
(WebInspector.loaded):
(WebInspector.contentLoaded):
Move InspectorFrontendHost.loaded to later in the load.
Calling it early just shows the window before we have
a user interface to show.

* UserInterface/Base/Test.js:
(WebInspector.loaded):
(WebInspector.contentLoaded):
Match the changes in Main.js.

* UserInterface/Protocol/InspectorFrontendAPI.js:
(InspectorFrontendAPI.savedURL): Change comment.
(InspectorFrontendAPI.appendedToURL): Change comment.
(InspectorFrontendAPI.dispatch): Add an assert and early
return to be safe from unknown commands.
(InspectorFrontendAPI.loadCompleted): Delete _pendingCommands,
no need to keep an empty array around a one time use.

Source/WebKit/ios:

* WebCoreSupport/WebInspectorClientIOS.mm:
(WebInspectorClient::WebInspectorClient):
Removed m_frontendClient initialization since it is
now a std::unique_ptr that defaults to nullptr.

Source/WebKit/mac:

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::WebInspectorClient):
(WebInspectorClient::openInspectorFrontend):
(WebInspectorClient::releaseFrontend):
Own WebInspectorFrontendClient instead of moving it.

Source/WebKit/win:

* WebCoreSupport/WebInspectorClient.cpp:
(WebInspectorClient::openInspectorFrontend):
* WebCoreSupport/WebInspectorClient.h:
(WebInspectorClient::frontendClient):
Own WebInspectorFrontendClient instead of moving it.

Source/WebKit2:

* CMakeLists.txt:
* DerivedSources.make:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* WebKit2.xcodeproj/project.pbxproj:
Added new WebInspectorUI files and removed WebInspectorFrontendClient.cpp.

* Shared/APIObject.h: Added BundleInspectorUI.

* Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.mm:
(WebKit::ChildProcessMainDelegate::getExtraInitializationData):
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
Add support for "inspector-process" data, a boolean that is used by
WebProcess::initializeProcessName.

* UIProcess/API/C/WKInspector.cpp:
(WKInspectorIsDebuggingJavaScript):
(WKInspectorToggleJavaScriptDebugging):
(WKInspectorIsProfilingJavaScript):
(WKInspectorToggleJavaScriptProfiling):
* UIProcess/API/C/WKInspector.h:
Stub out functions we don't support but need to keep for nightly compatibility.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorPageGroups::createInspectorPageGroup):
(WebKit::WebInspectorProxy::WebInspectorProxy):
(WebKit::WebInspectorProxy::invalidate):
(WebKit::WebInspectorProxy::connect):
(WebKit::WebInspectorProxy::showConsole):
(WebKit::WebInspectorProxy::showResources):
(WebKit::WebInspectorProxy::showMainResourceForFrame):
(WebKit::WebInspectorProxy::attach):
(WebKit::WebInspectorProxy::detach):
(WebKit::WebInspectorProxy::inspectorContext):
(WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend):
(WebKit::WebInspectorProxy::eagerlyCreateInspectorPage):
(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::open):
(WebKit::WebInspectorProxy::didClose):
(WebKit::WebInspectorProxy::attachAvailabilityChanged):
* UIProcess/WebInspectorProxy.h:
(WebKit::WebInspectorProxy::isConnected):
(WebKit::WebInspectorProxy::canAttach):
* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/efl/WebInspectorProxyEfl.cpp:
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::platformAttach):
* UIProcess/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter close]):
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
(WebKit::WebInspectorProxy::platformDidClose):
(WebKit::WebInspectorProxy::platformHide):
(WebKit::WebInspectorProxy::platformSave):
(WebKit::WebInspectorProxy::platformAppend):
(WebKit::WebInspectorProxy::platformAttach):
Changed how the Inspector page is created by making it in a new WebContext for
the Inspector. This removes us from the main process pool and guarantees no process
sharing for our user interface. Also send new WebInspectorUI messages to the Inspector
page and not the inspected page when appropriate.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getLaunchOptions): Add "inspector-process" to extraInitializationData
if the context is the Inspector context. This is used by WebProcess::initializeProcessName.

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::openInspectorFrontend):
(WebKit::WebInspectorClient::closeInspectorFrontend):
(WebKit::WebInspectorClient::bringFrontendToFront):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
Remove the InspectorFrontendChannel class from WebInspectorClient and clean up a little.
InspectorFrontendChannel implementation moved to WebInspector.

* WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp: Removed. Superseded by WebInspectorUI.

* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::create):
(WebKit::WebInspector::WebInspector):
(WebKit::WebInspector::createInspectorPage):
(WebKit::WebInspector::closeFrontend):
(WebKit::WebInspector::openInNewTab):
(WebKit::WebInspector::showConsole):
(WebKit::WebInspector::showResources):
(WebKit::WebInspector::showMainResourceForFrame):
(WebKit::WebInspector::startPageProfiling):
(WebKit::WebInspector::stopPageProfiling):
(WebKit::WebInspector::canAttachWindow):
(WebKit::WebInspector::updateDockingAvailability):
(WebKit::WebInspector::sendMessageToBackend):
(WebKit::WebInspector::sendMessageToFrontend):
(WebKit::WebInspector::remoteFrontendConnected):
(WebKit::WebInspector::remoteFrontendDisconnected):
* WebProcess/WebPage/WebInspector.h:
(WebKit::WebInspector::didClose):
(WebKit::WebInspector::didReceiveInvalidMessage):
(WebKit::WebInspector::setAttached):
* WebProcess/WebPage/WebInspector.messages.in:
Stop taking an optional InspectorFrontendChannel and inherit it instead. Create a connection that
can be passed to the other web process for WebInspectorUI to use. Stop referencing Inspector's page
directly, since it is in another process now.

* WebProcess/WebPage/WebInspectorUI.cpp: Added.
(WebKit::WebInspectorUI::create):
(WebKit::WebInspectorUI::WebInspectorUI):
(WebKit::WebInspectorUI::establishConnection):
(WebKit::WebInspectorUI::windowObjectCleared):
(WebKit::WebInspectorUI::frontendLoaded):
(WebKit::WebInspectorUI::moveWindowBy):
(WebKit::WebInspectorUI::bringToFront):
(WebKit::WebInspectorUI::closeWindow):
(WebKit::WebInspectorUI::requestSetDockSide):
(WebKit::WebInspectorUI::setDockSide):
(WebKit::WebInspectorUI::changeAttachedWindowHeight):
(WebKit::WebInspectorUI::changeAttachedWindowWidth):
(WebKit::WebInspectorUI::setToolbarHeight):
(WebKit::WebInspectorUI::openInNewTab):
(WebKit::WebInspectorUI::save):
(WebKit::WebInspectorUI::append):
(WebKit::WebInspectorUI::inspectedURLChanged):
(WebKit::WebInspectorUI::showConsole):
(WebKit::WebInspectorUI::showResources):
(WebKit::WebInspectorUI::showMainResourceForFrame):
(WebKit::WebInspectorUI::startPageProfiling):
(WebKit::WebInspectorUI::stopPageProfiling):
(WebKit::WebInspectorUI::didSave):
(WebKit::WebInspectorUI::didAppend):
(WebKit::WebInspectorUI::sendMessageToFrontend):
(WebKit::WebInspectorUI::sendMessageToBackend):
(WebKit::WebInspectorUI::evaluateCommandOnLoad):
(WebKit::WebInspectorUI::evaluateExpressionOnLoad):
(WebKit::WebInspectorUI::evaluatePendingExpressions):
* WebProcess/WebPage/WebInspectorUI.h: Added.
(WebKit::WebInspectorUI::page):
(WebKit::WebInspectorUI::didClose):
(WebKit::WebInspectorUI::didReceiveInvalidMessage):
(WebKit::WebInspectorUI::attachedBottom):
(WebKit::WebInspectorUI::attachedRight):
(WebKit::WebInspectorUI::detached):
(WebKit::WebInspectorUI::evaluateCommandOnLoad):
* WebProcess/WebPage/WebInspectorUI.messages.in: Added.
* WebProcess/WebPage/efl/WebInspectorUIEfl.cpp: Added.
(WebKit::WebInspectorUI::canSave):
(WebKit::WebInspectorUI::localizedStringsURL):
* WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp: Added.
(WebKit::WebInspectorUI::canSave):
(WebKit::WebInspectorUI::localizedStringsURL):
* WebProcess/WebPage/mac/WebInspectorUIMac.mm: Added.
(WebKit::WebInspectorUI::canSave):
(WebKit::WebInspectorUI::localizedStringsURL):
Implement the InspectorFrontendClient and handle a connection to the inspected page's WebInspector.

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::~WebPage):
(WebKit::WebPage::inspector):
(WebKit::WebPage::inspectorUI):
(WebKit::WebPage::didReceiveMessage):
Setup as a listener for WebInspectorUI messages.

* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::isInspectorPage): It is an Inspector page if we have a m_inspectorUI.

* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::initializeProcessName):
Name the process "%@ Web Inspector" if it is an Inspector content process. Processes in that
context are not shared with multiple pages.

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

60 files changed:
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/WebCore.exp.in
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/ScriptGlobalObject.h
Source/WebCore/bindings/js/ScriptState.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/page/Chrome.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Base/Test.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js
Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
Source/WebKit/ios/ChangeLog
Source/WebKit/ios/WebCoreSupport/WebInspectorClientIOS.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit/win/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.make
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.mm
Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm
Source/WebKit2/UIProcess/API/C/WKInspector.cpp
Source/WebKit2/UIProcess/API/C/WKInspector.h
Source/WebKit2/UIProcess/WebInspectorProxy.cpp
Source/WebKit2/UIProcess/WebInspectorProxy.h
Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp
Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h
Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp [deleted file]
Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.h
Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.messages.in [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/efl/WebInspectorUIEfl.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/mac/WebInspectorUIMac.mm [new file with mode: 0644]
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm

index d38fe4c..ff909e0 100644 (file)
@@ -1,3 +1,38 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * English.lproj/Localizable.strings: Updated.
+
+        * WebCore.exp.in:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptGlobalObject.h:
+        * bindings/js/ScriptState.h:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorPageAgent.h:
+        * page/Chrome.h:
+        Exported a few functions and private headers.
+
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::setInspectorFrontendClient):
+        (WebCore::InspectorController::hasInspectorFrontendClient):
+        (WebCore::InspectorController::show):
+        * inspector/InspectorController.h:
+        Make InspectorFrontendClient a pointer instead of a std::unique_ptr.
+        This makes it easier to implement InspectorFrontendClient as
+        part of an existing object that is externally owned.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::openDummyInspectorFrontend):
+        (WebCore::Internals::closeDummyInspectorFrontend):
+        * testing/Internals.h:
+        Change InspectorFrontendClientDummy from being moved to owned.
+
 2014-09-23  Dean Jackson  <dino@apple.com>
 
         [Yosemite] Button text doesn't go white while pushing the button, like it does for real buttons
index 141167e..77dd707 100644 (file)
@@ -49,6 +49,9 @@
 /* Visible name of the web process. The argument is the application name. */
 "%@ Web Content" = "%@ Web Content";
 
+/* Visible name of Web Inspector's web process. The argument is the application name. */
+"%@ Web Inspector" = "%@ Web Inspector";
+
 /* Name of application's single WebCrypto master key in Keychain */
 "%@ WebCrypto Master Key" = "%@ WebCrypto Master Key";
 
index 21729a9..4445d50 100644 (file)
@@ -770,6 +770,7 @@ __ZN7WebCore17SQLiteTransactionD1Ev
 __ZN7WebCore17SubresourceLoader6createEPNS_5FrameEPNS_14CachedResourceERKNS_15ResourceRequestERKNS_21ResourceLoaderOptionsE
 __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
 __ZN7WebCore17encodeForFileNameERKN3WTF6StringE
+__ZN7WebCore17execStateFromPageERNS_15DOMWrapperWorldEPNS_4PageE
 __ZN7WebCore17languageDidChangeEv
 __ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
 __ZN7WebCore17sRGBColorSpaceRefEv
@@ -793,6 +794,7 @@ __ZN7WebCore18PlatformPasteboard8addTypesERKN3WTF6VectorINS1_6StringELm0ENS1_15C
 __ZN7WebCore18PlatformPasteboard8getTypesERN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore18PlatformPasteboard8setTypesERKN3WTF6VectorINS1_6StringELm0ENS1_15CrashOnOverflowEEE
 __ZN7WebCore18PlatformPasteboardC1ERKN3WTF6StringE
+__ZN7WebCore18ScriptGlobalObject3setEPN3JSC9ExecStateEPKcPNS_21InspectorFrontendHostE
 __ZN7WebCore18StyleSheetContents11parseStringERKN3WTF6StringE
 __ZN7WebCore18StyleSheetContentsC1EPNS_15StyleRuleImportERKN3WTF6StringERKNS_16CSSParserContextE
 __ZN7WebCore18StyleSheetContentsD1Ev
@@ -1925,7 +1927,10 @@ __ZNK7WebCore5Range9endOffsetERi
 __ZNK7WebCore5Range9firstNodeEv
 __ZNK7WebCore5Range9textQuadsERN3WTF6VectorINS_9FloatQuadELm0ENS1_15CrashOnOverflowEEEbPNS0_20RangeInFixedPositionE
 __ZNK7WebCore5Range9textRectsERN3WTF6VectorINS_7IntRectELm0ENS1_15CrashOnOverflowEEEbPNS0_20RangeInFixedPositionE
+__ZNK7WebCore6Chrome10windowRectEv
 __ZNK7WebCore6Chrome12createWindowEPNS_5FrameERKNS_16FrameLoadRequestERKNS_14WindowFeaturesERKNS_16NavigationActionE
+__ZNK7WebCore6Chrome13setWindowRectERKNS_9FloatRectE
+__ZNK7WebCore6Chrome4showEv
 __ZNK7WebCore6Editor12selectedTextEv
 __ZNK7WebCore6Editor13canEditRichlyEv
 __ZNK7WebCore6Editor16compositionRangeEv
@@ -3122,13 +3127,18 @@ __ZN7WebCore5ColorC1ERKN3WTF6StringE
 #if ENABLE(INSPECTOR)
 __ZN7WebCore14SchemeRegistry27shouldTreatURLSchemeAsLocalERKN3WTF6StringE
 __ZN7WebCore15InspectorClient31doDispatchMessageOnFrontendPageEPNS_4PageERKN3WTF6StringE
+__ZN7WebCore18InspectorPageAgent7frameIdEPNS_5FrameE
 __ZN7WebCore19InspectorController15connectFrontendEPN9Inspector24InspectorFrontendChannelEb
 __ZN7WebCore19InspectorController18disconnectFrontendEN9Inspector25InspectorDisconnectReasonE
 __ZN7WebCore19InspectorController18setProfilerEnabledEb
 __ZN7WebCore19InspectorController25evaluateForTestInFrontendERKN3WTF6StringE
-__ZN7WebCore19InspectorController26setInspectorFrontendClientENSt3__110unique_ptrINS_23InspectorFrontendClientENS1_14default_deleteIS3_EEEE
+__ZN7WebCore19InspectorController26setInspectorFrontendClientEPNS_23InspectorFrontendClientE
+__ZN7WebCore19InspectorController27dispatchMessageFromFrontendERKN3WTF6StringE
 __ZN7WebCore19InspectorController4showEv
 __ZN7WebCore19InspectorController5closeEv
+__ZN7WebCore21InspectorFrontendHost16disconnectClientEv
+__ZN7WebCore21InspectorFrontendHostC1EPNS_23InspectorFrontendClientEPNS_4PageE
+__ZN7WebCore21InspectorFrontendHostD1Ev
 __ZN7WebCore22instrumentationForPageEPNS_4PageE
 __ZN7WebCore24InspectorInstrumentation17s_frontendCounterE
 __ZN7WebCore24InspectorInstrumentation26instrumentingAgentsForPageEPNS_4PageE
index 87d2bbc..0c6a3e3 100644 (file)
                4F1534E011B533020021FD86 /* EditingBehaviorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F1534DF11B533020021FD86 /* EditingBehaviorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4F4F5FFB11CBD2E100A186BF /* InspectorWebFrontendDispatchers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F4F5FFA11CBD2D200A186BF /* InspectorWebFrontendDispatchers.cpp */; };
                4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F6FDD621341DEDD001F8EE3 /* InspectorPageAgent.cpp */; };
-               4F6FDD651341DEDD001F8EE3 /* InspectorPageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F6FDD631341DEDD001F8EE3 /* InspectorPageAgent.h */; };
+               4F6FDD651341DEDD001F8EE3 /* InspectorPageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F6FDD631341DEDD001F8EE3 /* InspectorPageAgent.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4F707A9911EF679400ACDA69 /* InspectorWebBackendDispatchers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4F707A9711EF679400ACDA69 /* InspectorWebBackendDispatchers.cpp */; };
                4F707A9A11EF679400ACDA69 /* InspectorWebBackendDispatchers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F707A9811EF679400ACDA69 /* InspectorWebBackendDispatchers.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4FB390AD15EF61F3007AD51F /* GeneratedImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FB390AC15EF61F3007AD51F /* GeneratedImage.cpp */; };
                79F2F5A11091939A000D87CB /* CompositionEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 79F2F59E1091939A000D87CB /* CompositionEvent.cpp */; };
                79F2F5A21091939A000D87CB /* CompositionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 79F2F59F1091939A000D87CB /* CompositionEvent.h */; };
                7A0E770E10C00A8800A0276E /* InspectorFrontendHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A0E770B10C00A8800A0276E /* InspectorFrontendHost.cpp */; };
-               7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E770C10C00A8800A0276E /* InspectorFrontendHost.h */; };
+               7A0E770F10C00A8800A0276E /* InspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E770C10C00A8800A0276E /* InspectorFrontendHost.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7A0E771E10C00DB100A0276E /* JSInspectorFrontendHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A0E771C10C00DB100A0276E /* JSInspectorFrontendHost.cpp */; };
                7A0E771F10C00DB100A0276E /* JSInspectorFrontendHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A0E771D10C00DB100A0276E /* JSInspectorFrontendHost.h */; };
                7A1D7FCB18F85F0F00C385AD /* mediaControlsLocalizedStrings.js in Resources */ = {isa = PBXBuildFile; fileRef = 7A1D7FC918F85F0F00C385AD /* mediaControlsLocalizedStrings.js */; };
                7AB0B1C11211A62200A76940 /* InspectorDatabaseAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB0B1BF1211A62200A76940 /* InspectorDatabaseAgent.h */; };
                7ACD88D314C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7ACD88D114C08BD60084EDD2 /* InspectorIndexedDBAgent.cpp */; };
                7ACD88D414C08BD60084EDD2 /* InspectorIndexedDBAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ACD88D214C08BD60084EDD2 /* InspectorIndexedDBAgent.h */; };
-               7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; };
+               7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7AF9B20218CFB2DF00C64BEF /* VTTRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9B1FC18CFB2DF00C64BEF /* VTTRegion.cpp */; };
                7AF9B20318CFB2DF00C64BEF /* VTTRegion.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B1FD18CFB2DF00C64BEF /* VTTRegion.h */; };
                7AF9B20518CFB2DF00C64BEF /* VTTRegionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9B1FF18CFB2DF00C64BEF /* VTTRegionList.cpp */; };
index 8aa055b..92bf206 100644 (file)
@@ -47,7 +47,7 @@ class ScriptGlobalObject {
 public:
     static bool set(JSC::ExecState*, const char* name, const Deprecated::ScriptObject&);
 #if ENABLE(INSPECTOR)
-    static bool set(JSC::ExecState*, const char* name, InspectorFrontendHost*);
+    WEBCORE_EXPORT static bool set(JSC::ExecState*, const char* name, InspectorFrontendHost*);
 #endif
 
     static bool get(JSC::ExecState*, const char* name, Deprecated::ScriptObject&);
index 8a82cab..7e26ac7 100644 (file)
@@ -58,7 +58,7 @@ ScriptExecutionContext* scriptExecutionContextFromExecState(JSC::ExecState*);
 JSC::ExecState* mainWorldExecState(Frame*);
 
 JSC::ExecState* execStateFromNode(DOMWrapperWorld&, Node*);
-JSC::ExecState* execStateFromPage(DOMWrapperWorld&, Page*);
+WEBCORE_EXPORT JSC::ExecState* execStateFromPage(DOMWrapperWorld&, Page*);
 JSC::ExecState* execStateFromWorkerGlobalScope(WorkerGlobalScope*);
 
 } // namespace WebCore
index 171a6a2..6722315 100644 (file)
@@ -86,6 +86,7 @@ InspectorController::InspectorController(Page& page, InspectorClient* inspectorC
     , m_inspectorFrontendChannel(nullptr)
     , m_page(page)
     , m_inspectorClient(inspectorClient)
+    , m_inspectorFrontendClient(nullptr)
     , m_isUnderTest(false)
 #if ENABLE(REMOTE_INSPECTOR)
     , m_hasRemoteFrontend(false)
@@ -188,9 +189,9 @@ void InspectorController::inspectedPageDestroyed()
     m_inspectorClient = nullptr;
 }
 
-void InspectorController::setInspectorFrontendClient(std::unique_ptr<InspectorFrontendClient> inspectorFrontendClient)
+void InspectorController::setInspectorFrontendClient(InspectorFrontendClient* inspectorFrontendClient)
 {
-    m_inspectorFrontendClient = WTF::move(inspectorFrontendClient);
+    m_inspectorFrontendClient = inspectorFrontendClient;
 }
 
 bool InspectorController::hasLocalFrontend() const
@@ -213,7 +214,7 @@ bool InspectorController::hasRemoteFrontend() const
 
 bool InspectorController::hasInspectorFrontendClient() const
 {
-    return m_inspectorFrontendClient.get();
+    return m_inspectorFrontendClient;
 }
 
 void InspectorController::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld& world)
@@ -283,9 +284,10 @@ void InspectorController::show()
     if (m_inspectorFrontendChannel)
         m_inspectorClient->bringFrontendToFront();
     else {
-        InspectorFrontendChannel* frontendChannel = m_inspectorClient->openInspectorFrontend(this);
-        if (frontendChannel)
-            connectFrontend(frontendChannel, false);
+        if (InspectorFrontendChannel* frontendChannel = m_inspectorClient->openInspectorFrontend(this)) {
+            bool isAutomaticInspection = false;
+            connectFrontend(frontendChannel, isAutomaticInspection);
+        }
     }
 }
 
index 12a1e6a..432b639 100644 (file)
@@ -83,7 +83,7 @@ public:
     WEBCORE_EXPORT void show();
     WEBCORE_EXPORT void close();
 
-    WEBCORE_EXPORT void setInspectorFrontendClient(std::unique_ptr<InspectorFrontendClient>);
+    WEBCORE_EXPORT void setInspectorFrontendClient(InspectorFrontendClient*);
     bool hasInspectorFrontendClient() const;
     void didClearWindowObjectInWorld(Frame*, DOMWrapperWorld&);
 
@@ -121,7 +121,7 @@ public:
     void resume();
 
     InspectorClient* inspectorClient() const { return m_inspectorClient; }
-    InspectorPageAgent* pageAgent() const { return m_pageAgent; }
+    WEBCORE_EXPORT InspectorPageAgent* pageAgent() const { return m_pageAgent; }
 
     virtual bool developerExtrasEnabled() const override;
     virtual bool canAccessInspectedScriptState(JSC::ExecState*) const override;
@@ -146,10 +146,10 @@ private:
     InspectorTimelineAgent* m_timelineAgent;
 
     RefPtr<Inspector::InspectorBackendDispatcher> m_inspectorBackendDispatcher;
-    std::unique_ptr<InspectorFrontendClient> m_inspectorFrontendClient;
     Inspector::InspectorFrontendChannel* m_inspectorFrontendChannel;
     Page& m_page;
     InspectorClient* m_inspectorClient;
+    InspectorFrontendClient* m_inspectorFrontendClient;
     Inspector::InspectorAgentRegistry m_agents;
     Vector<InspectorInstrumentationCookie, 2> m_injectedScriptInstrumentationCookies;
     bool m_isUnderTest;
index 8e8cd85..1a74edb 100644 (file)
@@ -50,8 +50,8 @@ public:
         return adoptRef(new InspectorFrontendHost(client, frontendPage));
     }
 
-    ~InspectorFrontendHost();
-    void disconnectClient();
+    WEBCORE_EXPORT ~InspectorFrontendHost();
+    WEBCORE_EXPORT void disconnectClient();
 
     void loaded();
     void requestSetDockSide(const String&);
@@ -95,7 +95,7 @@ private:
 #if ENABLE(CONTEXT_MENUS)
     friend class FrontendMenuProvider;
 #endif
-    InspectorFrontendHost(InspectorFrontendClient*, Page* frontendPage);
+    WEBCORE_EXPORT InspectorFrontendHost(InspectorFrontendClient*, Page* frontendPage);
 
     InspectorFrontendClient* m_client;
     Page* m_frontendPage;
index 110670e..25fe1d5 100644 (file)
@@ -155,7 +155,7 @@ public:
     Frame* mainFrame();
     String createIdentifier();
     Frame* frameForId(const String& frameId);
-    String frameId(Frame*);
+    WEBCORE_EXPORT String frameId(Frame*);
     bool hasIdForFrame(Frame*) const;
     String loaderId(DocumentLoader*);
     Frame* findFrameWithSecurityOrigin(const String& originRawString);
index fca7f90..3e4f5f0 100644 (file)
@@ -102,8 +102,8 @@ public:
 
     void contentsSizeChanged(Frame*, const IntSize&) const;
 
-    void setWindowRect(const FloatRect&) const;
-    FloatRect windowRect() const;
+    WEBCORE_EXPORT void setWindowRect(const FloatRect&) const;
+    WEBCORE_EXPORT FloatRect windowRect() const;
 
     FloatRect pageRect() const;
 
@@ -117,7 +117,7 @@ public:
     void focusedFrameChanged(Frame*) const;
 
     WEBCORE_EXPORT Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) const;
-    void show() const;
+    WEBCORE_EXPORT void show() const;
 
     bool canRunModal() const;
     bool canRunModalNow() const;
index 4a2b3a4..08ef51f 100644 (file)
@@ -1470,13 +1470,11 @@ PassRefPtr<DOMWindow> Internals::openDummyInspectorFrontend(const String& url)
     Page* frontendPage = m_frontendWindow->document()->page();
     ASSERT(frontendPage);
 
-    auto frontendClient = std::make_unique<InspectorFrontendClientDummy>(&page->inspectorController(), frontendPage);
-
-    frontendPage->inspectorController().setInspectorFrontendClient(WTF::move(frontendClient));
-
-    m_frontendChannel = adoptPtr(new InspectorFrontendChannelDummy(frontendPage));
+    m_frontendClient = std::make_unique<InspectorFrontendClientDummy>(&page->inspectorController(), frontendPage);
+    frontendPage->inspectorController().setInspectorFrontendClient(m_frontendClient.get());
 
     bool isAutomaticInspection = false;
+    m_frontendChannel = std::make_unique<InspectorFrontendChannelDummy>(frontendPage);
     page->inspectorController().connectFrontend(m_frontendChannel.get(), isAutomaticInspection);
 
     return m_frontendWindow;
@@ -1490,10 +1488,11 @@ void Internals::closeDummyInspectorFrontend()
 
     page->inspectorController().disconnectFrontend(InspectorDisconnectReason::InspectorDestroyed);
 
-    m_frontendChannel.release();
+    m_frontendClient = nullptr;
+    m_frontendChannel = nullptr;
 
     m_frontendWindow->close(m_frontendWindow->scriptExecutionContext());
-    m_frontendWindow.release();
+    m_frontendWindow.clear();
 }
 
 void Internals::setJavaScriptProfilingEnabled(bool enabled, ExceptionCode& ec)
index 3ff9a7f..6cc7d24 100644 (file)
@@ -50,6 +50,7 @@ class DocumentMarker;
 class Element;
 class Frame;
 class InspectorFrontendChannelDummy;
+class InspectorFrontendClientDummy;
 class InternalSettings;
 class MallocStatistics;
 class MemoryInfo;
@@ -350,7 +351,8 @@ private:
     DocumentMarker* markerAt(Node*, const String& markerType, unsigned index, ExceptionCode&);
 #if ENABLE(INSPECTOR)
     RefPtr<DOMWindow> m_frontendWindow;
-    OwnPtr<InspectorFrontendChannelDummy> m_frontendChannel;
+    std::unique_ptr<InspectorFrontendClientDummy> m_frontendClient;
+    std::unique_ptr<InspectorFrontendChannelDummy> m_frontendChannel;
 #endif
 };
 
index 0c152ca..6e2aa03 100644 (file)
@@ -1,3 +1,33 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * Localizations/en.lproj/localizedStrings.js: Updated.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector.loaded):
+        (WebInspector.contentLoaded):
+        Move InspectorFrontendHost.loaded to later in the load.
+        Calling it early just shows the window before we have
+        a user interface to show.
+
+        * UserInterface/Base/Test.js:
+        (WebInspector.loaded):
+        (WebInspector.contentLoaded):
+        Match the changes in Main.js.
+
+        * UserInterface/Protocol/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.savedURL): Change comment.
+        (InspectorFrontendAPI.appendedToURL): Change comment.
+        (InspectorFrontendAPI.dispatch): Add an assert and early
+        return to be safe from unknown commands.
+        (InspectorFrontendAPI.loadCompleted): Delete _pendingCommands,
+        no need to keep an empty array around a one time use.
+
 2014-09-24  Andres Gomez  <agomez@igalia.com>
 
         Unreviewed. Add more free icons for the Web Inspector in GTK+
index 2192120..a2b4911 100644 (file)
Binary files a/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js and b/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js differ
index ed8e2a0..fa234c7 100644 (file)
@@ -49,10 +49,7 @@ WebInspector.TypeIdentifierCookieKey = "represented-object-type";
 
 WebInspector.loaded = function()
 {
-    // Tell the InspectorFrontendHost we loaded first to establish communication with InspectorBackend.
-    InspectorFrontendHost.loaded();
-
-    // Initialize WebSocket to communication
+    // Initialize WebSocket to communication.
     this._initializeWebSocketIfNeeded();
 
     // Register observers for events from the InspectorBackend.
@@ -328,12 +325,13 @@ WebInspector.contentLoaded = function()
     if (this._detailsSidebarWidthSetting.value)
         this.detailsSidebar.width = this._detailsSidebarWidthSetting.value;
 
-    // Update the docked state based on the query string passed when the Web Inspector was loaded.
-    this.updateDockedState(parseLocationQueryParameters().dockSide || "undocked");
-
-    // Tell the frontend API we are loaded so any pending frontend commands can be dispatched.
+    // Signal that the frontend is now ready to receive messages.
     InspectorFrontendAPI.loadCompleted();
 
+    // Tell the InspectorFrontendHost we loaded, which causes the window to display
+    // and pending InspectorFrontendAPI commands to be sent.
+    InspectorFrontendHost.loaded();
+
     // Set collapsed after loading the pending frontend commands are dispatched so only the final
     // selected sidebar panel gets shown and has a say in what content view gets shown.
     this.navigationSidebar.collapsed = this._navigationSidebarCollapsedSetting.value;
index 742075a..380ea67 100644 (file)
@@ -55,15 +55,16 @@ WebInspector.loaded = function()
 
     // Perform one-time tasks.
     WebInspector.CSSCompletions.requestCSSNameCompletions();
-
-    // Establish communication with the InspectorBackend.
-    InspectorFrontendHost.loaded();
 }
 
 WebInspector.contentLoaded = function()
 {
     // Signal that the frontend is now ready to receive messages.
     InspectorFrontendAPI.loadCompleted();
+
+    // Tell the InspectorFrontendHost we loaded, which causes the window to display
+    // and pending InspectorFrontendAPI commands to be sent.
+    InspectorFrontendHost.loaded();
 }
 
 WebInspector.UIString = function(string)
index 1227211..a64768b 100644 (file)
 
 InspectorFrontendAPI = {
     _loaded: false,
-
     _pendingCommands: [],
 
     savedURL: function(url)
     {
-        // FIXME: Not implemented.
+        // Not used yet.
     },
 
     appendedToURL: function(url)
     {
-        // FIXME: Not implemented.
-    },
-
-    isDebuggingEnabled: function()
-    {
-        // FIXME: Not implemented.
-        return false;
-    },
-
-    setDebuggingEnabled: function(enabled)
-    {
-        // FIXME: Not implemented.
+        // Not used yet.
     },
 
     isTimelineProfilingEnabled: function()
@@ -108,11 +96,6 @@ InspectorFrontendAPI = {
         WebInspector.resourceSidebarPanel.showSourceCodeForFrame(frameIdentifier, true);
     },
 
-    setDockingUnavailable: function(unavailable)
-    {
-        // Not used.
-    },
-
     contextMenuItemSelected: function(id)
     {
         WebInspector.contextMenuItemSelected(id);
@@ -141,6 +124,10 @@ InspectorFrontendAPI = {
         }
 
         var methodName = signature.shift();
+        console.assert(InspectorFrontendAPI[methodName], "Unexpected InspectorFrontendAPI method name: " + InspectorFrontendAPI[methodName]);
+        if (!InspectorFrontendAPI[methodName])
+            return;
+
         return InspectorFrontendAPI[methodName].apply(InspectorFrontendAPI, signature);
     },
 
@@ -151,6 +138,6 @@ InspectorFrontendAPI = {
         for (var i = 0; i < InspectorFrontendAPI._pendingCommands.length; ++i)
             InspectorFrontendAPI.dispatch(InspectorFrontendAPI._pendingCommands[i]);
 
-        InspectorFrontendAPI._pendingCommands = [];
+        delete InspectorFrontendAPI._pendingCommands;
     }
 };
index da715e2..ba53271 100644 (file)
@@ -227,7 +227,7 @@ EXPORTS
         symbolWithPointer(?openInNewTab@InspectorFrontendClientLocal@WebCore@@UAEXABVString@WTF@@@Z, ?openInNewTab@InspectorFrontendClientLocal@WebCore@@UEAAXAEBVString@WTF@@@Z)
         symbolWithPointer(?requestSetDockSide@InspectorFrontendClientLocal@WebCore@@UAEXW4DockSide@InspectorFrontendClient@2@@Z, ?requestSetDockSide@InspectorFrontendClientLocal@WebCore@@UEAAXW4DockSide@InspectorFrontendClient@2@@Z)
         symbolWithPointer(?sendMessageToBackend@InspectorFrontendClientLocal@WebCore@@UAEXABVString@WTF@@@Z, ?sendMessageToBackend@InspectorFrontendClientLocal@WebCore@@UEAAXAEBVString@WTF@@@Z)
-        symbolWithPointer(?setInspectorFrontendClient@InspectorController@WebCore@@QAEXV?$unique_ptr@VInspectorFrontendClient@WebCore@@U?$default_delete@VInspectorFrontendClient@WebCore@@@std@@@std@@@Z, ?setInspectorFrontendClient@InspectorController@WebCore@@QEAAXV?$unique_ptr@VInspectorFrontendClient@WebCore@@U?$default_delete@VInspectorFrontendClient@WebCore@@@std@@@std@@@Z)
+        symbolWithPointer(?setInspectorFrontendClient@InspectorController@WebCore@@QAEXPAVInspectorFrontendClient@2@@Z, ?setInspectorFrontendClient@InspectorController@WebCore@@QEAAXVInspectorFrontendClient@2@@Z)
         symbolWithPointer(?setProperty@Settings@InspectorFrontendClientLocal@WebCore@@UAEXABVString@WTF@@0@Z, ?setProperty@Settings@InspectorFrontendClientLocal@WebCore@@UEAAXAEBVString@WTF@@0@Z)
         symbolWithPointer(?windowObjectCleared@InspectorFrontendClientLocal@WebCore@@UAEXXZ, ?windowObjectCleared@InspectorFrontendClientLocal@WebCore@@UEAAXXZ)
         symbolWithPointer(?pathByAppendingComponent@WebCore@@YA?AVString@WTF@@ABV23@0@Z, ?pathByAppendingComponent@WebCore@@YA?AVString@WTF@@AEBV23@0@Z)
index 6e4ab3b..38511ad 100644 (file)
@@ -1,3 +1,16 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * WebCoreSupport/WebInspectorClientIOS.mm:
+        (WebInspectorClient::WebInspectorClient):
+        Removed m_frontendClient initialization since it is
+        now a std::unique_ptr that defaults to nullptr.
+
 2014-09-23  Chris Dumez  <cdumez@apple.com>
 
         Use downcast<HTML*Element>() instead of toHTML*Element()
index d30d8b9..98dcaed 100644 (file)
@@ -46,7 +46,6 @@ WebInspectorClient::WebInspectorClient(WebView *webView)
     : m_webView(webView)
     , m_highlighter(adoptNS([[WebNodeHighlighter alloc] initWithInspectedWebView:webView]))
     , m_frontendPage(0)
-    , m_frontendClient(0)
 {
 }
 
index a77e3f1..45aa8e7 100644 (file)
@@ -1,3 +1,18 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorClient::WebInspectorClient):
+        (WebInspectorClient::openInspectorFrontend):
+        (WebInspectorClient::releaseFrontend):
+        Own WebInspectorFrontendClient instead of moving it.
+
 2014-09-23  Chris Dumez  <cdumez@apple.com>
 
         Use downcast<HTML*Element>() instead of toHTML*Element()
index 4856836..89877eb 100644 (file)
@@ -100,7 +100,7 @@ private:
     WebView *m_webView;
     RetainPtr<WebNodeHighlighter> m_highlighter;
     WebCore::Page* m_frontendPage;
-    WebInspectorFrontendClient* m_frontendClient;
+    std::unique_ptr<WebInspectorFrontendClient> m_frontendClient;
 };
 
 
index 6e1789d..8308b9e 100644 (file)
@@ -133,8 +133,7 @@ using namespace WebCore;
 WebInspectorClient::WebInspectorClient(WebView *webView)
     : m_webView(webView)
     , m_highlighter(adoptNS([[WebNodeHighlighter alloc] initWithInspectedWebView:webView]))
-    , m_frontendPage(0)
-    , m_frontendClient(0)
+    , m_frontendPage(nullptr)
 {
 }
 
@@ -150,11 +149,13 @@ InspectorFrontendChannel* WebInspectorClient::openInspectorFrontend(InspectorCon
     [windowController.get() setInspectorClient:this];
 
     m_frontendPage = core([windowController.get() webView]);
-    auto frontendClient = std::make_unique<WebInspectorFrontendClient>(m_webView, windowController.get(), inspectorController, m_frontendPage, createFrontendSettings());
-    m_frontendClient = frontendClient.get();
-    RetainPtr<WebInspectorFrontend> webInspectorFrontend = adoptNS([[WebInspectorFrontend alloc] initWithFrontendClient:frontendClient.get()]);
+    m_frontendClient = std::make_unique<WebInspectorFrontendClient>(m_webView, windowController.get(), inspectorController, m_frontendPage, createFrontendSettings());
+
+    RetainPtr<WebInspectorFrontend> webInspectorFrontend = adoptNS([[WebInspectorFrontend alloc] initWithFrontendClient:m_frontendClient.get()]);
     [[m_webView inspector] setFrontend:webInspectorFrontend.get()];
-    m_frontendPage->inspectorController().setInspectorFrontendClient(WTF::move(frontendClient));
+
+    m_frontendPage->inspectorController().setInspectorFrontendClient(m_frontendClient.get());
+
     return this;
 }
 
@@ -199,8 +200,8 @@ void WebInspectorClient::didSetSearchingForNode(bool enabled)
 
 void WebInspectorClient::releaseFrontend()
 {
-    m_frontendClient = 0;
-    m_frontendPage = 0;
+    m_frontendClient = nullptr;
+    m_frontendPage = nullptr;
 }
 
 
index 0861049..20ffc3b 100644 (file)
@@ -1,3 +1,17 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorClient::openInspectorFrontend):
+        * WebCoreSupport/WebInspectorClient.h:
+        (WebInspectorClient::frontendClient):
+        Own WebInspectorFrontendClient instead of moving it.
+
 2014-09-23  Christophe Dumez  <cdumez@apple.com>
 
         Unreviewed build fix after r173893.
index 3f36def..90edde5 100644 (file)
@@ -68,7 +68,6 @@ static const IntRect& defaultWindowRect()
 WebInspectorClient::WebInspectorClient(WebView* webView)
     : m_inspectedWebView(webView)
     , m_frontendPage(0)
-    , m_frontendClient(0)
 {
     ASSERT(m_inspectedWebView);
     m_inspectedWebView->viewWindow(&m_inspectedWebViewHandle);
@@ -171,9 +170,8 @@ WebCore::InspectorFrontendChannel* WebInspectorClient::openInspectorFrontend(Ins
         return 0;
 
     m_frontendPage = core(frontendWebView.get());
-    auto frontendClient = std::make_unique<WebInspectorFrontendClient>(m_inspectedWebView, m_inspectedWebViewHandle, frontendHwnd, frontendWebView, frontendWebViewHwnd, this, createFrontendSettings());
-    m_frontendClient = frontendClient.get();
-    m_frontendPage->inspectorController().setInspectorFrontendClient(WTF::move(frontendClient));
+    m_frontendClient = std::make_unique<WebInspectorFrontendClient>(m_inspectedWebView, m_inspectedWebViewHandle, frontendHwnd, frontendWebView, frontendWebViewHwnd, this, createFrontendSettings());
+    m_frontendPage->inspectorController().setInspectorFrontendClient(m_frontendClient.get());
     m_frontendHandle = frontendHwnd;
     return this;
 }
@@ -219,7 +217,7 @@ void WebInspectorClient::updateHighlight()
 
 void WebInspectorClient::releaseFrontend()
 {
-    m_frontendClient = 0;
+    m_frontendClient = nullptr;
     m_frontendPage = 0;
     m_frontendHandle = 0;
 }
index b31dd89..47fbea0 100644 (file)
@@ -75,7 +75,7 @@ public:
 
     void releaseFrontend();
 
-    WebInspectorFrontendClient* frontendClient() { return m_frontendClient; }
+    WebInspectorFrontendClient* frontendClient() { return m_frontendClient.get(); }
 
     void updateHighlight();
 
@@ -85,7 +85,7 @@ private:
 
     WebView* m_inspectedWebView;
     WebCore::Page* m_frontendPage;
-    WebInspectorFrontendClient* m_frontendClient;
+    std::unique_ptr<WebInspectorFrontendClient> m_frontendClient;
     HWND m_inspectedWebViewHandle;
     HWND m_frontendHandle;
 
index 4f3923d..6bdc59d 100644 (file)
@@ -530,7 +530,6 @@ set(WebKit2_SOURCES
     WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
     WebProcess/WebCoreSupport/WebGeolocationClient.cpp
     WebProcess/WebCoreSupport/WebInspectorClient.cpp
-    WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp
     WebProcess/WebCoreSupport/WebNotificationClient.cpp
     WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
     WebProcess/WebCoreSupport/WebPlugInClient.cpp
@@ -552,6 +551,7 @@ set(WebKit2_SOURCES
     WebProcess/WebPage/WebDocumentLoader.cpp
     WebProcess/WebPage/WebFrame.cpp
     WebProcess/WebPage/WebInspector.cpp
+    WebProcess/WebPage/WebInspectorUI.cpp
     WebProcess/WebPage/WebOpenPanelResultListener.cpp
     WebProcess/WebPage/WebPage.cpp
     WebProcess/WebPage/WebPageGroupProxy.cpp
@@ -645,6 +645,7 @@ set(WebKit2_MESSAGES_IN_FILES
     WebProcess/WebPage/EventDispatcher.messages.in
     WebProcess/WebPage/VisitedLinkTableController.messages.in
     WebProcess/WebPage/WebInspector.messages.in
+    WebProcess/WebPage/WebInspectorUI.messages.in
     WebProcess/WebPage/WebPage.messages.in
     WebProcess/WebPage/WebPageGroupProxy.messages.in
 )
index 5089b33..ece56a8 100644 (file)
@@ -1,3 +1,180 @@
+2014-09-21  Timothy Hatcher  <timothy@apple.com>
+
+        Make the Web Inspector use a separate web process.
+
+        https://bugs.webkit.org/show_bug.cgi?id=135120
+
+        Reviewed by Anders Carlsson.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * WebKit2.xcodeproj/project.pbxproj:
+        Added new WebInspectorUI files and removed WebInspectorFrontendClient.cpp.
+
+        * Shared/APIObject.h: Added BundleInspectorUI.
+
+        * Shared/EntryPointUtilities/mac/LegacyProcess/ChildProcessEntryPoint.mm:
+        (WebKit::ChildProcessMainDelegate::getExtraInitializationData):
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::getExtraInitializationData):
+        Add support for "inspector-process" data, a boolean that is used by
+        WebProcess::initializeProcessName.
+
+        * UIProcess/API/C/WKInspector.cpp:
+        (WKInspectorIsDebuggingJavaScript):
+        (WKInspectorToggleJavaScriptDebugging):
+        (WKInspectorIsProfilingJavaScript):
+        (WKInspectorToggleJavaScriptProfiling):
+        * UIProcess/API/C/WKInspector.h:
+        Stub out functions we don't support but need to keep for nightly compatibility.
+
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorPageGroups::createInspectorPageGroup):
+        (WebKit::WebInspectorProxy::WebInspectorProxy):
+        (WebKit::WebInspectorProxy::invalidate):
+        (WebKit::WebInspectorProxy::connect):
+        (WebKit::WebInspectorProxy::showConsole):
+        (WebKit::WebInspectorProxy::showResources):
+        (WebKit::WebInspectorProxy::showMainResourceForFrame):
+        (WebKit::WebInspectorProxy::attach):
+        (WebKit::WebInspectorProxy::detach):
+        (WebKit::WebInspectorProxy::inspectorContext):
+        (WebKit::WebInspectorProxy::dispatchMessageFromRemoteFrontend):
+        (WebKit::WebInspectorProxy::eagerlyCreateInspectorPage):
+        (WebKit::WebInspectorProxy::createInspectorPage):
+        (WebKit::WebInspectorProxy::open):
+        (WebKit::WebInspectorProxy::didClose):
+        (WebKit::WebInspectorProxy::attachAvailabilityChanged):
+        * UIProcess/WebInspectorProxy.h:
+        (WebKit::WebInspectorProxy::isConnected):
+        (WebKit::WebInspectorProxy::canAttach):
+        * UIProcess/WebInspectorProxy.messages.in:
+        * UIProcess/efl/WebInspectorProxyEfl.cpp:
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+        (WebKit::WebInspectorProxy::platformAttach):
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (-[WKWebInspectorProxyObjCAdapter close]):
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+        (WebKit::WebInspectorProxy::platformDidClose):
+        (WebKit::WebInspectorProxy::platformHide):
+        (WebKit::WebInspectorProxy::platformSave):
+        (WebKit::WebInspectorProxy::platformAppend):
+        (WebKit::WebInspectorProxy::platformAttach):
+        Changed how the Inspector page is created by making it in a new WebContext for
+        the Inspector. This removes us from the main process pool and guarantees no process
+        sharing for our user interface. Also send new WebInspectorUI messages to the Inspector
+        page and not the inspected page when appropriate.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::getLaunchOptions): Add "inspector-process" to extraInitializationData
+        if the context is the Inspector context. This is used by WebProcess::initializeProcessName.
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::openInspectorFrontend):
+        (WebKit::WebInspectorClient::closeInspectorFrontend):
+        (WebKit::WebInspectorClient::bringFrontendToFront):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        Remove the InspectorFrontendChannel class from WebInspectorClient and clean up a little.
+        InspectorFrontendChannel implementation moved to WebInspector.
+
+        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp: Removed. Superseded by WebInspectorUI.
+
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::create):
+        (WebKit::WebInspector::WebInspector):
+        (WebKit::WebInspector::createInspectorPage):
+        (WebKit::WebInspector::closeFrontend):
+        (WebKit::WebInspector::openInNewTab):
+        (WebKit::WebInspector::showConsole):
+        (WebKit::WebInspector::showResources):
+        (WebKit::WebInspector::showMainResourceForFrame):
+        (WebKit::WebInspector::startPageProfiling):
+        (WebKit::WebInspector::stopPageProfiling):
+        (WebKit::WebInspector::canAttachWindow):
+        (WebKit::WebInspector::updateDockingAvailability):
+        (WebKit::WebInspector::sendMessageToBackend):
+        (WebKit::WebInspector::sendMessageToFrontend):
+        (WebKit::WebInspector::remoteFrontendConnected):
+        (WebKit::WebInspector::remoteFrontendDisconnected):
+        * WebProcess/WebPage/WebInspector.h:
+        (WebKit::WebInspector::didClose):
+        (WebKit::WebInspector::didReceiveInvalidMessage):
+        (WebKit::WebInspector::setAttached):
+        * WebProcess/WebPage/WebInspector.messages.in:
+        Stop taking an optional InspectorFrontendChannel and inherit it instead. Create a connection that
+        can be passed to the other web process for WebInspectorUI to use. Stop referencing Inspector's page
+        directly, since it is in another process now.
+
+        * WebProcess/WebPage/WebInspectorUI.cpp: Added.
+        (WebKit::WebInspectorUI::create):
+        (WebKit::WebInspectorUI::WebInspectorUI):
+        (WebKit::WebInspectorUI::establishConnection):
+        (WebKit::WebInspectorUI::windowObjectCleared):
+        (WebKit::WebInspectorUI::frontendLoaded):
+        (WebKit::WebInspectorUI::moveWindowBy):
+        (WebKit::WebInspectorUI::bringToFront):
+        (WebKit::WebInspectorUI::closeWindow):
+        (WebKit::WebInspectorUI::requestSetDockSide):
+        (WebKit::WebInspectorUI::setDockSide):
+        (WebKit::WebInspectorUI::changeAttachedWindowHeight):
+        (WebKit::WebInspectorUI::changeAttachedWindowWidth):
+        (WebKit::WebInspectorUI::setToolbarHeight):
+        (WebKit::WebInspectorUI::openInNewTab):
+        (WebKit::WebInspectorUI::save):
+        (WebKit::WebInspectorUI::append):
+        (WebKit::WebInspectorUI::inspectedURLChanged):
+        (WebKit::WebInspectorUI::showConsole):
+        (WebKit::WebInspectorUI::showResources):
+        (WebKit::WebInspectorUI::showMainResourceForFrame):
+        (WebKit::WebInspectorUI::startPageProfiling):
+        (WebKit::WebInspectorUI::stopPageProfiling):
+        (WebKit::WebInspectorUI::didSave):
+        (WebKit::WebInspectorUI::didAppend):
+        (WebKit::WebInspectorUI::sendMessageToFrontend):
+        (WebKit::WebInspectorUI::sendMessageToBackend):
+        (WebKit::WebInspectorUI::evaluateCommandOnLoad):
+        (WebKit::WebInspectorUI::evaluateExpressionOnLoad):
+        (WebKit::WebInspectorUI::evaluatePendingExpressions):
+        * WebProcess/WebPage/WebInspectorUI.h: Added.
+        (WebKit::WebInspectorUI::page):
+        (WebKit::WebInspectorUI::didClose):
+        (WebKit::WebInspectorUI::didReceiveInvalidMessage):
+        (WebKit::WebInspectorUI::attachedBottom):
+        (WebKit::WebInspectorUI::attachedRight):
+        (WebKit::WebInspectorUI::detached):
+        (WebKit::WebInspectorUI::evaluateCommandOnLoad):
+        * WebProcess/WebPage/WebInspectorUI.messages.in: Added.
+        * WebProcess/WebPage/efl/WebInspectorUIEfl.cpp: Added.
+        (WebKit::WebInspectorUI::canSave):
+        (WebKit::WebInspectorUI::localizedStringsURL):
+        * WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp: Added.
+        (WebKit::WebInspectorUI::canSave):
+        (WebKit::WebInspectorUI::localizedStringsURL):
+        * WebProcess/WebPage/mac/WebInspectorUIMac.mm: Added.
+        (WebKit::WebInspectorUI::canSave):
+        (WebKit::WebInspectorUI::localizedStringsURL):
+        Implement the InspectorFrontendClient and handle a connection to the inspected page's WebInspector.
+
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage):
+        (WebKit::WebPage::~WebPage):
+        (WebKit::WebPage::inspector):
+        (WebKit::WebPage::inspectorUI):
+        (WebKit::WebPage::didReceiveMessage):
+        Setup as a listener for WebInspectorUI messages.
+
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::isInspectorPage): It is an Inspector page if we have a m_inspectorUI.
+
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::initializeProcessName):
+        Name the process "%@ Web Inspector" if it is an Inspector content process. Processes in that
+        context are not shared with multiple pages.
+
 2014-09-24  Dean Jackson  <dino@apple.com>
 
         Add a deprecated stub for WKPreferencesSetMultithreadedWebGLEnabled (and Get)
index eaef516..ca06a06 100644 (file)
@@ -121,6 +121,7 @@ MESSAGE_RECEIVERS = \
     WebIconDatabaseProxy \
     WebInspector \
     WebInspectorProxy \
+    WebInspectorUI \
     WebMediaCacheManager \
     WebMediaCacheManagerProxy \
     WebNotificationManager \
index 01e34ea..f07fb63 100644 (file)
@@ -194,7 +194,7 @@ list(APPEND WebKit2_SOURCES
 
     WebProcess/WebPage/atk/WebPageAccessibilityObjectAtk.cpp
 
-    WebProcess/WebPage/efl/WebInspectorEfl.cpp
+    WebProcess/WebPage/efl/WebInspectorUIEfl.cpp
     WebProcess/WebPage/efl/WebPageEfl.cpp
 
     WebProcess/efl/SeccompFiltersWebProcessEfl.cpp
index 6856861..fe63c1f 100644 (file)
@@ -302,7 +302,7 @@ list(APPEND WebKit2_SOURCES
 
     WebProcess/WebPage/gtk/LayerTreeHostGtk.cpp
     WebProcess/WebPage/gtk/PrinterListGtk.cpp
-    WebProcess/WebPage/gtk/WebInspectorGtk.cpp
+    WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp
     WebProcess/WebPage/gtk/WebPageGtk.cpp
     WebProcess/WebPage/gtk/WebPrintOperationGtk.cpp
 
index 6df4918..922e6da 100644 (file)
@@ -143,6 +143,7 @@ public:
         BundleFrame,
         BundleHitTestResult,
         BundleInspector,
+        BundleInspectorUI,
         BundleNavigationAction,
         BundleNodeHandle,
         BundlePage,
index 13f306e..d95cefd 100644 (file)
@@ -88,8 +88,11 @@ bool ChildProcessMainDelegate::getClientProcessName(String& clientProcessName)
     return true;
 }
 
-bool ChildProcessMainDelegate::getExtraInitializationData(HashMap<String, String>&)
+bool ChildProcessMainDelegate::getExtraInitializationData(HashMap<String, String>& extraInitializationData)
 {
+    String inspectorProcess = m_commandLine["inspector-process"];
+    if (!inspectorProcess.isEmpty())
+        extraInitializationData.add(ASCIILiteral("inspector-process"), inspectorProcess);
     return true;
 }
 
index 1697ee9..365ea8d 100644 (file)
@@ -92,8 +92,14 @@ bool XPCServiceInitializerDelegate::getClientProcessName(String& clientProcessNa
     return true;
 }
 
-bool XPCServiceInitializerDelegate::getExtraInitializationData(HashMap<String, String>&)
+bool XPCServiceInitializerDelegate::getExtraInitializationData(HashMap<String, String>& extraInitializationData)
 {
+    xpc_object_t extraDataInitializationDataObject = xpc_dictionary_get_value(m_initializerMessage, "extra-initialization-data");
+
+    String inspectorProcess = xpc_dictionary_get_string(extraDataInitializationDataObject, "inspector-process");
+    if (!inspectorProcess.isEmpty())
+        extraInitializationData.add(ASCIILiteral("inspector-process"), inspectorProcess);
+
     return true;
 }
 
index 16e845b..d85f5b9 100644 (file)
@@ -174,44 +174,6 @@ void WKInspectorDetach(WKInspectorRef inspectorRef)
 #endif
 }
 
-bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspectorRef)
-{
-#if ENABLE(INSPECTOR)
-    return toImpl(inspectorRef)->isDebuggingJavaScript();
-#else
-    UNUSED_PARAM(inspectorRef);
-    return false;
-#endif
-}
-
-void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspectorRef)
-{
-#if ENABLE(INSPECTOR)
-    toImpl(inspectorRef)->toggleJavaScriptDebugging();
-#else
-    UNUSED_PARAM(inspectorRef);
-#endif
-}
-
-bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspectorRef)
-{
-#if ENABLE(INSPECTOR)
-    return toImpl(inspectorRef)->isProfilingJavaScript();
-#else
-    UNUSED_PARAM(inspectorRef);
-    return false;
-#endif
-}
-
-void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspectorRef)
-{
-#if ENABLE(INSPECTOR)
-    toImpl(inspectorRef)->toggleJavaScriptProfiling();
-#else
-    UNUSED_PARAM(inspectorRef);
-#endif
-}
-
 bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef)
 {
 #if ENABLE(INSPECTOR)
index ba76489..14654fc 100644 (file)
@@ -58,12 +58,6 @@ WK_EXPORT bool WKInspectorIsAttached(WKInspectorRef inspector);
 WK_EXPORT void WKInspectorAttach(WKInspectorRef inspector);
 WK_EXPORT void WKInspectorDetach(WKInspectorRef inspector);
 
-WK_EXPORT bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspector);
-WK_EXPORT void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspector);
-
-WK_EXPORT bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspector);
-WK_EXPORT void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspector);
-
 WK_EXPORT bool WKInspectorIsProfilingPage(WKInspectorRef inspector);
 WK_EXPORT void WKInspectorTogglePageProfiling(WKInspectorRef inspector);
 
index be37704..ce2bf47 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 #if ENABLE(INSPECTOR)
 
 #include "APIURLRequest.h"
+#include "WebContext.h"
 #include "WebFramePolicyListenerProxy.h"
 #include "WebFrameProxy.h"
 #include "WebInspectorMessages.h"
 #include "WebInspectorProxyMessages.h"
-#include "WebPageCreationParameters.h"
+#include "WebInspectorUIMessages.h"
 #include "WebPageGroup.h"
 #include "WebPageProxy.h"
 #include "WebPreferences.h"
@@ -57,9 +58,6 @@ const unsigned WebInspectorProxy::minimumWindowHeight = 400;
 const unsigned WebInspectorProxy::initialWindowWidth = 1000;
 const unsigned WebInspectorProxy::initialWindowHeight = 650;
 
-const unsigned WebInspectorProxy::minimumAttachedWidth = 750;
-const unsigned WebInspectorProxy::minimumAttachedHeight = 250;
-
 class WebInspectorPageGroups {
 public:
     static WebInspectorPageGroups& shared()
@@ -105,11 +103,12 @@ private:
         RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(String::format("__WebInspectorPageGroupLevel%u__", level), false, false);
 
 #ifndef NDEBUG
-        // Allow developers to inspect the Web Inspector in debug builds.
+        // Allow developers to inspect the Web Inspector in debug builds without changing settings.
         pageGroup->preferences().setDeveloperExtrasEnabled(true);
         pageGroup->preferences().setLogsPageMessagesToSystemConsoleEnabled(true);
 #endif
 
+        pageGroup->preferences().setAllowFileAccessFromFileURLs(true);
         pageGroup->preferences().setApplicationChromeModeEnabled(true);
 
         return pageGroup.release();
@@ -124,16 +123,18 @@ private:
 
 WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
     : m_page(page)
+    , m_inspectorPage(nullptr)
+    , m_underTest(false)
     , m_isVisible(false)
     , m_isAttached(false)
-    , m_isDebuggingJavaScript(false)
-    , m_isProfilingJavaScript(false)
+    , m_canAttach(false)
     , m_isProfilingPage(false)
     , m_showMessageSent(false)
-    , m_createdInspectorPage(false)
     , m_ignoreFirstBringToFront(false)
     , m_attachmentSide(AttachmentSideBottom)
-#if PLATFORM(GTK) || PLATFORM(EFL)
+#if PLATFORM(MAC)
+    , m_closeTimer(RunLoop::main(), this, &WebInspectorProxy::closeTimerFired)
+#elif PLATFORM(GTK) || PLATFORM(EFL)
     , m_inspectorView(0)
     , m_inspectorWindow(0)
 #endif
@@ -165,7 +166,7 @@ void WebInspectorProxy::invalidate()
 
     didClose();
 
-    m_page = 0;
+    m_page = nullptr;
 }
 
 // Public APIs
@@ -188,6 +189,8 @@ void WebInspectorProxy::connect()
     m_showMessageSent = true;
     m_ignoreFirstBringToFront = true;
 
+    eagerlyCreateInspectorPage();
+
     m_page->process().send(Messages::WebInspector::Show(), m_page->pageID());
 }
 
@@ -232,6 +235,8 @@ void WebInspectorProxy::showConsole()
     if (!m_page)
         return;
 
+    eagerlyCreateInspectorPage();
+
     m_page->process().send(Messages::WebInspector::ShowConsole(), m_page->pageID());
 }
 
@@ -240,6 +245,8 @@ void WebInspectorProxy::showResources()
     if (!m_page)
         return;
 
+    eagerlyCreateInspectorPage();
+
     m_page->process().send(Messages::WebInspector::ShowResources(), m_page->pageID());
 }
 
@@ -248,6 +255,8 @@ void WebInspectorProxy::showMainResourceForFrame(WebFrameProxy* frame)
     if (!m_page)
         return;
 
+    eagerlyCreateInspectorPage();
+
     m_page->process().send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_page->pageID());
 }
 
@@ -274,13 +283,15 @@ void WebInspectorProxy::attach(AttachmentSide side)
     if (m_isVisible)
         inspectorPageGroup()->preferences().setInspectorStartsAttached(true);
 
+    m_page->process().send(Messages::WebInspector::SetAttached(true), m_page->pageID());
+
     switch (m_attachmentSide) {
     case AttachmentSideBottom:
-        m_page->process().send(Messages::WebInspector::AttachedBottom(), m_page->pageID());
+        m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID());
         break;
 
     case AttachmentSideRight:
-        m_page->process().send(Messages::WebInspector::AttachedRight(), m_page->pageID());
+        m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID());
         break;
     }
 
@@ -297,7 +308,8 @@ void WebInspectorProxy::detach()
     if (m_isVisible)
         inspectorPageGroup()->preferences().setInspectorStartsAttached(false);
 
-    m_page->process().send(Messages::WebInspector::Detached(), m_page->pageID());
+    m_page->process().send(Messages::WebInspector::SetAttached(false), m_page->pageID());
+    m_inspectorPage->process().send(Messages::WebInspectorUI::Detached(), m_inspectorPage->pageID());
 
     platformDetach();
 }
@@ -314,34 +326,6 @@ void WebInspectorProxy::setAttachedWindowWidth(unsigned width)
     platformSetAttachedWindowWidth(width);
 }
 
-void WebInspectorProxy::toggleJavaScriptDebugging()
-{
-    if (!m_page)
-        return;
-
-    if (m_isDebuggingJavaScript)
-        m_page->process().send(Messages::WebInspector::StopJavaScriptDebugging(), m_page->pageID());
-    else
-        m_page->process().send(Messages::WebInspector::StartJavaScriptDebugging(), m_page->pageID());
-
-    // FIXME: have the WebProcess notify us on state changes.
-    m_isDebuggingJavaScript = !m_isDebuggingJavaScript;
-}
-
-void WebInspectorProxy::toggleJavaScriptProfiling()
-{
-    if (!m_page)
-        return;
-
-    if (m_isProfilingJavaScript)
-        m_page->process().send(Messages::WebInspector::StopJavaScriptProfiling(), m_page->pageID());
-    else
-        m_page->process().send(Messages::WebInspector::StartJavaScriptProfiling(), m_page->pageID());
-
-    // FIXME: have the WebProcess notify us on state changes.
-    m_isProfilingJavaScript = !m_isProfilingJavaScript;
-}
-
 void WebInspectorProxy::togglePageProfiling()
 {
     if (!m_page)
@@ -361,6 +345,22 @@ bool WebInspectorProxy::isInspectorPage(WebPageProxy& page)
     return WebInspectorPageGroups::shared().isInspectorPageGroup(page.pageGroup());
 }
 
+WebContext& WebInspectorProxy::inspectorContext()
+{
+    // Having our own context removes us from the main context's process pool and
+    // guarantees no process sharing for our user interface.
+
+    static WebContext* context;
+    if (!context) {
+        WebContextConfiguration configuration;
+        WebContext::applyPlatformSpecificConfigurationDefaults(configuration);
+        context = (WebContext::create(configuration)).leakRef();
+        context->setProcessModel(ProcessModelMultipleSecondaryProcesses);
+    }
+
+    return *context;
+}
+
 static bool isMainOrTestInspectorPage(const WebInspectorProxy* webInspectorProxy, WKURLRequestRef requestRef)
 {
     URL requestURL(URL(), toImpl(requestRef)->resourceRequest().url());
@@ -426,29 +426,20 @@ void WebInspectorProxy::remoteFrontendDisconnected()
 
 void WebInspectorProxy::dispatchMessageFromRemoteFrontend(const String& message)
 {
-    m_page->process().send(Messages::WebInspector::DispatchMessageFromRemoteFrontend(message), m_page->pageID());
+    m_page->process().send(Messages::WebInspector::SendMessageToBackend(message), m_page->pageID());
 }
 #endif
 
-// Called by WebInspectorProxy messages
-void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters& inspectorPageParameters)
+void WebInspectorProxy::eagerlyCreateInspectorPage()
 {
-    inspectorPageID = 0;
-
-    if (!m_page)
+    if (m_inspectorPage)
         return;
 
-    m_isAttached = shouldOpenAttached();
-    m_attachmentSide = static_cast<AttachmentSide>(inspectorPageGroup()->preferences().inspectorAttachmentSide());
-
-    WebPageProxy* inspectorPage = platformCreateInspectorPage();
-    ASSERT(inspectorPage);
-    if (!inspectorPage)
+    m_inspectorPage = platformCreateInspectorPage();
+    ASSERT(m_inspectorPage);
+    if (!m_inspectorPage)
         return;
 
-    inspectorPageID = inspectorPage->pageID();
-    inspectorPageParameters = inspectorPage->creationParameters();
-
     WKPagePolicyClientV1 policyClient = {
         { 1, this },
         0, /* decidePolicyForNavigationAction_deprecatedForUseWithV0 */
@@ -459,73 +450,57 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr
         0, /* decidePolicyForResponse */
     };
 
-    WKPageSetPagePolicyClient(toAPI(inspectorPage), &policyClient.base);
-
-    StringBuilder url;
-
-    url.append(inspectorPageURL());
-
-    url.appendLiteral("?dockSide=");
-
-    if (m_isAttached) {
-        switch (m_attachmentSide) {
-        case AttachmentSideBottom:
-            url.appendLiteral("bottom");
-            m_page->process().send(Messages::WebInspector::AttachedBottom(), m_page->pageID());
-            break;
-        case AttachmentSideRight:
-            url.appendLiteral("right");
-            m_page->process().send(Messages::WebInspector::AttachedRight(), m_page->pageID());
-            break;
-        }
-    } else
-        url.appendLiteral("undocked");
+    WKPageSetPagePolicyClient(toAPI(m_inspectorPage), &policyClient.base);
 
-    m_page->process().assumeReadAccessToBaseURL(inspectorBaseURL());
-
-    inspectorPage->loadRequest(URL(URL(), url.toString()));
-
-    m_createdInspectorPage = true;
+    m_inspectorPage->process().addMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID(), *this);
+    m_inspectorPage->process().assumeReadAccessToBaseURL(inspectorBaseURL());
 }
 
-void WebInspectorProxy::createInspectorPageForTest(uint64_t& inspectorPageID, WebPageCreationParameters& inspectorPageParameters)
+// Called by WebInspectorProxy messages
+void WebInspectorProxy::createInspectorPage(IPC::Attachment connectionIdentifier, bool canAttach, bool underTest)
 {
-    inspectorPageID = 0;
-
     if (!m_page)
         return;
 
-    m_isAttached = false;
+    eagerlyCreateInspectorPage();
 
-    WebPageProxy* inspectorPage = platformCreateInspectorPage();
-    ASSERT(inspectorPage);
-    if (!inspectorPage)
+    ASSERT(m_inspectorPage);
+    if (!m_inspectorPage)
         return;
 
-    inspectorPageID = inspectorPage->pageID();
-    inspectorPageParameters = inspectorPage->creationParameters();
+    m_underTest = underTest;
 
-    WKPagePolicyClientV1 policyClient = {
-        { 1, this },
-        0, /* decidePolicyForNavigationAction_deprecatedForUseWithV0 */
-        0, /* decidePolicyForNewWindowAction */
-        0, /* decidePolicyForResponse_deprecatedForUseWithV0 */
-        0, /* unableToImplementPolicy */
-        decidePolicyForNavigationAction,
-        0, /* decidePolicyForResponse */
-    };
+    m_inspectorPage->process().send(Messages::WebInspectorUI::EstablishConnection(connectionIdentifier, m_page->pageID(), m_underTest), m_inspectorPage->pageID());
 
-    WKPageSetPagePolicyClient(toAPI(inspectorPage), &policyClient.base);
+    if (!m_underTest) {
+        m_canAttach = canAttach;
+        m_isAttached = shouldOpenAttached();
+        m_attachmentSide = static_cast<AttachmentSide>(inspectorPageGroup()->preferences().inspectorAttachmentSide());
 
-    m_page->process().assumeReadAccessToBaseURL(inspectorBaseURL());
+        m_page->process().send(Messages::WebInspector::SetAttached(m_isAttached), m_page->pageID());
 
-    inspectorPage->loadRequest(URL(URL(), inspectorTestPageURL()));
+        if (m_isAttached) {
+            switch (m_attachmentSide) {
+            case AttachmentSideBottom:
+                m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedBottom(), m_inspectorPage->pageID());
+                break;
 
-    m_createdInspectorPage = true;
+            case AttachmentSideRight:
+                m_inspectorPage->process().send(Messages::WebInspectorUI::AttachedRight(), m_inspectorPage->pageID());
+                break;
+            }
+        } else
+            m_inspectorPage->process().send(Messages::WebInspectorUI::Detached(), m_inspectorPage->pageID());
+    }
+
+    m_inspectorPage->loadRequest(URL(URL(), m_underTest ? inspectorTestPageURL() : inspectorPageURL()));
 }
 
 void WebInspectorProxy::open()
 {
+    if (m_underTest)
+        return;
+
     m_isVisible = true;
 
     platformOpen();
@@ -533,20 +508,22 @@ void WebInspectorProxy::open()
 
 void WebInspectorProxy::didClose()
 {
-    if (!m_createdInspectorPage)
+    if (!m_inspectorPage)
         return;
 
+    m_inspectorPage->process().removeMessageReceiver(Messages::WebInspectorProxy::messageReceiverName(), m_page->pageID());
+    m_inspectorPage = nullptr;
+
     m_isVisible = false;
-    m_isDebuggingJavaScript = false;
-    m_isProfilingJavaScript = false;
     m_isProfilingPage = false;
-    m_createdInspectorPage = false;
     m_showMessageSent = false;
     m_ignoreFirstBringToFront = false;
 
     if (m_isAttached)
         platformDetach();
     m_isAttached = false;
+    m_canAttach = false;
+    m_underTest = false;
 
     platformDidClose();
 }
@@ -569,6 +546,8 @@ void WebInspectorProxy::bringToFront()
 
 void WebInspectorProxy::attachAvailabilityChanged(bool available)
 {
+    m_canAttach = available;
+
     platformAttachAvailabilityChanged(available);
 }
 
@@ -587,28 +566,6 @@ void WebInspectorProxy::append(const String& filename, const String& content)
     platformAppend(filename, content);
 }
 
-bool WebInspectorProxy::canAttach()
-{
-    // Keep this in sync with InspectorFrontendClientLocal::canAttachWindow. There are two implementations
-    // to make life easier in the multi-process world we have. WebInspectorProxy uses canAttach to decide if
-    // we can attach on open (on the UI process side). And InspectorFrontendClientLocal::canAttachWindow is
-    // used to decide if we can attach when the attach button is pressed (on the WebProcess side).
-
-    // If we are already attached, allow attaching again to allow switching sides.
-    if (m_isAttached)
-        return true;
-
-    // Don't allow attaching to another inspector -- two inspectors in one window is too much!
-    if (m_level > 1)
-        return false;
-
-    // Don't allow the attach if the window would be too small to accommodate the minimum inspector height.
-    unsigned inspectedPageHeight = platformInspectedWindowHeight();
-    unsigned inspectedPageWidth = platformInspectedWindowWidth();
-    unsigned maximumAttachedHeight = inspectedPageHeight * 3 / 4;
-    return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
-}
-
 bool WebInspectorProxy::shouldOpenAttached()
 {
     return inspectorPageGroup()->preferences().inspectorStartsAttached() && canAttach();
index 17a7498..e0cd3db 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  * Portions Copyright (c) 2011 Motorola Mobility, Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -30,6 +30,7 @@
 #if ENABLE(INSPECTOR)
 
 #include "APIObject.h"
+#include "Attachment.h"
 #include "MessageReceiver.h"
 #include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
@@ -40,6 +41,7 @@
 #include "WKGeometry.h"
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/RunLoop.h>
 
 OBJC_CLASS NSButton;
 OBJC_CLASS NSURL;
@@ -59,10 +61,10 @@ OBJC_CLASS WKWebInspectorWKView;
 
 namespace WebKit {
 
+class WebContext;
 class WebFrameProxy;
 class WebPageGroup;
 class WebPageProxy;
-struct WebPageCreationParameters;
 
 enum AttachmentSide {
     AttachmentSideBottom,
@@ -83,7 +85,7 @@ public:
     // Public APIs
     WebPageProxy* page() const { return m_page; }
 
-    bool isConnected() const { return m_createdInspectorPage; }
+    bool isConnected() const { return !!m_inspectorPage; }
     bool isVisible() const { return m_isVisible; }
     bool isFront();
 
@@ -102,6 +104,8 @@ public:
 
     void setInspectorWindowFrame(WKRect&);
     WKRect inspectorWindowFrame();
+
+    void closeTimerFired();
 #endif
 
 #if PLATFORM(GTK)
@@ -123,16 +127,11 @@ public:
     void setAttachedWindowWidth(unsigned);
     void setToolbarHeight(unsigned height) { platformSetToolbarHeight(height); }
 
-    bool isDebuggingJavaScript() const { return m_isDebuggingJavaScript; }
-    void toggleJavaScriptDebugging();
-
-    bool isProfilingJavaScript() const { return m_isProfilingJavaScript; }
-    void toggleJavaScriptProfiling();
-
     bool isProfilingPage() const { return m_isProfilingPage; }
     void togglePageProfiling();
 
     static bool isInspectorPage(WebPageProxy&);
+    static WebContext& inspectorContext();
 
     // Provided by platform WebInspectorProxy implementations.
     String inspectorPageURL() const;
@@ -150,9 +149,10 @@ public:
 private:
     explicit WebInspectorProxy(WebPageProxy*);
 
+    void eagerlyCreateInspectorPage();
+
     // IPC::MessageReceiver
     virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
-    virtual void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
 
     WebPageProxy* platformCreateInspectorPage();
     void platformOpen();
@@ -173,8 +173,7 @@ private:
     void platformAppend(const String& filename, const String& content);
 
     // Called by WebInspectorProxy messages
-    void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
-    void createInspectorPageForTest(uint64_t& inspectorPageID, WebPageCreationParameters&);
+    void createInspectorPage(IPC::Attachment, bool canAttach, bool underTest);
     void didClose();
     void bringToFront();
     void attachAvailabilityChanged(bool);
@@ -187,7 +186,7 @@ private:
     void sendMessageToRemoteFrontend(const String& message);
 #endif
 
-    bool canAttach();
+    bool canAttach() const { return m_canAttach; }
     bool shouldOpenAttached();
 
     void open();
@@ -204,19 +203,15 @@ private:
     static const unsigned initialWindowWidth;
     static const unsigned initialWindowHeight;
 
-    // Keep this in sync with the value in InspectorFrontendClientLocal.
-    static const unsigned minimumAttachedWidth;
-    static const unsigned minimumAttachedHeight;
-
     WebPageProxy* m_page;
+    WebPageProxy* m_inspectorPage;
 
+    bool m_underTest;
     bool m_isVisible;
     bool m_isAttached;
-    bool m_isDebuggingJavaScript;
-    bool m_isProfilingJavaScript;
+    bool m_canAttach;
     bool m_isProfilingPage;
     bool m_showMessageSent;
-    bool m_createdInspectorPage;
     bool m_ignoreFirstBringToFront;
 
     // The debugger stops all the pages in the same PageGroup. Having
@@ -232,8 +227,9 @@ private:
     RetainPtr<NSButton> m_dockBottomButton;
     RetainPtr<NSButton> m_dockRightButton;
     RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
-    String m_urlString;
     HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
+    RunLoop::Timer<WebInspectorProxy> m_closeTimer;
+    String m_urlString;
 #elif PLATFORM(GTK)
     WebInspectorClientGtk m_client;
     GtkWidget* m_inspectorView;
index e6c944d..eb7fa9b 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 #if ENABLE(INSPECTOR)
 
 messages -> WebInspectorProxy {
-    CreateInspectorPage() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
-    CreateInspectorPageForTest() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
+    CreateInspectorPage(IPC::Attachment connectionIdentifier, bool canAttach, bool underTest)
+
     DidClose()
     BringToFront()
+
     InspectedURLChanged(String urlString)
 
     Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
@@ -35,6 +36,7 @@ messages -> WebInspectorProxy {
     AttachBottom()
     AttachRight()
     Detach()
+
     AttachAvailabilityChanged(bool available)
 
     SetAttachedWindowHeight(unsigned height)
index 9049f9b..9732c05 100644 (file)
@@ -39,6 +39,7 @@
 #include "WebUserContentControllerProxy.h"
 #include "WebBackForwardListItem.h"
 #include "WebContext.h"
+#include "WebInspectorProxy.h"
 #include "WebNavigationDataStore.h"
 #include "WebNotificationManagerProxy.h"
 #include "WebPageGroup.h"
@@ -115,6 +116,8 @@ WebProcessProxy::~WebProcessProxy()
 void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
 {
     launchOptions.processType = ProcessLauncher::WebProcess;
+    if (&m_context.get() == &WebInspectorProxy::inspectorContext())
+        launchOptions.extraInitializationData.add(ASCIILiteral("inspector-process"), ASCIILiteral("1"));
     platformGetLaunchOptions(launchOptions);
 }
 
index eec39cc..091217a 100644 (file)
@@ -104,7 +104,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
     if (!m_inspectorWindow)
         return 0;
 
-    WKContextRef wkContext = toAPI(&page()->process().context());
+    WKContextRef wkContext = toAPI(&inspectorContext());
     WKPageGroupRef wkPageGroup = toAPI(inspectorPageGroup());
 
     m_inspectorView = EWKViewCreate(wkContext, wkPageGroup, ecore_evas_get(m_inspectorWindow), /* smart */ 0);
index 50e45c4..b22192e 100644 (file)
@@ -62,7 +62,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
 {
     ASSERT(m_page);
     ASSERT(!m_inspectorView);
-    m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&page()->process().context(), nullptr, inspectorPageGroup(), nullptr, m_page));
+    m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorContext(), nullptr, inspectorPageGroup(), nullptr, nullptr));
     g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView));
     return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
 }
@@ -182,8 +182,11 @@ void WebInspectorProxy::platformAttach()
         m_inspectorWindow = 0;
     }
 
-    // Set a default attached size based on InspectorFrontendClientLocal.
+    // Set a default sizes based on InspectorFrontendClientLocal.
     static const unsigned defaultAttachedSize = 300;
+    static const unsigned minimumAttachedWidth = 750;
+    static const unsigned minimumAttachedHeight = 250;
+
     if (m_attachmentSide == AttachmentSideBottom) {
         unsigned maximumAttachedHeight = platformInspectedWindowHeight() * 3 / 4;
         platformSetAttachedWindowHeight(std::max(minimumAttachedHeight, std::min(defaultAttachedSize, maximumAttachedHeight)));
index c6c668c..9dd75d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,7 +29,6 @@
 #if PLATFORM(MAC) && ENABLE(INSPECTOR)
 
 #import "WKAPICast.h"
-#import "WebContext.h"
 #import "WKInspectorPrivateMac.h"
 #import "WKMutableArray.h"
 #import "WKOpenPanelParameters.h"
 #import "WKRetainPtr.h"
 #import "WKURLCF.h"
 #import "WKViewPrivate.h"
+#import "WebContext.h"
 #import "WebInspectorMessages.h"
+#import "WebInspectorUIMessages.h"
 #import "WebPageGroup.h"
 #import "WebPageProxy.h"
 #import "WebPreferences.h"
 #import "WebProcessProxy.h"
-#import <algorithm>
-#import <mach-o/dyld.h>
-#import <WebKitSystemInterface.h>
+#import <QuartzCore/CoreAnimation.h>
 #import <WebCore/InspectorFrontendClientLocal.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/SoftLinking.h>
+#import <WebKitSystemInterface.h>
+#import <algorithm>
+#import <mach-o/dyld.h>
 #import <wtf/text/Base64.h>
 #import <wtf/text/WTFString.h>
 
@@ -73,10 +75,16 @@ static const CGFloat dockButtonSpacing = dockButtonMargin * 2;
 static const NSUInteger windowStyleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSTexturedBackgroundWindowMask;
 #endif
 
+// The time we keep our WebView alive before closing it and its process.
+// Reusing the WebView improves start up time for people that jump in and out of the Inspector.
+static const unsigned webViewCloseTimeout = 60;
+
 // WKWebInspectorProxyObjCAdapter is a helper ObjC object used as a delegate or notification observer
 // for the sole purpose of getting back into the C++ code from an ObjC caller.
 
-@interface WKWebInspectorProxyObjCAdapter ()
+@interface WKWebInspectorProxyObjCAdapter () {
+    BOOL _ignoreNextInspectedViewFrameDidChange;
+}
 
 - (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy;
 - (void)close;
@@ -114,7 +122,7 @@ static const NSUInteger windowStyleMask = NSTitledWindowMask | NSClosableWindowM
 
 - (void)close
 {
-    _inspectorProxy = 0;
+    _inspectorProxy = nullptr;
 }
 
 - (void)windowDidMove:(NSNotification *)notification
@@ -132,8 +140,18 @@ static const NSUInteger windowStyleMask = NSTitledWindowMask | NSClosableWindowM
     static_cast<WebInspectorProxy*>(_inspectorProxy)->close();
 }
 
+- (void)ignoreNextInspectedViewFrameDidChange
+{
+    _ignoreNextInspectedViewFrameDidChange = YES;
+}
+
 - (void)inspectedViewFrameDidChange:(NSNotification *)notification
 {
+    if (_ignoreNextInspectedViewFrameDidChange)
+        return;
+
+    _ignoreNextInspectedViewFrameDidChange = NO;
+
     // Resizing the views while inside this notification can lead to bad results when entering
     // or exiting full screen. To avoid that we need to perform the work after a delay. We only
     // depend on this for enforcing the height constraints, so a small delay isn't terrible. Most
@@ -269,6 +287,18 @@ WKRect WebInspectorProxy::inspectorWindowFrame()
     return WKRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
 }
 
+void WebInspectorProxy::closeTimerFired()
+{
+    ASSERT(!m_isAttached || !m_inspectorWindow);
+    if (m_isAttached || m_inspectorWindow)
+        return;
+
+    m_inspectorView = nil;
+
+    [m_inspectorProxyObjCAdapter close];
+    m_inspectorProxyObjCAdapter = nil;
+}
+
 static NSButton *createDockButton(NSString *imageName)
 {
     // Create a full screen button so we can turn it into a dock button.
@@ -395,7 +425,16 @@ void WebInspectorProxy::updateInspectorWindowTitle() const
 WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
 {
     ASSERT(m_page);
+
+    m_closeTimer.stop();
+
+    if (m_inspectorView) {
+        ASSERT(m_inspectorProxyObjCAdapter);
+        return toImpl(m_inspectorView.get().pageRef);
+    }
+
     ASSERT(!m_inspectorView);
+    ASSERT(!m_inspectorProxyObjCAdapter);
 
     NSRect initialRect;
     if (m_isAttached) {
@@ -418,7 +457,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
             initialRect = [NSWindow contentRectForFrameRect:windowFrame styleMask:windowStyleMask];
     }
 
-    m_inspectorView = adoptNS([[WKWebInspectorWKView alloc] initWithFrame:initialRect contextRef:toAPI(&page()->process().context()) pageGroupRef:toAPI(inspectorPageGroup()) relatedToPage:toAPI(m_page)]);
+    m_inspectorView = adoptNS([[WKWebInspectorWKView alloc] initWithFrame:initialRect contextRef:toAPI(&inspectorContext()) pageGroupRef:toAPI(inspectorPageGroup()) relatedToPage:nullptr]);
     ASSERT(m_inspectorView);
 
 #if __MAC_OS_X_VERSION_MIN_REQUIRED <= 1090
@@ -426,8 +465,10 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
 #endif
 
     m_inspectorProxyObjCAdapter = adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
+    ASSERT(m_inspectorProxyObjCAdapter);
 
     WebPageProxy* inspectorPage = toImpl(m_inspectorView.get().pageRef);
+    ASSERT(inspectorPage);
 
     WKPageUIClientV2 uiClient = {
         { 2, this },
@@ -499,13 +540,10 @@ void WebInspectorProxy::platformDidClose()
     if (m_inspectorWindow) {
         [m_inspectorWindow setDelegate:nil];
         [m_inspectorWindow orderOut:nil];
-        m_inspectorWindow = 0;
+        m_inspectorWindow = nil;
     }
 
-    m_inspectorView = 0;
-
-    [m_inspectorProxyObjCAdapter close];
-    m_inspectorProxyObjCAdapter = 0;
+    m_closeTimer.startOneShot(webViewCloseTimeout);
 }
 
 void WebInspectorProxy::platformHide()
@@ -518,7 +556,7 @@ void WebInspectorProxy::platformHide()
     if (m_inspectorWindow) {
         [m_inspectorWindow setDelegate:nil];
         [m_inspectorWindow orderOut:nil];
-        m_inspectorWindow = 0;
+        m_inspectorWindow = nil;
     }
 }
 
@@ -589,7 +627,7 @@ void WebInspectorProxy::platformSave(const String& suggestedURL, const String& c
         } else
             [contentCopy writeToURL:actualURL atomically:YES encoding:NSUTF8StringEncoding error:NULL];
 
-        m_page->process().send(Messages::WebInspector::DidSave([actualURL absoluteString]), m_page->pageID());
+        m_inspectorPage->process().send(Messages::WebInspectorUI::DidSave([actualURL absoluteString]), m_inspectorPage->pageID());
     };
 
     if (!forceSaveDialog) {
@@ -623,7 +661,7 @@ void WebInspectorProxy::platformAppend(const String& suggestedURL, const String&
     [handle writeData:[content dataUsingEncoding:NSUTF8StringEncoding]];
     [handle closeFile];
 
-    m_page->process().send(Messages::WebInspector::DidAppend([actualURL absoluteString]), m_page->pageID());
+    m_inspectorPage->process().send(Messages::WebInspectorUI::DidAppend([actualURL absoluteString]), m_inspectorPage->pageID());
 }
 
 void WebInspectorProxy::windowFrameDidChange()
@@ -679,6 +717,11 @@ void WebInspectorProxy::inspectedViewFrameDidChange(CGFloat currentDimension)
         }
     }
 
+    if (NSEqualRects([m_inspectorView frame], inspectorFrame) && NSEqualRects([inspectedView frame], inspectedViewFrame))
+        return;
+
+    [m_inspectorProxyObjCAdapter ignoreNextInspectedViewFrameDidChange];
+
     // Disable screen updates to make sure the layers for both views resize in sync.
     [[m_inspectorView window] disableScreenUpdatesUntilFlush];
 
@@ -708,7 +751,7 @@ void WebInspectorProxy::platformAttach()
     if (m_inspectorWindow) {
         [m_inspectorWindow setDelegate:nil];
         [m_inspectorWindow orderOut:nil];
-        m_inspectorWindow = 0;
+        m_inspectorWindow = nil;
     }
 
     [m_inspectorView removeFromSuperview];
index 67c36f0..d0a92f9 100644 (file)
                1AFE436518B6C081009C7A48 /* UIDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1AFE436318B6C081009C7A48 /* UIDelegate.mm */; };
                1AFE436618B6C081009C7A48 /* UIDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AFE436418B6C081009C7A48 /* UIDelegate.h */; };
                1AFF49001833DE78009AB15A /* WKDeprecatedFunctions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */; };
+               1C891D6519B124FF00BA79DD /* WebInspectorUI.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */; };
+               1C891D6619B124FF00BA79DD /* WebInspectorUI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C891D6319B124FF00BA79DD /* WebInspectorUI.h */; };
                1C8AE7611992F63A00ABF6EC /* DockBottomLegacy.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1C8AE75F1992F62F00ABF6EC /* DockBottomLegacy.pdf */; };
                1C8AE7621992F63C00ABF6EC /* DockRightLegacy.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1C8AE7601992F62F00ABF6EC /* DockRightLegacy.pdf */; };
-               1C8E25A81270E3BB00BC7BD0 /* WebInspectorFrontendClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E256B1270DE3800BC7BD0 /* WebInspectorFrontendClient.cpp */; };
-               1C8E25A91270E3BC00BC7BD0 /* WebInspectorFrontendClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E256A1270DE3800BC7BD0 /* WebInspectorFrontendClient.h */; };
                1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E281E1275D15400BC7BD0 /* WebInspector.h */; };
                1C8E28211275D15400BC7BD0 /* WebInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E281F1275D15400BC7BD0 /* WebInspector.cpp */; };
                1C8E28341275D73800BC7BD0 /* WebInspectorProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C8E28321275D73800BC7BD0 /* WebInspectorProxy.h */; };
                1CA8B936127C774E00576C2B /* WebInspectorProxyMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */; };
                1CA8B945127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */; };
                1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */; };
-               1CA8B954127C891500576C2B /* WebInspectorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */; };
+               1CA8B954127C891500576C2B /* WebInspectorUIMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C8E2DAD1278C5B200BC7BD0 /* WebInspectorUIMac.mm */; };
                1CB75C941701E880009F809F /* DockRight.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1CB75C931701E880009F809F /* DockRight.pdf */; };
+               1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */; };
+               1CBBE4A119B66C53006B7D81 /* WebInspectorUIMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */; };
                1CBC945E16515ED200D68AAE /* DockBottom.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1CBC945D16515ED200D68AAE /* DockBottom.pdf */; };
                1F335BC0185B84F0001A201A /* WKWebProcessPlugInLoadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F335BBF185B84D8001A201A /* WKWebProcessPlugInLoadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1F604BA81889FA7400EE0395 /* WKRenderingProgressEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F604BA61889FA7400EE0395 /* WKRenderingProgressEvents.h */; settings = {ATTRIBUTES = (Private, ); }; };
                1AFF48FE1833DE78009AB15A /* WKDeprecatedFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKDeprecatedFunctions.cpp; sourceTree = "<group>"; };
                1BB417C912C00CCA002BE67B /* TextCheckerCompletion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCheckerCompletion.cpp; sourceTree = "<group>"; };
                1C77C1951288A872006A742F /* WebInspectorProxy.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorProxy.messages.in; sourceTree = "<group>"; };
+               1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUI.cpp; sourceTree = "<group>"; };
+               1C891D6319B124FF00BA79DD /* WebInspectorUI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorUI.h; sourceTree = "<group>"; };
+               1C891D6419B124FF00BA79DD /* WebInspectorUI.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspectorUI.messages.in; sourceTree = "<group>"; };
                1C8AE75F1992F62F00ABF6EC /* DockBottomLegacy.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = DockBottomLegacy.pdf; path = Resources/DockBottomLegacy.pdf; sourceTree = "<group>"; };
                1C8AE7601992F62F00ABF6EC /* DockRightLegacy.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = DockRightLegacy.pdf; path = Resources/DockRightLegacy.pdf; sourceTree = "<group>"; };
-               1C8E256A1270DE3800BC7BD0 /* WebInspectorFrontendClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorFrontendClient.h; sourceTree = "<group>"; };
-               1C8E256B1270DE3800BC7BD0 /* WebInspectorFrontendClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorFrontendClient.cpp; sourceTree = "<group>"; };
                1C8E281E1275D15400BC7BD0 /* WebInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspector.h; sourceTree = "<group>"; };
                1C8E281F1275D15400BC7BD0 /* WebInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspector.cpp; sourceTree = "<group>"; };
                1C8E28321275D73800BC7BD0 /* WebInspectorProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxy.h; sourceTree = "<group>"; };
                1C8E2A1C1277833F00BC7BD0 /* WebInspector.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebInspector.messages.in; sourceTree = "<group>"; };
                1C8E2A311277852400BC7BD0 /* WebInspectorMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorMessageReceiver.cpp; sourceTree = "<group>"; };
                1C8E2A321277852400BC7BD0 /* WebInspectorMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorMessages.h; sourceTree = "<group>"; };
-               1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorMac.mm; sourceTree = "<group>"; };
+               1C8E2DAD1278C5B200BC7BD0 /* WebInspectorUIMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorUIMac.mm; sourceTree = "<group>"; };
                1CA8B935127C774E00576C2B /* WebInspectorProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebInspectorProxyMac.mm; sourceTree = "<group>"; };
                1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorProxyMessageReceiver.cpp; sourceTree = "<group>"; };
                1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorProxyMessages.h; sourceTree = "<group>"; };
                1CB75C931701E880009F809F /* DockRight.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = DockRight.pdf; path = Resources/DockRight.pdf; sourceTree = "<group>"; };
+               1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorUIMessageReceiver.cpp; sourceTree = "<group>"; };
+               1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebInspectorUIMessages.h; sourceTree = "<group>"; };
                1CBC945D16515ED200D68AAE /* DockBottom.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; name = DockBottom.pdf; path = Resources/DockBottom.pdf; sourceTree = "<group>"; };
                1CC417C912C00CCA002BE67B /* TextCheckerCompletion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCheckerCompletion.h; sourceTree = "<group>"; };
                1F0181691858DC1500F92884 /* WKWebProcessPlugInFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFrame.h; sourceTree = "<group>"; };
                                BC1BE1DE12D54A410004A228 /* WebGeolocationClient.h */,
                                BC111A59112F4FBB00337BAB /* WebInspectorClient.cpp */,
                                BC032D6D10F4378D0058C15A /* WebInspectorClient.h */,
-                               1C8E256B1270DE3800BC7BD0 /* WebInspectorFrontendClient.cpp */,
-                               1C8E256A1270DE3800BC7BD0 /* WebInspectorFrontendClient.h */,
                                31099971146C759B0029DEB9 /* WebNotificationClient.cpp */,
                                31099968146C71F50029DEB9 /* WebNotificationClient.h */,
                                512127C11908239A00DAF35C /* WebPasteboardOverrides.cpp */,
                                1C8E281F1275D15400BC7BD0 /* WebInspector.cpp */,
                                1C8E281E1275D15400BC7BD0 /* WebInspector.h */,
                                1C8E2A1C1277833F00BC7BD0 /* WebInspector.messages.in */,
+                               1C891D6219B124FF00BA79DD /* WebInspectorUI.cpp */,
+                               1C891D6319B124FF00BA79DD /* WebInspectorUI.h */,
+                               1C891D6419B124FF00BA79DD /* WebInspectorUI.messages.in */,
                                BC857F8412B82D0B00EDEB2E /* WebOpenPanelResultListener.cpp */,
                                BC857F8312B82D0B00EDEB2E /* WebOpenPanelResultListener.h */,
                                BC963D6A113DD19200574BE2 /* WebPage.cpp */,
                                5192D5751961FD0300CD19AA /* ServicesOverlayController.mm */,
                                1AAF263714687C39004A1E8A /* TiledCoreAnimationDrawingArea.h */,
                                1AAF263614687C39004A1E8A /* TiledCoreAnimationDrawingArea.mm */,
-                               1C8E2DAD1278C5B200BC7BD0 /* WebInspectorMac.mm */,
+                               1C8E2DAD1278C5B200BC7BD0 /* WebInspectorUIMac.mm */,
                                BC963D6D113DD1A500574BE2 /* WebPageMac.mm */,
                                29CD55A8128E294F00133C85 /* WKAccessibilityWebPageObjectBase.h */,
                                29CD55A9128E294F00133C85 /* WKAccessibilityWebPageObjectBase.mm */,
                                1C8E2A321277852400BC7BD0 /* WebInspectorMessages.h */,
                                1CA8B943127C882A00576C2B /* WebInspectorProxyMessageReceiver.cpp */,
                                1CA8B944127C882A00576C2B /* WebInspectorProxyMessages.h */,
+                               1CBBE49E19B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp */,
+                               1CBBE49F19B66C53006B7D81 /* WebInspectorUIMessages.h */,
                                33D3A3C41339617900709BE4 /* WebMediaCacheManagerMessageReceiver.cpp */,
                                33D3A3C51339617900709BE4 /* WebMediaCacheManagerMessages.h */,
                                33D3A3C61339617900709BE4 /* WebMediaCacheManagerProxyMessageReceiver.cpp */,
                                2DACE64E18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h in Headers */,
                                51578B831209ECEF00A37C4A /* APIData.h in Headers */,
                                F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */,
+                               1C891D6619B124FF00BA79DD /* WebInspectorUI.h in Headers */,
                                F62A76B712B1B25F0005F1B6 /* WebDatabaseManagerMessages.h in Headers */,
                                F62A765D12B1ABC30005F1B6 /* WebDatabaseManagerProxy.h in Headers */,
                                2D6AB541192B1C4A003A9FD1 /* WKPDFPageNumberIndicator.h in Headers */,
                                1C8E28201275D15400BC7BD0 /* WebInspector.h in Headers */,
                                1A3CC16718906ACF001E6ED8 /* WKWebView.h in Headers */,
                                BC032D8210F4378D0058C15A /* WebInspectorClient.h in Headers */,
-                               1C8E25A91270E3BC00BC7BD0 /* WebInspectorFrontendClient.h in Headers */,
                                1C8E2A361277852400BC7BD0 /* WebInspectorMessages.h in Headers */,
                                1C8E28341275D73800BC7BD0 /* WebInspectorProxy.h in Headers */,
                                1CA8B946127C882A00576C2B /* WebInspectorProxyMessages.h in Headers */,
                                F634445D12A885E9000612D8 /* WKSecurityOrigin.h in Headers */,
                                1AAF08B819269E6D00B6390C /* WebUserContentControllerMessages.h in Headers */,
                                BC407604124FF0270068F20A /* WKSerializedScriptValue.h in Headers */,
+                               1CBBE4A119B66C53006B7D81 /* WebInspectorUIMessages.h in Headers */,
                                0FCB4E4C18BBE044000FCFC9 /* WKContentView.h in Headers */,
                                37A64E5718F38F4600EB30F1 /* _WKFormInputSession.h in Headers */,
                                1F604BAA1889FBB800EE0395 /* WKRenderingProgressEventsInternal.h in Headers */,
                                00B9661918E25AE100CE1F88 /* FindClient.mm in Sources */,
                                1AE5B7FB11E7AED200BA6767 /* NetscapePluginMac.mm in Sources */,
                                7C361D721927FA360036A59D /* WebScriptMessageHandler.cpp in Sources */,
+                               1C891D6519B124FF00BA79DD /* WebInspectorUI.cpp in Sources */,
                                1A4A9C5512B816CF008FE984 /* NetscapePluginModule.cpp in Sources */,
                                1A4A9C9A12B821CD008FE984 /* NetscapePluginModuleMac.mm in Sources */,
                                1AA5889311EE70400061B882 /* NetscapePluginStream.cpp in Sources */,
                                1A2D8439127F65D5001EB962 /* NPObjectMessageReceiverMessageReceiver.cpp in Sources */,
                                1AAF08AD1926936700B6390C /* WebUserContentController.cpp in Sources */,
                                1A2D82A6127F4EAB001EB962 /* NPObjectProxy.cpp in Sources */,
+                               1CBBE4A019B66C53006B7D81 /* WebInspectorUIMessageReceiver.cpp in Sources */,
                                1A2D82A8127F4EAB001EB962 /* NPRemoteObjectMap.cpp in Sources */,
                                1A2161B111F37664008AD0F5 /* NPRuntimeObjectMap.cpp in Sources */,
                                1A2162B011F38971008AD0F5 /* NPRuntimeUtilities.cpp in Sources */,
                                BCCF6ABC12C91EF9008F9C35 /* WebImage.cpp in Sources */,
                                1C8E28211275D15400BC7BD0 /* WebInspector.cpp in Sources */,
                                BC111A60112F4FBB00337BAB /* WebInspectorClient.cpp in Sources */,
-                               1C8E25A81270E3BB00BC7BD0 /* WebInspectorFrontendClient.cpp in Sources */,
-                               1CA8B954127C891500576C2B /* WebInspectorMac.mm in Sources */,
+                               1CA8B954127C891500576C2B /* WebInspectorUIMac.mm in Sources */,
                                1C8E2A351277852400BC7BD0 /* WebInspectorMessageReceiver.cpp in Sources */,
                                1C8E28351275D73800BC7BD0 /* WebInspectorProxy.cpp in Sources */,
                                1CA8B936127C774E00576C2B /* WebInspectorProxyMac.mm in Sources */,
index 501d41c..859358b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -84,20 +84,21 @@ void WebInspectorClient::inspectorDestroyed()
 
 WebCore::InspectorFrontendChannel* WebInspectorClient::openInspectorFrontend(InspectorController* controller)
 {
-    WebPage* inspectorPage = controller->isUnderTest() ? m_page->inspector()->createInspectorPageForTest() : m_page->inspector()->createInspectorPage();
-    ASSERT_UNUSED(inspectorPage, inspectorPage);
-    return this;
+    m_page->inspector()->createInspectorPage(controller->isUnderTest());
+
+    return m_page->inspector();
 }
 
 void WebInspectorClient::closeInspectorFrontend()
 {
     if (m_page->inspector())
-        m_page->inspector()->didClose();
+        m_page->inspector()->closeFrontend();
 }
 
 void WebInspectorClient::bringFrontendToFront()
 {
-    m_page->inspector()->bringToFront();
+    if (m_page->inspector())
+        m_page->inspector()->bringToFront();
 }
 
 void WebInspectorClient::didResizeMainFrame(Frame*)
@@ -197,34 +198,6 @@ void WebInspectorClient::didSetSearchingForNode(bool enabled)
 }
 #endif
 
-bool WebInspectorClient::sendMessageToFrontend(const String& message)
-{
-    WebInspector* inspector = m_page->inspector();
-    if (!inspector)
-        return false;
-
-#if ENABLE(INSPECTOR_SERVER)
-    if (inspector->hasRemoteFrontendConnected()) {
-        inspector->sendMessageToRemoteFrontend(message);
-        return true;
-    }
-#endif
-
-    WebPage* inspectorPage = inspector->inspectorPage();
-    if (inspectorPage)
-        return doDispatchMessageOnFrontendPage(inspectorPage->corePage(), message);
-
-    return false;
-}
-
-bool WebInspectorClient::supportsFrameInstrumentation()
-{
-#if USE(COORDINATED_GRAPHICS)
-    return true;
-#endif
-    return false;
-}
-
 void WebInspectorClient::pageOverlayDestroyed(PageOverlay*)
 {
 }
index 7033bde..798cac7 100644 (file)
@@ -45,22 +45,23 @@ namespace WebKit {
 class WebPage;
 class RepaintIndicatorLayerClient;
 
-class WebInspectorClient : public WebCore::InspectorClient, public WebCore::InspectorFrontendChannel, private PageOverlay::Client {
+class WebInspectorClient : public WebCore::InspectorClient, private PageOverlay::Client {
 friend class RepaintIndicatorLayerClient;
 public:
     WebInspectorClient(WebPage*);
     virtual ~WebInspectorClient();
 
 private:
-    virtual void inspectorDestroyed() override;
+    // WebCore::InspectorClient
+    void inspectorDestroyed() override;
 
-    virtual InspectorFrontendChannel* openInspectorFrontend(WebCore::InspectorController*) override;
-    virtual void closeInspectorFrontend() override;
-    virtual void bringFrontendToFront() override;
-    virtual void didResizeMainFrame(WebCore::Frame*) override;
+    WebCore::InspectorFrontendChannel* openInspectorFrontend(WebCore::InspectorController*) override;
+    void closeInspectorFrontend() override;
+    void bringFrontendToFront() override;
+    void didResizeMainFrame(WebCore::Frame*) override;
 
-    virtual void highlight() override;
-    virtual void hideHighlight() override;
+    void highlight() override;
+    void hideHighlight() override;
 
 #if PLATFORM(IOS)
     virtual void showInspectorIndication() override;
@@ -72,10 +73,6 @@ private:
     virtual bool overridesShowPaintRects() const override { return true; }
     virtual void showPaintRect(const WebCore::FloatRect&) override;
 
-    virtual bool sendMessageToFrontend(const String&) override;
-
-    virtual bool supportsFrameInstrumentation();
-
     // PageOverlay::Client
     virtual void pageOverlayDestroyed(PageOverlay*) override;
     virtual void willMoveToWebPage(PageOverlay*, WebPage*) override;
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp
deleted file mode 100644 (file)
index d43dae1..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebInspectorFrontendClient.h"
-
-#if ENABLE(INSPECTOR)
-
-#include "WebInspector.h"
-#include "WebPage.h"
-#include <WebCore/InspectorController.h>
-#include <WebCore/Page.h>
-#include <inspector/InspectorAgentBase.h>
-#include <wtf/text/WTFString.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-WebInspectorFrontendClient::WebInspectorFrontendClient(WebPage* page, WebPage* inspectorPage)
-    : InspectorFrontendClientLocal(&page->corePage()->inspectorController(), inspectorPage->corePage(), std::make_unique<Settings>())
-    , m_page(page)
-{
-}
-
-String WebInspectorFrontendClient::localizedStringsURL()
-{
-    return m_page->inspector()->localizedStringsURL();
-}
-
-void WebInspectorFrontendClient::bringToFront()
-{
-    m_page->inspector()->bringToFront();
-}
-
-void WebInspectorFrontendClient::closeWindow()
-{
-    m_page->corePage()->inspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
-    m_page->inspector()->didClose();
-}
-
-bool WebInspectorFrontendClient::canSave()
-{
-    return m_page->inspector()->canSave();
-}
-
-void WebInspectorFrontendClient::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
-{
-    m_page->inspector()->save(filename, content, base64Encoded, forceSaveAs);
-}
-
-void WebInspectorFrontendClient::append(const String& filename, const String& content)
-{
-    m_page->inspector()->append(filename, content);
-}
-
-void WebInspectorFrontendClient::attachWindow(DockSide dockSide)
-{
-    switch (dockSide) {
-    case InspectorFrontendClient::DockSide::Undocked:
-        ASSERT_NOT_REACHED();
-        break;
-    case InspectorFrontendClient::DockSide::Bottom:
-        m_page->inspector()->attachBottom();
-        break;
-    case InspectorFrontendClient::DockSide::Right:
-        m_page->inspector()->attachRight();
-        break;
-    }
-}
-
-void WebInspectorFrontendClient::detachWindow()
-{
-    m_page->inspector()->detach();
-}
-
-void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height)
-{
-    m_page->inspector()->setAttachedWindowHeight(height);
-}
-
-void WebInspectorFrontendClient::setAttachedWindowWidth(unsigned width)
-{
-    m_page->inspector()->setAttachedWindowWidth(width);
-}
-
-void WebInspectorFrontendClient::setToolbarHeight(unsigned height)
-{
-    m_page->inspector()->setToolbarHeight(height);
-}
-
-void WebInspectorFrontendClient::inspectedURLChanged(const String& urlString)
-{
-    m_page->inspector()->inspectedURLChanged(urlString);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(INSPECTOR)
index df6110c..52e3f5b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "WebInspector.h"
 
 #if ENABLE(INSPECTOR)
+
 #include "WebFrame.h"
-#include "WebInspectorFrontendClient.h"
+#include "WebInspectorMessages.h"
 #include "WebInspectorProxyMessages.h"
+#include "WebInspectorUIMessages.h"
 #include "WebPage.h"
-#include "WebPageCreationParameters.h"
 #include "WebProcess.h"
+#include <WebCore/Chrome.h>
+#include <WebCore/Document.h>
+#include <WebCore/FrameLoadRequest.h>
+#include <WebCore/FrameView.h>
 #include <WebCore/InspectorController.h>
 #include <WebCore/InspectorFrontendClient.h>
+#include <WebCore/InspectorPageAgent.h>
 #include <WebCore/MainFrame.h>
+#include <WebCore/NotImplemented.h>
 #include <WebCore/Page.h>
 #include <WebCore/ScriptController.h>
-#include <inspector/InspectorAgentBase.h>
-#include <bindings/ScriptValue.h>
-#include <wtf/text/StringConcatenate.h>
+#include <WebCore/WindowFeatures.h>
 
 using namespace WebCore;
 
+static const float minimumAttachedHeight = 250;
+static const float maximumAttachedHeightRatio = 0.75;
+static const float minimumAttachedWidth = 750;
+
 namespace WebKit {
 
-PassRefPtr<WebInspector> WebInspector::create(WebPage* page, InspectorFrontendChannel* frontendChannel)
+PassRefPtr<WebInspector> WebInspector::create(WebPage* page)
 {
-    return adoptRef(new WebInspector(page, frontendChannel));
+    return adoptRef(new WebInspector(page));
 }
 
-WebInspector::WebInspector(WebPage* page, InspectorFrontendChannel* frontendChannel)
+WebInspector::WebInspector(WebPage* page)
     : m_page(page)
-    , m_inspectorPage(nullptr)
-    , m_frontendClient(nullptr)
-    , m_frontendChannel(frontendChannel)
-#if PLATFORM(COCOA)
-    , m_hasLocalizedStringsURL(false)
-#endif
-#if ENABLE(INSPECTOR_SERVER)
-    , m_remoteFrontendConnected(false)
-#endif
+    , m_attached(false)
+    , m_previousCanAttach(false)
 {
 }
 
 // Called from WebInspectorClient
-WebPage* WebInspector::createInspectorPage()
+void WebInspector::createInspectorPage(bool underTest)
 {
     if (!m_page)
-        return nullptr;
-
-    ASSERT(!m_inspectorPage);
-    ASSERT(!m_frontendClient);
-
-    uint64_t inspectorPageID = 0;
-    WebPageCreationParameters parameters;
-
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebInspectorProxy::CreateInspectorPage(),
-            Messages::WebInspectorProxy::CreateInspectorPage::Reply(inspectorPageID, parameters),
-            m_page->pageID(), std::chrono::milliseconds::max())) {
-        return nullptr;
-    }
+        return;
 
-    if (!inspectorPageID)
-        return nullptr;
+#if OS(DARWIN)
+    mach_port_t listeningPort;
+    mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+
+    IPC::Connection::Identifier connectionIdentifer(listeningPort);
+    IPC::Attachment connectionClientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
+    IPC::Connection::Identifier connectionIdentifer(socketPair.server);
+    IPC::Attachment connectionClientPort(socketPair.client);
+#else
+    notImplemented();
+    return;
+#endif
 
-    WebProcess::shared().createWebPage(inspectorPageID, parameters);
-    m_inspectorPage = WebProcess::shared().webPage(inspectorPageID);
-    ASSERT(m_inspectorPage);
+    m_frontendConnection = IPC::Connection::createServerConnection(connectionIdentifer, this, RunLoop::main());
+    m_frontendConnection->open();
 
-    auto frontendClient = std::make_unique<WebInspectorFrontendClient>(m_page, m_inspectorPage);
-    m_frontendClient = frontendClient.get();
-    m_inspectorPage->corePage()->inspectorController().setInspectorFrontendClient(WTF::move(frontendClient));
-    return m_inspectorPage;
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::CreateInspectorPage(connectionClientPort, canAttachWindow(), underTest), m_page->pageID());
 }
 
-WebPage* WebInspector::createInspectorPageForTest()
+void WebInspector::closeFrontend()
 {
-    if (!m_page)
-        return nullptr;
-
-    ASSERT(!m_inspectorPage);
-    ASSERT(!m_frontendClient);
-
-    uint64_t inspectorPageID = 0;
-    WebPageCreationParameters parameters;
-
-    if (!WebProcess::shared().parentProcessConnection()->sendSync(Messages::WebInspectorProxy::CreateInspectorPageForTest(),
-            Messages::WebInspectorProxy::CreateInspectorPageForTest::Reply(inspectorPageID, parameters),
-            m_page->pageID(), std::chrono::milliseconds::max())) {
-        return nullptr;
-    }
-
-    if (!inspectorPageID)
-        return nullptr;
-
-    WebProcess::shared().createWebPage(inspectorPageID, parameters);
-    m_inspectorPage = WebProcess::shared().webPage(inspectorPageID);
-    ASSERT(m_inspectorPage);
-
-    auto frontendClient = std::make_unique<WebInspectorFrontendClient>(m_page, m_inspectorPage);
-    m_frontendClient = frontendClient.get();
-    m_inspectorPage->corePage()->inspectorController().setInspectorFrontendClient(WTF::move(frontendClient));
-    return m_inspectorPage;
-}
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::DidClose(), m_page->pageID());
 
-void WebInspector::destroyInspectorPage()
-{
-    m_inspectorPage = nullptr;
-    m_frontendClient = nullptr;
-    m_frontendChannel = nullptr;
-}
+    m_frontendConnection->invalidate();
+    m_frontendConnection = nullptr;
 
-// Called from WebInspectorFrontendClient
-void WebInspector::didClose()
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::DidClose(), m_page->pageID());
-    destroyInspectorPage();
+    m_attached = false;
+    m_previousCanAttach = false;
 }
 
 void WebInspector::bringToFront()
@@ -145,51 +110,6 @@ void WebInspector::bringToFront()
     WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::BringToFront(), m_page->pageID());
 }
 
-void WebInspector::inspectedURLChanged(const String& urlString)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::InspectedURLChanged(urlString), m_page->pageID());
-}
-
-void WebInspector::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Save(filename, content, base64Encoded, forceSaveAs), m_page->pageID());
-}
-
-void WebInspector::append(const String& filename, const String& content)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Append(filename, content), m_page->pageID());
-}
-
-void WebInspector::attachBottom()
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::AttachBottom(), m_page->pageID());
-}
-
-void WebInspector::attachRight()
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::AttachRight(), m_page->pageID());
-}
-
-void WebInspector::detach()
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Detach(), m_page->pageID());
-}
-
-void WebInspector::setAttachedWindowHeight(unsigned height)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowHeight(height), m_page->pageID());
-}
-
-void WebInspector::setAttachedWindowWidth(unsigned width)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowWidth(width), m_page->pageID());
-}
-
-void WebInspector::setToolbarHeight(unsigned height)
-{
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetToolbarHeight(height), m_page->pageID());
-}
-
 // Called by WebInspector messages
 void WebInspector::show()
 {
@@ -201,34 +121,17 @@ void WebInspector::close()
     m_page->corePage()->inspectorController().close();
 }
 
-void WebInspector::didSave(const String& url)
-{
-    ASSERT(m_inspectorPage);
-    m_inspectorPage->corePage()->mainFrame().script().executeScript(makeString("InspectorFrontendAPI.savedURL(\"", url, "\")"));
-}
-
-void WebInspector::didAppend(const String& url)
-{
-    ASSERT(m_inspectorPage);
-    m_inspectorPage->corePage()->mainFrame().script().executeScript(makeString("InspectorFrontendAPI.appendedToURL(\"", url, "\")"));
-}
-
-void WebInspector::attachedBottom()
+void WebInspector::openInNewTab(const String& urlString)
 {
-    if (m_frontendClient)
-        m_frontendClient->setAttachedWindow(InspectorFrontendClient::DockSide::Bottom);
-}
+    Page* inspectedPage = m_page->corePage();
+    Frame& inspectedMainFrame = inspectedPage->mainFrame();
+    FrameLoadRequest request(inspectedMainFrame.document()->securityOrigin(), ResourceRequest(urlString), "_blank");
 
-void WebInspector::attachedRight()
-{
-    if (m_frontendClient)
-        m_frontendClient->setAttachedWindow(InspectorFrontendClient::DockSide::Right);
-}
+    Page* newPage = inspectedPage->chrome().createWindow(&inspectedMainFrame, request, WindowFeatures(), NavigationAction(request.resourceRequest(), NavigationTypeLinkClicked));
+    if (!newPage)
+        return;
 
-void WebInspector::detached()
-{
-    if (m_frontendClient)
-        m_frontendClient->setAttachedWindow(InspectorFrontendClient::DockSide::Undocked);
+    newPage->mainFrame().loader().load(request);
 }
 
 void WebInspector::evaluateScriptForTest(const String& script)
@@ -239,109 +142,95 @@ void WebInspector::evaluateScriptForTest(const String& script)
 void WebInspector::showConsole()
 {
     m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->showConsole();
+    m_frontendConnection->send(Messages::WebInspectorUI::ShowConsole(), 0);
 }
 
 void WebInspector::showResources()
 {
     m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->showResources();
+    m_frontendConnection->send(Messages::WebInspectorUI::ShowResources(), 0);
 }
 
-void WebInspector::showMainResourceForFrame(uint64_t frameID)
+void WebInspector::showMainResourceForFrame(uint64_t frameIdentifier)
 {
-    WebFrame* frame = WebProcess::shared().webFrame(frameID);
+    WebFrame* frame = WebProcess::shared().webFrame(frameIdentifier);
     if (!frame)
         return;
 
     m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->showMainResourceForFrame(frame->coreFrame());
-}
 
-void WebInspector::startJavaScriptDebugging()
-{
-    m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->setDebuggingEnabled(true);
+    String inspectorFrameIdentifier = m_page->corePage()->inspectorController().pageAgent()->frameId(frame->coreFrame());
+    m_frontendConnection->send(Messages::WebInspectorUI::ShowMainResourceForFrame(inspectorFrameIdentifier), 0);
 }
 
-void WebInspector::stopJavaScriptDebugging()
+void WebInspector::startPageProfiling()
 {
     m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->setDebuggingEnabled(false);
-}
-
-void WebInspector::setJavaScriptProfilingEnabled(bool)
-{
-    // No longer supported.
+    m_frontendConnection->send(Messages::WebInspectorUI::StartPageProfiling(), 0);
 }
 
-void WebInspector::startJavaScriptProfiling()
+void WebInspector::stopPageProfiling()
 {
-    // No longer supported.
+    m_page->corePage()->inspectorController().show();
+    m_frontendConnection->send(Messages::WebInspectorUI::StopPageProfiling(), 0);
 }
 
-void WebInspector::stopJavaScriptProfiling()
+bool WebInspector::canAttachWindow()
 {
-    // No longer supported.
-}
+    // Don't allow attaching to another inspector -- two inspectors in one window is too much!
+    if (m_page->isInspectorPage())
+        return false;
 
-void WebInspector::startPageProfiling()
-{
-    m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->setTimelineProfilingEnabled(true);
-}
+    // If we are already attached, allow attaching again to allow switching sides.
+    if (m_attached)
+        return true;
 
-void WebInspector::stopPageProfiling()
-{
-    m_page->corePage()->inspectorController().show();
-    if (m_frontendClient)
-        m_frontendClient->setTimelineProfilingEnabled(false);
+    // Don't allow the attach if the window would be too small to accommodate the minimum inspector size.
+    unsigned inspectedPageHeight = m_page->corePage()->mainFrame().view()->visibleHeight();
+    unsigned inspectedPageWidth = m_page->corePage()->mainFrame().view()->visibleWidth();
+    unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
+    return minimumAttachedHeight <= maximumAttachedHeight && minimumAttachedWidth <= inspectedPageWidth;
 }
 
 void WebInspector::updateDockingAvailability()
 {
-    if (!m_frontendClient)
+    if (m_attached)
         return;
 
-    bool canAttachWindow = m_frontendClient->canAttachWindow();
+    bool canAttachWindow = this->canAttachWindow();
+    if (m_previousCanAttach == canAttachWindow)
+        return;
+
+    m_previousCanAttach = canAttachWindow;
+
     WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::AttachAvailabilityChanged(canAttachWindow), m_page->pageID());
-    m_frontendClient->setDockingUnavailable(!canAttachWindow);
 }
 
-#if ENABLE(INSPECTOR_SERVER)
-void WebInspector::sendMessageToRemoteFrontend(const String& message)
+void WebInspector::sendMessageToBackend(const String& message)
 {
-    ASSERT(m_remoteFrontendConnected);
-    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SendMessageToRemoteFrontend(message), m_page->pageID());
+    m_page->corePage()->inspectorController().dispatchMessageFromFrontend(message);
 }
 
-void WebInspector::dispatchMessageFromRemoteFrontend(const String& message)
+bool WebInspector::sendMessageToFrontend(const String& message)
 {
-    m_page->corePage()->inspectorController().dispatchMessageFromFrontend(message);
+#if !ENABLE(INSPECTOR_SERVER)
+    m_frontendConnection->send(Messages::WebInspectorUI::SendMessageToFrontend(message), 0);
+#else
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SendMessageToRemoteFrontend(message), m_page->pageID());
+#endif
+    return true;
 }
 
+#if ENABLE(INSPECTOR_SERVER)
 void WebInspector::remoteFrontendConnected()
 {
-    ASSERT(!m_remoteFrontendConnected);
-    // Switching between in-process and remote inspectors isn't supported yet.
-    ASSERT(!m_inspectorPage);
-
     bool isAutomaticInspection = false;
-    m_page->corePage()->inspectorController().connectFrontend(m_frontendChannel, isAutomaticInspection);
-    m_remoteFrontendConnected = true;
+    m_page->corePage()->inspectorController().connectFrontend(this, isAutomaticInspection);
 }
 
 void WebInspector::remoteFrontendDisconnected()
 {
-    ASSERT(m_remoteFrontendConnected);
     m_page->corePage()->inspectorController().disconnectFrontend(Inspector::InspectorDisconnectReason::InspectorDestroyed);
-    m_remoteFrontendConnected = false;
 }
 #endif
 
index c93bcb3..3c19b9e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 
 #include "APIObject.h"
 #include "Connection.h"
+#include "MessageReceiver.h"
 #include <WebCore/InspectorForwarding.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
 
-class WebInspectorFrontendClient;
 class WebPage;
 
-class WebInspector : public API::ObjectImpl<API::Object::Type::BundleInspector> {
+class WebInspector : public API::ObjectImpl<API::Object::Type::BundleInspector>, public IPC::Connection::Client, public WebCore::InspectorFrontendChannel {
 public:
-    static PassRefPtr<WebInspector> create(WebPage*, WebCore::InspectorFrontendChannel*);
+    static PassRefPtr<WebInspector> create(WebPage*);
 
     WebPage* page() const { return m_page; }
-    WebPage* inspectorPage() const { return m_inspectorPage; }
+
+    void updateDockingAvailability();
+
+    virtual bool sendMessageToFrontend(const String& message) override;
 
     // Implemented in generated WebInspectorMessageReceiver.cpp
-    void didReceiveWebInspectorMessage(IPC::Connection*, IPC::MessageDecoder&);
+    void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&);
+
+    // IPC::Connection::Client
+    void didClose(IPC::Connection*) { close(); }
+    void didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference messageReceiverName, IPC::StringReference messageName) { close(); }
 
     // Called by WebInspector messages
+    void connectionEstablished();
+
     void show();
     void close();
 
-    void didSave(const String& url);
-    void didAppend(const String& url);
+    void openInNewTab(const String& urlString);
+
+    void canAttachWindow(bool& result);
+
+    void showConsole();
+    void showResources();
 
-    void attachedBottom();
-    void attachedRight();
-    void detached();
+    void showMainResourceForFrame(uint64_t frameIdentifier);
+
+    void setAttached(bool attached) { m_attached = attached; }
 
     void evaluateScriptForTest(const String& script);
 
-    void setJavaScriptProfilingEnabled(bool);
     void startPageProfiling();
     void stopPageProfiling();
 
+    void sendMessageToBackend(const String&);
+
 #if ENABLE(INSPECTOR_SERVER)
-    bool hasRemoteFrontendConnected() const { return m_remoteFrontendConnected; }
-    void sendMessageToRemoteFrontend(const String& message);
-    void dispatchMessageFromRemoteFrontend(const String& message);
     void remoteFrontendConnected();
     void remoteFrontendDisconnected();
 #endif
 
 private:
     friend class WebInspectorClient;
-    friend class WebInspectorFrontendClient;
 
-    explicit WebInspector(WebPage*, WebCore::InspectorFrontendChannel*);
+    explicit WebInspector(WebPage*);
+
+    bool canAttachWindow();
 
     // Called from WebInspectorClient
-    WebPage* createInspectorPage();
-    WebPage* createInspectorPageForTest();
-    void destroyInspectorPage();
+    void createInspectorPage(bool underTest);
 
-    // Called from WebInspectorFrontendClient
-    void didClose();
+    void closeFrontend();
     void bringToFront();
-    void inspectedURLChanged(const String&);
-
-    bool canSave() const;
-    void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
-    void append(const String& filename, const String& content);
-
-    void attachBottom();
-    void attachRight();
-    void detach();
 
-    void setAttachedWindowHeight(unsigned);
-    void setAttachedWindowWidth(unsigned);
-    void setToolbarHeight(unsigned);
-
-    // Implemented in platform WebInspector file
-    String localizedStringsURL() const;
-
-    void showConsole();
-
-    void showResources();
-
-    void showMainResourceForFrame(uint64_t frameID);
-
-    void startJavaScriptDebugging();
-    void stopJavaScriptDebugging();
-
-    void startJavaScriptProfiling();
-    void stopJavaScriptProfiling();
+    WebPage* m_page;
 
-    void updateDockingAvailability();
+    RefPtr<IPC::Connection> m_frontendConnection;
 
-    WebPage* m_page;
-    WebPage* m_inspectorPage;
-    WebInspectorFrontendClient* m_frontendClient;
-    WebCore::InspectorFrontendChannel* m_frontendChannel;
-#if PLATFORM(COCOA)
-    mutable String m_localizedStringsURL;
-    mutable bool m_hasLocalizedStringsURL;
-#endif
-#if ENABLE(INSPECTOR_SERVER)
-    bool m_remoteFrontendConnected;
-#endif
+    bool m_attached;
+    bool m_previousCanAttach;
 };
 
 } // namespace WebKit
index c23b86f..fc073ca 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
 
 #if ENABLE(INSPECTOR)
 
-messages -> WebInspector LegacyReceiver {
+messages -> WebInspector {
     Show()
     Close()
-    AttachedBottom()
-    AttachedRight()
-    Detached()
-    DidSave(String url)
-    DidAppend(String url)
+
+    SetAttached(bool attached)
+
     ShowConsole()
     ShowResources()
-    ShowMainResourceForFrame(uint64_t frameID)
-    StartJavaScriptDebugging()
-    StopJavaScriptDebugging()
-    StartJavaScriptProfiling()
-    StopJavaScriptProfiling()
+
+    ShowMainResourceForFrame(uint64_t frameIdentifier)
+
+    OpenInNewTab(String url)
+
     StartPageProfiling()
     StopPageProfiling()
 
+    SendMessageToBackend(String message)
+
 #if ENABLE(INSPECTOR_SERVER)
-    DispatchMessageFromRemoteFrontend(String message)
     RemoteFrontendConnected()
     RemoteFrontendDisconnected()
 #endif
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp b/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp
new file mode 100644 (file)
index 0000000..3e5516c
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInspectorUI.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebInspectorMessages.h"
+#include "WebInspectorProxyMessages.h"
+#include "WebPage.h"
+#include "WebProcess.h"
+#include <JavaScriptCore/ScriptValue.h>
+#include <WebCore/Chrome.h>
+#include <WebCore/DOMWrapperWorld.h>
+#include <WebCore/InspectorController.h>
+#include <WebCore/MainFrame.h>
+#include <WebCore/NotImplemented.h>
+#include <WebCore/ScriptController.h>
+#include <WebCore/ScriptGlobalObject.h>
+#include <WebCore/ScriptState.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebInspectorUI> WebInspectorUI::create(WebPage* page)
+{
+    return adoptRef(new WebInspectorUI(page));
+}
+
+WebInspectorUI::WebInspectorUI(WebPage* page)
+    : m_page(page)
+    , m_inspectedPageIdentifier(0)
+    , m_underTest(false)
+    , m_frontendLoaded(false)
+    , m_dockSide(DockSide::Undocked)
+#if PLATFORM(COCOA)
+    , m_hasLocalizedStringsURL(false)
+#endif
+{
+}
+
+void WebInspectorUI::establishConnection(IPC::Attachment encodedConnectionIdentifier, uint64_t inspectedPageIdentifier, bool underTest)
+{
+#if OS(DARWIN)
+    IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
+#elif USE(UNIX_DOMAIN_SOCKETS)
+    IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.releaseFileDescriptor());
+#else
+    notImplemented();
+    return;
+#endif
+
+    if (IPC::Connection::identifierIsNull(connectionIdentifier))
+        return;
+
+    m_inspectedPageIdentifier = inspectedPageIdentifier;
+    m_frontendLoaded = false;
+    m_underTest = underTest;
+
+    m_page->corePage()->inspectorController().setInspectorFrontendClient(this);
+
+    m_backendConnection = IPC::Connection::createClientConnection(connectionIdentifier, this, RunLoop::main());
+    m_backendConnection->open();
+}
+
+void WebInspectorUI::windowObjectCleared()
+{
+    if (m_frontendHost)
+        m_frontendHost->disconnectClient();
+
+    m_frontendHost = InspectorFrontendHost::create(this, m_page->corePage());
+    ScriptGlobalObject::set(execStateFromPage(mainThreadNormalWorld(), m_page->corePage()), ASCIILiteral("InspectorFrontendHost"), m_frontendHost.get());
+}
+
+void WebInspectorUI::frontendLoaded()
+{
+    m_frontendLoaded = true;
+
+    evaluatePendingExpressions();
+    bringToFront();
+}
+
+void WebInspectorUI::moveWindowBy(float x, float y)
+{
+    FloatRect frameRect = m_page->corePage()->chrome().windowRect();
+    frameRect.move(x, y);
+    m_page->corePage()->chrome().setWindowRect(frameRect);
+}
+
+void WebInspectorUI::bringToFront()
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::BringToFront(), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::closeWindow()
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::DidClose(), m_inspectedPageIdentifier);
+
+    m_backendConnection->invalidate();
+    m_backendConnection = nullptr;
+
+    m_inspectedPageIdentifier = 0;
+    m_underTest = false;
+}
+
+void WebInspectorUI::requestSetDockSide(DockSide side)
+{
+    switch (side) {
+    case DockSide::Undocked:
+        WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Detach(), m_inspectedPageIdentifier);
+        break;
+
+    case DockSide::Right:
+        WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::AttachRight(), m_inspectedPageIdentifier);
+        break;
+
+    case DockSide::Bottom:
+        WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::AttachBottom(), m_inspectedPageIdentifier);
+        break;
+    }
+}
+
+void WebInspectorUI::setDockSide(DockSide side)
+{
+    const char* sideString;
+
+    switch (side) {
+    case DockSide::Undocked:
+        sideString = "undocked";
+        break;
+
+    case DockSide::Right:
+        sideString = "right";
+        break;
+
+    case DockSide::Bottom:
+        sideString = "bottom";
+        break;
+    }
+
+    m_dockSide = side;
+
+    evaluateCommandOnLoad(ASCIILiteral("setDockSide"), ASCIILiteral(sideString));
+}
+
+void WebInspectorUI::changeAttachedWindowHeight(unsigned height)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowHeight(height), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::changeAttachedWindowWidth(unsigned width)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowWidth(width), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::setToolbarHeight(unsigned height)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::SetToolbarHeight(height), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::openInNewTab(const String& url)
+{
+    m_backendConnection->send(Messages::WebInspector::OpenInNewTab(url), 0);
+}
+
+void WebInspectorUI::save(const WTF::String& filename, const WTF::String& content, bool base64Encoded, bool forceSaveAs)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Save(filename, content, base64Encoded, forceSaveAs), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::append(const WTF::String& filename, const WTF::String& content)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::Append(filename, content), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::inspectedURLChanged(const String& urlString)
+{
+    WebProcess::shared().parentProcessConnection()->send(Messages::WebInspectorProxy::InspectedURLChanged(urlString), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::showConsole()
+{
+    evaluateCommandOnLoad(ASCIILiteral("showConsole"));
+}
+
+void WebInspectorUI::showResources()
+{
+    evaluateCommandOnLoad(ASCIILiteral("showResources"));
+}
+
+void WebInspectorUI::showMainResourceForFrame(String frameIdentifier)
+{
+    evaluateCommandOnLoad(ASCIILiteral("showMainResourceForFrame"), frameIdentifier);
+}
+
+void WebInspectorUI::startPageProfiling()
+{
+    evaluateCommandOnLoad(ASCIILiteral("setTimelineProfilingEnabled"), true);
+}
+
+void WebInspectorUI::stopPageProfiling()
+{
+    evaluateCommandOnLoad(ASCIILiteral("setTimelineProfilingEnabled"), false);
+}
+
+void WebInspectorUI::didSave(const String& url)
+{
+    evaluateCommandOnLoad(ASCIILiteral("savedURL"), url);
+}
+
+void WebInspectorUI::didAppend(const String& url)
+{
+    evaluateCommandOnLoad(ASCIILiteral("appendedToURL"), url);
+}
+
+void WebInspectorUI::sendMessageToFrontend(const String& message)
+{
+    evaluateExpressionOnLoad(makeString("InspectorFrontendAPI.dispatchMessageAsync(", message, ")"));
+}
+
+void WebInspectorUI::sendMessageToBackend(const String& message)
+{
+    m_backendConnection->send(Messages::WebInspector::SendMessageToBackend(message), 0);
+}
+
+void WebInspectorUI::evaluateCommandOnLoad(const String& command, const String& argument)
+{
+    if (argument.isNull())
+        evaluateExpressionOnLoad(makeString("InspectorFrontendAPI.dispatch([\"", command, "\"])"));
+    else
+        evaluateExpressionOnLoad(makeString("InspectorFrontendAPI.dispatch([\"", command, "\", \"", argument, "\"])"));
+}
+
+void WebInspectorUI::evaluateCommandOnLoad(const String& command, bool argument)
+{
+    evaluateCommandOnLoad(command, ASCIILiteral(argument ? "true" : "false"));
+}
+
+void WebInspectorUI::evaluateExpressionOnLoad(const String& expression)
+{
+    if (m_frontendLoaded) {
+        ASSERT(m_queue.isEmpty());
+        m_page->corePage()->mainFrame().script().executeScript(expression);
+        return;
+    }
+
+    m_queue.append(expression);
+}
+
+void WebInspectorUI::evaluatePendingExpressions()
+{
+    ASSERT(m_frontendLoaded);
+
+    for (const String& expression : m_queue)
+        m_page->corePage()->mainFrame().script().executeScript(expression);
+
+    m_queue.clear();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.h b/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.h
new file mode 100644 (file)
index 0000000..bdbfcbe
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebInspectorUI_h
+#define WebInspectorUI_h
+
+#if ENABLE(INSPECTOR)
+
+#include "APIObject.h"
+#include "Connection.h"
+#include <WebCore/InspectorForwarding.h>
+#include <WebCore/InspectorFrontendClient.h>
+#include <WebCore/InspectorFrontendHost.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebInspectorUI : public API::ObjectImpl<API::Object::Type::BundleInspectorUI>, public IPC::Connection::Client, public WebCore::InspectorFrontendClient {
+public:
+    static PassRefPtr<WebInspectorUI> create(WebPage*);
+
+    WebPage* page() const { return m_page; }
+
+    // Implemented in generated WebInspectorUIMessageReceiver.cpp
+    void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&);
+
+    // IPC::Connection::Client
+    void didClose(IPC::Connection*) { closeWindow(); }
+    void didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference messageReceiverName, IPC::StringReference messageName) { closeWindow(); }
+
+    // Called by WebInspectorUI messages
+    void establishConnection(IPC::Attachment connectionIdentifier, uint64_t inspectedPageIdentifier, bool underTest);
+
+    void showConsole();
+    void showResources();
+
+    void showMainResourceForFrame(String frameIdentifier);
+
+    void startPageProfiling();
+    void stopPageProfiling();
+
+    void attachedBottom() { setDockSide(DockSide::Bottom); }
+    void attachedRight() { setDockSide(DockSide::Right); }
+    void detached() { setDockSide(DockSide::Undocked); }
+
+    void setDockSide(DockSide);
+
+    void didSave(const String& url);
+    void didAppend(const String& url);
+
+    void sendMessageToFrontend(const String&);
+
+    // WebCore::InspectorFrontendClient
+    void windowObjectCleared() override;
+    void frontendLoaded() override;
+
+    void moveWindowBy(float x, float y) override;
+
+    String localizedStringsURL() override;
+
+    void bringToFront() override;
+    void closeWindow() override;
+
+    void requestSetDockSide(DockSide) override;
+    void changeAttachedWindowHeight(unsigned) override;
+    void changeAttachedWindowWidth(unsigned) override;
+
+    void setToolbarHeight(unsigned) override;
+
+    void openInNewTab(const String& url) override;
+
+    bool canSave() override;
+    void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) override;
+    void append(const WTF::String& url, const WTF::String& content) override;
+
+    void inspectedURLChanged(const String&) override;
+
+    void sendMessageToBackend(const String&) override;
+
+    bool isUnderTest() override { return m_underTest; }
+
+private:
+    explicit WebInspectorUI(WebPage*);
+
+    void evaluateCommandOnLoad(const String& command, const String& argument = String());
+    void evaluateCommandOnLoad(const String& command, const ASCIILiteral& argument) { evaluateCommandOnLoad(command, String(argument)); }
+    void evaluateCommandOnLoad(const String& command, bool argument);
+    void evaluateExpressionOnLoad(const String& expression);
+    void evaluatePendingExpressions();
+
+    WebPage* m_page;
+
+    RefPtr<IPC::Connection> m_backendConnection;
+    uint64_t m_inspectedPageIdentifier;
+
+    bool m_underTest;
+    bool m_frontendLoaded;
+    Deque<String> m_queue;
+
+    RefPtr<WebCore::InspectorFrontendHost> m_frontendHost;
+
+    DockSide m_dockSide;
+
+#if PLATFORM(COCOA)
+    mutable String m_localizedStringsURL;
+    mutable bool m_hasLocalizedStringsURL;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // WebInspectorUI_h
diff --git a/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.messages.in b/Source/WebKit2/WebProcess/WebPage/WebInspectorUI.messages.in
new file mode 100644 (file)
index 0000000..23eb5fd
--- /dev/null
@@ -0,0 +1,46 @@
+# Copyright (C) 2014 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#if ENABLE(INSPECTOR)
+
+messages -> WebInspectorUI {
+    EstablishConnection(IPC::Attachment connectionIdentifier, uint64_t inspectedPageIdentifier, bool underTest)
+
+    AttachedBottom()
+    AttachedRight()
+    Detached()
+
+    ShowConsole()
+    ShowResources()
+
+    ShowMainResourceForFrame(String frameIdentifier)
+
+    StartPageProfiling()
+    StopPageProfiling()
+
+    DidSave(String url)
+    DidAppend(String url)
+
+    SendMessageToFrontend(String message)
+}
+
+#endif
index e62acfd..ccc63b5 100644 (file)
@@ -80,6 +80,8 @@
 #include "WebInspector.h"
 #include "WebInspectorClient.h"
 #include "WebInspectorMessages.h"
+#include "WebInspectorUI.h"
+#include "WebInspectorUIMessages.h"
 #include "WebNotificationClient.h"
 #include "WebOpenPanelResultListener.h"
 #include "WebPageCreationParameters.h"
@@ -460,6 +462,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #endif
 #if ENABLE(INSPECTOR)
     WebProcess::shared().addMessageReceiver(Messages::WebInspector::messageReceiverName(), m_pageID, *this);
+    WebProcess::shared().addMessageReceiver(Messages::WebInspectorUI::messageReceiverName(), m_pageID, *this);
 #endif
 #if ENABLE(FULLSCREEN_API)
     WebProcess::shared().addMessageReceiver(Messages::WebFullScreenManager::messageReceiverName(), m_pageID, *this);
@@ -520,6 +523,7 @@ WebPage::~WebPage()
 #endif
 #if ENABLE(INSPECTOR)
     WebProcess::shared().removeMessageReceiver(Messages::WebInspector::messageReceiverName(), m_pageID);
+    WebProcess::shared().removeMessageReceiver(Messages::WebInspectorUI::messageReceiverName(), m_pageID);
 #endif
 #if ENABLE(FULLSCREEN_API)
     WebProcess::shared().removeMessageReceiver(Messages::WebFullScreenManager::messageReceiverName(), m_pageID);
@@ -2886,18 +2890,26 @@ void WebPage::didFlushLayerTreeAtTime(std::chrono::milliseconds timestamp)
 }
 #endif
 
-    
 #if ENABLE(INSPECTOR)
 WebInspector* WebPage::inspector()
 {
     if (m_isClosed)
-        return 0;
+        return nullptr;
     if (!m_inspector)
-        m_inspector = WebInspector::create(this, m_inspectorClient);
+        m_inspector = WebInspector::create(this);
     return m_inspector.get();
 }
+
+WebInspectorUI* WebPage::inspectorUI()
+{
+    if (m_isClosed)
+        return nullptr;
+    if (!m_inspectorUI)
+        m_inspectorUI = WebInspectorUI::create(this);
+    return m_inspectorUI.get();
+}
 #endif
-    
+
 #if PLATFORM(IOS)
 WebVideoFullscreenManager* WebPage::videoFullscreenManager()
 {
@@ -3479,7 +3491,13 @@ void WebPage::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder
 #if ENABLE(INSPECTOR)
     if (decoder.messageReceiverName() == Messages::WebInspector::messageReceiverName()) {
         if (WebInspector* inspector = this->inspector())
-            inspector->didReceiveWebInspectorMessage(connection, decoder);
+            inspector->didReceiveMessage(connection, decoder);
+        return;
+    }
+
+    if (decoder.messageReceiverName() == Messages::WebInspectorUI::messageReceiverName()) {
+        if (WebInspectorUI* inspectorUI = this->inspectorUI())
+            inspectorUI->didReceiveMessage(connection, decoder);
         return;
     }
 #endif
index baba506..b7d448c 100644 (file)
@@ -153,6 +153,7 @@ class WebFullScreenManager;
 class WebImage;
 class WebInspector;
 class WebInspectorClient;
+class WebInspectorUI;
 class WebKeyboardEvent;
 class WebMouseEvent;
 class WebNotificationClient;
@@ -226,8 +227,10 @@ public:
 
 #if ENABLE(INSPECTOR)
     WebInspector* inspector();
+    WebInspectorUI* inspectorUI();
+    bool isInspectorPage() { return !!m_inspectorUI; }
 #endif
-    
+
 #if PLATFORM(IOS)
     WebVideoFullscreenManager* videoFullscreenManager();
 #endif
@@ -1159,6 +1162,7 @@ private:
 
 #if ENABLE(INSPECTOR)
     RefPtr<WebInspector> m_inspector;
+    RefPtr<WebInspectorUI> m_inspectorUI;
 #endif
 #if PLATFORM(IOS)
     RefPtr<WebVideoFullscreenManager> m_videoFullscreenManager;
diff --git a/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorUIEfl.cpp b/Source/WebKit2/WebProcess/WebPage/efl/WebInspectorUIEfl.cpp
new file mode 100644 (file)
index 0000000..1857c7b
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInspectorUI.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <WebCore/EflInspectorUtilities.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+bool WebInspectorUI::canSave()
+{
+    return false;
+}
+
+String WebInspectorUI::localizedStringsURL()
+{
+    return "file://" + WebCore::inspectorResourcePath() + "/localizedStrings.js";
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp b/Source/WebKit2/WebProcess/WebPage/gtk/WebInspectorUIGtk.cpp
new file mode 100644 (file)
index 0000000..4646785
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebInspectorUI.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <WebCore/FileSystem.h>
+#include <glib.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+bool WebInspectorUI::canSave()
+{
+    return false;
+}
+
+String WebInspectorUI::localizedStringsURL()
+{
+    return String("resource:///org/webkitgtk/inspector/Localizations/en.lproj/localizedStrings.js");
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorUIMac.mm b/Source/WebKit2/WebProcess/WebPage/mac/WebInspectorUIMac.mm
new file mode 100644 (file)
index 0000000..2be76a6
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebInspectorUI.h"
+
+#if ENABLE(INSPECTOR)
+
+#import <WebCore/SoftLinking.h>
+
+SOFT_LINK_STAGED_FRAMEWORK(WebInspectorUI, PrivateFrameworks, A)
+
+namespace WebKit {
+
+bool WebInspectorUI::canSave()
+{
+    return true;
+}
+
+String WebInspectorUI::localizedStringsURL()
+{
+    if (!m_hasLocalizedStringsURL) {
+        // Call the soft link framework function to dlopen it, then [NSBundle bundleWithIdentifier:] will work.
+        WebInspectorUILibrary();
+
+        NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"] pathForResource:@"localizedStrings" ofType:@"js"];
+        if ([path length])
+            m_localizedStringsURL = [[NSURL fileURLWithPath:path] absoluteString];
+        else
+            m_localizedStringsURL = String();
+        m_hasLocalizedStringsURL = true;
+    }
+
+    return m_localizedStringsURL;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
index 2cbfeab..52ebfb0 100644 (file)
@@ -205,7 +205,11 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
 void WebProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
 {
 #if !PLATFORM(IOS)
-    NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+    NSString *applicationName;
+    if (parameters.extraInitializationData.get(ASCIILiteral("inspector-process")) == "1")
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Inspector", "Visible name of Web Inspector's web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
+    else
+        applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ Web Content", "Visible name of the web process. The argument is the application name."), (NSString *)parameters.uiProcessName];
     WKSetVisibleApplicationName((CFStringRef)applicationName);
 #endif
 }