haikuwebkit/LayoutTests/fast/shadow-dom/focus-navigation-across-slo...

39 lines
1.6 KiB
Plaintext
Raw Permalink Normal View History

Focus ordering should respect slot elements https://bugs.webkit.org/show_bug.cgi?id=151379 Reviewed by Antti Koivisto. Source/WebCore: Implemented the sequential focus navigation ordering as discussed on https://github.com/w3c/webcomponents/issues/375 New behavior treats each shadow root and slot as a "focus scope". The focus navigation ordering is defined within each "focus scope" using tabindex, treating any "focus scope owner" (e.g. shadow host or a slot) as if it was having tabindex=0 if it wasn't itself focusable. This patch modifies FocusNavigationScope to support a focus scope defined for a slot element in addition to the one defined for a shadow tree and a document as previously supported. Tests: fast/shadow-dom/focus-across-details-element.html fast/shadow-dom/focus-navigation-across-slots.html * dom/Node.cpp: (WebCore::parentShadowRoot): Extracted from assignedSlot. (WebCore::Node::assignedSlot): (WebCore::Node::assignedSlotForBindings): Added. * dom/Node.h: * dom/NonDocumentTypeChildNode.idl: * html/HTMLDetailsElement.h: (HTMLDetailsElement::hasCustomFocusLogic): Added. Don't treat details element as a "focus scope". * html/HTMLSummaryElement.h: (HTMLSummaryElement::hasCustomFocusLogic): Ditto for summary element. * page/FocusController.cpp: (WebCore::hasCustomFocusLogic): Moved. (WebCore::isFocusScopeOwner): Added. Returns true on a shadow host without a custom focus logic or on a slot inside a shadow tree whose shadow host doesn't have a custom focus logic. (WebCore::FocusNavigationScope::firstChildInScope): Now takes a reference. Call isFocusScopeOwner to check for both slots and shadow roots instead of just the latter. This fixes a subtle bug that focus may never get out of textarea in some cases due to its failure to check hasCustomFocusLogic. (WebCore::FocusNavigationScope::lastChildInScope): Ditto. (WebCore::FocusNavigationScope::parentInScope): Made this a member function since it needs to check against m_slotElement inside the focus scope of a slot. (WebCore::FocusNavigationScope::nextSiblingInScope): Added. Finds the next assigned node in a slot in the focus scope defined for a slot. Just calls nextSibling() in the focus scope for shadow tree and document. (WebCore::FocusNavigationScope::previousSiblingInScope): Ditto for finding the previous sibling. (WebCore::FocusNavigationScope::firstNodeInScope): Added. This function replaces rootNode() which doesn't exist for the focus scope of a slot element. (WebCore::FocusNavigationScope::lastNodeInScope): Ditto for the last node. (WebCore::FocusNavigationScope::nextInScope): (WebCore::FocusNavigationScope::previousInScope): (WebCore::FocusNavigationScope::FocusNavigationScope): Added a variant that takes HTMLSlotElement. (WebCore::FocusNavigationScope::owner): Added the support for slot elements. (WebCore::FocusNavigationScope::scopeOf): Ditto. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Ditto. (WebCore::isFocusableElementOrScopeOwner): Added the support for slot elements and renamed from isFocusableOrHasShadowTreeWithoutCustomFocusLogic. (WebCore::isNonFocusableScopeOwner): Ditto. Renamed from isNonFocusableShadowHost. (WebCore::isFocusableScopeOwner): Ditto. Renamed from isFocusableShadowHost. (WebCore::shadowAdjustedTabIndex): Added the support for slot elements. (WebCore::FocusController::findFocusableElementAcrossFocusScope): (WebCore::FocusController::nextFocusableElementWithinScope): (WebCore::FocusController::previousFocusableElementWithinScope): (WebCore::FocusController::findElementWithExactTabIndex): (WebCore::nextElementWithGreaterTabIndex): Call firstNodeInScope() instead of rootNode() here since there is no root node for the focus scope defined for a slot element. (WebCore::previousElementWithLowerTabIndex): Ditto for scope.lastNodeInScope(). (WebCore::FocusController::nextFocusableElementOrScopeOwner): (WebCore::FocusController::previousFocusableElementOrScopeOwner): (WebCore::parentInScope): Deleted. (WebCore::FocusNavigationScope::rootNode): Deleted. (WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Deleted. (WebCore::isNonFocusableShadowHost): Deleted. (WebCore::isFocusableShadowHost): Deleted. (WebCore::isFocusableOrHasShadowTreeWithoutCustomFocusLogic): Deleted. LayoutTests: Added regression tests for moving focus by tab and shift+tab across user-defined shadow trees with slots and details element. * fast/shadow-dom/focus-across-details-element-expected.txt: Added. * fast/shadow-dom/focus-across-details-element.html: Added. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: Added. * fast/shadow-dom/focus-navigation-across-slots.html: Added. Canonical link: https://commits.webkit.org/175885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-16 20:26:40 +00:00
Tests for moving focus by pressing tab key across shadow boundaries.
To manually test, press tab key sixteen times then shift+tab sixteen times.
It should traverse focusable elements in the increasing numerical order and then in the reverse order.
1. First sequentially focusable element
2. The focusable element in shadow tree with the higehst tabindex
3. The focusable element in shadow tree with the lowest tabindex
4. Slotted content with tabindex=4
5. Slotted content with tabindex=0
6. The focusable element in shadow tree with the higehst tabindex
7. Focusable slot 1
8. Content in slot 1 with tabindex=7
9. Content in slot 1 with tabindex=0
10. Content in slot 2 with tabindex=1
11. Content in slot 2 with tabindex=1
12. Content in slot 2 with tabindex=0
Focus navigation order in slot fallback contents is wrong https://bugs.webkit.org/show_bug.cgi?id=178001 <rdar://problem/42842997> Reviewed by Antti Koivisto. Source/WebCore: The bug here is that when a slot uses its fallback content, the fallback content's focus order doesn't get grouped by that of the slot. Consider the following DOM tree: - ShadowRoot - div tabindex = 2 - slot tabindex = 1 - span tabindex = 3 In this example, the sequential focus navigation should be slot, span, then div. Even though span has tabindex order of 3, which is lower than that of div, the fallback content of the slot should be grouped together before the focus moves out of the slot content. In WebKit, this concept of grouping elements for the sequential focus navigation ordering is implemeneted as FocusNavigationScope. Both ShadowRoot and HTMLSlotElement are treated as a focus scope owner but we had a bug that a slot element which uses its fallback content was not treated as a focus scope owner. This patch addresses the bug by treating a slot wich uses its fallback content as a focus scope owner. Test: fast/shadow-dom/focus-navigation-across-slots.html * page/FocusController.cpp: (WebCore::isFocusScopeOwner): Treat a slot elment hs a focus scope owner regardless of whether it has assigned nodes or not. (WebCore::FocusNavigationScope::SlotKind): Added. (WebCore::FocusNavigationScope::m_slotKind): Added. (WebCore::FocusNavigationScope::parentInScope const): Return null if `node` is a child of the slot element for which this FocusNavigationScope is created (i.e. `node` is slot's fallback content). (WebCore::FocusNavigationScope::firstNodeInScope const): Return the first child node when this FocusNavigationScope is for a slot element using its fallback content. (WebCore::FocusNavigationScope::lastNodeInScope const): Ditto for the last child. (WebCore::FocusNavigationScope::FocusNavigationScope): (WebCore::FocusNavigationScope::scopeOf): The scope of a child of a slot element which uses its fallback content is its slot element (i.e. the current node is a fallback content). We can't simply check the current node is a slot element which uses a fallback content since the scope of a slot element is the parent scope. e.g. its tree scope like ShadowRoot or Document inside which this slot element appears. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Create the appropriate FocusNavigationScope based on whether the slot element has assigned or it uses its fallback content. LayoutTests: Updated the sequential focus navigation test for shadow DOM and its expectation. New test passes in Firefox & Chrome other than the fact both browsers fail to focus a slot elemennt. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: * fast/shadow-dom/focus-navigation-across-slots.html: Canonical link: https://commits.webkit.org/203901@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-22 19:59:24 +00:00
13. Focusable slot element.
14. Focusable slot fallback content with tabindex=0
Focus ordering should respect slot elements https://bugs.webkit.org/show_bug.cgi?id=151379 Reviewed by Antti Koivisto. Source/WebCore: Implemented the sequential focus navigation ordering as discussed on https://github.com/w3c/webcomponents/issues/375 New behavior treats each shadow root and slot as a "focus scope". The focus navigation ordering is defined within each "focus scope" using tabindex, treating any "focus scope owner" (e.g. shadow host or a slot) as if it was having tabindex=0 if it wasn't itself focusable. This patch modifies FocusNavigationScope to support a focus scope defined for a slot element in addition to the one defined for a shadow tree and a document as previously supported. Tests: fast/shadow-dom/focus-across-details-element.html fast/shadow-dom/focus-navigation-across-slots.html * dom/Node.cpp: (WebCore::parentShadowRoot): Extracted from assignedSlot. (WebCore::Node::assignedSlot): (WebCore::Node::assignedSlotForBindings): Added. * dom/Node.h: * dom/NonDocumentTypeChildNode.idl: * html/HTMLDetailsElement.h: (HTMLDetailsElement::hasCustomFocusLogic): Added. Don't treat details element as a "focus scope". * html/HTMLSummaryElement.h: (HTMLSummaryElement::hasCustomFocusLogic): Ditto for summary element. * page/FocusController.cpp: (WebCore::hasCustomFocusLogic): Moved. (WebCore::isFocusScopeOwner): Added. Returns true on a shadow host without a custom focus logic or on a slot inside a shadow tree whose shadow host doesn't have a custom focus logic. (WebCore::FocusNavigationScope::firstChildInScope): Now takes a reference. Call isFocusScopeOwner to check for both slots and shadow roots instead of just the latter. This fixes a subtle bug that focus may never get out of textarea in some cases due to its failure to check hasCustomFocusLogic. (WebCore::FocusNavigationScope::lastChildInScope): Ditto. (WebCore::FocusNavigationScope::parentInScope): Made this a member function since it needs to check against m_slotElement inside the focus scope of a slot. (WebCore::FocusNavigationScope::nextSiblingInScope): Added. Finds the next assigned node in a slot in the focus scope defined for a slot. Just calls nextSibling() in the focus scope for shadow tree and document. (WebCore::FocusNavigationScope::previousSiblingInScope): Ditto for finding the previous sibling. (WebCore::FocusNavigationScope::firstNodeInScope): Added. This function replaces rootNode() which doesn't exist for the focus scope of a slot element. (WebCore::FocusNavigationScope::lastNodeInScope): Ditto for the last node. (WebCore::FocusNavigationScope::nextInScope): (WebCore::FocusNavigationScope::previousInScope): (WebCore::FocusNavigationScope::FocusNavigationScope): Added a variant that takes HTMLSlotElement. (WebCore::FocusNavigationScope::owner): Added the support for slot elements. (WebCore::FocusNavigationScope::scopeOf): Ditto. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Ditto. (WebCore::isFocusableElementOrScopeOwner): Added the support for slot elements and renamed from isFocusableOrHasShadowTreeWithoutCustomFocusLogic. (WebCore::isNonFocusableScopeOwner): Ditto. Renamed from isNonFocusableShadowHost. (WebCore::isFocusableScopeOwner): Ditto. Renamed from isFocusableShadowHost. (WebCore::shadowAdjustedTabIndex): Added the support for slot elements. (WebCore::FocusController::findFocusableElementAcrossFocusScope): (WebCore::FocusController::nextFocusableElementWithinScope): (WebCore::FocusController::previousFocusableElementWithinScope): (WebCore::FocusController::findElementWithExactTabIndex): (WebCore::nextElementWithGreaterTabIndex): Call firstNodeInScope() instead of rootNode() here since there is no root node for the focus scope defined for a slot element. (WebCore::previousElementWithLowerTabIndex): Ditto for scope.lastNodeInScope(). (WebCore::FocusController::nextFocusableElementOrScopeOwner): (WebCore::FocusController::previousFocusableElementOrScopeOwner): (WebCore::parentInScope): Deleted. (WebCore::FocusNavigationScope::rootNode): Deleted. (WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Deleted. (WebCore::isNonFocusableShadowHost): Deleted. (WebCore::isFocusableShadowHost): Deleted. (WebCore::isFocusableOrHasShadowTreeWithoutCustomFocusLogic): Deleted. LayoutTests: Added regression tests for moving focus by tab and shift+tab across user-defined shadow trees with slots and details element. * fast/shadow-dom/focus-across-details-element-expected.txt: Added. * fast/shadow-dom/focus-across-details-element.html: Added. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: Added. * fast/shadow-dom/focus-navigation-across-slots.html: Added. Canonical link: https://commits.webkit.org/175885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-16 20:26:40 +00:00
15. Shadow content with tabindex=2
Focus navigation order in slot fallback contents is wrong https://bugs.webkit.org/show_bug.cgi?id=178001 <rdar://problem/42842997> Reviewed by Antti Koivisto. Source/WebCore: The bug here is that when a slot uses its fallback content, the fallback content's focus order doesn't get grouped by that of the slot. Consider the following DOM tree: - ShadowRoot - div tabindex = 2 - slot tabindex = 1 - span tabindex = 3 In this example, the sequential focus navigation should be slot, span, then div. Even though span has tabindex order of 3, which is lower than that of div, the fallback content of the slot should be grouped together before the focus moves out of the slot content. In WebKit, this concept of grouping elements for the sequential focus navigation ordering is implemeneted as FocusNavigationScope. Both ShadowRoot and HTMLSlotElement are treated as a focus scope owner but we had a bug that a slot element which uses its fallback content was not treated as a focus scope owner. This patch addresses the bug by treating a slot wich uses its fallback content as a focus scope owner. Test: fast/shadow-dom/focus-navigation-across-slots.html * page/FocusController.cpp: (WebCore::isFocusScopeOwner): Treat a slot elment hs a focus scope owner regardless of whether it has assigned nodes or not. (WebCore::FocusNavigationScope::SlotKind): Added. (WebCore::FocusNavigationScope::m_slotKind): Added. (WebCore::FocusNavigationScope::parentInScope const): Return null if `node` is a child of the slot element for which this FocusNavigationScope is created (i.e. `node` is slot's fallback content). (WebCore::FocusNavigationScope::firstNodeInScope const): Return the first child node when this FocusNavigationScope is for a slot element using its fallback content. (WebCore::FocusNavigationScope::lastNodeInScope const): Ditto for the last child. (WebCore::FocusNavigationScope::FocusNavigationScope): (WebCore::FocusNavigationScope::scopeOf): The scope of a child of a slot element which uses its fallback content is its slot element (i.e. the current node is a fallback content). We can't simply check the current node is a slot element which uses a fallback content since the scope of a slot element is the parent scope. e.g. its tree scope like ShadowRoot or Document inside which this slot element appears. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Create the appropriate FocusNavigationScope based on whether the slot element has assigned or it uses its fallback content. LayoutTests: Updated the sequential focus navigation test for shadow DOM and its expectation. New test passes in Firefox & Chrome other than the fact both browsers fail to focus a slot elemennt. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: * fast/shadow-dom/focus-navigation-across-slots.html: Canonical link: https://commits.webkit.org/203901@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-22 19:59:24 +00:00
16. Non-focusable slot fallback with tabindex=1
17. Non-focusable slot fallback with tabindex=0
16. Non-focusable slot fallback with tabindex=1
Focus ordering should respect slot elements https://bugs.webkit.org/show_bug.cgi?id=151379 Reviewed by Antti Koivisto. Source/WebCore: Implemented the sequential focus navigation ordering as discussed on https://github.com/w3c/webcomponents/issues/375 New behavior treats each shadow root and slot as a "focus scope". The focus navigation ordering is defined within each "focus scope" using tabindex, treating any "focus scope owner" (e.g. shadow host or a slot) as if it was having tabindex=0 if it wasn't itself focusable. This patch modifies FocusNavigationScope to support a focus scope defined for a slot element in addition to the one defined for a shadow tree and a document as previously supported. Tests: fast/shadow-dom/focus-across-details-element.html fast/shadow-dom/focus-navigation-across-slots.html * dom/Node.cpp: (WebCore::parentShadowRoot): Extracted from assignedSlot. (WebCore::Node::assignedSlot): (WebCore::Node::assignedSlotForBindings): Added. * dom/Node.h: * dom/NonDocumentTypeChildNode.idl: * html/HTMLDetailsElement.h: (HTMLDetailsElement::hasCustomFocusLogic): Added. Don't treat details element as a "focus scope". * html/HTMLSummaryElement.h: (HTMLSummaryElement::hasCustomFocusLogic): Ditto for summary element. * page/FocusController.cpp: (WebCore::hasCustomFocusLogic): Moved. (WebCore::isFocusScopeOwner): Added. Returns true on a shadow host without a custom focus logic or on a slot inside a shadow tree whose shadow host doesn't have a custom focus logic. (WebCore::FocusNavigationScope::firstChildInScope): Now takes a reference. Call isFocusScopeOwner to check for both slots and shadow roots instead of just the latter. This fixes a subtle bug that focus may never get out of textarea in some cases due to its failure to check hasCustomFocusLogic. (WebCore::FocusNavigationScope::lastChildInScope): Ditto. (WebCore::FocusNavigationScope::parentInScope): Made this a member function since it needs to check against m_slotElement inside the focus scope of a slot. (WebCore::FocusNavigationScope::nextSiblingInScope): Added. Finds the next assigned node in a slot in the focus scope defined for a slot. Just calls nextSibling() in the focus scope for shadow tree and document. (WebCore::FocusNavigationScope::previousSiblingInScope): Ditto for finding the previous sibling. (WebCore::FocusNavigationScope::firstNodeInScope): Added. This function replaces rootNode() which doesn't exist for the focus scope of a slot element. (WebCore::FocusNavigationScope::lastNodeInScope): Ditto for the last node. (WebCore::FocusNavigationScope::nextInScope): (WebCore::FocusNavigationScope::previousInScope): (WebCore::FocusNavigationScope::FocusNavigationScope): Added a variant that takes HTMLSlotElement. (WebCore::FocusNavigationScope::owner): Added the support for slot elements. (WebCore::FocusNavigationScope::scopeOf): Ditto. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Ditto. (WebCore::isFocusableElementOrScopeOwner): Added the support for slot elements and renamed from isFocusableOrHasShadowTreeWithoutCustomFocusLogic. (WebCore::isNonFocusableScopeOwner): Ditto. Renamed from isNonFocusableShadowHost. (WebCore::isFocusableScopeOwner): Ditto. Renamed from isFocusableShadowHost. (WebCore::shadowAdjustedTabIndex): Added the support for slot elements. (WebCore::FocusController::findFocusableElementAcrossFocusScope): (WebCore::FocusController::nextFocusableElementWithinScope): (WebCore::FocusController::previousFocusableElementWithinScope): (WebCore::FocusController::findElementWithExactTabIndex): (WebCore::nextElementWithGreaterTabIndex): Call firstNodeInScope() instead of rootNode() here since there is no root node for the focus scope defined for a slot element. (WebCore::previousElementWithLowerTabIndex): Ditto for scope.lastNodeInScope(). (WebCore::FocusController::nextFocusableElementOrScopeOwner): (WebCore::FocusController::previousFocusableElementOrScopeOwner): (WebCore::parentInScope): Deleted. (WebCore::FocusNavigationScope::rootNode): Deleted. (WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Deleted. (WebCore::isNonFocusableShadowHost): Deleted. (WebCore::isFocusableShadowHost): Deleted. (WebCore::isFocusableOrHasShadowTreeWithoutCustomFocusLogic): Deleted. LayoutTests: Added regression tests for moving focus by tab and shift+tab across user-defined shadow trees with slots and details element. * fast/shadow-dom/focus-across-details-element-expected.txt: Added. * fast/shadow-dom/focus-across-details-element.html: Added. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: Added. * fast/shadow-dom/focus-navigation-across-slots.html: Added. Canonical link: https://commits.webkit.org/175885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-16 20:26:40 +00:00
15. Shadow content with tabindex=2
Focus navigation order in slot fallback contents is wrong https://bugs.webkit.org/show_bug.cgi?id=178001 <rdar://problem/42842997> Reviewed by Antti Koivisto. Source/WebCore: The bug here is that when a slot uses its fallback content, the fallback content's focus order doesn't get grouped by that of the slot. Consider the following DOM tree: - ShadowRoot - div tabindex = 2 - slot tabindex = 1 - span tabindex = 3 In this example, the sequential focus navigation should be slot, span, then div. Even though span has tabindex order of 3, which is lower than that of div, the fallback content of the slot should be grouped together before the focus moves out of the slot content. In WebKit, this concept of grouping elements for the sequential focus navigation ordering is implemeneted as FocusNavigationScope. Both ShadowRoot and HTMLSlotElement are treated as a focus scope owner but we had a bug that a slot element which uses its fallback content was not treated as a focus scope owner. This patch addresses the bug by treating a slot wich uses its fallback content as a focus scope owner. Test: fast/shadow-dom/focus-navigation-across-slots.html * page/FocusController.cpp: (WebCore::isFocusScopeOwner): Treat a slot elment hs a focus scope owner regardless of whether it has assigned nodes or not. (WebCore::FocusNavigationScope::SlotKind): Added. (WebCore::FocusNavigationScope::m_slotKind): Added. (WebCore::FocusNavigationScope::parentInScope const): Return null if `node` is a child of the slot element for which this FocusNavigationScope is created (i.e. `node` is slot's fallback content). (WebCore::FocusNavigationScope::firstNodeInScope const): Return the first child node when this FocusNavigationScope is for a slot element using its fallback content. (WebCore::FocusNavigationScope::lastNodeInScope const): Ditto for the last child. (WebCore::FocusNavigationScope::FocusNavigationScope): (WebCore::FocusNavigationScope::scopeOf): The scope of a child of a slot element which uses its fallback content is its slot element (i.e. the current node is a fallback content). We can't simply check the current node is a slot element which uses a fallback content since the scope of a slot element is the parent scope. e.g. its tree scope like ShadowRoot or Document inside which this slot element appears. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Create the appropriate FocusNavigationScope based on whether the slot element has assigned or it uses its fallback content. LayoutTests: Updated the sequential focus navigation test for shadow DOM and its expectation. New test passes in Firefox & Chrome other than the fact both browsers fail to focus a slot elemennt. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: * fast/shadow-dom/focus-navigation-across-slots.html: Canonical link: https://commits.webkit.org/203901@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235191 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-22 19:59:24 +00:00
14. Focusable slot fallback content with tabindex=0
13. Focusable slot element.
Focus ordering should respect slot elements https://bugs.webkit.org/show_bug.cgi?id=151379 Reviewed by Antti Koivisto. Source/WebCore: Implemented the sequential focus navigation ordering as discussed on https://github.com/w3c/webcomponents/issues/375 New behavior treats each shadow root and slot as a "focus scope". The focus navigation ordering is defined within each "focus scope" using tabindex, treating any "focus scope owner" (e.g. shadow host or a slot) as if it was having tabindex=0 if it wasn't itself focusable. This patch modifies FocusNavigationScope to support a focus scope defined for a slot element in addition to the one defined for a shadow tree and a document as previously supported. Tests: fast/shadow-dom/focus-across-details-element.html fast/shadow-dom/focus-navigation-across-slots.html * dom/Node.cpp: (WebCore::parentShadowRoot): Extracted from assignedSlot. (WebCore::Node::assignedSlot): (WebCore::Node::assignedSlotForBindings): Added. * dom/Node.h: * dom/NonDocumentTypeChildNode.idl: * html/HTMLDetailsElement.h: (HTMLDetailsElement::hasCustomFocusLogic): Added. Don't treat details element as a "focus scope". * html/HTMLSummaryElement.h: (HTMLSummaryElement::hasCustomFocusLogic): Ditto for summary element. * page/FocusController.cpp: (WebCore::hasCustomFocusLogic): Moved. (WebCore::isFocusScopeOwner): Added. Returns true on a shadow host without a custom focus logic or on a slot inside a shadow tree whose shadow host doesn't have a custom focus logic. (WebCore::FocusNavigationScope::firstChildInScope): Now takes a reference. Call isFocusScopeOwner to check for both slots and shadow roots instead of just the latter. This fixes a subtle bug that focus may never get out of textarea in some cases due to its failure to check hasCustomFocusLogic. (WebCore::FocusNavigationScope::lastChildInScope): Ditto. (WebCore::FocusNavigationScope::parentInScope): Made this a member function since it needs to check against m_slotElement inside the focus scope of a slot. (WebCore::FocusNavigationScope::nextSiblingInScope): Added. Finds the next assigned node in a slot in the focus scope defined for a slot. Just calls nextSibling() in the focus scope for shadow tree and document. (WebCore::FocusNavigationScope::previousSiblingInScope): Ditto for finding the previous sibling. (WebCore::FocusNavigationScope::firstNodeInScope): Added. This function replaces rootNode() which doesn't exist for the focus scope of a slot element. (WebCore::FocusNavigationScope::lastNodeInScope): Ditto for the last node. (WebCore::FocusNavigationScope::nextInScope): (WebCore::FocusNavigationScope::previousInScope): (WebCore::FocusNavigationScope::FocusNavigationScope): Added a variant that takes HTMLSlotElement. (WebCore::FocusNavigationScope::owner): Added the support for slot elements. (WebCore::FocusNavigationScope::scopeOf): Ditto. (WebCore::FocusNavigationScope::scopeOwnedByScopeOwner): Ditto. (WebCore::isFocusableElementOrScopeOwner): Added the support for slot elements and renamed from isFocusableOrHasShadowTreeWithoutCustomFocusLogic. (WebCore::isNonFocusableScopeOwner): Ditto. Renamed from isNonFocusableShadowHost. (WebCore::isFocusableScopeOwner): Ditto. Renamed from isFocusableShadowHost. (WebCore::shadowAdjustedTabIndex): Added the support for slot elements. (WebCore::FocusController::findFocusableElementAcrossFocusScope): (WebCore::FocusController::nextFocusableElementWithinScope): (WebCore::FocusController::previousFocusableElementWithinScope): (WebCore::FocusController::findElementWithExactTabIndex): (WebCore::nextElementWithGreaterTabIndex): Call firstNodeInScope() instead of rootNode() here since there is no root node for the focus scope defined for a slot element. (WebCore::previousElementWithLowerTabIndex): Ditto for scope.lastNodeInScope(). (WebCore::FocusController::nextFocusableElementOrScopeOwner): (WebCore::FocusController::previousFocusableElementOrScopeOwner): (WebCore::parentInScope): Deleted. (WebCore::FocusNavigationScope::rootNode): Deleted. (WebCore::FocusNavigationScope::scopeOwnedByShadowHost): Deleted. (WebCore::isNonFocusableShadowHost): Deleted. (WebCore::isFocusableShadowHost): Deleted. (WebCore::isFocusableOrHasShadowTreeWithoutCustomFocusLogic): Deleted. LayoutTests: Added regression tests for moving focus by tab and shift+tab across user-defined shadow trees with slots and details element. * fast/shadow-dom/focus-across-details-element-expected.txt: Added. * fast/shadow-dom/focus-across-details-element.html: Added. * fast/shadow-dom/focus-navigation-across-slots-expected.txt: Added. * fast/shadow-dom/focus-navigation-across-slots.html: Added. Canonical link: https://commits.webkit.org/175885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-05-16 20:26:40 +00:00
12. Content in slot 2 with tabindex=0
11. Content in slot 2 with tabindex=1
10. Content in slot 2 with tabindex=1
9. Content in slot 1 with tabindex=0
8. Content in slot 1 with tabindex=7
7. Focusable slot 1
6. The focusable element in shadow tree with the higehst tabindex
5. Slotted content with tabindex=0
4. Slotted content with tabindex=4
3. The focusable element in shadow tree with the lowest tabindex
2. The focusable element in shadow tree with the higehst tabindex
1. First sequentially focusable element