Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 9d4fccacaa23d20fbc6870a3f1278b656bbd5acf
https://github.com/WebKit/WebKit/commit/9d4fccacaa23d20fbc6870a3f1278b656bbd5acf
Author: Tyler Wilcock <[email protected]>
Date: 2026-07-20 (Mon, 20 Jul 2026)
Changed paths:
A LayoutTests/accessibility/aria-actions-focus-author-override-expected.txt
A LayoutTests/accessibility/aria-actions-focus-author-override.html
A LayoutTests/accessibility/aria-actions-focus-in-other-frame-expected.txt
A LayoutTests/accessibility/aria-actions-focus-in-other-frame.html
A LayoutTests/accessibility/aria-actions-focus-no-origin-expected.txt
A LayoutTests/accessibility/aria-actions-focus-no-origin.html
A LayoutTests/accessibility/aria-actions-focus-restore-fallback-expected.txt
A LayoutTests/accessibility/aria-actions-focus-restore-fallback.html
A LayoutTests/accessibility/aria-actions-preserves-focus-expected.txt
A LayoutTests/accessibility/aria-actions-preserves-focus.html
M LayoutTests/platform/glib/TestExpectations
M Source/WebCore/accessibility/AXCoreObject.cpp
M Source/WebCore/accessibility/AXObjectCache.cpp
M Source/WebCore/accessibility/AXObjectCache.h
M Source/WebCore/accessibility/AccessibilityObject.cpp
M Source/WebCore/accessibility/AccessibilityObject.h
Log Message:
-----------
AX: Preserve the user's focus when invoking an aria-actions custom action
https://bugs.webkit.org/show_bug.cgi?id=319391
rdar://182223716
Reviewed by Dominic Mazzoni.
An element's aria-actions attribute exposes other elements as custom actions on
that element. When an assistive technology invokes one of those actions, the
following sequence happens:
1. The platform's custom-action handler calls performCustomActionPress()
which resolves the action target and presses it.
2. This dispatches a simulated click (to pretend a "real" mouseclick
happened for privacy reasons). This inherently causes focus to
move to it.
The result is that invoking an action steals focus from wherever the AT user
was,
and fires an accessibility focus notification for the target. This is not the
desired user experience for aria-actions -- focus should remain on the
originating,
aria-actions-having element.
Fix this by giving the custom-action path its own press variant,
pressPreservingFocus().
It records where focus currently is, presses the action target, and if the
press moved
focus onto that target, restores focus to where it was. The accessibility focus
notifications
for both the transient move onto the target and the restore are suppressed, so
the momentary
focus movement is never surfaced to the assistive technology. The
check-and-restore is done
synchronously, so no author script can run between observing that focus landed
on the target and restoring it. This only affects the aria-actions
custom-action path.
If author script moved focus somewhere other than the action target, that is
respected and left
in place. If the origin can no longer take focus back (e.g. it was disconnected
during the press),
the real focus is surfaced so the assistive technology can move there instead
of being left
pointed at the stale origin.
This heuristic aligns with other browsers.
* LayoutTests/accessibility/aria-actions-focus-author-override-expected.txt:
Added.
* LayoutTests/accessibility/aria-actions-focus-author-override.html: Added.
* LayoutTests/accessibility/aria-actions-focus-in-other-frame-expected.txt:
Added.
* LayoutTests/accessibility/aria-actions-focus-in-other-frame.html: Added.
* LayoutTests/accessibility/aria-actions-focus-no-origin-expected.txt: Added.
* LayoutTests/accessibility/aria-actions-focus-no-origin.html: Added.
* LayoutTests/accessibility/aria-actions-focus-restore-fallback-expected.txt:
Added.
* LayoutTests/accessibility/aria-actions-focus-restore-fallback.html: Added.
* LayoutTests/accessibility/aria-actions-preserves-focus-expected.txt: Added.
* LayoutTests/accessibility/aria-actions-preserves-focus.html: Added.
* LayoutTests/platform/glib/TestExpectations:
* Source/WebCore/accessibility/AXCoreObject.cpp:
(WebCore::Accessibility::performCustomActionPress):
* Source/WebCore/accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::onFocusChange):
* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::pressPreservingFocus):
* Source/WebCore/accessibility/AccessibilityObject.h:
Canonical link: https://commits.webkit.org/317542@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications