Title: [286776] trunk
Revision
286776
Author
[email protected]
Date
2021-12-09 06:03:45 -0800 (Thu, 09 Dec 2021)

Log Message

[selectors] Match :focus-visible on <select> elements
https://bugs.webkit.org/show_bug.cgi?id=233924

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/forms/select-listbox-focusring.html

* dom/Element.cpp:
(WebCore::shouldAlwaysHaveFocusVisibleWhenFocused):

LayoutTests:

* fast/forms/select-listbox-focusring-expected.html: Added.
* fast/forms/select-listbox-focusring.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (286775 => 286776)


--- trunk/LayoutTests/ChangeLog	2021-12-09 13:14:30 UTC (rev 286775)
+++ trunk/LayoutTests/ChangeLog	2021-12-09 14:03:45 UTC (rev 286776)
@@ -1,3 +1,13 @@
+2021-12-09  Manuel Rego Casasnovas  <[email protected]>
+
+        [selectors] Match :focus-visible on <select> elements
+        https://bugs.webkit.org/show_bug.cgi?id=233924
+
+        Reviewed by Antti Koivisto.
+
+        * fast/forms/select-listbox-focusring-expected.html: Added.
+        * fast/forms/select-listbox-focusring.html: Added.
+
 2021-12-08  Patrick Griffis  <[email protected]>
 
         CSP: Skip whitespace at beginning of policy header

Added: trunk/LayoutTests/fast/forms/select-listbox-focusring-expected.html (0 => 286776)


--- trunk/LayoutTests/fast/forms/select-listbox-focusring-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select-listbox-focusring-expected.html	2021-12-09 14:03:45 UTC (rev 286776)
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<p>This test checks that focusing a SELECT element via mouse click, after focusing a previous element via mouse click, the SELECT element shows a focus ring.</p>
+<p id="instructions"></p>
+<input id="input">
+<select id="select">
+    <option>a</option>
+    <option>b</option>
+</select>
+
+<script>
+    function clickElement(element) {
+        if (window.eventSender) {
+            eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+        else {
+            instructions.innerHTML = "Click on the element " + element.tagName;
+        }
+    }
+
+    clickElement(select);
+</script>

Added: trunk/LayoutTests/fast/forms/select-listbox-focusring.html (0 => 286776)


--- trunk/LayoutTests/fast/forms/select-listbox-focusring.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/select-listbox-focusring.html	2021-12-09 14:03:45 UTC (rev 286776)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<p>This test checks that focusing a SELECT element via mouse click, after focusing a previous element via mouse click, the SELECT element shows a focus ring.</p>
+<p id="instructions"></p>
+<input id="input">
+<select id="select">
+    <option>a</option>
+    <option>b</option>
+</select>
+
+<script>
+    function clickElement(element) {
+        if (window.eventSender) {
+            eventSender.mouseMoveTo(element.offsetLeft + 5, element.offsetTop + 5);
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+        else {
+            instructions.innerHTML = "Click on the element " + element.tagName;
+        }
+    }
+
+    target.addEventListener("focus", () => {
+        clickElement(select);
+    });
+    clickElement(target);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (286775 => 286776)


--- trunk/Source/WebCore/ChangeLog	2021-12-09 13:14:30 UTC (rev 286775)
+++ trunk/Source/WebCore/ChangeLog	2021-12-09 14:03:45 UTC (rev 286776)
@@ -1,3 +1,15 @@
+2021-12-09  Manuel Rego Casasnovas  <[email protected]>
+
+        [selectors] Match :focus-visible on <select> elements
+        https://bugs.webkit.org/show_bug.cgi?id=233924
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/forms/select-listbox-focusring.html
+
+        * dom/Element.cpp:
+        (WebCore::shouldAlwaysHaveFocusVisibleWhenFocused):
+
 2021-12-09  Antti Koivisto  <[email protected]>
 
         [selectors] Use :focus-visible in the user agent style sheet

Modified: trunk/Source/WebCore/dom/Element.cpp (286775 => 286776)


--- trunk/Source/WebCore/dom/Element.cpp	2021-12-09 13:14:30 UTC (rev 286775)
+++ trunk/Source/WebCore/dom/Element.cpp	2021-12-09 14:03:45 UTC (rev 286776)
@@ -807,7 +807,7 @@
 
 static bool shouldAlwaysHaveFocusVisibleWhenFocused(const Element& element)
 {
-    return element.isTextField() || element.isContentEditable();
+    return element.isTextField() || element.isContentEditable() || is<HTMLSelectElement>(element);
 }
 
 void Element::setFocus(bool flag, FocusVisibility visibility)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to