Web Inspector: inspector settings should not be shared between different inspection...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Nov 2015 02:49:51 +0000 (02:49 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Nov 2015 02:49:51 +0000 (02:49 +0000)
commit7b3e4580b05abcad8215ab4c12f3564e76ae3208
treed9430fcf1668571d5dbd8e09839372cb75f80a8f
parent3841bb2cc31b228744c7335d928c2ff60398b841
Web Inspector: inspector settings should not be shared between different inspection levels
https://bugs.webkit.org/show_bug.cgi?id=151151

Reviewed by Timothy Hatcher.

Source/WebCore:

InspectorController and InspectorFrontendClient should know how to compute their
inspection levels, so that this level can be exposed to the Inspector frontend for
preference disambiguation by inspection level.

 - A Page with normal web content has an inspection level of 0.
 - The first Web Inspector has an inspection level of 1.
 - The second Web Inspector that inspects the Inspector has an inspection level of 2.
 - And so forth...

For local frontend clients (WK1 and the ProtocolTestStub), the inspection level of
a Page computed as follows:

- If the page's inspector controller has no frontend client, then the Page
is normal web content (level 0).
- If the page's inspector controller has a frontend client, ask for its inspection level.
A frontend client looks at the inspection level reported by inspected page's inspector
controller and increments by one to account for the crossed inspection boundary.

No new tests, this is blocked by test infrastructure fixes (https://webkit.org/b/151573).

* inspector/InspectorController.cpp:
(WebCore::InspectorController::inspectionLevel): Added.
(WebCore::InspectorController::hasInspectorFrontendClient): Deleted.
* inspector/InspectorController.h:
* inspector/InspectorFrontendClient.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::canAttachWindow): Check inspectionLevel().
(WebCore::InspectorFrontendClientLocal::inspectionLevel): Added.
* inspector/InspectorFrontendClientLocal.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::inspectionLevel): Added.
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.idl:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate): Check inspectionLevel().

Source/WebInspectorUI:

It's really annoying to have shared settings between Inspector^1 and Inspector^2, because
they are not designed to respond to external changes to local storage keys. As a result,
the two inspectors seemingly have different settings while both are open, but the settings
clobber each other depending on which inspector is closed first. On the next inspector
being opened, it has settings that reflect whichever inspector closed last.

To fix this, alter the local storage key prefix to incude the inspection level when it is
greater than 1 (i.e., inspecting the inspector). The storage prefix becomes
"com.apple.WebInspector-${inspectionLevel}." in this case.
This is backwards-compatible for normal Inspector, who keeps the same storage prefix.

Alternate approaches that were considered and abandoned:

 - Use separate WKWebSiteDataStores for each inspection level. This API (as it currently is)
does not support multiple on-disk storage locations. We don't want to add an entirely new
Library directory for each inspector level, and sharing a single location doesn't fix the
shared-settings bug. Changing storage location would lose all existing Inspector settings.

 - Sync settings between multiple open Inspectors. This would be catastrophic, as changing
the active tab on one inspector would immediately propagate to the other open inspectors.

* UserInterface/Models/Setting.js:
(WebInspector.Setting):
* UserInterface/Protocol/InspectorFrontendHostStub.js:
(window.InspectorFrontendHost.WebInspector.InspectorFrontendHostStub.prototype.inspectionLevel):

Source/WebKit2:

In WebKit2, we already track the inspection level of WebPages in order to give inspectors
different page groups. Send the inspection level to WebInspectorUI WebProcess when
establishing a connection from the UIProcess. Use this number in the FrontendClient.

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::inspectionLevel): Renamed from inspectorLevel to be consistent.
(WebKit::WebInspectorProxy::inspectorPageGroupIdentifier):
(WebKit::WebInspectorProxy::didRelaunchInspectorPageProcess):
(WebKit::WebInspectorProxy::eagerlyCreateInspectorPage):
(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::inspectorLevel): Deleted.
* UIProcess/WebInspectorProxy.h:
* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::updateInspectorWindowTitle):
* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::establishConnection):
* WebProcess/WebPage/WebInspectorUI.h:
* WebProcess/WebPage/WebInspectorUI.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192756 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorFrontendClient.h
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/page/ContextMenuController.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/Setting.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendHostStub.js
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebInspectorProxy.cpp
Source/WebKit2/UIProcess/WebInspectorProxy.h
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.cpp
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.h
Source/WebKit2/WebProcess/WebPage/WebInspectorUI.messages.in