Title: [259065] trunk
Revision
259065
Author
rn...@webkit.org
Date
2020-03-26 12:58:32 -0700 (Thu, 26 Mar 2020)

Log Message

Sequential focus navigation can't get out of a descendent of a slot element in a document tree
https://bugs.webkit.org/show_bug.cgi?id=199633

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by slot element outside a shadow tree not being treated as a focus navigation
scope owner as specified in the HTML5 specification:
https://html.spec.whatwg.org/multipage/interaction.html#focus-navigation-scope-owner

Fixed the bug by treating it as such unless custom focusing behavior is used.

Test: fast/shadow-dom/focus-across-slot-outside-shadow-tree.html

* page/FocusController.cpp:
(WebCore::isFocusScopeOwner):

LayoutTests:

Skip the newly added test in iOS since eventSender isn't supported on iOS.

* platform/ios/TestExpectations:
* fast/shadow-dom/focus-across-slot-outside-shadow-tree-expected.txt: Added.
* fast/shadow-dom/focus-across-slot-outside-shadow-tree.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259064 => 259065)


--- trunk/LayoutTests/ChangeLog	2020-03-26 19:26:21 UTC (rev 259064)
+++ trunk/LayoutTests/ChangeLog	2020-03-26 19:58:32 UTC (rev 259065)
@@ -1,3 +1,16 @@
+2020-03-25  Ryosuke Niwa  <rn...@webkit.org>
+
+        Sequential focus navigation can't get out of a descendent of a slot element in a document tree
+        https://bugs.webkit.org/show_bug.cgi?id=199633
+
+        Reviewed by Darin Adler.
+
+        Skip the newly added test in iOS since eventSender isn't supported on iOS.
+
+        * platform/ios/TestExpectations:
+        * fast/shadow-dom/focus-across-slot-outside-shadow-tree-expected.txt: Added.
+        * fast/shadow-dom/focus-across-slot-outside-shadow-tree.html: Added.
+
 2020-03-26  Ryan Haddad  <ryanhad...@apple.com>
 
         [win] animations/many-pseudo-animations.html is failing

Added: trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree-expected.txt (0 => 259065)


--- trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree-expected.txt	2020-03-26 19:58:32 UTC (rev 259065)
@@ -0,0 +1,23 @@
+This tests moving the focus from a descendent of a slot element to an element which appears later in the tree order.
+WebKit should focus each input element in the order of their number
+
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+9
+8
+7
+6
+5
+4
+3
+2
+1
+

Added: trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree.html (0 => 259065)


--- trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree.html	                        (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/focus-across-slot-outside-shadow-tree.html	2020-03-26 19:58:32 UTC (rev 259065)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests moving the focus from a descendent of a slot element to an element which appears later in the tree order.<br>
+WebKit should focus each input element in the order of their number</p>
+<div id="container">
+    2.<input placeholder="2">
+    <slot>
+        3.<input placeholder="3">
+    </slot>
+    4.<input placeholder="4">
+    1.<input placeholder="1" tabindex="1">
+    <slot>
+        5.<input placeholder="5" tabindex="2">
+    </slot>
+</div>
+<div id="host">
+    7.<input placeholder="7">
+    <slot>
+        8.<input placeholder="8">
+    </slot>
+    9.<input placeholder="9">
+    6.<input placeholder="6" tabindex="1">
+    <slot>
+        10.<input placeholder="10" tabindex="2">
+    </slot>
+</div>
+<pre id="log"></pre>
+<script>
+
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+for (const element of Array.from(document.querySelectorAll('input')))
+    element.addEventListener('focus', (event) => log.textContent += event.target.placeholder + '\n');
+
+host.attachShadow({mode: 'closed'}).append(...Array.from(host.childNodes));
+
+document.body.focus();
+if (window.eventSender) {
+    for (let i = 0; i < 10; i++)
+        eventSender.keyDown('\t');
+    for (let i = 0; i < 9; i++)
+        eventSender.keyDown('\t', ['shiftKey']);
+    container.remove();
+    host.remove();
+}
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios/TestExpectations (259064 => 259065)


--- trunk/LayoutTests/platform/ios/TestExpectations	2020-03-26 19:26:21 UTC (rev 259064)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2020-03-26 19:58:32 UTC (rev 259065)
@@ -972,6 +972,7 @@
 fast/shadow-dom/activate-over-slotted-content.html [ Skip ]
 fast/shadow-dom/clear-active-state-in-shadow.html [ Skip ]
 fast/shadow-dom/focus-across-details-element.html [ Skip ]
+fast/shadow-dom/focus-across-slot-outside-shadow-tree.html [ Skip ]
 fast/shadow-dom/focus-navigation-across-slots.html [ Skip ]
 fast/shadow-dom/hover-over-nested-slotted-content.html [ Skip ]
 fast/shadow-dom/hover-over-slotted-content.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (259064 => 259065)


--- trunk/Source/WebCore/ChangeLog	2020-03-26 19:26:21 UTC (rev 259064)
+++ trunk/Source/WebCore/ChangeLog	2020-03-26 19:58:32 UTC (rev 259065)
@@ -1,3 +1,21 @@
+2020-03-25  Ryosuke Niwa  <rn...@webkit.org>
+
+        Sequential focus navigation can't get out of a descendent of a slot element in a document tree
+        https://bugs.webkit.org/show_bug.cgi?id=199633
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by slot element outside a shadow tree not being treated as a focus navigation
+        scope owner as specified in the HTML5 specification:
+        https://html.spec.whatwg.org/multipage/interaction.html#focus-navigation-scope-owner
+
+        Fixed the bug by treating it as such unless custom focusing behavior is used.
+
+        Test: fast/shadow-dom/focus-across-slot-outside-shadow-tree.html
+
+        * page/FocusController.cpp:
+        (WebCore::isFocusScopeOwner):
+
 2020-03-26  Kate Cheney  <katherine_che...@apple.com>
 
         ScopeRuleSets::initializeUserStyle() should not add console logging if there are no injected user style sheets

Modified: trunk/Source/WebCore/page/FocusController.cpp (259064 => 259065)


--- trunk/Source/WebCore/page/FocusController.cpp	2020-03-26 19:26:21 UTC (rev 259064)
+++ trunk/Source/WebCore/page/FocusController.cpp	2020-03-26 19:58:32 UTC (rev 259065)
@@ -77,9 +77,9 @@
         return true;
     if (is<HTMLSlotElement>(element)) {
         ShadowRoot* root = element.containingShadowRoot();
-        if (root && root->host() && !hasCustomFocusLogic(*root->host()))
+        if (!root || !root->host() || !hasCustomFocusLogic(*root->host()))
             return true;
-    } 
+    }
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to