Web Inspector: Add support for forcing color scheme appearance in DOM tree.
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2018 21:16:07 +0000 (21:16 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2018 21:16:07 +0000 (21:16 +0000)
commitca45cd65c5da9518b22c468ad911362a7f73b30e
treedabd089f007c1bc75e55717f4ec80ca8e39a7bc2
parentc0ba79cc749983705609167ae9b56ed9dbc6c872
Web Inspector: Add support for forcing color scheme appearance in DOM tree.
https://bugs.webkit.org/show_bug.cgi?id=191820
rdar://problem/46153172

Reviewed by Devin Rousso.

Source/JavaScriptCore:

* inspector/protocol/Page.json: Added setForcedAppearance.
Also added the defaultAppearanceDidChange event and Appearance enum.

Source/WebCore:

Test: inspector/css/force-page-appearance.html

* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::defaultAppearanceDidChangeImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::defaultAppearanceDidChange):
* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::enable): Fire defaultAppearanceDidChange() on macOS Majave.
(WebCore::InspectorPageAgent::disable): Call setForcedAppearance() with empty string.
(WebCore::InspectorPageAgent::defaultAppearanceDidChange): Added.
(WebCore::InspectorPageAgent::setForcedAppearance): Added.
* inspector/agents/InspectorPageAgent.h:
* page/Page.cpp:
(WebCore::Page::setUseDarkAppearance): Call InspectorInstrumentation::defaultAppearanceDidChange().
(WebCore::Page::useDarkAppearance const): Return override value if not nullopt.
(WebCore::Page::setUseDarkAppearanceOverride): Added.
* page/Page.h:
(WebCore::Page::defaultUseDarkAppearance const): Added.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js: Updated.
* UserInterface/Controllers/CSSManager.js:
(WI.CSSManager):
(WI.CSSManager.prototype.get defaultAppearance): Added.
(WI.CSSManager.prototype.get forcedAppearance): Added.
(WI.CSSManager.prototype.set forcedAppearance): Added.
(WI.CSSManager.prototype.canForceAppearance): Added.
(WI.CSSManager.prototype.defaultAppearanceDidChange): Added.
* UserInterface/Images/Appearance.svg: Added.
* UserInterface/Protocol/PageObserver.js:
(WI.PageObserver.prototype.defaultAppearanceChanged): Added.
* UserInterface/Views/DOMTreeContentView.js:
(WI.DOMTreeContentView):
(WI.DOMTreeContentView.prototype.get navigationItems):
(WI.DOMTreeContentView.prototype._defaultAppearanceDidChange): Added.
(WI.DOMTreeContentView.prototype._toggleAppearance): Added.

LayoutTests:

* TestExpectations: Skip dark mode tests on other platforms.
* inspector/css/force-page-appearance-expected.txt: Added.
* inspector/css/force-page-appearance.html: Added.
* platform/mac/TestExpectations: Expect dark mode tests to pass on Mojave and later.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238570 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/inspector/css/force-page-appearance-expected.txt [new file with mode: 0644]
LayoutTests/inspector/css/force-page-appearance.html [new file with mode: 0644]
LayoutTests/platform/mac/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Page.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Controllers/CSSManager.js
Source/WebInspectorUI/UserInterface/Images/Appearance.svg [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Protocol/PageObserver.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeContentView.js