Changeset 255342 in webkit
- Timestamp:
- Jan 29, 2020, 1:49:33 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r255273 r255342 1 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Should use light theme unless website declares support for dark themes in color-schemes property 4 https://bugs.webkit.org/show_bug.cgi?id=197947 5 6 Reviewed by Michael Catanzaro. 7 8 Do not define HAVE_OS_DARK_MODE_SUPPORT. 9 10 * Source/cmake/OptionsGTK.cmake: 11 1 12 2020-01-28 Don Olmstead <don.olmstead@sony.com> 2 13 -
trunk/LayoutTests/ChangeLog
r255341 r255342 1 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Should use light theme unless website declares support for dark themes in color-schemes property 4 https://bugs.webkit.org/show_bug.cgi?id=197947 5 6 Reviewed by Michael Catanzaro. 7 8 Rebaseline several tests for the new behavior. 9 10 * platform/gtk/css-dark-mode/color-scheme-priority-expected.txt: Added. 11 * platform/gtk/css-dark-mode/default-colors-expected.txt: 12 * platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt: 13 1 14 2020-01-29 Megan Gardner <megan_gardner@apple.com> 2 15 -
trunk/LayoutTests/platform/gtk/css-dark-mode/default-colors-expected.txt
r246676 r255342 3 3 PASS View base background color is white, since the page isn't in dark mode 4 4 PASS Set dark appearance 5 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)" 5 PASS Body text color is black, since the page hasn't set a supported color scheme 6 6 PASS View base background color is white, since the page hasn't set a supported color scheme 7 7 PASS Set prefers-color-schemes: light dark on the body 8 PASS Body text color is white 9 FAIL View base background color is a dark grey assert_equals: expected "rgb(30, 30, 30)" but got "rgb( 51, 57, 59)"8 FAIL Body text color is white assert_equals: expected "rgb(255, 255, 255)" but got "rgb(0, 0, 0)" 9 FAIL View base background color is a dark grey assert_equals: expected "rgb(30, 30, 30)" but got "rgb(255, 255, 255)" 10 10 -
trunk/LayoutTests/platform/gtk/css-dark-mode/prefers-color-scheme-expected.txt
r244766 r255342 3 3 PASS Element colors are correct in light color scheme with boolean context query 4 4 PASS Dark color scheme enabled 5 FAIL Element colors are correct in dark color scheme assert_equals: expected "rgb(0, 0, 0)" but got "rgb(255, 255, 255)" 6 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)" 5 PASS Element colors are correct in dark color scheme 6 PASS Element colors are correct in dark color scheme with boolean context query 7 7 -
trunk/Source/WTF/ChangeLog
r255255 r255342 1 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Should use light theme unless website declares support for dark themes in color-schemes property 4 https://bugs.webkit.org/show_bug.cgi?id=197947 5 6 Reviewed by Michael Catanzaro. 7 8 Do not define HAVE_OS_DARK_MODE_SUPPORT for the GTK port. 9 10 * wtf/PlatformHave.h: 11 1 12 2020-01-28 Jonathan Bedard <jbedard@apple.com> 2 13 -
trunk/Source/WTF/wtf/PlatformHave.h
r255255 r255342 374 374 #endif 375 375 376 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK)376 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || PLATFORM(IOS) || PLATFORM(MACCATALYST) 377 377 #define HAVE_OS_DARK_MODE_SUPPORT 1 378 378 #endif -
trunk/Source/WebCore/ChangeLog
r255340 r255342 1 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Should use light theme unless website declares support for dark themes in color-schemes property 4 https://bugs.webkit.org/show_bug.cgi?id=197947 5 6 Reviewed by Michael Catanzaro. 7 8 * dom/Document.cpp: 9 (WebCore::Document::useDarkAppearance const): Remove HAVE(OS_DARK_MODE_SUPPORT) because ENABLE(DARK_MODE_CSS) 10 guards should be enough. 11 * page/FrameView.cpp: 12 (WebCore::FrameView::updateBackgroundRecursively): Revert changes made in r244635. 13 * page/Page.cpp: 14 (WebCore::Page::effectiveAppearanceDidChange): Use ENABLE(DARK_MODE_CSS) instead of HAVE(OS_DARK_MODE_SUPPORT). 15 (WebCore::Page::useDarkAppearance const): Ditto. 16 * rendering/RenderThemeGtk.cpp: 17 (WebCore::RenderThemeGtk::systemColor const): Revert changes made in r244635. 18 * rendering/RenderThemeGtk.h: 19 * testing/InternalSettings.cpp: 20 (WebCore::InternalSettings::setUseDarkAppearanceInternal): Revert changes made in r244635. 21 1 22 2020-01-29 Sunny He <sunny_he@apple.com> 2 23 -
trunk/Source/WebCore/dom/Document.cpp
r255260 r255342 7094 7094 bool Document::useDarkAppearance(const RenderStyle* style) const 7095 7095 { 7096 #if HAVE(OS_DARK_MODE_SUPPORT)7097 7096 #if ENABLE(DARK_MODE_CSS) 7098 7097 OptionSet<ColorScheme> colorScheme; … … 7122 7121 if (colorScheme.contains(ColorScheme::Dark)) 7123 7122 return pageUsesDarkAppearance; 7124 #endif7125 #else7126 UNUSED_PARAM(style);7127 7123 #endif 7128 7124 -
trunk/Source/WebCore/page/FrameView.cpp
r255226 r255342 3032 3032 { 3033 3033 #if HAVE(OS_DARK_MODE_SUPPORT) 3034 #if PLATFORM(COCOA) 3035 static const auto cssValueControlBackground = CSSValueAppleSystemControlBackground; 3036 #else 3037 static const auto cssValueControlBackground = CSSValueWindow; 3038 #endif 3039 Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(cssValueControlBackground, styleColorOptions())); 3034 Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions())); 3040 3035 #else 3041 3036 Color baseBackgroundColor = backgroundColor.valueOr(Color::white); -
trunk/Source/WebCore/page/Page.cpp
r255338 r255342 2734 2734 void Page::effectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel) 2735 2735 { 2736 #if HAVE(OS_DARK_MODE_SUPPORT)2736 #if ENABLE(DARK_MODE_CSS) 2737 2737 if (m_useDarkAppearance == useDarkAppearance && m_useElevatedUserInterfaceLevel == useElevatedUserInterfaceLevel) 2738 2738 return; … … 2758 2758 bool Page::useDarkAppearance() const 2759 2759 { 2760 #if HAVE(OS_DARK_MODE_SUPPORT)2760 #if ENABLE(DARK_MODE_CSS) 2761 2761 FrameView* view = mainFrame().view(); 2762 2762 if (!view || !equalLettersIgnoringASCIICase(view->mediaType(), "screen")) -
trunk/Source/WebCore/rendering/RenderThemeGtk.cpp
r252308 r255342 125 125 #endif 126 126 127 static void themeChangedCallback()128 {129 Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();130 }131 132 RenderThemeGtk::RenderThemeGtk()133 {134 static bool themeMonitorInitialized = false;135 if (!themeMonitorInitialized) {136 GtkSettings* settings = gtk_settings_get_default();137 g_signal_connect(settings, "notify::gtk-theme-name", G_CALLBACK(themeChangedCallback), nullptr);138 g_signal_connect(settings, "notify::gtk-color-scheme", G_CALLBACK(themeChangedCallback), nullptr);139 themeMonitorInitialized = true;140 }141 }142 143 127 enum RenderThemePart { 144 128 Entry, … … 952 936 case CSSValueGraytext: 953 937 return styleColor(Entry, GTK_STATE_FLAG_INSENSITIVE, StyleColorForeground); 954 case CSSValueWebkitControlBackground:955 return styleColor(Entry, GTK_STATE_FLAG_ACTIVE, StyleColorBackground);956 case CSSValueWindow: {957 // Only get window color from the theme in dark mode.958 gboolean preferDarkTheme = FALSE;959 if (auto* settings = gtk_settings_get_default())960 g_object_get(settings, "gtk-application-prefer-dark-theme", &preferDarkTheme, nullptr);961 if (preferDarkTheme)962 return styleColor(Window, GTK_STATE_FLAG_ACTIVE, StyleColorBackground);963 break;964 }965 938 default: 966 939 break; -
trunk/Source/WebCore/rendering/RenderThemeGtk.h
r252308 r255342 105 105 106 106 private: 107 RenderThemeGtk();108 107 virtual ~RenderThemeGtk(); 109 108 -
trunk/Source/WebCore/testing/InternalSettings.cpp
r255241 r255342 52 52 #endif 53 53 54 #if PLATFORM(GTK)55 #include <gtk/gtk.h>56 #endif57 58 54 namespace WebCore { 59 55 … … 544 540 void InternalSettings::setUseDarkAppearanceInternal(bool useDarkAppearance) 545 541 { 546 #if PLATFORM(GTK)547 // GTK doesn't allow to change the theme from the web process, but tests need to do it, so548 // we do it here only for tests.549 if (auto* settings = gtk_settings_get_default()) {550 gboolean preferDarkTheme;551 g_object_get(settings, "gtk-application-prefer-dark-theme", &preferDarkTheme, nullptr);552 if (preferDarkTheme != useDarkAppearance)553 g_object_set(settings, "gtk-application-prefer-dark-theme", useDarkAppearance, nullptr);554 }555 #endif556 542 ASSERT(m_page); 557 543 m_page->effectiveAppearanceDidChange(useDarkAppearance, m_page->useElevatedUserInterfaceLevel()); -
trunk/Source/WebKit/ChangeLog
r255339 r255342 1 2020-01-28 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Should use light theme unless website declares support for dark themes in color-schemes property 4 https://bugs.webkit.org/show_bug.cgi?id=197947 5 6 Reviewed by Michael Catanzaro. 7 8 Handle the theme changes in the UI process, converting dark variant to the light one before sending the theme 9 name to the web process. The web process is still notified when a dark theme is in use, so that if website 10 prefers a dark color scheme it will be used, but the gtk theme that will be used for controls styling will 11 always be light. 12 13 * Shared/WebPageCreationParameters.cpp: 14 (WebKit::WebPageCreationParameters::encode const): Encode themeName. 15 (WebKit::WebPageCreationParameters::decode): Decode themeName. 16 * Shared/WebPageCreationParameters.h: 17 * UIProcess/API/gtk/PageClientImpl.cpp: 18 (WebKit::PageClientImpl::themeName const): Get the theme name that should be used by the web process. 19 * UIProcess/API/gtk/PageClientImpl.h: 20 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 21 (themeChanged): Call WebPageProxy::themeDidChange(). 22 (applicationPreferDarkThemeChanged): 23 (webkitWebViewBaseSetToplevelOnScreenWindow): Use a different callback for the theme name change. 24 * UIProcess/PageClient.h: 25 * UIProcess/WebPageProxy.cpp: 26 * UIProcess/WebPageProxy.h: 27 * UIProcess/gtk/WebPageProxyGtk.cpp: 28 (WebKit::WebPageProxy::themeDidChange): Send ThemeDidChange message to the web process with the theme name to use. 29 * WebProcess/WebPage/WebPage.cpp: 30 (WebKit::WebPage::WebPage): Initialize the theme name. 31 (WebKit::WebPage::effectiveAppearanceDidChange): Use this now for GTK port too. 32 * WebProcess/WebPage/WebPage.h: 33 * WebProcess/WebPage/WebPage.messages.in: Add ThemeDidChange message. 34 * WebProcess/WebPage/gtk/WebPageGtk.cpp: 35 (WebKit::WebPage::themeDidChange): Set the theme given name in gtk settings. 36 * WebProcess/gtk/WebProcessMainGtk.cpp: 37 1 38 2020-01-28 Timothy Horton <timothy_horton@apple.com> 2 39 -
trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp
r255127 r255342 143 143 encoder << shouldCaptureVideoInGPUProcess; 144 144 encoder << shouldCaptureDisplayInUIProcess; 145 146 #if PLATFORM(GTK) 147 encoder << themeName; 148 #endif 145 149 } 146 150 … … 439 443 return WTF::nullopt; 440 444 445 #if PLATFORM(GTK) 446 if (!decoder.decode(parameters.themeName)) 447 return WTF::nullopt; 448 #endif 449 441 450 return parameters; 442 451 } -
trunk/Source/WebKit/Shared/WebPageCreationParameters.h
r255127 r255342 214 214 bool shouldCaptureVideoInGPUProcess { false }; 215 215 bool shouldCaptureDisplayInUIProcess { false }; 216 217 #if PLATFORM(GTK) 218 String themeName; 219 #endif 216 220 }; 217 221 -
trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.cpp
r253749 r255342 584 584 } 585 585 586 String PageClientImpl::themeName() const 587 { 588 if (auto* themeNameEnv = g_getenv("GTK_THEME")) { 589 String name = String::fromUTF8(themeNameEnv); 590 if (name.endsWith("-dark") || name.endsWith(":dark")) 591 return name.substring(0, name.length() - 5); 592 return name; 593 } 594 595 GUniqueOutPtr<char> themeNameSetting; 596 g_object_get(gtk_widget_get_settings(m_viewWidget), "gtk-theme-name", &themeNameSetting.outPtr(), nullptr); 597 String name = String::fromUTF8(themeNameSetting.get()); 598 if (name.endsWith("-dark")) 599 return name.substring(0, name.length() - 5); 600 return name; 601 } 602 586 603 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h
r255322 r255342 173 173 void didChangeWebPageID() const override; 174 174 175 String themeName() const override; 176 175 177 // Members of PageClientImpl class 176 178 GtkWidget* m_viewWidget; -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r254822 r255342 296 296 static void themeChanged(WebKitWebViewBase* webViewBase) 297 297 { 298 webViewBase->priv->pageProxy->themeDidChange(); 299 } 300 301 static void applicationPreferDarkThemeChanged(WebKitWebViewBase* webViewBase) 302 { 298 303 webViewBase->priv->pageProxy->effectiveAppearanceDidChange(); 299 304 } … … 375 380 g_signal_connect_swapped(settings, "notify::gtk-theme-name", G_CALLBACK(themeChanged), webViewBase); 376 381 priv->applicationPreferDarkThemeID = 377 g_signal_connect_swapped(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK( themeChanged), webViewBase);382 g_signal_connect_swapped(settings, "notify::gtk-application-prefer-dark-theme", G_CALLBACK(applicationPreferDarkThemeChanged), webViewBase); 378 383 379 384 if (gtk_widget_get_realized(GTK_WIDGET(window))) -
trunk/Source/WebKit/UIProcess/PageClient.h
r255322 r255342 517 517 518 518 virtual void didChangeWebPageID() const { } 519 520 #if PLATFORM(GTK) 521 virtual String themeName() const = 0; 522 #endif 519 523 }; 520 524 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r255322 r255342 7642 7642 parameters.shouldCaptureDisplayInUIProcess = m_process->processPool().configuration().shouldCaptureDisplayInUIProcess(); 7643 7643 7644 #if PLATFORM(GTK) 7645 parameters.themeName = pageClient().themeName(); 7646 #endif 7647 7644 7648 return parameters; 7645 7649 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r255322 r255342 870 870 PlatformViewWidget viewWidget(); 871 871 bool makeGLContextCurrent(); 872 void themeDidChange(); 872 873 #endif 873 874 -
trunk/Source/WebKit/UIProcess/gtk/WebPageProxyGtk.cpp
r254121 r255342 185 185 } 186 186 187 void WebPageProxy::themeDidChange() 188 { 189 if (!hasRunningProcess()) 190 return; 191 192 send(Messages::WebPage::ThemeDidChange(pageClient().themeName())); 193 effectiveAppearanceDidChange(); 194 } 195 187 196 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r255127 r255342 594 594 setPaginationLineGridEnabled(parameters.paginationLineGridEnabled); 595 595 596 #if PLATFORM(GTK) 597 themeDidChange(WTFMove(parameters.themeName)); 598 #endif 599 596 600 effectiveAppearanceDidChange(parameters.useDarkAppearance, parameters.useElevatedUserInterfaceLevel); 597 601 … … 4710 4714 #endif 4711 4715 4712 #if !PLATFORM(GTK)4713 4716 void WebPage::effectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel) 4714 4717 { 4715 4718 corePage()->effectiveAppearanceDidChange(useDarkAppearance, useElevatedUserInterfaceLevel); 4716 4719 } 4717 #endif4718 4720 4719 4721 void WebPage::freezeLayerTreeDueToSwipeAnimation() -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r255127 r255342 797 797 798 798 void getCenterForZoomGesture(const WebCore::IntPoint& centerInViewCoordinates, CompletionHandler<void(WebCore::IntPoint&&)>&&); 799 800 void themeDidChange(String&&); 799 801 #endif 800 802 … … 2045 2047 2046 2048 String m_overriddenMediaType; 2049 2050 #if PLATFORM(GTK) 2051 String m_themeName; 2052 #endif 2047 2053 }; 2048 2054 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r255127 r255342 507 507 EffectiveAppearanceDidChange(bool useDarkAppearance, bool useElevatedUserInterfaceLevel); 508 508 509 #if PLATFORM(GTK) 510 ThemeDidChange(String themeName) 511 #endif 512 509 513 #if PLATFORM(COCOA) 510 514 RequestActiveNowPlayingSessionInfo(WebKit::CallbackID callbackID) -
trunk/Source/WebKit/WebProcess/WebPage/gtk/WebPageGtk.cpp
r254122 r255342 158 158 } 159 159 160 void WebPage:: effectiveAppearanceDidChange(bool useDarkAppearance, bool useInactiveAppearance)160 void WebPage::themeDidChange(String&& themeName) 161 161 { 162 if (auto* settings = gtk_settings_get_default()) 163 g_object_set(settings, "gtk-application-prefer-dark-theme", useDarkAppearance, nullptr); 164 corePage()->effectiveAppearanceDidChange(useDarkAppearance, useInactiveAppearance); 162 if (m_themeName == themeName) 163 return; 164 165 m_themeName = WTFMove(themeName); 166 g_object_set(gtk_settings_get_default(), "gtk-theme-name", m_themeName.utf8().data(), nullptr); 167 Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment(); 165 168 } 166 169 -
trunk/Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp
r255067 r255342 54 54 XInitThreads(); 55 55 #endif 56 57 // Ignore the GTK_THEME environment variable, the theme is always set by the UI process now. 58 g_unsetenv("GTK_THEME"); 59 56 60 gtk_init(nullptr, nullptr); 57 61 -
trunk/Source/cmake/OptionsGTK.cmake
r255241 r255342 211 211 212 212 SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTKUnixPrint_FOUND}) 213 SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)214 213 215 214 if (USE_WPE_RENDERER)
Note:
See TracChangeset
for help on using the changeset viewer.