[GTK] Should use light theme unless website declares support for dark themes in color...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jan 2020 09:49:33 +0000 (09:49 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Jan 2020 09:49:33 +0000 (09:49 +0000)
commitd3894a21e45f3d88b2aa7ef85b46b7d034fed3a3
treeb5c7f153155c93806a65a2b0d0fa2aa91dfd3629
parentdde92880f885896ea660d0a2be9eec47819c4817
[GTK] Should use light theme unless website declares support for dark themes in color-schemes property
https://bugs.webkit.org/show_bug.cgi?id=197947

Reviewed by Michael Catanzaro.

.:

Do not define HAVE_OS_DARK_MODE_SUPPORT.

* Source/cmake/OptionsGTK.cmake:

Source/WebCore:

* dom/Document.cpp:
(WebCore::Document::useDarkAppearance const): Remove HAVE(OS_DARK_MODE_SUPPORT) because ENABLE(DARK_MODE_CSS)
guards should be enough.
* page/FrameView.cpp:
(WebCore::FrameView::updateBackgroundRecursively): Revert changes made in r244635.
* page/Page.cpp:
(WebCore::Page::effectiveAppearanceDidChange): Use ENABLE(DARK_MODE_CSS) instead of HAVE(OS_DARK_MODE_SUPPORT).
(WebCore::Page::useDarkAppearance const): Ditto.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::systemColor const): Revert changes made in r244635.
* rendering/RenderThemeGtk.h:
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::setUseDarkAppearanceInternal): Revert changes made in r244635.

Source/WebKit:

Handle the theme changes in the UI process, converting dark variant to the light one before sending the theme
name to the web process. The web process is still notified when a dark theme is in use, so that if website
prefers a dark color scheme it will be used, but the gtk theme that will be used for controls styling will
always be light.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const): Encode themeName.
(WebKit::WebPageCreationParameters::decode): Decode themeName.
* Shared/WebPageCreationParameters.h:
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::themeName const): Get the theme name that should be used by the web process.
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(themeChanged): Call WebPageProxy::themeDidChange().
(applicationPreferDarkThemeChanged):
(webkitWebViewBaseSetToplevelOnScreenWindow): Use a different callback for the theme name change.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::themeDidChange): Send ThemeDidChange message to the web process with the theme name to use.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage): Initialize the theme name.
(WebKit::WebPage::effectiveAppearanceDidChange): Use this now for GTK port too.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in: Add ThemeDidChange message.
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::themeDidChange): Set the theme given name in gtk settings.
* WebProcess/gtk/WebProcessMainGtk.cpp:

Source/WTF:

Do not define HAVE_OS_DARK_MODE_SUPPORT for the GTK port.

* wtf/PlatformHave.h:

LayoutTests:

Rebaseline several tests for the new behavior.

* platform/gtk/css-dark-mode/color-scheme-priority-expected.txt: Added.
* platform/gtk/css-dark-mode/default-colors-expected.txt:
* platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255342 268f45cc-cd09-0410-ab3c-d52691b4dbfc
30 files changed:
ChangeLog
LayoutTests/ChangeLog
LayoutTests/platform/gtk/css-dark-mode/color-scheme-priority-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt
LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt
Source/WTF/ChangeLog
Source/WTF/wtf/PlatformHave.h
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/Page.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeGtk.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPageCreationParameters.cpp
Source/WebKit/Shared/WebPageCreationParameters.h
Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in
Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp
Source/cmake/OptionsGTK.cmake