REGRESSION(r244635): [GTK] Wrong background color used in non-dark mode
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2019 10:14:01 +0000 (10:14 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2019 10:14:01 +0000 (10:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197276

Reviewed by Michael Catanzaro.

Since r244635, we are now getting the frame view background color from the theme. That's correct for dark mode,
but in non-dark mode we still want to use white backgrounds by default. This made a lot of tests to fail.

* css/CSSValueKeywords.in: Add -webkit-control-background when HAVE(OS_DARK_MODE_SUPPORT).
* css/html.css: Use -webkit-control-background instead of -apple-system-control-background.
* page/FrameView.cpp:
(WebCore::FrameView::updateBackgroundRecursively): Use CSSValueWindow instead of CSSValueWindowframe.
* rendering/RenderThemeGtk.cpp:
(WebCore::RenderThemeGtk::systemColor const): Only get the window background from the theme in dark mode. Handle
also CSSValueWebkitControlBackground.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::systemColor const): Handle CSSValueWebkitControlBackground when HAVE(OS_DARK_MODE_SUPPORT).

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244731 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/html.css
Source/WebCore/page/FrameView.cpp
Source/WebCore/rendering/RenderThemeGtk.cpp
Source/WebCore/rendering/RenderThemeMac.mm

index dd3fde6..d3c9459 100644 (file)
@@ -1,3 +1,23 @@
+2019-04-25  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        REGRESSION(r244635): [GTK] Wrong background color used in non-dark mode
+        https://bugs.webkit.org/show_bug.cgi?id=197276
+
+        Reviewed by Michael Catanzaro.
+
+        Since r244635, we are now getting the frame view background color from the theme. That's correct for dark mode,
+        but in non-dark mode we still want to use white backgrounds by default. This made a lot of tests to fail.
+
+        * css/CSSValueKeywords.in: Add -webkit-control-background when HAVE(OS_DARK_MODE_SUPPORT).
+        * css/html.css: Use -webkit-control-background instead of -apple-system-control-background.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateBackgroundRecursively): Use CSSValueWindow instead of CSSValueWindowframe.
+        * rendering/RenderThemeGtk.cpp:
+        (WebCore::RenderThemeGtk::systemColor const): Only get the window background from the theme in dark mode. Handle
+        also CSSValueWebkitControlBackground.
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::systemColor const): Handle CSSValueWebkitControlBackground when HAVE(OS_DARK_MODE_SUPPORT).
+
 2019-04-28  Andy Estes  <aestes@apple.com>
 
         [Apple Pay] Increment the API version from 6 to 7
index e37931e..aa2d854 100644 (file)
@@ -268,6 +268,9 @@ windowtext
 -apple-system-indigo
 -apple-system-teal
 #endif
+#if defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT
+-webkit-control-background
+#endif
 -webkit-focus-ring-color
 currentcolor
 //
index 8220806..09a968e 100644 (file)
@@ -389,7 +389,7 @@ input:matches([type="password"], [type="search"]) {
     -webkit-appearance: textfield;
 #if defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT
     color: text;
-    background-color: -apple-system-control-background;
+    background-color: -webkit-control-background;
 #else
     background-color: white;
 #endif
@@ -667,7 +667,7 @@ textarea {
 #if !(defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY)
 #if defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT
     color: text;
-    background-color: -apple-system-control-background;
+    background-color: -webkit-control-background;
 #else
     background-color: white;
 #endif
@@ -954,7 +954,7 @@ select {
     border: 1px solid;
 #if defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT
     color: text;
-    background-color: -apple-system-control-background;
+    background-color: -webkit-control-background;
 #else
     color: black;
     background-color: white;
index 7a7b72e..50813d8 100644 (file)
@@ -3004,7 +3004,7 @@ void FrameView::updateBackgroundRecursively(const Optional<Color>& backgroundCol
 #if PLATFORM(MAC) || PLATFORM(IOS_FAMILY)
     static const auto cssValueControlBackground = CSSValueAppleSystemControlBackground;
 #else
-    static const auto cssValueControlBackground = CSSValueWindowframe;
+    static const auto cssValueControlBackground = CSSValueWindow;
 #endif
     Color baseBackgroundColor = backgroundColor.valueOr(RenderTheme::singleton().systemColor(cssValueControlBackground, styleColorOptions()));
 #else
index a6dbb55..9286cf6 100644 (file)
@@ -1780,13 +1780,24 @@ 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);
 #if GTK_CHECK_VERSION(3, 20, 0)
-    case CSSValueWindowframe:
-        return styleColor(Window, 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;
+    }
 #endif
     default:
-        return RenderTheme::systemColor(cssValueId, options);
+        break;
     }
+
+    return RenderTheme::systemColor(cssValueId, options);
 }
 
 void RenderThemeGtk::platformColorsDidChange()
index cc1f06f..552f0bd 100644 (file)
@@ -715,6 +715,9 @@ Color RenderThemeMac::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::O
             case CSSValueAppleSystemTextBackground:
                 return @selector(textBackgroundColor);
             case CSSValueAppleSystemControlBackground:
+#if HAVE(OS_DARK_MODE_SUPPORT)
+            case CSSValueWebkitControlBackground:
+#endif
                 return @selector(controlBackgroundColor);
             case CSSValueAppleSystemAlternateSelectedText:
                 return @selector(alternateSelectedControlTextColor);