Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0a597dfab77395d30b03887d170115b01b866698
https://github.com/WebKit/WebKit/commit/0a597dfab77395d30b03887d170115b01b866698
Author: Ahmad Saleem <[email protected]>
Date: 2026-05-27 (Wed, 27 May 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt
R
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt
R
LayoutTests/platform/win/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt
R
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt
M Source/WebCore/page/EventHandler.cpp
Log Message:
-----------
Programmatic focus after keyboard interaction should match :focus-visible
https://bugs.webkit.org/show_bug.cgi?id=315486
rdar://177850766
Reviewed by Ryosuke Niwa.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
CSS Selectors Level 4 ยง9.4 "The Focus-Indicated Pseudo-class:
:focus-visible" [1] lists the following non-normative UA heuristics for
when :focus-visible should match:
"If the user interacts with the page via keyboard or some other
non-pointing device, indicate focus."
"If the previously-focused element indicated focus, and a script
causes focus to move elsewhere, indicate focus on the newly focused
element."
WebKit only consulted Document::wasLastFocusByClick() to decide focus
visibility for bindings-triggered focus moves. That flag is set when a
mouse click focuses an element and never cleared on subsequent keyboard
input. The sequence:
click -> script focus A -> key -> script focus B
therefore left B with FocusVisibility::Invisible, even though the user
had switched to keyboard interaction between the click and the second
script focus.
Clear Document::m_latestFocusTrigger from setHasFocusVisibleIfNeeded
when its existing userHasInteractedViaKeyword gate is true, so the next
bindings-triggered focus takes the "trigger != Click -> Visible" path
in Element::focus.
[1] https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo
*
LayoutTests/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt:
Progression
* Source/WebCore/page/EventHandler.cpp:
(WebCore::EventHandler::internalKeyEvent):
> Platform Specific Expectations:
*
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt:
Removed.
*
LayoutTests/platform/win/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt:
Removed.
*
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/css/selectors/focus-visible-028-expected.txt:
Removed.
Canonical link: https://commits.webkit.org/314012@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications