Title: [284232] trunk
Revision
284232
Author
akeer...@apple.com
Date
2021-10-14 21:25:14 -0700 (Thu, 14 Oct 2021)

Log Message

[iOS] Support accent-color for controls without text
https://bugs.webkit.org/show_bug.cgi?id=231762
rdar://84261702

Reviewed by Tim Horton.

Source/WebCore:

Add support for 'accent-color' on checkboxes, radio buttons,
<input type=range>, <progress> elements, and the <datalist>
indicator button.

* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::controlTintColor):
(WebCore::RenderThemeIOS::checkboxRadioBackgroundColor):
(WebCore::RenderThemeIOS::paintCheckbox):
(WebCore::RenderThemeIOS::paintRadio):
(WebCore::RenderThemeIOS::paintProgressBarWithFormControlRefresh):
(WebCore::RenderThemeIOS::paintListButton):
(WebCore::RenderThemeIOS::paintSliderTicks):
(WebCore::RenderThemeIOS::paintSliderTrackWithFormControlRefresh):

LayoutTests:

Add new "Pass" results.

* TestExpectations:
* platform/ios/TestExpectations:
* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284231 => 284232)


--- trunk/LayoutTests/ChangeLog	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/LayoutTests/ChangeLog	2021-10-15 04:25:14 UTC (rev 284232)
@@ -1,3 +1,17 @@
+2021-10-14  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] Support accent-color for controls without text
+        https://bugs.webkit.org/show_bug.cgi?id=231762
+        rdar://84261702
+
+        Reviewed by Tim Horton.
+
+        Add new "Pass" results.
+
+        * TestExpectations:
+        * platform/ios/TestExpectations:
+        * platform/mac/TestExpectations:
+
 2021-10-14  Alan Bujtas  <za...@apple.com>
 
         WPT progression after turning on the IFC codepath for inline boxes with background decoration (r284194).

Modified: trunk/LayoutTests/TestExpectations (284231 => 284232)


--- trunk/LayoutTests/TestExpectations	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/LayoutTests/TestExpectations	2021-10-15 04:25:14 UTC (rev 284232)
@@ -1124,7 +1124,7 @@
 # Support for VP9 encoded videos with transparency is only available on ports that use GStreamer.
 media/video-with-alpha.html [ Skip ]
 
-# accent-color is currently only supported on macOS
+# accent-color is currently only supported on Cocoa platforms
 fast/css/accent-color/checkbox.html [ ImageOnlyFailure ]
 fast/css/accent-color/datalist.html [ ImageOnlyFailure ]
 fast/css/accent-color/progress.html [ ImageOnlyFailure ]

Modified: trunk/LayoutTests/platform/ios/TestExpectations (284231 => 284232)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-10-15 04:25:14 UTC (rev 284232)
@@ -43,6 +43,17 @@
 fast/css/webkit-named-image/apple-pay-logo-white [ Pass ]
 fast/css/getComputedStyle/computed-style-apple-pay-button.html [ Pass ]
 
+# accent-color is currently only supported on Cocoa platforms
+fast/css/accent-color/checkbox.html [ Pass ]
+fast/css/accent-color/datalist.html [ Pass ]
+fast/css/accent-color/progress.html [ Pass ]
+fast/css/accent-color/radio.html [ Pass ]
+fast/css/accent-color/range.html [ Pass ]
+fast/css/accent-color/text.html [ Pass ]
+imported/w3c/web-platform-tests/css/css-ui/accent-color-checkbox-checked-001.tentative.html [ Pass ]
+
+webkit.org/b/231764 fast/css/accent-color/select.html [ ImageOnlyFailure ]
+
 fast/css/ios [ Pass ]
 fast/media/ios [ Pass ]
 

Modified: trunk/LayoutTests/platform/mac/TestExpectations (284231 => 284232)


--- trunk/LayoutTests/platform/mac/TestExpectations	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2021-10-15 04:25:14 UTC (rev 284232)
@@ -2339,7 +2339,7 @@
 
 webkit.org/b/230116 imported/w3c/web-platform-tests/webrtc-extensions/transfer-datachannel.html [ Pass Failure ]
 
-# accent-color is currently only supported on macOS
+# accent-color is currently only supported on Cocoa platforms
 fast/css/accent-color/checkbox.html [ Pass ]
 fast/css/accent-color/progress.html [ Pass ]
 fast/css/accent-color/radio.html [ Pass ]

Modified: trunk/Source/WebCore/ChangeLog (284231 => 284232)


--- trunk/Source/WebCore/ChangeLog	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/Source/WebCore/ChangeLog	2021-10-15 04:25:14 UTC (rev 284232)
@@ -1,3 +1,26 @@
+2021-10-14  Aditya Keerthi  <akeer...@apple.com>
+
+        [iOS] Support accent-color for controls without text
+        https://bugs.webkit.org/show_bug.cgi?id=231762
+        rdar://84261702
+
+        Reviewed by Tim Horton.
+
+        Add support for 'accent-color' on checkboxes, radio buttons,
+        <input type=range>, <progress> elements, and the <datalist>
+        indicator button.
+
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::controlTintColor):
+        (WebCore::RenderThemeIOS::checkboxRadioBackgroundColor):
+        (WebCore::RenderThemeIOS::paintCheckbox):
+        (WebCore::RenderThemeIOS::paintRadio):
+        (WebCore::RenderThemeIOS::paintProgressBarWithFormControlRefresh):
+        (WebCore::RenderThemeIOS::paintListButton):
+        (WebCore::RenderThemeIOS::paintSliderTicks):
+        (WebCore::RenderThemeIOS::paintSliderTrackWithFormControlRefresh):
+
 2021-10-14  Robin Morisset  <rmoris...@apple.com>
 
         Allow WASM to use up to 4GB

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (284231 => 284232)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2021-10-15 04:25:14 UTC (rev 284232)
@@ -119,7 +119,7 @@
 
 #if ENABLE(IOS_FORM_CONTROL_REFRESH)
     Color checkboxRadioBorderColor(OptionSet<ControlStates::States>, OptionSet<StyleColorOptions>);
-    Color checkboxRadioBackgroundColor(bool useAlternateDesign, OptionSet<ControlStates::States>, OptionSet<StyleColorOptions>);
+    Color checkboxRadioBackgroundColor(bool useAlternateDesign, const RenderStyle&, OptionSet<ControlStates::States>, OptionSet<StyleColorOptions>);
     RefPtr<Gradient> checkboxRadioBackgroundGradient(const FloatRect&, OptionSet<ControlStates::States>);
     Color checkboxRadioIndicatorColor(OptionSet<ControlStates::States>, OptionSet<StyleColorOptions>);
 
@@ -205,6 +205,8 @@
 
     Color systemColor(CSSValueID, OptionSet<StyleColorOptions>) const override;
 
+    Color controlTintColor(const RenderStyle&, OptionSet<StyleColorOptions>) const;
+
     void adjustStyleForAlternateFormControlDesignTransition(RenderStyle&, const Element*) const;
 
 #if USE(SYSTEM_PREVIEW)

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (284231 => 284232)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-10-15 03:20:18 UTC (rev 284231)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-10-15 04:25:14 UTC (rev 284232)
@@ -1556,6 +1556,15 @@
     }).iterator->value;
 }
 
+Color RenderThemeIOS::controlTintColor(const RenderStyle& style, OptionSet<StyleColorOptions> options) const
+{
+    Color tintColor = style.effectiveAccentColor();
+    if (tintColor.isValid())
+        return tintColor;
+
+    return systemColor(CSSValueAppleSystemBlue, options);
+}
+
 #if ENABLE(ATTACHMENT_ELEMENT)
 
 const CGSize attachmentSize = { 160, 119 };
@@ -2161,7 +2170,7 @@
     return defaultBorderColor;
 }
 
-Color RenderThemeIOS::checkboxRadioBackgroundColor(bool useAlternateDesign, OptionSet<ControlStates::States> states, OptionSet<StyleColorOptions> styleColorOptions)
+Color RenderThemeIOS::checkboxRadioBackgroundColor(bool useAlternateDesign, const RenderStyle& style, OptionSet<ControlStates::States> states, OptionSet<StyleColorOptions> styleColorOptions)
 {
     bool isEmpty = !states.containsAny({ ControlStates::States::Checked, ControlStates::States::Indeterminate });
     bool isEnabled = states.contains(ControlStates::States::Enabled);
@@ -2181,7 +2190,7 @@
     if (!isEnabled)
         return systemColor(isEmpty ? CSSValueWebkitControlBackground : CSSValueAppleSystemOpaqueTertiaryFill, styleColorOptions);
 
-    auto enabledBackgroundColor = systemColor(isEmpty ? CSSValueWebkitControlBackground : CSSValueAppleSystemBlue, styleColorOptions);
+    auto enabledBackgroundColor = isEmpty ? systemColor(CSSValueWebkitControlBackground, styleColorOptions) : controlTintColor(style, styleColorOptions);
     if (isPressed)
         return enabledBackgroundColor.colorWithAlphaMultipliedBy(pressedStateOpacity);
 
@@ -2271,7 +2280,7 @@
     auto controlStates = extractControlStatesForRenderer(box);
     auto styleColorOptions = box.styleColorOptions();
 
-    auto backgroundColor = checkboxRadioBackgroundColor(useAlternateDesign, controlStates, styleColorOptions);
+    auto backgroundColor = checkboxRadioBackgroundColor(useAlternateDesign, box.style(), controlStates, styleColorOptions);
 
     bool checked = controlStates.contains(ControlStates::States::Checked);
     bool indeterminate = controlStates.contains(ControlStates::States::Indeterminate);
@@ -2354,7 +2363,7 @@
     auto controlStates = extractControlStatesForRenderer(box);
     auto styleColorOptions = box.styleColorOptions();
 
-    auto backgroundColor = checkboxRadioBackgroundColor(useAlternateDesign, controlStates, styleColorOptions);
+    auto backgroundColor = checkboxRadioBackgroundColor(useAlternateDesign, box.style(), controlStates, styleColorOptions);
 
     FloatRoundedRect radioRect { rect, FloatRoundedRect::Radii(rect.width() / 2, rect.height() / 2) };
 
@@ -2476,7 +2485,7 @@
     }
 
     FloatRect barRect(barLeft, barTop, barWidth, barHeight);
-    context.fillRoundedRect(FloatRoundedRect(barRect, barCornerRadii), systemColor(CSSValueAppleSystemBlue, styleColorOptions).colorWithAlphaMultipliedBy(alpha));
+    context.fillRoundedRect(FloatRoundedRect(barRect, barCornerRadii), controlTintColor(renderer.style(), styleColorOptions).colorWithAlphaMultipliedBy(alpha));
 
     return false;
 }
@@ -2574,7 +2583,7 @@
     transform.scale(scale);
     path.transform(transform);
 
-    context.setFillColor(systemColor(CSSValueAppleSystemBlue, box.styleColorOptions()));
+    context.setFillColor(controlTintColor(style, box.styleColorOptions()));
     context.fillPath(path);
 
     return false;
@@ -2638,7 +2647,7 @@
                 tickRect.setY(rect.y() + tickRatio * (rect.height() - tickRect.height()));
 
             FloatRoundedRect roundedTickRect(snapRectToDevicePixels(LayoutRect(tickRect), deviceScaleFactor), tickCornerRadii);
-            context.fillRoundedRect(roundedTickRect, systemColor((value >= *optionValue) ? CSSValueAppleSystemBlue : CSSValueAppleSystemOpaqueSeparator, styleColorOptions));
+            context.fillRoundedRect(roundedTickRect, (value >= *optionValue) ? controlTintColor(box.style(), styleColorOptions) : systemColor(CSSValueAppleSystemOpaqueSeparator, styleColorOptions));
         }
     }
 }
@@ -2714,7 +2723,7 @@
     }
 
     FloatRoundedRect fillRect(trackClip, cornerRadii);
-    context.fillRoundedRect(fillRect, systemColor(CSSValueAppleSystemBlue, styleColorOptions));
+    context.fillRoundedRect(fillRect, controlTintColor(box.style(), styleColorOptions));
 
     return false;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to