Title: [279987] trunk
Revision
279987
Author
[email protected]
Date
2021-07-16 09:39:15 -0700 (Fri, 16 Jul 2021)

Log Message

[GTK][WPE] Support color-schemes CSS property
https://bugs.webkit.org/show_bug.cgi?id=208204

Patch by Alexander Mikhaylenko <[email protected]> on 2021-07-16
Reviewed by Adrian Perez de Castro.

.:

* Source/cmake/OptionsGTK.cmake:
Enable HAVE_OS_DARK_MODE_SUPPORT.
* Source/cmake/OptionsWPE.cmake:
Enable ENABLE_DARK_MODE_CSS and HAVE_OS_DARK_MODE_SUPPORT.

Source/WebCore:

Last time we tried enabling dark mode, we broke many webpages since we couldn't have diferent
controls, and more importantly, different system colors and defaults for pages that do and
don't support dark mode.

Now that we don't use GTK for this, we can try again. This time, use hardcoded system colors
and return different colors depending on StyleColor::Options::UseDarkAppearance.

To avoid dark-on-dark text on entries, we also need to enable HAVE_OS_DARK_MODE_SUPPORT for GTK
and make sure it's passed to use agent CSS. And since Adwaita controls are also used in WPE, we
need to enable it for WPE as well, and since WPE didn't have ENABLE_DARK_MODE_CSS, flip  that as
well, all in lockstep.

No new tests, reenabled the existing css-dark-mode tests.

* PlatformGTK.cmake:
* PlatformWPE.cmake:
Pass HAVE_OS_DARK_MODE_SUPPORT to user agent CSS.
* css/CSSValueKeywords.in:
Expose -webkit-control-background for anything with HAVE_OS_DARK_MODE_SUPPORT.
* css/themeAdwaita.css:
(input[type="search"]::-webkit-search-results-button,):
(input[type="search"]::-webkit-search-cancel-button):
(body[dir="rtl"] input[type="search"]::-webkit-search-cancel-button):
(input[type="search"]::-webkit-search-results-button:hover,):
(input[type="search"]::-webkit-search-cancel-button:hover): Deleted.
Use mask images instead of content so we can recolor them. Change
color on hover as opacity and inherit entry's color otherwise to
make sure it's legible with dark appearance.
* page/FrameView.cpp:
(WebCore::FrameView::updateBackgroundRecursively):
Use CSSValueWindow for background instead of CSSValueAppleSystemControlBackground
when the latter is not available.
* platform/adwaita/ThemeAdwaita.cpp:
(WebCore::ThemeAdwaita::focusColor):
(WebCore::ThemeAdwaita::paintFocus):
(WebCore::ThemeAdwaita::paintArrow):
(WebCore::ThemeAdwaita::paint):
(WebCore::ThemeAdwaita::paintCheckbox):
(WebCore::ThemeAdwaita::paintRadio):
(WebCore::ThemeAdwaita::paintButton):
(WebCore::ThemeAdwaita::paintSpinButton):
* platform/adwaita/ThemeAdwaita.h:
* rendering/RenderThemeAdwaita.cpp:
(WebCore::RenderThemeAdwaita::platformFocusRingColor const):
(WebCore::RenderThemeAdwaita::systemColor const):
(WebCore::RenderThemeAdwaita::paintTextField):
(WebCore::RenderThemeAdwaita::adjustTextFieldStyle const):
(WebCore::RenderThemeAdwaita::adjustTextAreaStyle const):
(WebCore::RenderThemeAdwaita::adjustSearchFieldStyle const):
Add a border radius to the default style, so the background doesn't bleed through
the corners.
(WebCore::RenderThemeAdwaita::paintMenuList):
(WebCore::RenderThemeAdwaita::paintProgressBar):
(WebCore::RenderThemeAdwaita::paintSliderTrack):
(WebCore::RenderThemeAdwaita::paintSliderThumb):
* rendering/RenderThemeAdwaita.h:

Source/WTF:

* wtf/PlatformHave.h:
Enable HAVE_OS_DARK_MODE_SUPPORT for GTK and WPE.

LayoutTests:

Reenable css-dark-mode tests for GTK as they pass now. Enable the same tests in WPE.
Keep css-dark-mode/older-syntax/supported-color-schemes-css.html as [ Pass Crash ] for now,
according to https://bugs.webkit.org/show_bug.cgi?id=202229#c2

* platform/gtk/TestExpectations:
* platform/gtk/css-dark-mode/color-scheme-css-expected.txt: Removed.
* platform/gtk/css-dark-mode/color-scheme-meta-expected.txt: Removed.
* platform/gtk/css-dark-mode/color-scheme-priority-expected.txt: Removed.
* platform/gtk/css-dark-mode/default-colors-expected.txt: Removed.
* platform/gtk/css-dark-mode/older-syntax/supported-color-schemes-css-expected.txt: Removed.
* platform/gtk/css-dark-mode/older-syntax/supported-color-schemes-meta-expected.txt: Removed.
* platform/wpe/TestExpectations:

Modified Paths

Removed Paths

  • trunk/LayoutTests/platform/gtk/css-dark-mode/

Diff

Modified: trunk/ChangeLog (279986 => 279987)


--- trunk/ChangeLog	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/ChangeLog	2021-07-16 16:39:15 UTC (rev 279987)
@@ -1,3 +1,15 @@
+2021-07-16  Alexander Mikhaylenko  <[email protected]>
+
+        [GTK][WPE] Support color-schemes CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=208204
+
+        Reviewed by Adrian Perez de Castro.
+
+        * Source/cmake/OptionsGTK.cmake:
+        Enable HAVE_OS_DARK_MODE_SUPPORT.
+        * Source/cmake/OptionsWPE.cmake:
+        Enable ENABLE_DARK_MODE_CSS and HAVE_OS_DARK_MODE_SUPPORT.
+
 2021-07-15  Philippe Normand  <[email protected]>
 
         Unreviewed, CMake fix-up after r279940

Modified: trunk/LayoutTests/ChangeLog (279986 => 279987)


--- trunk/LayoutTests/ChangeLog	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/LayoutTests/ChangeLog	2021-07-16 16:39:15 UTC (rev 279987)
@@ -1,3 +1,23 @@
+2021-07-16  Alexander Mikhaylenko  <[email protected]>
+
+        [GTK][WPE] Support color-schemes CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=208204
+
+        Reviewed by Adrian Perez de Castro.
+
+        Reenable css-dark-mode tests for GTK as they pass now. Enable the same tests in WPE.
+        Keep css-dark-mode/older-syntax/supported-color-schemes-css.html as [ Pass Crash ] for now,
+        according to https://bugs.webkit.org/show_bug.cgi?id=202229#c2
+
+        * platform/gtk/TestExpectations:
+        * platform/gtk/css-dark-mode/color-scheme-css-expected.txt: Removed.
+        * platform/gtk/css-dark-mode/color-scheme-meta-expected.txt: Removed.
+        * platform/gtk/css-dark-mode/color-scheme-priority-expected.txt: Removed.
+        * platform/gtk/css-dark-mode/default-colors-expected.txt: Removed.
+        * platform/gtk/css-dark-mode/older-syntax/supported-color-schemes-css-expected.txt: Removed.
+        * platform/gtk/css-dark-mode/older-syntax/supported-color-schemes-meta-expected.txt: Removed.
+        * platform/wpe/TestExpectations:
+
 2021-07-15  Chris Dumez  <[email protected]>
 
         Implement 'SubmitEvent' interface

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (279986 => 279987)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2021-07-16 16:39:15 UTC (rev 279987)
@@ -1923,10 +1923,7 @@
 webkit.org/b/202227 compositing/backing/layer-outside-tiled-parent.html [ Failure ]
 webkit.org/b/202228 compositing/layer-creation/fixed-position-descendants-out-of-view.html [ Failure ]
 
-webkit.org/b/202229 css-dark-mode/color-scheme-css.html [ Failure ]
-webkit.org/b/202229 css-dark-mode/color-scheme-meta.html [ Failure ]
-webkit.org/b/202229 css-dark-mode/older-syntax/supported-color-schemes-css.html [ Crash Failure ]
-webkit.org/b/202229 css-dark-mode/older-syntax/supported-color-schemes-meta.html [ Failure ]
+webkit.org/b/202229 css-dark-mode/older-syntax/supported-color-schemes-css.html [ Pass Crash ]
 
 webkit.org/b/202744 compositing/layer-creation/absolute-in-async-overflow-scroll.html [ Failure ]
 webkit.org/b/202744 compositing/overflow/overflow-auto-with-touch.html [ Failure ]

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (279986 => 279987)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2021-07-16 16:39:15 UTC (rev 279987)
@@ -365,8 +365,8 @@
 fast/events/touch/gesture/resources/drag-inside-nested-iframes3.html [ Skip ]
 fast/text/selection-is-prevent-defaulted.html [ Skip ]
 
-# ENABLE_DARK_MODE_CSS is OFF in WPE.
-css-dark-mode [ Skip ]
+css-dark-mode [ Pass ]
+css-dark-mode/older-systems [ Skip ]
 
 # Tests below are copied from wk2 expectations, because we've marked
 #  as passing the whole fast/events directory.
@@ -1323,6 +1323,8 @@
 
 webkit.org/b/194933 http/tests/cookies/same-site/user-load-cross-site-redirect.py [ Failure ]
 
+webkit.org/b/202229 css-dark-mode/older-syntax/supported-color-schemes-css.html [ Pass Crash ]
+
 # WEBGL2 is disabled
 webkit.org/b/208188 fast/canvas/webgl/webgl2 [ Skip ]
 webkit.org/b/208188 fast/canvas/webgl/bufferData-offset-length.html [ Skip ]

Modified: trunk/Source/WTF/ChangeLog (279986 => 279987)


--- trunk/Source/WTF/ChangeLog	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WTF/ChangeLog	2021-07-16 16:39:15 UTC (rev 279987)
@@ -1,3 +1,13 @@
+2021-07-16  Alexander Mikhaylenko  <[email protected]>
+
+        [GTK][WPE] Support color-schemes CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=208204
+
+        Reviewed by Adrian Perez de Castro.
+
+        * wtf/PlatformHave.h:
+        Enable HAVE_OS_DARK_MODE_SUPPORT for GTK and WPE.
+
 2021-07-15  Jean-Yves Avenard  <[email protected]>
 
         [Wk1] media/media-source/media-webm-opus-partial.html is a consistent failure (Enable VP8/VP9/Vorbis/Opus in WebKitLegacy)

Modified: trunk/Source/WTF/wtf/PlatformHave.h (279986 => 279987)


--- trunk/Source/WTF/wtf/PlatformHave.h	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WTF/wtf/PlatformHave.h	2021-07-16 16:39:15 UTC (rev 279987)
@@ -391,7 +391,7 @@
 #define HAVE_NSHTTPCOOKIESTORAGE__INITWITHIDENTIFIER_WITH_INACCURATE_NULLABILITY 1
 #endif
 
-#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST)
+#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || PLATFORM(GTK) || PLATFORM(WPE)
 #define HAVE_OS_DARK_MODE_SUPPORT 1
 #endif
 

Modified: trunk/Source/WebCore/ChangeLog (279986 => 279987)


--- trunk/Source/WebCore/ChangeLog	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/ChangeLog	2021-07-16 16:39:15 UTC (rev 279987)
@@ -1,3 +1,67 @@
+2021-07-16  Alexander Mikhaylenko  <[email protected]>
+
+        [GTK][WPE] Support color-schemes CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=208204
+
+        Reviewed by Adrian Perez de Castro.
+
+        Last time we tried enabling dark mode, we broke many webpages since we couldn't have diferent
+        controls, and more importantly, different system colors and defaults for pages that do and
+        don't support dark mode.
+
+        Now that we don't use GTK for this, we can try again. This time, use hardcoded system colors
+        and return different colors depending on StyleColor::Options::UseDarkAppearance.
+
+        To avoid dark-on-dark text on entries, we also need to enable HAVE_OS_DARK_MODE_SUPPORT for GTK
+        and make sure it's passed to use agent CSS. And since Adwaita controls are also used in WPE, we
+        need to enable it for WPE as well, and since WPE didn't have ENABLE_DARK_MODE_CSS, flip  that as
+        well, all in lockstep.
+
+        No new tests, reenabled the existing css-dark-mode tests.
+
+        * PlatformGTK.cmake:
+        * PlatformWPE.cmake:
+        Pass HAVE_OS_DARK_MODE_SUPPORT to user agent CSS.
+        * css/CSSValueKeywords.in:
+        Expose -webkit-control-background for anything with HAVE_OS_DARK_MODE_SUPPORT.
+        * css/themeAdwaita.css:
+        (input[type="search"]::-webkit-search-results-button,):
+        (input[type="search"]::-webkit-search-cancel-button):
+        (body[dir="rtl"] input[type="search"]::-webkit-search-cancel-button):
+        (input[type="search"]::-webkit-search-results-button:hover,):
+        (input[type="search"]::-webkit-search-cancel-button:hover): Deleted.
+        Use mask images instead of content so we can recolor them. Change
+        color on hover as opacity and inherit entry's color otherwise to
+        make sure it's legible with dark appearance.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::updateBackgroundRecursively):
+        Use CSSValueWindow for background instead of CSSValueAppleSystemControlBackground
+        when the latter is not available.
+        * platform/adwaita/ThemeAdwaita.cpp:
+        (WebCore::ThemeAdwaita::focusColor):
+        (WebCore::ThemeAdwaita::paintFocus):
+        (WebCore::ThemeAdwaita::paintArrow):
+        (WebCore::ThemeAdwaita::paint):
+        (WebCore::ThemeAdwaita::paintCheckbox):
+        (WebCore::ThemeAdwaita::paintRadio):
+        (WebCore::ThemeAdwaita::paintButton):
+        (WebCore::ThemeAdwaita::paintSpinButton):
+        * platform/adwaita/ThemeAdwaita.h:
+        * rendering/RenderThemeAdwaita.cpp:
+        (WebCore::RenderThemeAdwaita::platformFocusRingColor const):
+        (WebCore::RenderThemeAdwaita::systemColor const):
+        (WebCore::RenderThemeAdwaita::paintTextField):
+        (WebCore::RenderThemeAdwaita::adjustTextFieldStyle const):
+        (WebCore::RenderThemeAdwaita::adjustTextAreaStyle const):
+        (WebCore::RenderThemeAdwaita::adjustSearchFieldStyle const):
+        Add a border radius to the default style, so the background doesn't bleed through
+        the corners.
+        (WebCore::RenderThemeAdwaita::paintMenuList):
+        (WebCore::RenderThemeAdwaita::paintProgressBar):
+        (WebCore::RenderThemeAdwaita::paintSliderTrack):
+        (WebCore::RenderThemeAdwaita::paintSliderThumb):
+        * rendering/RenderThemeAdwaita.h:
+
 2021-07-16  Philippe Normand  <[email protected]>
 
         [GStreamer] RealtimeMediaSourceCenter and VideoEncoder are not libwebrtc-specific

Modified: trunk/Source/WebCore/PlatformGTK.cmake (279986 => 279987)


--- trunk/Source/WebCore/PlatformGTK.cmake	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/PlatformGTK.cmake	2021-07-16 16:39:15 UTC (rev 279987)
@@ -61,6 +61,8 @@
     platform/text/enchant/TextCheckerEnchant.h
 )
 
+set(CSS_VALUE_PLATFORM_DEFINES "HAVE_OS_DARK_MODE_SUPPORT=1")
+
 list(APPEND WebCore_USER_AGENT_STYLE_SHEETS
     ${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsAdwaita.css
     ${WEBCORE_DIR}/css/themeAdwaita.css

Modified: trunk/Source/WebCore/PlatformWPE.cmake (279986 => 279987)


--- trunk/Source/WebCore/PlatformWPE.cmake	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/PlatformWPE.cmake	2021-07-16 16:39:15 UTC (rev 279987)
@@ -40,6 +40,8 @@
     platform/graphics/wayland/WlUniquePtr.h
 )
 
+set(CSS_VALUE_PLATFORM_DEFINES "HAVE_OS_DARK_MODE_SUPPORT=1")
+
 list(APPEND WebCore_USER_AGENT_STYLE_SHEETS
     ${WEBCORE_DIR}/css/themeAdwaita.css
     ${WEBCORE_DIR}/Modules/mediacontrols/mediaControlsAdwaita.css

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (279986 => 279987)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2021-07-16 16:39:15 UTC (rev 279987)
@@ -260,7 +260,6 @@
 -apple-system-red
 -apple-system-yellow
 -apple-system-app-highlight-background
--webkit-control-background
 #endif
 #if defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC
 -apple-system-alternate-selected-text
@@ -282,6 +281,9 @@
 -apple-system-opaque-tertiary-fill
 -apple-system-opaque-separator
 #endif
+#if (defined(WTF_PLATFORM_MAC) && WTF_PLATFORM_MAC) || (defined(WTF_PLATFORM_IOS_FAMILY) && WTF_PLATFORM_IOS_FAMILY) || (defined(HAVE_OS_DARK_MODE_SUPPORT) && HAVE_OS_DARK_MODE_SUPPORT)
+-webkit-control-background
+#endif
 -webkit-focus-ring-color
 currentcolor
 //

Modified: trunk/Source/WebCore/css/themeAdwaita.css (279986 => 279987)


--- trunk/Source/WebCore/css/themeAdwaita.css	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/css/themeAdwaita.css	2021-07-16 16:39:15 UTC (rev 279987)
@@ -26,40 +26,47 @@
     -webkit-box-shadow: none !important;
     width: 1em;
     height: 1em;
-    content: url("data:image/svg+xml;utf-8, \
+    -webkit-mask-image: url("data:image/svg+xml;utf-8, \
         <svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'> \
-          <g color='%23000' font-weight='400' font-family='sans-serif' white-space='normal' fill='%23474747'> \
+          <g color='%23000' font-weight='400' font-family='sans-serif' white-space='normal' fill='black'> \
             <path d='M6.508 1C3.48 1 1.002 3.473 1.002 6.5c0 3.026 2.478 5.5 5.506 5.5s5.504-2.474 5.504-5.5c0-3.027-2.476-5.5-5.504-5.5zm0 2a3.486 3.486 0 0 1 3.504 3.5c0 1.944-1.556 3.5-3.504 3.5a3.488 3.488 0 0 1-3.506-3.5C3.002 4.555 4.56 3 6.508 3z' style='line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none' overflow='visible'/> \
             <path d='M10 8.99a1 1 0 0 0-.695 1.717l4.004 4a1 1 0 1 0 1.414-1.414l-4.004-4A1 1 0 0 0 10 8.99z' style='line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:%23000;text-transform:none;text-orientation:mixed;shape-padding:0;isolation:auto;mix-blend-mode:normal;marker:none' overflow='visible'/> \
           </g> \
         </svg>");
+    -webkit-mask-size: 1em 1em;
 }
 
-input[type="search"]::-webkit-search-results-button:hover,
-input[type="search"]::-webkit-search-results-decoration:hover {
-    filter: brightness(10%);
-}
-
 input[type="search"]::-webkit-search-cancel-button {
     -webkit-appearance: none;
     -webkit-box-shadow: none !important;
     width: 1em;
     height: 1em;
-    content: url("data:image/svg+xml;utf-8, \
+    -webkit-mask-image: url("data:image/svg+xml;utf-8, \
         <svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'> \
-          <path d='M6 2L0 8l6 6h9.035A1.03 1.03 0 0 0 16 13V3c0-.53-.346-1-1.009-1zm1 3h1.031c.255.011.51.129.688.313L10 6.593l1.313-1.28c.265-.231.446-.306.687-.313h1v1c0 .286-.034.55-.25.75l-1.281 1.281 1.25 1.25c.188.188.281.454.281.719v1h-1c-.265 0-.53-.093-.719-.281L10 9.438l-1.281 1.28A1.015 1.015 0 0 1 8 11H7v-1c0-.265.093-.53.281-.719l1.282-1.25L7.28 6.75A.909.909 0 0 1 7 6z' style='marker:none' color='%23000' overflow='visible' fill='%23474747'/> \
+          <path d='M6 2L0 8l6 6h9.035A1.03 1.03 0 0 0 16 13V3c0-.53-.346-1-1.009-1zm1 3h1.031c.255.011.51.129.688.313L10 6.593l1.313-1.28c.265-.231.446-.306.687-.313h1v1c0 .286-.034.55-.25.75l-1.281 1.281 1.25 1.25c.188.188.281.454.281.719v1h-1c-.265 0-.53-.093-.719-.281L10 9.438l-1.281 1.28A1.015 1.015 0 0 1 8 11H7v-1c0-.265.093-.53.281-.719l1.282-1.25L7.28 6.75A.909.909 0 0 1 7 6z' style='marker:none' color='%23000' overflow='visible' fill='black'/> \
         </svg>");
+    -webkit-mask-size: 1em 1em;
 }
 
 body[dir="rtl"] input[type="search"]::-webkit-search-cancel-button {
     -webkit-appearance: none;
     -webkit-box-shadow: none !important;
-    content: url("data:image/svg+xml;utf-8, \
+    -webkit-mask-image: url("data:image/svg+xml;utf-8, \
         <svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'> \
-          <path d='M10 2l6 6-6 6H.965A1.03 1.03 0 0 1 0 13V3c0-.53.346-1 1.009-1zM9 5H7.969a1.04 1.04 0 0 0-.688.313L6 6.593l-1.313-1.28C4.423 5.082 4.242 5.006 4 5H3v1c0 .286.034.55.25.75l1.281 1.281-1.25 1.25A1.015 1.015 0 0 0 3 10v1h1c.265 0 .53-.093.719-.281L6 9.438l1.281 1.28c.188.189.454.282.719.282h1v-1c0-.265-.093-.53-.281-.719l-1.281-1.25 1.28-1.281A.909.909 0 0 0 9 6z' style='marker:none' color='%23000' overflow='visible' fill='%23474747'/> \
+          <path d='M10 2l6 6-6 6H.965A1.03 1.03 0 0 1 0 13V3c0-.53.346-1 1.009-1zM9 5H7.969a1.04 1.04 0 0 0-.688.313L6 6.593l-1.313-1.28C4.423 5.082 4.242 5.006 4 5H3v1c0 .286.034.55.25.75l1.281 1.281-1.25 1.25A1.015 1.015 0 0 0 3 10v1h1c.265 0 .53-.093.719-.281L6 9.438l1.281 1.28c.188.189.454.282.719.282h1v-1c0-.265-.093-.53-.281-.719l-1.281-1.25 1.28-1.281A.909.909 0 0 0 9 6z' style='marker:none' color='%23000' overflow='visible' fill='black'/> \
         </svg>");
+    -webkit-mask-size: 1em 1em;
 }
 
+input[type="search"]::-webkit-search-results-button,
+input[type="search"]::-webkit-search-results-decoration,
+input[type="search"]::-webkit-search-cancel-button {
+    background-color: currentColor;
+    opacity: .75;
+}
+
+input[type="search"]::-webkit-search-results-button:hover,
+input[type="search"]::-webkit-search-results-decoration:hover,
 input[type="search"]::-webkit-search-cancel-button:hover {
-    filter: brightness(10%);
+    opacity: 1;
 }

Modified: trunk/Source/WebCore/page/FrameView.cpp (279986 => 279987)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-07-16 16:39:15 UTC (rev 279987)
@@ -3027,8 +3027,13 @@
 void FrameView::updateBackgroundRecursively(const std::optional<Color>& backgroundColor)
 {
 #if HAVE(OS_DARK_MODE_SUPPORT)
-    Color baseBackgroundColor = backgroundColor.value_or(RenderTheme::singleton().systemColor(CSSValueAppleSystemControlBackground, styleColorOptions()));
+#if PLATFORM(COCOA)
+    static const auto cssValueControlBackground = CSSValueAppleSystemControlBackground;
 #else
+    static const auto cssValueControlBackground = CSSValueWindow;
+#endif
+    Color baseBackgroundColor = backgroundColor.value_or(RenderTheme::singleton().systemColor(cssValueControlBackground, styleColorOptions()));
+#else
     Color baseBackgroundColor = backgroundColor.value_or(Color::white);
 #endif
 

Modified: trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp (279986 => 279987)


--- trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.cpp	2021-07-16 16:39:15 UTC (rev 279987)
@@ -36,29 +36,50 @@
 namespace WebCore {
 
 static const unsigned focusLineWidth = 1;
-static constexpr auto focusRingColor = SRGBA<uint8_t> { 46, 52, 54, 150 };
+static constexpr auto focusRingColorLight = SRGBA<uint8_t> { 46, 52, 54, 150 };
+static constexpr auto focusRingColorDark = SRGBA<uint8_t> { 238, 238, 236, 150 };
 static const unsigned arrowSize = 16;
-static constexpr auto arrowColor = SRGBA<uint8_t> { 46, 52, 54 };
+static constexpr auto arrowColorLight = SRGBA<uint8_t> { 46, 52, 54 };
+static constexpr auto arrowColorDark = SRGBA<uint8_t> { 238, 238, 236 };
 static const int buttonFocusOffset = -3;
 static const unsigned buttonPadding = 5;
 static const int buttonBorderSize = 1; // Keep in sync with menuListButtonBorderSize in RenderThemeAdwaita.
-static constexpr auto buttonBorderColor = SRGBA<uint8_t> { 205, 199, 194 };
-static constexpr auto buttonBackgroundColor = SRGBA<uint8_t> { 244, 242, 241 };
-static constexpr auto buttonBackgroundPressedColor = SRGBA<uint8_t> { 214, 209, 205 };
-static constexpr auto buttonBackgroundHoveredColor = SRGBA<uint8_t> { 248, 248, 247 };
-static constexpr auto buttonBackgroundDisabledColor = SRGBA<uint8_t> { 246, 246, 244 };
-static constexpr auto toggleBackgroundColor = Color::white;
-static constexpr auto toggleBackgroundHoveredColor = SRGBA<uint8_t> { 242, 242, 242 };
-static constexpr auto toggleBackgroundDisabledColor = SRGBA<uint8_t> { 252, 252, 252 };
+
+static constexpr auto buttonBorderColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto buttonBackgroundColorLight = SRGBA<uint8_t> { 244, 242, 241 };
+static constexpr auto buttonBackgroundPressedColorLight = SRGBA<uint8_t> { 214, 209, 205 };
+static constexpr auto buttonBackgroundHoveredColorLight = SRGBA<uint8_t> { 248, 248, 247 };
+static constexpr auto buttonBackgroundDisabledColorLight = SRGBA<uint8_t> { 250, 249, 248 };
+static constexpr auto toggleBackgroundColorLight = Color::white;
+static constexpr auto toggleBackgroundHoveredColorLight = SRGBA<uint8_t> { 214, 209, 205 };
+static constexpr auto toggleBackgroundDisabledColorLight = SRGBA<uint8_t> { 250, 249, 248 };
+
+static constexpr auto buttonBorderColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto buttonBackgroundColorDark = SRGBA<uint8_t> { 52, 52, 52 };
+static constexpr auto buttonBackgroundPressedColorDark = SRGBA<uint8_t> { 30, 30, 30 };
+static constexpr auto buttonBackgroundHoveredColorDark = SRGBA<uint8_t> { 55, 55, 55 };
+static constexpr auto buttonBackgroundDisabledColorDark = SRGBA<uint8_t> { 50, 50, 50 };
+static constexpr auto toggleBackgroundColorDark = SRGBA<uint8_t> { 45, 45, 45 };
+static constexpr auto toggleBackgroundHoveredColorDark = SRGBA<uint8_t> { 30, 30, 30 };
+static constexpr auto toggleBackgroundDisabledColorDark = SRGBA<uint8_t> { 50, 50, 50 };
+
 static const double toggleSize = 14.;
 static const int toggleFocusOffset = 2;
-static constexpr auto toggleColor = SRGBA<uint8_t> { 46, 52, 54 };
-static constexpr auto toggleDisabledColor = SRGBA<uint8_t> { 160, 160, 160 };
-static constexpr auto spinButtonBorderColor = SRGBA<uint8_t> { 220, 223, 227 };
-static constexpr auto spinButtonBackgroundColor = SRGBA<uint8_t> { 252, 252, 252 };
-static constexpr auto spinButtonBackgroundHoveredColor = SRGBA<uint8_t> { 46, 52, 54, 50 };
-static constexpr auto spinButtonBackgroundPressedColor = SRGBA<uint8_t> { 46, 52, 54, 70 };
 
+static constexpr auto toggleColorLight = SRGBA<uint8_t> { 46, 52, 54 };
+static constexpr auto toggleDisabledColorLight = SRGBA<uint8_t> { 146, 149, 149 };
+static constexpr auto spinButtonBorderColorLight = SRGBA<uint8_t> { 240, 238, 237 };
+static constexpr auto spinButtonBackgroundColorLight = Color::white;
+static constexpr auto spinButtonBackgroundHoveredColorLight = SRGBA<uint8_t> { 46, 52, 54, 50 };
+static constexpr auto spinButtonBackgroundPressedColorLight = SRGBA<uint8_t> { 46, 52, 54, 70 };
+
+static constexpr auto toggleColorDark = SRGBA<uint8_t> { 238, 238, 236 };
+static constexpr auto toggleDisabledColorDark = SRGBA<uint8_t> { 145, 145, 144 };
+static constexpr auto spinButtonBorderColorDark = SRGBA<uint8_t> { 40, 40, 40 };
+static constexpr auto spinButtonBackgroundColorDark = SRGBA<uint8_t> { 45, 45, 45 };
+static constexpr auto spinButtonBackgroundHoveredColorDark = SRGBA<uint8_t> { 238, 238, 236, 50 };
+static constexpr auto spinButtonBackgroundPressedColorDark = SRGBA<uint8_t> { 238, 238, 236, 70 };
+
 #if !PLATFORM(GTK) || USE(GTK4)
 Theme& Theme::singleton()
 {
@@ -87,18 +108,18 @@
     return activeSelectionBackgroundColor();
 }
 
-Color ThemeAdwaita::focusColor()
+Color ThemeAdwaita::focusColor(bool useDarkAppearance)
 {
-    return focusRingColor;
+    return useDarkAppearance ? focusRingColorDark : focusRingColorLight;
 }
 
-void ThemeAdwaita::paintFocus(GraphicsContext& graphicsContext, const FloatRect& rect, int offset)
+void ThemeAdwaita::paintFocus(GraphicsContext& graphicsContext, const FloatRect& rect, int offset, bool useDarkAppearance)
 {
     FloatRect focusRect = rect;
     focusRect.inflate(offset);
     Path path;
     path.addRoundedRect(focusRect, { 2, 2 });
-    paintFocus(graphicsContext, path, focusRingColor);
+    paintFocus(graphicsContext, path, focusColor(useDarkAppearance));
 }
 
 void ThemeAdwaita::paintFocus(GraphicsContext& graphicsContext, const Path& path, const Color& color)
@@ -128,7 +149,7 @@
     paintFocus(graphicsContext, path, color);
 }
 
-void ThemeAdwaita::paintArrow(GraphicsContext& graphicsContext, ArrowDirection direction)
+void ThemeAdwaita::paintArrow(GraphicsContext& graphicsContext, ArrowDirection direction, bool useDarkAppearance)
 {
     Path path;
     switch (direction) {
@@ -145,7 +166,7 @@
     }
     path.closeSubpath();
 
-    graphicsContext.setFillColor(arrowColor);
+    graphicsContext.setFillColor(useDarkAppearance ? arrowColorDark : arrowColorLight);
     graphicsContext.fillPath(path);
 }
 
@@ -207,23 +228,23 @@
     return Theme::controlBorder(part, font, zoomedBox, zoomFactor);
 }
 
-void ThemeAdwaita::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float zoomFactor, ScrollView*, float, float, bool, bool)
+void ThemeAdwaita::paint(ControlPart part, ControlStates& states, GraphicsContext& context, const FloatRect& zoomedRect, float, ScrollView*, float, float, bool, bool useDarkAppearance)
 {
     switch (part) {
     case CheckboxPart:
-        paintCheckbox(states, context, zoomedRect, zoomFactor);
+        paintCheckbox(states, context, zoomedRect, useDarkAppearance);
         break;
     case RadioPart:
-        paintRadio(states, context, zoomedRect, zoomFactor);
+        paintRadio(states, context, zoomedRect, useDarkAppearance);
         break;
     case PushButtonPart:
     case DefaultButtonPart:
     case ButtonPart:
     case SquareButtonPart:
-        paintButton(states, context, zoomedRect, zoomFactor);
+        paintButton(states, context, zoomedRect, useDarkAppearance);
         break;
     case InnerSpinButtonPart:
-        paintSpinButton(states, context, zoomedRect, zoomFactor);
+        paintSpinButton(states, context, zoomedRect, useDarkAppearance);
         break;
     default:
         break;
@@ -230,7 +251,7 @@
     }
 }
 
-void ThemeAdwaita::paintCheckbox(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
+void ThemeAdwaita::paintCheckbox(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance)
 {
     GraphicsContextStateSaver stateSaver(graphicsContext);
 
@@ -244,6 +265,29 @@
             fieldRect.move(0, (zoomedRect.height() - fieldRect.height()) / 2.0);
     }
 
+    SRGBA<uint8_t> buttonBorderColor;
+    SRGBA<uint8_t> toggleBackgroundColor;
+    SRGBA<uint8_t> toggleBackgroundHoveredColor;
+    SRGBA<uint8_t> toggleBackgroundDisabledColor;
+    SRGBA<uint8_t> toggleColor;
+    SRGBA<uint8_t> toggleDisabledColor;
+
+    if (useDarkAppearance) {
+        buttonBorderColor = buttonBorderColorDark;
+        toggleBackgroundColor = toggleBackgroundColorDark;
+        toggleBackgroundHoveredColor = toggleBackgroundHoveredColorDark;
+        toggleBackgroundDisabledColor = toggleBackgroundDisabledColorDark;
+        toggleColor = toggleColorDark;
+        toggleDisabledColor = toggleDisabledColorDark;
+    } else {
+        buttonBorderColor = buttonBorderColorLight;
+        toggleBackgroundColor = toggleBackgroundColorLight;
+        toggleBackgroundHoveredColor = toggleBackgroundHoveredColorLight;
+        toggleBackgroundDisabledColor = toggleBackgroundDisabledColorLight;
+        toggleDisabledColor = toggleDisabledColorLight;
+        toggleColor = toggleColorLight;
+    }
+
     FloatSize corner(2, 2);
     Path path;
     path.addRoundedRect(fieldRect, corner);
@@ -291,10 +335,10 @@
     }
 
     if (states.states().contains(ControlStates::States::Focused))
-        paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
+        paintFocus(graphicsContext, zoomedRect, toggleFocusOffset, useDarkAppearance);
 }
 
-void ThemeAdwaita::paintRadio(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
+void ThemeAdwaita::paintRadio(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance)
 {
     GraphicsContextStateSaver stateSaver(graphicsContext);
     FloatRect fieldRect = zoomedRect;
@@ -307,6 +351,29 @@
             fieldRect.move(0, (zoomedRect.height() - fieldRect.height()) / 2.0);
     }
 
+    SRGBA<uint8_t> buttonBorderColor;
+    SRGBA<uint8_t> toggleBackgroundColor;
+    SRGBA<uint8_t> toggleBackgroundHoveredColor;
+    SRGBA<uint8_t> toggleBackgroundDisabledColor;
+    SRGBA<uint8_t> toggleColor;
+    SRGBA<uint8_t> toggleDisabledColor;
+
+    if (useDarkAppearance) {
+        buttonBorderColor = buttonBorderColorDark;
+        toggleBackgroundColor = toggleBackgroundColorDark;
+        toggleBackgroundHoveredColor = toggleBackgroundHoveredColorDark;
+        toggleBackgroundDisabledColor = toggleBackgroundDisabledColorDark;
+        toggleColor = toggleColorDark;
+        toggleDisabledColor = toggleDisabledColorDark;
+    } else {
+        buttonBorderColor = buttonBorderColorLight;
+        toggleBackgroundColor = toggleBackgroundColorLight;
+        toggleBackgroundHoveredColor = toggleBackgroundHoveredColorLight;
+        toggleBackgroundDisabledColor = toggleBackgroundDisabledColorLight;
+        toggleDisabledColor = toggleDisabledColorLight;
+        toggleColor = toggleColorLight;
+    }
+
     Path path;
     path.addEllipse(fieldRect);
     fieldRect.inflate(-buttonBorderSize);
@@ -338,13 +405,33 @@
     }
 
     if (states.states().contains(ControlStates::States::Focused))
-        paintFocus(graphicsContext, zoomedRect, toggleFocusOffset);
+        paintFocus(graphicsContext, zoomedRect, toggleFocusOffset, useDarkAppearance);
 }
 
-void ThemeAdwaita::paintButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
+void ThemeAdwaita::paintButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance)
 {
     GraphicsContextStateSaver stateSaver(graphicsContext);
 
+    SRGBA<uint8_t> buttonBorderColor;
+    SRGBA<uint8_t> buttonBackgroundColor;
+    SRGBA<uint8_t> buttonBackgroundHoveredColor;
+    SRGBA<uint8_t> buttonBackgroundPressedColor;
+    SRGBA<uint8_t> buttonBackgroundDisabledColor;
+
+    if (useDarkAppearance) {
+        buttonBorderColor = buttonBorderColorDark;
+        buttonBackgroundColor = buttonBackgroundColorDark;
+        buttonBackgroundHoveredColor = buttonBackgroundHoveredColorDark;
+        buttonBackgroundPressedColor = buttonBackgroundPressedColorDark;
+        buttonBackgroundDisabledColor = buttonBackgroundDisabledColorDark;
+    } else {
+        buttonBorderColor = buttonBorderColorLight;
+        buttonBackgroundColor = buttonBackgroundColorLight;
+        buttonBackgroundHoveredColor = buttonBackgroundHoveredColorLight;
+        buttonBackgroundPressedColor = buttonBackgroundPressedColorLight;
+        buttonBackgroundDisabledColor = buttonBackgroundDisabledColorLight;
+    }
+
     FloatRect fieldRect = zoomedRect;
     FloatSize corner(5, 5);
     Path path;
@@ -370,13 +457,30 @@
     graphicsContext.fillPath(path);
 
     if (states.states().contains(ControlStates::States::Focused))
-        paintFocus(graphicsContext, zoomedRect, buttonFocusOffset);
+        paintFocus(graphicsContext, zoomedRect, buttonFocusOffset, useDarkAppearance);
 }
 
-void ThemeAdwaita::paintSpinButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, float)
+void ThemeAdwaita::paintSpinButton(ControlStates& states, GraphicsContext& graphicsContext, const FloatRect& zoomedRect, bool useDarkAppearance)
 {
     GraphicsContextStateSaver stateSaver(graphicsContext);
 
+    SRGBA<uint8_t> spinButtonBorderColor;
+    SRGBA<uint8_t> spinButtonBackgroundColor;
+    SRGBA<uint8_t> spinButtonBackgroundHoveredColor;
+    SRGBA<uint8_t> spinButtonBackgroundPressedColor;
+
+    if (useDarkAppearance) {
+        spinButtonBorderColor = spinButtonBorderColorDark;
+        spinButtonBackgroundColor = spinButtonBackgroundColorDark;
+        spinButtonBackgroundHoveredColor = spinButtonBackgroundHoveredColorDark;
+        spinButtonBackgroundPressedColor = spinButtonBackgroundPressedColorDark;
+    } else {
+        spinButtonBorderColor = spinButtonBorderColorLight;
+        spinButtonBackgroundColor = spinButtonBackgroundColorLight;
+        spinButtonBackgroundHoveredColor = spinButtonBackgroundHoveredColorLight;
+        spinButtonBackgroundPressedColor = spinButtonBackgroundPressedColorLight;
+    }
+
     FloatRect fieldRect = zoomedRect;
     FloatSize corner(2, 2);
     Path path;
@@ -415,7 +519,7 @@
             graphicsContext.translate(buttonRect.x(), buttonRect.y());
             graphicsContext.scale(FloatSize::narrowPrecision(buttonRect.width() / arrowSize, buttonRect.height() / arrowSize));
         }
-        paintArrow(graphicsContext, ArrowDirection::Up);
+        paintArrow(graphicsContext, ArrowDirection::Up, useDarkAppearance);
     }
 
     buttonRect.move(0, buttonRect.height());
@@ -437,7 +541,7 @@
             graphicsContext.translate(buttonRect.x(), buttonRect.y());
             graphicsContext.scale(FloatSize::narrowPrecision(buttonRect.width() / arrowSize, buttonRect.height() / arrowSize));
         }
-        paintArrow(graphicsContext, ArrowDirection::Down);
+        paintArrow(graphicsContext, ArrowDirection::Down, useDarkAppearance);
     }
 }
 

Modified: trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.h (279986 => 279987)


--- trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.h	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/platform/adwaita/ThemeAdwaita.h	2021-07-16 16:39:15 UTC (rev 279987)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "Color.h"
+#include "StyleColor.h"
 #include "Theme.h"
 
 namespace WebCore {
@@ -34,12 +35,12 @@
 
 class ThemeAdwaita : public Theme {
 public:
-    static Color focusColor();
-    static void paintFocus(GraphicsContext&, const FloatRect&, int offset);
+    static Color focusColor(bool focusColor);
+    static void paintFocus(GraphicsContext&, const FloatRect&, int offset, bool useDarkAppearance);
     static void paintFocus(GraphicsContext&, const Path&, const Color&);
     static void paintFocus(GraphicsContext&, const Vector<FloatRect>&, const Color&);
     enum class ArrowDirection { Up, Down };
-    static void paintArrow(GraphicsContext&, ArrowDirection);
+    static void paintArrow(GraphicsContext&, ArrowDirection, bool);
 
     virtual Color activeSelectionForegroundColor() const;
     virtual Color activeSelectionBackgroundColor() const;
@@ -53,10 +54,10 @@
     LengthBox controlBorder(ControlPart, const FontCascade&, const LengthBox&, float) const final;
     void paint(ControlPart, ControlStates&, GraphicsContext&, const FloatRect&, float, ScrollView*, float, float, bool, bool) final;
 
-    void paintCheckbox(ControlStates&, GraphicsContext&, const FloatRect&, float);
-    void paintRadio(ControlStates&, GraphicsContext&, const FloatRect&, float);
-    void paintButton(ControlStates&, GraphicsContext&, const FloatRect&, float);
-    void paintSpinButton(ControlStates&, GraphicsContext&, const FloatRect&, float);
+    void paintCheckbox(ControlStates&, GraphicsContext&, const FloatRect&, bool);
+    void paintRadio(ControlStates&, GraphicsContext&, const FloatRect&, bool);
+    void paintButton(ControlStates&, GraphicsContext&, const FloatRect&, bool);
+    void paintSpinButton(ControlStates&, GraphicsContext&, const FloatRect&, bool);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp (279986 => 279987)


--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.cpp	2021-07-16 16:39:15 UTC (rev 279987)
@@ -49,10 +49,16 @@
 namespace WebCore {
 
 static const int textFieldBorderSize = 1;
-static constexpr auto textFieldBorderColor = SRGBA<uint8_t> { 205, 199, 194 };
-static constexpr auto textFieldBorderDisabledColor = SRGBA<uint8_t> { 213, 208, 204 };
-static constexpr auto textFieldBackgroundColor = Color::white;
-static constexpr auto textFieldBackgroundDisabledColor = SRGBA<uint8_t> { 252, 252, 252 };
+static constexpr auto textFieldBorderColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto textFieldBorderDisabledColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto textFieldBackgroundColorLight = Color::white;
+static constexpr auto textFieldBackgroundDisabledColorLight = SRGBA<uint8_t> { 250, 249, 248 };
+
+static constexpr auto textFieldBorderColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto textFieldBorderDisabledColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto textFieldBackgroundColorDark = SRGBA<uint8_t> { 45, 45, 45 };
+static constexpr auto textFieldBackgroundDisabledColorDark = SRGBA<uint8_t> { 50, 50, 50 };
+
 static const unsigned menuListButtonArrowSize = 16;
 static const int menuListButtonFocusOffset = -3;
 static const unsigned menuListButtonPadding = 5;
@@ -61,19 +67,29 @@
 static const unsigned progressAnimationFrameCount = 75;
 static const Seconds progressAnimationFrameRate = 33_ms; // 30fps.
 static const unsigned progressBarSize = 6;
-static constexpr auto progressBarBorderColor = SRGBA<uint8_t> { 205, 199, 194 };
-static constexpr auto progressBarBackgroundColor = SRGBA<uint8_t> { 225, 222, 219 };
+static constexpr auto progressBarBorderColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto progressBarBackgroundColorLight = SRGBA<uint8_t> { 225, 222, 219 };
+static constexpr auto progressBarBorderColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto progressBarBackgroundColorDark = SRGBA<uint8_t> { 40, 40, 40 };
 static const unsigned sliderTrackSize = 6;
 static const int sliderTrackBorderSize = 1;
-static constexpr auto sliderTrackBorderColor = SRGBA<uint8_t> { 205, 199, 194 };
-static constexpr auto sliderTrackBackgroundColor = SRGBA<uint8_t> { 225, 222, 219 };
+static constexpr auto sliderTrackBorderColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto sliderTrackBackgroundColorLight = SRGBA<uint8_t> { 225, 222, 219 };
+static constexpr auto sliderTrackBorderColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto sliderTrackBackgroundColorDark = SRGBA<uint8_t> { 40, 40, 40 };
 static const int sliderTrackFocusOffset = 2;
 static const int sliderThumbSize = 20;
 static const int sliderThumbBorderSize = 1;
-static constexpr auto sliderThumbBorderColor = SRGBA<uint8_t> { 205, 199, 194 };
-static constexpr auto sliderThumbBackgroundColor = SRGBA<uint8_t> { 244, 242, 241 };
-static constexpr auto sliderThumbBackgroundHoveredColor = SRGBA<uint8_t> { 248, 248, 247 };
-static constexpr auto sliderThumbBackgroundDisabledColor = SRGBA<uint8_t> { 244, 242, 241 };
+static constexpr auto sliderThumbBorderColorLight = SRGBA<uint8_t> { 205, 199, 194 };
+static constexpr auto sliderThumbBackgroundColorLight = SRGBA<uint8_t> { 244, 242, 241 };
+static constexpr auto sliderThumbBackgroundHoveredColorLight = SRGBA<uint8_t> { 248, 248, 247 };
+static constexpr auto sliderThumbBackgroundDisabledColorLight = SRGBA<uint8_t> { 250, 249, 248 };
+
+static constexpr auto sliderThumbBorderColorDark = SRGBA<uint8_t> { 27, 27, 27 };
+static constexpr auto sliderThumbBackgroundColorDark = SRGBA<uint8_t> { 52, 52, 52 };
+static constexpr auto sliderThumbBackgroundHoveredColorDark = SRGBA<uint8_t> { 55, 55, 55 };
+static constexpr auto sliderThumbBackgroundDisabledColorDark = SRGBA<uint8_t> { 50, 50, 50 };
+
 #if ENABLE(VIDEO)
 static constexpr auto mediaSliderTrackBackgroundcolor = SRGBA<uint8_t> { 77, 77, 77 };
 static constexpr auto mediaSliderTrackBufferedColor = SRGBA<uint8_t> { 173, 173, 173 };
@@ -80,6 +96,11 @@
 static constexpr auto mediaSliderTrackActiveColor = SRGBA<uint8_t> { 252, 252, 252 };
 #endif
 
+static constexpr auto buttonTextColorLight = SRGBA<uint8_t> { 46, 52, 54 };
+static constexpr auto buttonTextDisabledColorLight = SRGBA<uint8_t> { 146, 149, 149 };
+static constexpr auto buttonTextColorDark = SRGBA<uint8_t> { 238, 238, 236 };
+static constexpr auto buttonTextDisabledColorDark = SRGBA<uint8_t> { 145, 145, 144 };
+
 #if !PLATFORM(GTK)
 RenderTheme& RenderTheme::singleton()
 {
@@ -154,9 +175,9 @@
     return static_cast<ThemeAdwaita&>(Theme::singleton()).inactiveSelectionForegroundColor();
 }
 
-Color RenderThemeAdwaita::platformFocusRingColor(OptionSet<StyleColor::Options>) const
+Color RenderThemeAdwaita::platformFocusRingColor(OptionSet<StyleColor::Options> options) const
 {
-    return ThemeAdwaita::focusColor();
+    return ThemeAdwaita::focusColor(options.contains(StyleColor::Options::UseDarkAppearance));
 }
 
 void RenderThemeAdwaita::platformColorsDidChange()
@@ -182,11 +203,76 @@
 }
 #endif
 
+Color RenderThemeAdwaita::systemColor(CSSValueID cssValueID, OptionSet<StyleColor::Options> options) const
+{
+    const bool useDarkAppearance = options.contains(StyleColor::Options::UseDarkAppearance);
+
+    switch (cssValueID) {
+    case CSSValueActivecaption:
+    case CSSValueActivebuttontext:
+    case CSSValueButtontext:
+        return useDarkAppearance ? buttonTextColorDark : buttonTextColorLight;
+
+    case CSSValueGraytext:
+        return useDarkAppearance ? buttonTextDisabledColorDark : buttonTextDisabledColorLight;
+
+    case CSSValueCanvas:
+    case CSSValueField:
+    case CSSValueWebkitControlBackground:
+        return useDarkAppearance ? textFieldBackgroundColorDark : textFieldBackgroundColorLight;
+
+    case CSSValueWindow:
+        return useDarkAppearance ? SRGBA<uint8_t> { 30, 30, 30 } : Color::white;
+
+    case CSSValueCanvastext:
+    case CSSValueCaptiontext:
+    case CSSValueFieldtext:
+    case CSSValueInactivecaptiontext:
+    case CSSValueInfotext:
+    case CSSValueText:
+    case CSSValueWindowtext:
+        return useDarkAppearance ? Color::white : Color::black;
+
+    case CSSValueInactiveborder:
+    case CSSValueInactivecaption:
+        return useDarkAppearance ? Color::black : Color::white;
+
+    case CSSValueWebkitFocusRingColor:
+    case CSSValueActiveborder:
+    case CSSValueHighlight:
+        // Hardcoded to avoid exposing a user appearance preference to the web for fingerprinting.
+        return SRGBA<uint8_t> { 52, 132, 228 };
+
+    case CSSValueHighlighttext:
+        return Color::white;
+
+    default:
+        return RenderTheme::systemColor(cssValueID, options);
+    }
+}
+
 bool RenderThemeAdwaita::paintTextField(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
 {
     auto& graphicsContext = paintInfo.context();
     GraphicsContextStateSaver stateSaver(graphicsContext);
 
+    SRGBA<uint8_t> textFieldBackgroundColor;
+    SRGBA<uint8_t> textFieldBackgroundDisabledColor;
+    SRGBA<uint8_t> textFieldBorderColor;
+    SRGBA<uint8_t> textFieldBorderDisabledColor;
+
+    if (renderObject.useDarkAppearance()) {
+        textFieldBackgroundColor = textFieldBackgroundColorDark;
+        textFieldBackgroundDisabledColor = textFieldBackgroundDisabledColorDark;
+        textFieldBorderColor= textFieldBorderColorDark;
+        textFieldBorderDisabledColor = textFieldBorderDisabledColorDark;
+    } else {
+        textFieldBackgroundColor = textFieldBackgroundColorLight;
+        textFieldBackgroundDisabledColor = textFieldBackgroundDisabledColorLight;
+        textFieldBorderColor = textFieldBorderColorLight;
+        textFieldBorderDisabledColor = textFieldBorderDisabledColorLight;
+    }
+
     int borderSize = textFieldBorderSize;
     if (isEnabled(renderObject) && !isReadOnlyControl(renderObject) && isFocused(renderObject))
         borderSize *= 2;
@@ -228,7 +314,7 @@
         {
             GraphicsContextStateSaver arrowStateSaver(graphicsContext);
             graphicsContext.translate(arrowRect.x(), arrowRect.y());
-            ThemeAdwaita::paintArrow(graphicsContext, ThemeAdwaita::ArrowDirection::Down);
+            ThemeAdwaita::paintArrow(graphicsContext, ThemeAdwaita::ArrowDirection::Down, renderObject.useDarkAppearance());
         }
     }
 #endif
@@ -236,16 +322,32 @@
     return false;
 }
 
+void RenderThemeAdwaita::adjustTextFieldStyle(RenderStyle& style, const Element*) const
+{
+    if (!style.hasExplicitlySetBorderRadius())
+        style.setBorderRadius(IntSize(5, 5));
+}
+
 bool RenderThemeAdwaita::paintTextArea(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& rect)
 {
     return paintTextField(renderObject, paintInfo, rect);
 }
 
+void RenderThemeAdwaita::adjustTextAreaStyle(RenderStyle& style, const Element* element) const
+{
+    adjustTextFieldStyle(style, element);
+}
+
 bool RenderThemeAdwaita::paintSearchField(const RenderObject& renderObject, const PaintInfo& paintInfo, const IntRect& rect)
 {
     return paintTextField(renderObject, paintInfo, rect);
 }
 
+void RenderThemeAdwaita::adjustSearchFieldStyle(RenderStyle& style, const Element* element) const
+{
+    adjustTextFieldStyle(style, element);
+}
+
 void RenderThemeAdwaita::adjustMenuListStyle(RenderStyle& style, const Element*) const
 {
     style.setLineHeight(RenderStyle::initialLineHeight());
@@ -280,7 +382,7 @@
     if (isHovered(renderObject))
         states.add(ControlStates::States::Hovered);
     ControlStates controlStates(states);
-    Theme::singleton().paint(ButtonPart, controlStates, graphicsContext, rect, 1., nullptr, 1., 1., false, false);
+    Theme::singleton().paint(ButtonPart, controlStates, graphicsContext, rect, 1., nullptr, 1., 1., false, renderObject.useDarkAppearance());
 
     FloatRect fieldRect = rect;
     fieldRect.inflate(menuListButtonBorderSize);
@@ -293,11 +395,11 @@
     {
         GraphicsContextStateSaver arrowStateSaver(graphicsContext);
         graphicsContext.translate(fieldRect.x(), fieldRect.y());
-        ThemeAdwaita::paintArrow(graphicsContext, ThemeAdwaita::ArrowDirection::Down);
+        ThemeAdwaita::paintArrow(graphicsContext, ThemeAdwaita::ArrowDirection::Down, renderObject.useDarkAppearance());
     }
 
     if (isFocused(renderObject))
-        ThemeAdwaita::paintFocus(graphicsContext, rect, menuListButtonFocusOffset);
+        ThemeAdwaita::paintFocus(graphicsContext, rect, menuListButtonFocusOffset, renderObject.useDarkAppearance());
 
     return false;
 }
@@ -330,6 +432,17 @@
     auto& graphicsContext = paintInfo.context();
     GraphicsContextStateSaver stateSaver(graphicsContext);
 
+    SRGBA<uint8_t> progressBarBackgroundColor;
+    SRGBA<uint8_t> progressBarBorderColor;
+
+    if (renderObject.useDarkAppearance()) {
+        progressBarBackgroundColor = progressBarBackgroundColorDark;
+        progressBarBorderColor = progressBarBorderColorDark;
+    } else {
+        progressBarBackgroundColor = progressBarBackgroundColorLight;
+        progressBarBorderColor = progressBarBorderColorLight;
+    }
+
     FloatRect fieldRect = rect;
     FloatSize corner(3, 3);
     Path path;
@@ -397,6 +510,17 @@
         fieldRect.setWidth(6);
     }
 
+    SRGBA<uint8_t> sliderTrackBackgroundColor;
+    SRGBA<uint8_t> sliderTrackBorderColor;
+
+    if (renderObject.useDarkAppearance()) {
+        sliderTrackBackgroundColor = sliderTrackBackgroundColorDark;
+        sliderTrackBorderColor = sliderTrackBorderColorDark;
+    } else {
+        sliderTrackBackgroundColor = sliderTrackBackgroundColorLight;
+        sliderTrackBorderColor = sliderTrackBorderColorLight;
+    }
+
     FloatSize corner(3, 3);
     Path path;
     path.addRoundedRect(fieldRect, corner);
@@ -450,7 +574,7 @@
 #endif
 
     if (isFocused(renderObject))
-        ThemeAdwaita::paintFocus(graphicsContext, fieldRect, sliderTrackFocusOffset);
+        ThemeAdwaita::paintFocus(graphicsContext, fieldRect, sliderTrackFocusOffset, renderObject.useDarkAppearance());
 
     return false;
 }
@@ -472,6 +596,23 @@
 
     ASSERT(renderObject.style().appearance() == SliderThumbHorizontalPart || renderObject.style().appearance() == SliderThumbVerticalPart);
 
+    SRGBA<uint8_t> sliderThumbBackgroundColor;
+    SRGBA<uint8_t> sliderThumbBackgroundHoveredColor;
+    SRGBA<uint8_t> sliderThumbBackgroundDisabledColor;
+    SRGBA<uint8_t> sliderThumbBorderColor;
+
+    if (renderObject.useDarkAppearance()) {
+        sliderThumbBackgroundColor = sliderThumbBackgroundColorDark;
+        sliderThumbBackgroundHoveredColor = sliderThumbBackgroundHoveredColorDark;
+        sliderThumbBackgroundDisabledColor = sliderThumbBackgroundDisabledColorDark;
+        sliderThumbBorderColor = sliderThumbBorderColorDark;
+    } else {
+        sliderThumbBackgroundColor = sliderThumbBackgroundColorLight;
+        sliderThumbBackgroundHoveredColor = sliderThumbBackgroundHoveredColorLight;
+        sliderThumbBackgroundDisabledColor = sliderThumbBackgroundDisabledColorLight;
+        sliderThumbBorderColor = sliderThumbBorderColorLight;
+    }
+
     FloatRect fieldRect = rect;
     Path path;
     path.addEllipse(fieldRect);

Modified: trunk/Source/WebCore/rendering/RenderThemeAdwaita.h (279986 => 279987)


--- trunk/Source/WebCore/rendering/RenderThemeAdwaita.h	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/WebCore/rendering/RenderThemeAdwaita.h	2021-07-16 16:39:15 UTC (rev 279987)
@@ -58,8 +58,13 @@
     void platformColorsDidChange() final;
 
     bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) final;
+    void adjustTextFieldStyle(RenderStyle&, const Element*) const final;
+
     bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) final;
+    void adjustTextAreaStyle(RenderStyle&, const Element*) const final;
+
     bool paintSearchField(const RenderObject&, const PaintInfo&, const IntRect&) final;
+    void adjustSearchFieldStyle(RenderStyle&, const Element*) const final;
 
     bool popsMenuBySpaceOrReturn() const final { return true; }
     void adjustMenuListStyle(RenderStyle&, const Element*) const override;
@@ -82,6 +87,8 @@
     bool paintMediaVolumeSliderTrack(const RenderObject&, const PaintInfo&, const IntRect&) final;
 #endif
 
+    Color systemColor(CSSValueID, OptionSet<StyleColor::Options>) const final;
+
 #if ENABLE(DATALIST_ELEMENT)
     IntSize sliderTickSize() const final;
     int sliderTickOffsetFromTrackCenter() const final;

Modified: trunk/Source/cmake/OptionsGTK.cmake (279986 => 279987)


--- trunk/Source/cmake/OptionsGTK.cmake	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/cmake/OptionsGTK.cmake	2021-07-16 16:39:15 UTC (rev 279987)
@@ -279,6 +279,7 @@
 add_definitions(-DSVN_REVISION="${SVN_REVISION}")
 
 SET_AND_EXPOSE_TO_BUILD(HAVE_GTK_UNIX_PRINTING ${GTK_UNIX_PRINT_FOUND})
+SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)
 
 # GUri is available in GLib since version 2.66, but we only want to use it if version is >= 2.67.1.
 if (PC_GLIB_VERSION VERSION_GREATER "2.67.1" OR PC_GLIB_VERSION STREQUAL "2.67.1")

Modified: trunk/Source/cmake/OptionsWPE.cmake (279986 => 279987)


--- trunk/Source/cmake/OptionsWPE.cmake	2021-07-16 16:13:49 UTC (rev 279986)
+++ trunk/Source/cmake/OptionsWPE.cmake	2021-07-16 16:39:15 UTC (rev 279987)
@@ -47,6 +47,7 @@
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_CONIC_GRADIENTS PRIVATE ON)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_PAINTING_API PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_CSS_TYPED_OM PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_DARK_MODE_CSS PRIVATE ON)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FILTERS_LEVEL_2 PRIVATE ON)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_GPU_PROCESS PRIVATE OFF)
 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_LAYOUT_FORMATTING_CONTEXT PRIVATE ${ENABLE_EXPERIMENTAL_FEATURES})
@@ -284,6 +285,7 @@
 SET_AND_EXPOSE_TO_BUILD(USE_TILED_BACKING_STORE TRUE)
 SET_AND_EXPOSE_TO_BUILD(USE_COORDINATED_GRAPHICS TRUE)
 SET_AND_EXPOSE_TO_BUILD(USE_NICOSIA TRUE)
+SET_AND_EXPOSE_TO_BUILD(HAVE_OS_DARK_MODE_SUPPORT 1)
 
 # GUri is available in GLib since version 2.66, but we only want to use it if version is >= 2.67.1.
 if (PC_GLIB_VERSION VERSION_GREATER "2.67.1" OR PC_GLIB_VERSION STREQUAL "2.67.1")
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to