Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2b05daadd0527630a62e38726f33ebfd6663c8d6
https://github.com/WebKit/WebKit/commit/2b05daadd0527630a62e38726f33ebfd6663c8d6
Author: Joshua Hoffman <[email protected]>
Date: 2025-12-11 (Thu, 11 Dec 2025)
Changed paths:
A
LayoutTests/accessibility/mac/live-regions/live-region-aria-label-expected.txt
A LayoutTests/accessibility/mac/live-regions/live-region-aria-label.html
A
LayoutTests/accessibility/mac/live-regions/live-region-img-alt-expected.txt
A LayoutTests/accessibility/mac/live-regions/live-region-img-alt.html
M
LayoutTests/accessibility/mac/live-regions/live-region-removals-expected.txt
M
LayoutTests/accessibility/mac/live-regions/live-region-with-atomic-expected.txt
M Source/WebCore/accessibility/AXCoreObject.h
M Source/WebCore/accessibility/AXLiveRegionManager.cpp
M Source/WebCore/accessibility/AXLogger.cpp
M Source/WebCore/accessibility/AccessibilityNodeObject.cpp
M Source/WebCore/accessibility/AccessibilityNodeObject.h
M Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Log Message:
-----------
AX: live regions should respect alternative text (alt, aria-label,
aria-labelledby)
https://bugs.webkit.org/show_bug.cgi?id=303969
rdar://74236057
Reviewed by Tyler Wilcock.
This patch allows for aria-live announcements to start respecting accessible
text.
Prior to this patch, we only respected image alt text via the text iterator.
But, by switching
to `textUnderElement`, and updating shouldIncludeInSnapshot and textForObject,
we can properly
handle alternative text.
The shouldIncludeInSnapshot change is necessary, since alternative text should
prevent
textual children from being included in an object's text.
There are two important changes to `textForObject`:
(1) Most text is computed using textUnderElement rather than using text marker
ranges. This
allows us to use the alternative text handling already built into this method
(with one
caveat as described in #2).
(2) `textUnderElement` only returns alt. text for descendants of its calling
node. This means,
if the object we want text for has an aria-label, that won't get considered.
This is why
we return the description (which accounts for alt text, aria-label, etc.)
before using
textUnderElement.
`TextUnderElementMode` has two new options specifically used by live regions:
- includeListMarkers: will return list marker text for list marker objects.
- descendIntoContainers: allows textUnderElement to scoop up text for table,
tree, and list
descendants.
Lastly, I added a new parameter, `prependNewline`, to
appendNameToStringBuilder. This allows
textUnderElement to insert newlines when appropriate (for example, after list
items). To
preserve existing behavior, if we are already inserting a space before an
object, we will
not also insert a newline. In the future, we should make `textUnderElement`
respect the text
emission behavior of objects, instead of inserting spaces.
Tests: accessibility/mac/live-regions/live-region-aria-label.html
accessibility/mac/live-regions/live-region-img-alt.html
*
LayoutTests/accessibility/mac/live-regions/live-region-aria-label-expected.txt:
Added.
* LayoutTests/accessibility/mac/live-regions/live-region-aria-label.html: Added.
* LayoutTests/accessibility/mac/live-regions/live-region-img-alt-expected.txt:
Copied from
LayoutTests/accessibility/mac/live-regions/live-region-removals-expected.txt.
* LayoutTests/accessibility/mac/live-regions/live-region-img-alt.html: Added.
* LayoutTests/accessibility/mac/live-regions/live-region-removals-expected.txt:
*
LayoutTests/accessibility/mac/live-regions/live-region-with-atomic-expected.txt:
* Source/WebCore/accessibility/AXCoreObject.h:
* Source/WebCore/accessibility/AXLiveRegionManager.cpp:
(WebCore::AXLiveRegionManager::buildLiveRegionSnapshot const):
(WebCore::AXLiveRegionManager::shouldIncludeInSnapshot const):
(WebCore::AXLiveRegionManager::textForObject const):
(WebCore::AXLiveRegionManager::computeAnnouncement const):
* Source/WebCore/accessibility/AXLogger.cpp:
(WebCore::operator<<):
* Source/WebCore/accessibility/AccessibilityNodeObject.cpp:
(WebCore::shouldUseAccessibilityObjectInnerText):
(WebCore::appendNameToStringBuilder):
(WebCore::shouldPrependNewline):
(WebCore::AccessibilityNodeObject::textUnderElement const):
(WebCore::accessibleNameForNode):
* Source/WebCore/accessibility/AccessibilityNodeObject.h:
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::textUnderElement const):
Canonical link: https://commits.webkit.org/304318@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications