Title: [287529] trunk
Revision
287529
Author
[email protected]
Date
2022-01-02 21:52:39 -0800 (Sun, 02 Jan 2022)

Log Message

Access key should work on focusable element.
https://bugs.webkit.org/show_bug.cgi?id=72359

Reviewed by Darin Adler.

Source/WebCore:

Elements that have "accesskey" attribute and are focusable should be focused when you use the access key,
this is happening for some elements but not all.
To fix the issue this patch moves accessKeyAction() implementation from some subclasses to HTMLElement,
which makes us match other browsers.

This patch changes the behavior for HTMLAnchorElement, as it was not focused before, but that matches other browsers too.

Test: fast/dom/accesskey-focus-element.html

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::accessKeyAction): Deleted.
* html/HTMLAnchorElement.h:
* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::accessKeyAction): Deleted.
* html/HTMLButtonElement.h:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::accessKeyAction):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::accessKeyAction): Deleted.
* html/HTMLSelectElement.h:

LayoutTests:

Add new test to check the behavior of accesskey on focusable and not focusable DIV, together with other elements
like INPUT, SELECT and A.
Update expectations for fast/forms/access-key.html test, as now more elements are focused than before.
Apart from that we had to modify accessibility/mac/search-predicate-visited-links.html as that was pressing a link
and the link is now focused.

This will make us also pass css/selectors/focus-visible-024.html from WPT, but that test cannot run properly on WebKit
due to webkit.org/b/234139.

* accessibility/mac/search-predicate-visited-links.html: Update test due to change of behavior.
* fast/dom/accesskey-focus-element-expected.txt: Added.
* fast/dom/accesskey-focus-element.html: Added.
* fast/forms/access-key-expected.txt: Update expectations.
* platform/ios/TestExpectations: Skip new accesskey test.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287528 => 287529)


--- trunk/LayoutTests/ChangeLog	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/LayoutTests/ChangeLog	2022-01-03 05:52:39 UTC (rev 287529)
@@ -1,3 +1,25 @@
+2022-01-02  Manuel Rego Casasnovas  <[email protected]>
+
+        Access key should work on focusable element.
+        https://bugs.webkit.org/show_bug.cgi?id=72359
+
+        Reviewed by Darin Adler.
+
+        Add new test to check the behavior of accesskey on focusable and not focusable DIV, together with other elements
+        like INPUT, SELECT and A.
+        Update expectations for fast/forms/access-key.html test, as now more elements are focused than before.
+        Apart from that we had to modify accessibility/mac/search-predicate-visited-links.html as that was pressing a link
+        and the link is now focused.
+
+        This will make us also pass css/selectors/focus-visible-024.html from WPT, but that test cannot run properly on WebKit
+        due to webkit.org/b/234139.
+
+        * accessibility/mac/search-predicate-visited-links.html: Update test due to change of behavior.
+        * fast/dom/accesskey-focus-element-expected.txt: Added.
+        * fast/dom/accesskey-focus-element.html: Added.
+        * fast/forms/access-key-expected.txt: Update expectations.
+        * platform/ios/TestExpectations: Skip new accesskey test.
+
 2022-01-02  Diego Pino Garcia  <[email protected]>
 
         [GTK] Unreviewed test gardening, emit baseline for imported/w3c/web-platform-tests/css/selectors/focus-visible-002.html

Modified: trunk/LayoutTests/accessibility/mac/search-predicate-visited-links.html (287528 => 287529)


--- trunk/LayoutTests/accessibility/mac/search-predicate-visited-links.html	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/LayoutTests/accessibility/mac/search-predicate-visited-links.html	2022-01-03 05:52:39 UTC (rev 287529)
@@ -31,7 +31,6 @@
         accessibilityController.focusedElement.childAtIndex(0).childAtIndex(0).press();
         setTimeout(function() {
 
-            startElement = accessibilityController.focusedElement.childAtIndex(0);
             resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXVisitedLinkSearchKey", "", false);
             shouldBe("resultElement.boolAttributeValue('AXVisited')", "true");
             shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");

Added: trunk/LayoutTests/fast/dom/accesskey-focus-element-expected.txt (0 => 287529)


--- trunk/LayoutTests/fast/dom/accesskey-focus-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/accesskey-focus-element-expected.txt	2022-01-03 05:52:39 UTC (rev 287529)
@@ -0,0 +1,8 @@
+
+
+PASS DIV element with tabindex can be focused via accesskey
+PASS DIV element without tabindex can NOT be focused via accesskey
+PASS INPUT element can be focused via accesskey
+PASS SELECT element can be focused via accesskey
+PASS A element can be focused via accesskey
+

Added: trunk/LayoutTests/fast/dom/accesskey-focus-element.html (0 => 287529)


--- trunk/LayoutTests/fast/dom/accesskey-focus-element.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/accesskey-focus-element.html	2022-01-03 05:52:39 UTC (rev 287529)
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>accesskey focus element</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+
+<div id="focusableDiv" tabindex="0" accesskey="a"></div>
+<div id="nonFocusableDiv" accesskey="b"></div>
+<input id="input" accesskey="c"</input>
+<select id="select" accesskey="d"></select>
+<a id="link" href="" accesskey="e"></a>
+
+<script>
+
+function pressAccessKey(key)
+{
+    if (navigator.userAgent.search(/\bMac OS X\b/) != -1)
+        modifiers = ["ctrlKey", "altKey"];
+    else
+        modifiers = ["altKey"];
+    eventSender.keyDown(key, modifiers);
+}
+
+test(() => {
+    pressAccessKey("a");
+    assert_equals(document.activeElement, focusableDiv);
+}, "DIV element with tabindex can be focused via accesskey");
+test(() => {
+    pressAccessKey("b");
+    assert_equals(document.activeElement, focusableDiv);
+}, "DIV element without tabindex can NOT be focused via accesskey");
+test(() => {
+    pressAccessKey("c");
+    assert_equals(document.activeElement, input);
+}, "INPUT element can be focused via accesskey");
+test(() => {
+    pressAccessKey("d");
+    assert_equals(document.activeElement, select);
+}, "SELECT element can be focused via accesskey");
+test(() => {
+    pressAccessKey("e");
+    assert_equals(document.activeElement, link);
+}, "A element can be focused via accesskey");
+
+</script>

Modified: trunk/LayoutTests/fast/forms/access-key-expected.txt (287528 => 287529)


--- trunk/LayoutTests/fast/forms/access-key-expected.txt	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/LayoutTests/fast/forms/access-key-expected.txt	2022-01-03 05:52:39 UTC (rev 287529)
@@ -17,11 +17,14 @@
 5 input type submit clicked
 6 input type reset focussed
 6 input type reset clicked
+7 link focussed
 7 link clicked
 8 input type associated to legend focussed
 9 input type associated to label around input focussed
 a input type associated to label closed before input focussed
+b area 1 focussed
 b area 1 clicked
+c area 2 focussed
 c area 2 clicked
 d select focussed
 d select clicked

Modified: trunk/LayoutTests/platform/ios/TestExpectations (287528 => 287529)


--- trunk/LayoutTests/platform/ios/TestExpectations	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2022-01-03 05:52:39 UTC (rev 287529)
@@ -968,6 +968,7 @@
 fast/forms/restore-selection-after-layout.html [ Skip ]
 fast/forms/search-event-delay.html [ Skip ]
 fast/forms/select-accesskey.html [ Skip ]
+fast/dom/accesskey-focus-element.html [ Skip ]
 fast/forms/select-cache-desynchronization.html [ Skip ]
 fast/forms/select-double-onchange.html [ Skip ]
 fast/forms/select-popup-pagekeys.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (287528 => 287529)


--- trunk/Source/WebCore/ChangeLog	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/ChangeLog	2022-01-03 05:52:39 UTC (rev 287529)
@@ -1,3 +1,31 @@
+2022-01-02  Manuel Rego Casasnovas  <[email protected]>
+
+        Access key should work on focusable element.
+        https://bugs.webkit.org/show_bug.cgi?id=72359
+
+        Reviewed by Darin Adler.
+
+        Elements that have "accesskey" attribute and are focusable should be focused when you use the access key,
+        this is happening for some elements but not all.
+        To fix the issue this patch moves accessKeyAction() implementation from some subclasses to HTMLElement,
+        which makes us match other browsers.
+
+        This patch changes the behavior for HTMLAnchorElement, as it was not focused before, but that matches other browsers too.
+
+        Test: fast/dom/accesskey-focus-element.html
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::accessKeyAction): Deleted.
+        * html/HTMLAnchorElement.h:
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::accessKeyAction): Deleted.
+        * html/HTMLButtonElement.h:
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::accessKeyAction):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::accessKeyAction): Deleted.
+        * html/HTMLSelectElement.h:
+
 2022-01-02  Diego Pino Garcia  <[email protected]>
 
         [GTK] Unreviewed build fix after r287519

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp	2022-01-03 05:52:39 UTC (rev 287529)
@@ -271,11 +271,6 @@
         HTMLElement::parseAttribute(name, value);
 }
 
-bool HTMLAnchorElement::accessKeyAction(bool sendMouseEvents)
-{
-    return dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
-}
-
 bool HTMLAnchorElement::isURLAttribute(const Attribute& attribute) const
 {
     return attribute.name().localName() == hrefAttr || HTMLElement::isURLAttribute(attribute);

Modified: trunk/Source/WebCore/html/HTMLAnchorElement.h (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLAnchorElement.h	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.h	2022-01-03 05:52:39 UTC (rev 287529)
@@ -91,7 +91,6 @@
     bool isKeyboardFocusable(KeyboardEvent*) const override;
     void defaultEventHandler(Event&) final;
     void setActive(bool active, bool pause, Style::InvalidationScope) final;
-    bool accessKeyAction(bool sendMouseEvents) final;
     bool isURLAttribute(const Attribute&) const final;
     bool canStartSelection() const final;
     String target() const override;

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2022-01-03 05:52:39 UTC (rev 287529)
@@ -223,13 +223,6 @@
     return true;
 }
 
-bool HTMLButtonElement::accessKeyAction(bool sendMouseEvents)
-{
-    focus();
-
-    return dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
-}
-
 bool HTMLButtonElement::isURLAttribute(const Attribute& attribute) const
 {
     return attribute.name() == formactionAttr || HTMLFormControlElement::isURLAttribute(attribute);

Modified: trunk/Source/WebCore/html/HTMLButtonElement.h (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLButtonElement.h	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLButtonElement.h	2022-01-03 05:52:39 UTC (rev 287529)
@@ -70,7 +70,6 @@
     bool isActivatedSubmit() const final;
     void setActivatedSubmit(bool flag) final;
 
-    bool accessKeyAction(bool sendMouseEvents) final;
     bool isURLAttribute(const Attribute&) const final;
 
     bool canStartSelection() const final { return false; }

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2022-01-03 05:52:39 UTC (rev 287529)
@@ -645,6 +645,8 @@
 
 bool HTMLElement::accessKeyAction(bool sendMouseEvents)
 {
+    if (isFocusable())
+        focus();
     return dispatchSimulatedClick(nullptr, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
 }
 

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2022-01-03 05:52:39 UTC (rev 287529)
@@ -388,12 +388,6 @@
         cache->childrenChanged(this);
 }
 
-bool HTMLSelectElement::accessKeyAction(bool sendMouseEvents)
-{
-    focus();
-    return dispatchSimulatedClick(0, sendMouseEvents ? SendMouseUpDownEvents : SendNoEvents);
-}
-
 void HTMLSelectElement::setMultiple(bool multiple)
 {
     bool oldMultiple = this->multiple();

Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (287528 => 287529)


--- trunk/Source/WebCore/html/HTMLSelectElement.h	2022-01-03 05:40:18 UTC (rev 287528)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h	2022-01-03 05:52:39 UTC (rev 287529)
@@ -73,7 +73,6 @@
 
     WEBCORE_EXPORT const Vector<HTMLElement*>& listItems() const;
 
-    bool accessKeyAction(bool sendMouseEvents) final;
     void accessKeySetSelectedIndex(int);
 
     WEBCORE_EXPORT void setMultiple(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to