Title: [279002] trunk/Source/WebCore
Revision
279002
Author
akeer...@apple.com
Date
2021-06-17 11:57:04 -0700 (Thu, 17 Jun 2021)

Log Message

REGRESSION (r277067): Incorrect text color for default-button appearance
https://bugs.webkit.org/show_bug.cgi?id=227129
<rdar://problem/79032808>

Reviewed by Tim Horton.

Buttons styled with '-webkit-appearance: default-button' currently rely
on the CSS value 'activebuttontext' for their text color. r277067
updated the color to use system colors, for consistency with the rest
of the platform.

In macOS Monterey, the 'activebuttontext' color and the default button
text color are not equivalent. 'Active' buttons no longer use
NSBackgroundStyleEmphasized, while default buttons still do.
Consequently, default buttons are rendered with an incorrect text color.

To fix, use the correct system color for the text color of default
buttons. To avoid changing the behavior of platforms other than
macOS, the 'activebuttontext' color remains the default text color
specified in RenderTheme.

* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::defaultButtonTextColor const):
(WebCore::RenderTheme::platformDefaultButtonTextColor const):
* rendering/RenderTheme.h:
* rendering/RenderThemeMac.h:
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::platformDefaultButtonTextColor const):
* rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279001 => 279002)


--- trunk/Source/WebCore/ChangeLog	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/ChangeLog	2021-06-17 18:57:04 UTC (rev 279002)
@@ -1,3 +1,36 @@
+2021-06-17  Aditya Keerthi  <akeer...@apple.com>
+
+        REGRESSION (r277067): Incorrect text color for default-button appearance
+        https://bugs.webkit.org/show_bug.cgi?id=227129
+        <rdar://problem/79032808>
+
+        Reviewed by Tim Horton.
+
+        Buttons styled with '-webkit-appearance: default-button' currently rely
+        on the CSS value 'activebuttontext' for their text color. r277067
+        updated the color to use system colors, for consistency with the rest
+        of the platform.
+
+        In macOS Monterey, the 'activebuttontext' color and the default button
+        text color are not equivalent. 'Active' buttons no longer use
+        NSBackgroundStyleEmphasized, while default buttons still do.
+        Consequently, default buttons are rendered with an incorrect text color.
+
+        To fix, use the correct system color for the text color of default
+        buttons. To avoid changing the behavior of platforms other than
+        macOS, the 'activebuttontext' color remains the default text color
+        specified in RenderTheme.
+
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::defaultButtonTextColor const):
+        (WebCore::RenderTheme::platformDefaultButtonTextColor const):
+        * rendering/RenderTheme.h:
+        * rendering/RenderThemeMac.h:
+        * rendering/RenderThemeMac.mm:
+        (WebCore::RenderThemeMac::platformDefaultButtonTextColor const):
+        * rendering/TextPaintStyle.cpp:
+        (WebCore::computeTextPaintStyle):
+
 2021-06-17  Enrique Ocaña González  <eoca...@igalia.com>
 
         [GTK] Unexpected timeout in http/tests/media/video-play-stall-seek.html

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (279001 => 279002)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2021-06-17 18:57:04 UTC (rev 279002)
@@ -1400,6 +1400,19 @@
 }
 #endif
 
+Color RenderTheme::defaultButtonTextColor(OptionSet<StyleColor::Options> options) const
+{
+    auto& cache = colorCache(options);
+    if (!cache.defaultButtonTextColor.isValid())
+        cache.defaultButtonTextColor = platformDefaultButtonTextColor(options);
+    return cache.defaultButtonTextColor;
+}
+
+Color RenderTheme::platformDefaultButtonTextColor(OptionSet<StyleColor::Options> options) const
+{
+    return systemColor(CSSValueActivebuttontext, options);
+}
+
 #if ENABLE(TOUCH_EVENTS)
 
 Color RenderTheme::tapHighlightColor()

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (279001 => 279002)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2021-06-17 18:57:04 UTC (rev 279002)
@@ -166,6 +166,8 @@
     Color appHighlightColor(OptionSet<StyleColor::Options>) const;
 #endif
 
+    Color defaultButtonTextColor(OptionSet<StyleColor::Options>) const;
+
     Color datePlaceholderTextColor(const Color& textColor, const Color& backgroundColor) const;
 
     virtual Color disabledTextColor(const Color& textColor, const Color& backgroundColor) const;
@@ -284,6 +286,9 @@
 #if ENABLE(APP_HIGHLIGHTS)
     virtual Color platformAppHighlightColor(OptionSet<StyleColor::Options>) const;
 #endif
+
+    virtual Color platformDefaultButtonTextColor(OptionSet<StyleColor::Options>) const;
+
     virtual bool supportsSelectionForegroundColors(OptionSet<StyleColor::Options>) const { return true; }
     virtual bool supportsListBoxSelectionForegroundColors(OptionSet<StyleColor::Options>) const { return true; }
 
@@ -442,6 +447,8 @@
 #if ENABLE(APP_HIGHLIGHTS)
         Color appHighlightColor;
 #endif
+
+        Color defaultButtonTextColor;
     };
 
     virtual ColorCache& colorCache(OptionSet<StyleColor::Options>) const;

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (279001 => 279002)


--- trunk/Source/WebCore/rendering/RenderThemeMac.h	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h	2021-06-17 18:57:04 UTC (rev 279002)
@@ -69,6 +69,7 @@
 #if ENABLE(APP_HIGHLIGHTS)
     Color platformAppHighlightColor(OptionSet<StyleColor::Options>) const final;
 #endif
+    Color platformDefaultButtonTextColor(OptionSet<StyleColor::Options>) const final;
 
     ScrollbarControlSize scrollbarControlSizeForPart(ControlPart) final { return ScrollbarControlSize::Small; }
 

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (279001 => 279002)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2021-06-17 18:57:04 UTC (rev 279002)
@@ -404,6 +404,12 @@
 }
 #endif
 
+Color RenderThemeMac::platformDefaultButtonTextColor(OptionSet<StyleColor::Options> options) const
+{
+    LocalDefaultSystemAppearance localAppearance(options.contains(StyleColor::Options::UseDarkAppearance));
+    return colorFromNSColor([NSColor alternateSelectedControlTextColor]);
+}
+
 static Color activeButtonTextColor()
 {
     // FIXME: <rdar://problem/77572622> There is no single corresponding NSColor for ActiveButtonText.

Modified: trunk/Source/WebCore/rendering/TextPaintStyle.cpp (279001 => 279002)


--- trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2021-06-17 18:43:54 UTC (rev 279001)
+++ trunk/Source/WebCore/rendering/TextPaintStyle.cpp	2021-06-17 18:57:04 UTC (rev 279002)
@@ -108,7 +108,7 @@
             OptionSet<StyleColor::Options> options;
             if (page->useSystemAppearance())
                 options.add(StyleColor::Options::UseSystemAppearance);
-            paintStyle.fillColor = RenderTheme::singleton().systemColor(CSSValueActivebuttontext, options);
+            paintStyle.fillColor = RenderTheme::singleton().defaultButtonTextColor(options);
             return paintStyle;
         }
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to