Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in this test that the host wasn't getting focused. #35257

Merged
merged 1 commit into from
Jul 28, 2022

Conversation

rniwa
Copy link
Contributor

@rniwa rniwa commented Jul 28, 2022

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

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
@rniwa rniwa merged commit c86f08b into web-platform-tests:master Jul 28, 2022
webkit-early-warning-system pushed a commit to rniwa/WebKit that referenced this pull request Jul 28, 2022
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
@rniwa rniwa deleted the fix-css-focus-visible-020 branch August 2, 2022 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants