Title: [256725] trunk
Revision
256725
Author
[email protected]
Date
2020-02-17 01:37:15 -0800 (Mon, 17 Feb 2020)

Log Message

Search cancel button becomes visible when there's a hover effect in CSS
https://bugs.webkit.org/show_bug.cgi?id=207328

Reviewed by Adrian Perez de Castro.

Source/WebCore:

Use a custom style resolver for search cancel button element to ensure it's always hidden when the input element
is empty.

Test: fast/forms/search-cancel-button-hover.html

* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): Call setHasCustomStyleResolveCallbacks().
(WebCore::SearchFieldCancelButtonElement::resolveCustomStyle): Set the render style visibility depending on
input current value.
* html/shadow/TextControlInnerElements.h:

LayoutTests:

* fast/forms/search-cancel-button-hover-expected.html: Added.
* fast/forms/search-cancel-button-hover.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (256724 => 256725)


--- trunk/LayoutTests/ChangeLog	2020-02-17 09:07:52 UTC (rev 256724)
+++ trunk/LayoutTests/ChangeLog	2020-02-17 09:37:15 UTC (rev 256725)
@@ -1,3 +1,13 @@
+2020-02-17  Carlos Garcia Campos  <[email protected]>
+
+        Search cancel button becomes visible when there's a hover effect in CSS
+        https://bugs.webkit.org/show_bug.cgi?id=207328
+
+        Reviewed by Adrian Perez de Castro.
+
+        * fast/forms/search-cancel-button-hover-expected.html: Added.
+        * fast/forms/search-cancel-button-hover.html: Added.
+
 2020-02-16  Lauro Moura  <[email protected]>
 
         [GTK] More debug build timeouts gardening

Added: trunk/LayoutTests/fast/forms/search-cancel-button-hover-expected.html (0 => 256725)


--- trunk/LayoutTests/fast/forms/search-cancel-button-hover-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/search-cancel-button-hover-expected.html	2020-02-17 09:37:15 UTC (rev 256725)
@@ -0,0 +1,23 @@
+<html>
+<head>
+<style>
+input[type="search"] {
+    color: transparent;
+}
+
+input[type="search"]::-webkit-search-cancel-button {
+    -webkit-appearance: none;
+    background-color: blue;
+    height: 1em;
+    width: 1em;
+}
+
+input[type="search"]::-webkit-search-cancel-button:hover {
+    background-color: red;
+}
+</style>
+</head>
+<body>
+<input type="search" id="search" autofocus/>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/search-cancel-button-hover.html (0 => 256725)


--- trunk/LayoutTests/fast/forms/search-cancel-button-hover.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/search-cancel-button-hover.html	2020-02-17 09:37:15 UTC (rev 256725)
@@ -0,0 +1,34 @@
+<html>
+<head>
+<style>
+input[type="search"] {
+    color: transparent;
+}
+
+input[type="search"]::-webkit-search-cancel-button {
+    -webkit-appearance: none;
+    background-color: blue;
+    height: 1em;
+    width: 1em;
+}
+
+input[type="search"]::-webkit-search-cancel-button:hover {
+    background-color: red;
+}
+</style>
+<script src=""
+</head>
+<body>
+<input type="search" id="search" value="foo"/>
+<script>
+if (window.testRunner) {
+    var input = document.getElementById("search");
+    var position = searchCancelButtonPosition(input);
+    eventSender.mouseMoveTo(position.x, position.y);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+    eventSender.mouseMoveTo(position.x + 1, position.y);
+}
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (256724 => 256725)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2020-02-17 09:07:52 UTC (rev 256724)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2020-02-17 09:37:15 UTC (rev 256725)
@@ -1027,6 +1027,7 @@
 fast/shadow-dom/fullscreen-in-slot-fullscreenElement.html [ Skip ]
 fast/shadow-dom/fullscreen-in-slot-webkitCurrentFullScreenElement.html [ Skip ]
 fast/events/focus-label-legend-elements-with-tab.html [ Skip ]
+fast/forms/search-cancel-button-hover.html [ Skip ]
 
 # No touch events
 fast/visual-viewport/ios/bottom-bar-with-keyboard.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (256724 => 256725)


--- trunk/Source/WebCore/ChangeLog	2020-02-17 09:07:52 UTC (rev 256724)
+++ trunk/Source/WebCore/ChangeLog	2020-02-17 09:37:15 UTC (rev 256725)
@@ -1,5 +1,23 @@
 2020-02-17  Carlos Garcia Campos  <[email protected]>
 
+        Search cancel button becomes visible when there's a hover effect in CSS
+        https://bugs.webkit.org/show_bug.cgi?id=207328
+
+        Reviewed by Adrian Perez de Castro.
+
+        Use a custom style resolver for search cancel button element to ensure it's always hidden when the input element
+        is empty.
+
+        Test: fast/forms/search-cancel-button-hover.html
+
+        * html/shadow/TextControlInnerElements.cpp:
+        (WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): Call setHasCustomStyleResolveCallbacks().
+        (WebCore::SearchFieldCancelButtonElement::resolveCustomStyle): Set the render style visibility depending on
+        input current value.
+        * html/shadow/TextControlInnerElements.h:
+
+2020-02-17  Carlos Garcia Campos  <[email protected]>
+
         [WPE] Use custom theme style to render text fields
         https://bugs.webkit.org/show_bug.cgi?id=207379
 

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp (256724 => 256725)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2020-02-17 09:07:52 UTC (rev 256724)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.cpp	2020-02-17 09:37:15 UTC (rev 256725)
@@ -252,6 +252,8 @@
 inline SearchFieldCancelButtonElement::SearchFieldCancelButtonElement(Document& document)
     : HTMLDivElement(divTag, document)
 {
+    setHasCustomStyleResolveCallbacks();
+
     setPseudo(AtomString("-webkit-search-cancel-button", AtomString::ConstructFromLiteral));
 #if !PLATFORM(IOS_FAMILY)
     setAttributeWithoutSynchronization(aria_labelAttr, AXSearchFieldCancelButtonText());
@@ -264,6 +266,14 @@
     return adoptRef(*new SearchFieldCancelButtonElement(document));
 }
 
+Optional<Style::ElementStyle> SearchFieldCancelButtonElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle*)
+{
+    auto elementStyle = resolveStyle(&parentStyle);
+    auto& inputElement = downcast<HTMLInputElement>(*shadowHost());
+    elementStyle.renderStyle->setVisibility(elementStyle.renderStyle->visibility() == Visibility::Hidden || inputElement.value().isEmpty() ? Visibility::Hidden : Visibility::Visible);
+    return elementStyle;
+}
+
 void SearchFieldCancelButtonElement::defaultEventHandler(Event& event)
 {
     RefPtr<HTMLInputElement> input(downcast<HTMLInputElement>(shadowHost()));

Modified: trunk/Source/WebCore/html/shadow/TextControlInnerElements.h (256724 => 256725)


--- trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2020-02-17 09:07:52 UTC (rev 256724)
+++ trunk/Source/WebCore/html/shadow/TextControlInnerElements.h	2020-02-17 09:37:15 UTC (rev 256725)
@@ -112,6 +112,7 @@
 private:
     SearchFieldCancelButtonElement(Document&);
     bool isMouseFocusable() const override { return false; }
+    Optional<Style::ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to