WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
wk2-dark-mode.diff (text/plain), 26.24 KB, created by
Carlos Garcia Campos
on 2020-01-28 08:41:32 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2020-01-28 08:41:32 PST
Size:
26.24 KB
patch
obsolete
>diff --git a/ChangeLog b/ChangeLog >index 165748f50fa..227b9822dcb 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,14 @@ >+2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ Do not define HAVE_OS_DARK_MODE_SUPPORT. >+ >+ * Source/cmake/OptionsGTK.cmake: >+ > 2020-01-22 Don Olmstead <don.olmstead@sony.com> > > [OpenSSL] Add stubs and build for Web Crypto >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index f6a5c97ed35..76bc5c98527 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ 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: >+ > 2020-01-27 Noam Rosenthal <noam@webkit.org> > > -webkit-image-set should support resolution units other than 'x' >diff --git a/LayoutTests/platform/gtk/css-dark-mode/color-scheme-priority-expected.txt b/LayoutTests/platform/gtk/css-dark-mode/color-scheme-priority-expected.txt >new file mode 100644 >index 00000000000..487b9f225c1 >--- /dev/null >+++ b/LayoutTests/platform/gtk/css-dark-mode/color-scheme-priority-expected.txt >@@ -0,0 +1,5 @@ >+ >+PASS Element colors are correct in light color scheme with light and dark color scheme >+PASS Dark color scheme enabled >+FAIL Element colors are correct in dark color scheme with light and dark color scheme assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)" >+ >diff --git a/LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt b/LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt >index 44f8b4f3d58..63aa4191983 100644 >--- a/LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt >+++ b/LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt >@@ -2,9 +2,9 @@ > PASS Body text color is black, since the page isn't in dark mode > PASS View base background color is white, since the page isn't in dark mode > PASS Set dark appearance >-FAIL Body text color is black, since the page hasn't set a supported color scheme assert_equals: expected "rgb(0, 0, 0)" but got "rgb(255, 255, 255)" >+PASS Body text color is black, since the page hasn't set a supported color scheme > PASS View base background color is white, since the page hasn't set a supported color scheme > PASS Set prefers-color-schemes: light dark on the body >-PASS Body text color is white >-FAIL View base background color is a dark grey assert_equals: expected "rgb(30, 30, 30)" but got "rgb(51, 57, 59)" >+FAIL Body text color is white assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)" >+FAIL View base background color is a dark grey assert_equals: expected "rgb(30, 30, 30)" but got "rgb(255, 255, 255)" > >diff --git a/LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt b/LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt >index a282533277d..02d00beea95 100644 >--- a/LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt >+++ b/LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt >@@ -2,6 +2,6 @@ > PASS Element colors are correct in light color scheme > PASS Element colors are correct in light color scheme with boolean context query > PASS Dark color scheme enabled >-FAIL Element colors are correct in dark color scheme assert_equals: expected "rgb(0, 0, 0)" but got "rgb(255, 255, 255)" >-FAIL Element colors are correct in dark color scheme with boolean context query assert_equals: expected "rgb(0, 0, 0)" but got "rgb(255, 255, 255)" >+PASS Element colors are correct in dark color scheme >+PASS Element colors are correct in dark color scheme with boolean context query > >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 97fa4e21f98..021d690de83 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,14 @@ >+2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ Do not define HAVE_OS_DARK_MODE_SUPPORT for the GTK port. >+ >+ * wtf/PlatformHave.h: >+ > 2020-01-27 Jonathan Bedard <jbedard@apple.com> > > WebCore: Remove iOS 11 macros from RenderThemeIOS.mm >diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h >index 4344a4d6768..0bd9c862376 100644 >--- a/Source/WTF/wtf/PlatformHave.h >+++ b/Source/WTF/wtf/PlatformHave.h >@@ -373,7 +373,7 @@ > #define HAVE_NSHTTPCOOKIESTORAGE__INITWITHIDENTIFIER_WITH_INACCURATE_NULLABILITY 1 > #endif > >-#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK) >+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS) || PLATFORM(MACCATALYST) > #define HAVE_OS_DARK_MODE_SUPPORT 1 > #endif > >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 84f0132f5e1..16980f2c3b3 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,24 @@ >+2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ * dom/Document.cpp: >+ (WebCore::Document::useDarkAppearance const): Remove HAVE(OS_DARK_MODE_SUPPORT) because ENABLE(DARK_MODE_CSS) >+ guads 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. >+ > 2020-01-27 Noam Rosenthal <noam@webkit.org> > > -webkit-image-set should support resolution units other than 'x' >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index b4da24ec8ea..a78bcf7a4aa 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -7084,7 +7084,6 @@ bool Document::useSystemAppearance() const > > bool Document::useDarkAppearance(const RenderStyle* style) const > { >-#if HAVE(OS_DARK_MODE_SUPPORT) > #if ENABLE(DARK_MODE_CSS) > OptionSet<ColorScheme> colorScheme; > >@@ -7113,9 +7112,6 @@ bool Document::useDarkAppearance(const RenderStyle* style) const > if (colorScheme.contains(ColorScheme::Dark)) > return pageUsesDarkAppearance; > #endif >-#else >- UNUSED_PARAM(style); >-#endif > > return false; > } >diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp >index 7cca9f72db3..a3ab5927736 100644 >--- a/Source/WebCore/page/FrameView.cpp >+++ b/Source/WebCore/page/FrameView.cpp >@@ -3031,12 +3031,7 @@ void FrameView::setBaseBackgroundColor(const Color& backgroundColor) > void FrameView::updateBackgroundRecursively(const Optional<Color>& backgroundColor) > { > #if HAVE(OS_DARK_MODE_SUPPORT) >-#if PLATFORM(COCOA) >- static const auto cssValueControlBackground = CSSValueAppleSystemControlBackground; >-#else >- static const auto cssValueControlBackground = CSSValueWindow; >-#endif >- Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(cssValueControlBackground, styleColorOptions())); >+ Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions())); > #else > Color baseBackgroundColor = backgroundColor.valueOr(Color::white); > #endif >diff --git a/Source/WebCore/page/Page.cpp b/Source/WebCore/page/Page.cpp >index 23accc06dfe..0e3f721913a 100644 >--- a/Source/WebCore/page/Page.cpp >+++ b/Source/WebCore/page/Page.cpp >@@ -2727,7 +2727,7 @@ void Page::setUseSystemAppearance(bool value) > > void Page::effectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel) > { >-#if HAVE(OS_DARK_MODE_SUPPORT) >+#if ENABLE(DARK_MODE_CSS) > if (m_useDarkAppearance == useDarkAppearance && m_useElevatedUserInterfaceLevel == useElevatedUserInterfaceLevel) > return; > >@@ -2751,7 +2751,7 @@ void Page::effectiveAppearanceDidChange(bool useDarkAppearance, bool useElevated > > bool Page::useDarkAppearance() const > { >-#if HAVE(OS_DARK_MODE_SUPPORT) >+#if ENABLE(DARK_MODE_CSS) > FrameView* view = mainFrame().view(); > if (!view || !equalLettersIgnoringASCIICase(view->mediaType(), "screen")) > return false; >diff --git a/Source/WebCore/rendering/RenderThemeGtk.cpp b/Source/WebCore/rendering/RenderThemeGtk.cpp >index 07e7a3237a6..1aba35bcd8d 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.cpp >+++ b/Source/WebCore/rendering/RenderThemeGtk.cpp >@@ -124,22 +124,6 @@ int RenderThemeGtk::sliderTickOffsetFromTrackCenter() const > } > #endif > >-static void themeChangedCallback() >-{ >- Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment(); >-} >- >-RenderThemeGtk::RenderThemeGtk() >-{ >- static bool themeMonitorInitialized = false; >- if (!themeMonitorInitialized) { >- GtkSettings* settings = gtk_settings_get_default(); >- g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(themeChangedCallback), nullptr); >- g_signal_connect(settings, "notify::gtk-color-scheme", G_CALLBACK(themeChangedCallback), nullptr); >- themeMonitorInitialized = true; >- } >-} >- > enum RenderThemePart { > Entry, > EntrySelection, >@@ -951,17 +935,6 @@ Color RenderThemeGtk::systemColor(CSSValueID cssValueId, OptionSet<StyleColor::O > return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorForeground); > case CSSValueGraytext: > return styleColor(Entry, GTK_STATE_FLAG_INSENSITIVE, StyleColorForeground); >- case CSSValueWebkitControlBackground: >- return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorBackground); >- case CSSValueWindow: { >- // Only get window color from the theme in dark mode. >- gboolean preferDarkTheme = FALSE; >- if (auto* settings = gtk_settings_get_default()) >- g_object_get(settings, "gtk-application-prefer-dark-theme", &preferDarkTheme, nullptr); >- if (preferDarkTheme) >- return styleColor(Window, GTK_STATE_FLAG_ACTIVE, StyleColorBackground); >- break; >- } > default: > break; > } >diff --git a/Source/WebCore/rendering/RenderThemeGtk.h b/Source/WebCore/rendering/RenderThemeGtk.h >index 9f5bf246fe2..87c3aad58ba 100644 >--- a/Source/WebCore/rendering/RenderThemeGtk.h >+++ b/Source/WebCore/rendering/RenderThemeGtk.h >@@ -104,7 +104,6 @@ public: > bool shouldHaveCapsLockIndicator(const HTMLInputElement&) const override; > > private: >- RenderThemeGtk(); > virtual ~RenderThemeGtk(); > > bool paintCheckbox(const RenderObject&, const PaintInfo&, const IntRect&) override; >diff --git a/Source/WebCore/testing/InternalSettings.cpp b/Source/WebCore/testing/InternalSettings.cpp >index bb08f5c65b5..51e464dc092 100644 >--- a/Source/WebCore/testing/InternalSettings.cpp >+++ b/Source/WebCore/testing/InternalSettings.cpp >@@ -51,10 +51,6 @@ > #include "SoupNetworkSession.h" > #endif > >-#if PLATFORM(GTK) >-#include <gtk/gtk.h> >-#endif >- > namespace WebCore { > > InternalSettings::Backup::Backup(Settings& settings) >@@ -545,16 +541,6 @@ ExceptionOr<bool> InternalSettings::shouldDisplayTrackKind(const String& kind) > > void InternalSettings::setUseDarkAppearanceInternal(bool useDarkAppearance) > { >-#if PLATFORM(GTK) >- // GTK doesn't allow to change the theme from the web process, but tests need to do it, so >- // we do it here only for tests. >- if (auto* settings = gtk_settings_get_default()) { >- gboolean preferDarkTheme; >- g_object_get(settings, "gtk-application-prefer-dark-theme", &preferDarkTheme, nullptr); >- if (preferDarkTheme != useDarkAppearance) >- g_object_set(settings, "gtk-application-prefer-dark-theme", useDarkAppearance, nullptr); >- } >-#endif > ASSERT(m_page); > m_page->effectiveAppearanceDidChange(useDarkAppearance, m_page->useElevatedUserInterfaceLevel()); > } >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index fa7d96b4b6c..0779fa3cf25 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,40 @@ >+2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [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 NOBODY (OOPS!). >+ >+ 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: >+ > 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> > > [GTK][WPE] QR code not loaded in web.whatsapp.com >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.cpp b/Source/WebKit/Shared/WebPageCreationParameters.cpp >index 6bfa99f213f..9085995d6fb 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebPageCreationParameters.cpp >@@ -142,6 +142,10 @@ void WebPageCreationParameters::encode(IPC::Encoder& encoder) const > encoder << shouldCaptureVideoInUIProcess; > encoder << shouldCaptureVideoInGPUProcess; > encoder << shouldCaptureDisplayInUIProcess; >+ >+#if PLATFORM(GTK) >+ encoder << themeName; >+#endif > } > > Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decoder& decoder) >@@ -438,6 +442,11 @@ Optional<WebPageCreationParameters> WebPageCreationParameters::decode(IPC::Decod > if (!decoder.decode(parameters.shouldCaptureDisplayInUIProcess)) > return WTF::nullopt; > >+#if PLATFORM(GTK) >+ if (!decoder.decode(parameters.themeName)) >+ return WTF::nullopt; >+#endif >+ > return parameters; > } > >diff --git a/Source/WebKit/Shared/WebPageCreationParameters.h b/Source/WebKit/Shared/WebPageCreationParameters.h >index a85551471aa..aa05714e7a3 100644 >--- a/Source/WebKit/Shared/WebPageCreationParameters.h >+++ b/Source/WebKit/Shared/WebPageCreationParameters.h >@@ -213,6 +213,10 @@ struct WebPageCreationParameters { > bool shouldCaptureVideoInUIProcess { false }; > bool shouldCaptureVideoInGPUProcess { false }; > bool shouldCaptureDisplayInUIProcess { false }; >+ >+#if PLATFORM(GTK) >+ String themeName; >+#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >index b1252daf742..8a6bda95a61 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp >@@ -583,4 +583,21 @@ void PageClientImpl::didChangeWebPageID() const > webkitWebViewDidChangePageID(WEBKIT_WEB_VIEW(m_viewWidget)); > } > >+String PageClientImpl::themeName() const >+{ >+ if (auto* themeNameEnv = g_getenv("GTK_THEME")) { >+ String name = String::fromUTF8(themeNameEnv); >+ if (name.endsWith("-dark") || name.endsWith(":dark")) >+ return name.substring(0, name.length() - 5); >+ return name; >+ } >+ >+ GUniqueOutPtr<char> themeNameSetting; >+ g_object_get(gtk_widget_get_settings(m_viewWidget), "gtk-theme-name", &themeNameSetting.outPtr(), nullptr); >+ String name = String::fromUTF8(themeNameSetting.get()); >+ if (name.endsWith("-dark")) >+ return name.substring(0, name.length() - 5); >+ return name; >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >index d7c904a512a..5d030e68f22 100644 >--- a/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >+++ b/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h >@@ -174,6 +174,8 @@ private: > > void didChangeWebPageID() const override; > >+ String themeName() const override; >+ > // Members of PageClientImpl class > GtkWidget* m_viewWidget; > DefaultUndoController m_undoController; >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >index 0d58bb3669d..dc3ef85c5ad 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp >@@ -294,6 +294,11 @@ static gboolean toplevelWindowStateEvent(GtkWidget*, GdkEventWindowState* event, > } > > static void themeChanged(WebKitWebViewBase* webViewBase) >+{ >+ webViewBase->priv->pageProxy->themeDidChange(); >+} >+ >+static void applicationPreferDarkThemeChanged(WebKitWebViewBase* webViewBase) > { > webViewBase->priv->pageProxy->effectiveAppearanceDidChange(); > } >@@ -374,7 +379,7 @@ static void webkitWebViewBaseSetToplevelOnScreenWindow(WebKitWebViewBase* webVie > priv->themeChangedID = > g_signal_connect_swapped(settings, "notify::gtk-theme-name", G_CALLBACK(themeChanged), webViewBase); > priv->applicationPreferDarkThemeID = >- g_signal_connect_swapped(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK(themeChanged), webViewBase); >+ g_signal_connect_swapped(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK(applicationPreferDarkThemeChanged), webViewBase); > > if (gtk_widget_get_realized(GTK_WIDGET(window))) > gtk_widget_realize(GTK_WIDGET(webViewBase)); >diff --git a/Source/WebKit/UIProcess/PageClient.h b/Source/WebKit/UIProcess/PageClient.h >index 9cb780f407f..dc11a22527c 100644 >--- a/Source/WebKit/UIProcess/PageClient.h >+++ b/Source/WebKit/UIProcess/PageClient.h >@@ -518,6 +518,10 @@ public: > #endif > > virtual void didChangeWebPageID() const { } >+ >+#if PLATFORM(GTK) >+ virtual String themeName() const = 0; >+#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index 07762ac07ff..89642a414eb 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -7618,6 +7618,10 @@ WebPageCreationParameters WebPageProxy::creationParameters(WebProcessProxy& proc > parameters.shouldCaptureVideoInGPUProcess = m_process->processPool().configuration().shouldCaptureVideoInGPUProcess(); > parameters.shouldCaptureDisplayInUIProcess = m_process->processPool().configuration().shouldCaptureDisplayInUIProcess(); > >+#if PLATFORM(GTK) >+ parameters.themeName = pageClient().themeName(); >+#endif >+ > return parameters; > } > >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 5d4a71d3307..1358cc8207c 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -869,6 +869,7 @@ public: > #if PLATFORM(GTK) > PlatformViewWidget viewWidget(); > bool makeGLContextCurrent(); >+ void themeDidChange(); > #endif > > const Optional<WebCore::Color>& backgroundColor() const { return m_backgroundColor; } >diff --git a/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp b/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp >index 8ee86fa1bea..e98b0523617 100644 >--- a/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp >+++ b/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp >@@ -184,4 +184,13 @@ void WebPageProxy::sendMessageToWebView(UserMessage&& message) > sendMessageToWebViewWithReply(WTFMove(message), [](UserMessage&&) { }); > } > >+void WebPageProxy::themeDidChange() >+{ >+ if (!hasRunningProcess()) >+ return; >+ >+ send(Messages::WebPage::ThemeDidChange(pageClient().themeName())); >+ effectiveAppearanceDidChange(); >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index bd341068fb7..e65361a4e0a 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -593,6 +593,10 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters) > setGapBetweenPages(parameters.gapBetweenPages); > setPaginationLineGridEnabled(parameters.paginationLineGridEnabled); > >+#if PLATFORM(GTK) >+ themeDidChange(WTFMove(parameters.themeName)); >+#endif >+ > effectiveAppearanceDidChange(parameters.useDarkAppearance, parameters.useElevatedUserInterfaceLevel); > > if (parameters.isEditable) >@@ -4709,12 +4713,10 @@ void WebPage::setUseSystemAppearance(bool useSystemAppearance) > > #endif > >-#if !PLATFORM(GTK) > void WebPage::effectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel) > { > corePage()->effectiveAppearanceDidChange(useDarkAppearance, useElevatedUserInterfaceLevel); > } >-#endif > > void WebPage::freezeLayerTreeDueToSwipeAnimation() > { >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index d540081f1d3..a275376f912 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -796,6 +796,8 @@ public: > void showEmojiPicker(WebCore::Frame&); > > void getCenterForZoomGesture(const WebCore::IntPoint& centerInViewCoordinates, CompletionHandler<void(WebCore::IntPoint&&)>&&); >+ >+ void themeDidChange(String&&); > #endif > > void didApplyStyle(); >@@ -2044,6 +2046,10 @@ private: > #endif > > String m_overriddenMediaType; >+ >+#if PLATFORM(GTK) >+ String m_themeName; >+#endif > }; > > #if !PLATFORM(IOS_FAMILY) >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >index d61df803b23..e9ad60f6113 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.messages.in >@@ -506,6 +506,10 @@ GenerateSyntheticEditingCommand(enum:uint8_t WebKit::SyntheticEditingCommandType > > EffectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel); > >+#if PLATFORM(GTK) >+ ThemeDidChange(String themeName) >+#endif >+ > #if PLATFORM(COCOA) > RequestActiveNowPlayingSessionInfo(WebKit::CallbackID callbackID) > #endif >diff --git a/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp b/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp >index 89dc11b893f..8e86ed3b12a 100644 >--- a/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp >+++ b/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp >@@ -157,11 +157,14 @@ void WebPage::showEmojiPicker(Frame& frame) > sendWithAsyncReply(Messages::WebPageProxy::ShowEmojiPicker(frame.view()->contentsToRootView(frame.selection().absoluteCaretBounds())), WTFMove(completionHandler)); > } > >-void WebPage::effectiveAppearanceDidChange(bool useDarkAppearance, bool useInactiveAppearance) >+void WebPage::themeDidChange(String&& themeName) > { >- if (auto* settings = gtk_settings_get_default()) >- g_object_set(settings, "gtk-application-prefer-dark-theme", useDarkAppearance, nullptr); >- corePage()->effectiveAppearanceDidChange(useDarkAppearance, useInactiveAppearance); >+ if (m_themeName == themeName) >+ return; >+ >+ m_themeName = WTFMove(themeName); >+ g_object_set(gtk_settings_get_default(), "gtk-theme-name", m_themeName.utf8().data(), nullptr); >+ Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment(); > } > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >index 45f4d296101..af66799953d 100644 >--- a/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >+++ b/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp >@@ -53,6 +53,10 @@ public: > #if (USE(COORDINATED_GRAPHICS) || USE(GSTREAMER_GL)) && PLATFORM(X11) > XInitThreads(); > #endif >+ >+ // Ignore the GTK_THEME environment variable, the theme is always set by the UI process now. >+ g_unsetenv("GTK_THEME"); >+ > gtk_init(nullptr, nullptr); > > bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); >diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake >index 904e379acd8..f1ffcae3d02 100644 >--- a/Source/cmake/OptionsGTK.cmake >+++ b/Source/cmake/OptionsGTK.cmake >@@ -211,7 +211,6 @@ set(GDK_LIBRARIES ${GDK3_LIBRARIES}) > set(GDK_INCLUDE_DIRS ${GDK3_INCLUDE_DIRS}) > > SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTKUnixPrint_FOUND}) >-SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1) > > if (USE_WPE_RENDERER) > find_package(WPE 1.3.0)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mcatanzaro
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 197947
: 389004