Title: [284984] trunk
Revision
284984
Author
akeer...@apple.com
Date
2021-10-28 09:15:05 -0700 (Thu, 28 Oct 2021)

Log Message

REGRESSION (r282451): [iOS] Cannot override background of search inputs with 'appearance: textfield'
https://bugs.webkit.org/show_bug.cgi?id=231503
rdar://84110684

Reviewed by Wenson Hsieh.

Source/WebCore:

r282451 made search inputs with 'appearance: textfield' always have the
standard text input background color. This change was necessary to fix
search input styling on sites that did not customize search input
backgrounds, but relied on 'appearance: textfield' to obtain the
appropriate styling.

However, the change also made it so that any customization to the
background color on top of the UA default was not honored. To fix,
check if the background color differs from the UA default prior to
making the adjustment.

Test: fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html

* rendering/RenderThemeIOS.mm:
(WebCore::RenderThemeIOS::adjustTextFieldStyle const):

LayoutTests:

* fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled-expected.txt: Added.
* fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (284983 => 284984)


--- trunk/LayoutTests/ChangeLog	2021-10-28 16:04:44 UTC (rev 284983)
+++ trunk/LayoutTests/ChangeLog	2021-10-28 16:15:05 UTC (rev 284984)
@@ -1,3 +1,14 @@
+2021-10-28  Aditya Keerthi  <akeer...@apple.com>
+
+        REGRESSION (r282451): [iOS] Cannot override background of search inputs with 'appearance: textfield'
+        https://bugs.webkit.org/show_bug.cgi?id=231503
+        rdar://84110684
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled-expected.txt: Added.
+        * fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html: Added.
+
 2021-10-28  Youenn Fablet  <you...@apple.com>
 
         [ Mac wk1 ] 2 media-capabilities/webrtc tests are flaky failures

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled-expected.txt (0 => 284984)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled-expected.txt	2021-10-28 16:15:05 UTC (rev 284984)
@@ -0,0 +1,10 @@
+Test that setting -webkit-appearance: textfield on a search input does not adjust the background color if the specified color differs from the UA default.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS searchBackgroundColor is "rgb(255, 0, 0)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html (0 => 284984)


--- trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html	2021-10-28 16:15:05 UTC (rev 284984)
@@ -0,0 +1,24 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true IOSFormControlRefreshEnabled=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src=""
+    <style>
+    #search {
+        -webkit-appearance: textfield;
+        background-color: red;
+    }
+    </style>
+</head>
+<body>
+<input type="search" id="search">
+</body>
+<script>
+
+description("Test that setting -webkit-appearance: textfield on a search input does not adjust the background color if the specified color differs from the UA default.");
+
+searchBackgroundColor = window.getComputedStyle(search).backgroundColor;
+shouldBeEqualToString("searchBackgroundColor", "rgb(255, 0, 0)");
+
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (284983 => 284984)


--- trunk/Source/WebCore/ChangeLog	2021-10-28 16:04:44 UTC (rev 284983)
+++ trunk/Source/WebCore/ChangeLog	2021-10-28 16:15:05 UTC (rev 284984)
@@ -1,3 +1,27 @@
+2021-10-28  Aditya Keerthi  <akeer...@apple.com>
+
+        REGRESSION (r282451): [iOS] Cannot override background of search inputs with 'appearance: textfield'
+        https://bugs.webkit.org/show_bug.cgi?id=231503
+        rdar://84110684
+
+        Reviewed by Wenson Hsieh.
+
+        r282451 made search inputs with 'appearance: textfield' always have the
+        standard text input background color. This change was necessary to fix
+        search input styling on sites that did not customize search input
+        backgrounds, but relied on 'appearance: textfield' to obtain the
+        appropriate styling.
+
+        However, the change also made it so that any customization to the
+        background color on top of the UA default was not honored. To fix,
+        check if the background color differs from the UA default prior to
+        making the adjustment.
+
+        Test: fast/forms/ios/form-control-refresh/search/textfield-appearance-background-styled.html
+
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::RenderThemeIOS::adjustTextFieldStyle const):
+
 2021-10-28  Youenn Fablet  <you...@apple.com>
 
         Fix CARingBuffer mix mode

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (284983 => 284984)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-10-28 16:04:44 UTC (rev 284983)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2021-10-28 16:15:05 UTC (rev 284984)
@@ -573,12 +573,20 @@
         hasTextfieldAppearance = input.isTextField() && !input.isSearchField();
     }
 
+    auto adjustBackgroundColor = [&] {
+        auto styleColorOptions = element->document().styleColorOptions(&style);
+        if (!style.backgroundColorEqualsToColorIgnoringVisited(systemColor(CSSValueAppleSystemOpaqueTertiaryFill, styleColorOptions)))
+            return;
+
+        style.setBackgroundColor(systemColor(CSSValueWebkitControlBackground, styleColorOptions));
+    };
+
     bool useAlternateDesign = element->document().settings().alternateFormControlDesignEnabled();
     if (useAlternateDesign) {
         if (hasTextfieldAppearance)
             style.setBackgroundColor(Color::transparentBlack);
         else
-            style.setBackgroundColor(systemColor(CSSValueWebkitControlBackground, element->document().styleColorOptions(&style)));
+            adjustBackgroundColor();
         style.resetBorderExceptRadius();
         return;
     }
@@ -586,7 +594,7 @@
     if (hasTextfieldAppearance)
         return;
 
-    style.setBackgroundColor(systemColor(CSSValueWebkitControlBackground, element->document().styleColorOptions(&style)));
+    adjustBackgroundColor();
 }
 
 void RenderThemeIOS::paintTextFieldInnerShadow(const PaintInfo& paintInfo, const FloatRoundedRect& roundedRect)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to