Repository navigation
Fix a bug in this test that the host wasn't getting focused. - #35257
Merged
Merged
Conversation
HTML defines steps to run when an element is inserted into a document (i.e. document tree), not anytime an element is connected to a document: https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute
nt1m
approved these changes
Jul 28, 2022
Rinkubot
pushed a commit
to Rinkubot/Webkit
that referenced
this pull request
Sep 3, 2025
Update delegatesFocus to match recent spec changes
https://bugs.webkit.org/show_bug.cgi?id=232564
Reviewed by Darin Adler.
Implemented the new behavior of focusDelegates and added the support for autofocus focus delegation.
Also fixed a bug that an element with autofocus content attribute inside a shadow tree gets focus.
See whatwg/html#7079
* LayoutTests/fast/shadow-dom/autofocus-in-shadow-tree-autofocus-host-expected.txt: Added.
* LayoutTests/fast/shadow-dom/autofocus-in-shadow-tree-autofocus-host.html: Added.
* LayoutTests/fast/shadow-dom/autofocus-in-shadow-tree-expected.txt: Added.
* LayoutTests/fast/shadow-dom/autofocus-in-shadow-tree.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-020.html: Merge the test fix
posted in web-platform-tests/wpt#35257.
* LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-autofocus-expected.txt: Rebaselined.
* LayoutTests/imported/w3c/web-platform-tests/shadow-dom/focus/focus-method-delegatesFocus-expected.txt: Ditto.
* Source/WebCore/dom/Element.cpp:
(WebCore::shouldAutofocus): Fixed the bug that this wasn't ignoring elements inside shadow trees.
Autofocus attribute yields autofocus candidates if the relevant element is **inserted** into a document,
not connected to it. See https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute
(WebCore::autoFocusDelegate): Added. This implements autofocus delegation mechanism for shadow root/host.
(WebCore::focusDelegateFromShadowHost): Renamed from findFirstProgramaticallyFocusableElementInComposedTree
and made it recursively traverse shadow trees instead of the composed/flat tree.
(WebCore::Element::focus):
Canonical link: https://commits.webkit.org/252901@main
Canonical link: https://commits.webkit.org/252432.292@safari-7614-branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HTML defines steps to run when an element is inserted into a document (i.e. document tree),
not anytime an element is connected to a document:
https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute