Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ead5853ca2e28c58103a3c8345128bd5574e917a
https://github.com/WebKit/WebKit/commit/ead5853ca2e28c58103a3c8345128bd5574e917a
Author: Tyler Wilcock <[email protected]>
Date: 2026-04-13 (Mon, 13 Apr 2026)
Changed paths:
A LayoutTests/accessibility/label-static-text-path-expected.txt
A LayoutTests/accessibility/label-static-text-path.html
M LayoutTests/accessibility/mac/bounds-for-range-expected.txt
M LayoutTests/accessibility/mac/element-paths-expected.txt
M LayoutTests/accessibility/mac/element-paths.html
A LayoutTests/accessibility/statictext-path-expected.txt
A LayoutTests/accessibility/statictext-path.html
A LayoutTests/accessibility/stitched-text-path-expected.txt
A LayoutTests/accessibility/stitched-text-path.html
M LayoutTests/platform/glib/TestExpectations
M Source/WebCore/accessibility/AXTextRun.cpp
M Source/WebCore/accessibility/AXTextRun.h
M Source/WebCore/accessibility/AccessibilityRenderObject.cpp
M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp
M Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
Log Message:
-----------
AX: Compute shrink-wrapped paths for multi-line text, links, and
static-text-only labels
https://bugs.webkit.org/show_bug.cgi?id=311852
rdar://174436965
Reviewed by Joshua Hoffman.
This commit adds on-demand path computation for multi-line static text, links,
and labels that contain only static text.
The core approach: collect per-line bounding rects from text runs, then
build a shrink-wrapped path via PathUtilities::pathWithShrinkWrappedRects.
This gives ATs like VoiceOver a tightly-fitting cursor around wrapped
text instead of a large rectangular bounding box that encompasses more
than the text being spoken / brailled.
AXTextRun changes:
- Refactor localRect() to delegate to new localRectsPerLine(), which
returns a per-line rect vector instead of a single unioned rect.
- Collapsed ranges (start == end) are handled directly in localRect()
with a caret-width rect.
AccessibilityRenderObject changes:
- Add rectsSpanMultipleLines() to replace the old needsPath heuristic.
This function respects vertical and RTL writing modes, unlike the old
implementation.
- Add computePathForMultiLineRenderInline() for main-thread inline element
paths.
- Fix textRuns() distanceFromBoundsInDirection: the old code only
computed this for non-left-aligned text, but all alignments need
it for accurate bounds. It also used lineBox->contentLogicalLeft()
alone, which gives the line's content area offset but misses the
run's position within the line. Adding textRun.xPos() fixes this.
Finally, only compute the offset for the first text box on each
line, since multiple text boxes can share a line (e.g. due to
inline formatting splits like <b> or <i>), and the offset of a
subsequent box would overwrite the correct value from the first.
* LayoutTests/accessibility/label-static-text-path-expected.txt: Added.
* LayoutTests/accessibility/label-static-text-path.html: Added.
* LayoutTests/accessibility/mac/bounds-for-range-expected.txt:
* LayoutTests/accessibility/mac/element-paths-expected.txt:
* LayoutTests/accessibility/mac/element-paths.html:
* LayoutTests/accessibility/statictext-path-expected.txt: Added.
* LayoutTests/accessibility/statictext-path.html: Added.
* LayoutTests/accessibility/stitched-text-path-expected.txt: Added.
* LayoutTests/accessibility/stitched-text-path.html: Added.
* Source/WebCore/accessibility/AXTextRun.cpp:
(WebCore::AXTextRuns::localRect const):
(WebCore::AXTextRuns::localRectsPerLine const):
* Source/WebCore/accessibility/AXTextRun.h:
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::rectsSpanMultipleLines):
(WebCore::computePathForMultiLineRenderInline):
(WebCore::AccessibilityRenderObject::elementPath const):
(WebCore::AccessibilityRenderObject::textRuns):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::collectPaintedLineRects):
(WebCore::buildPathFromLineRects):
(WebCore::elementPathForLink):
(WebCore::AXIsolatedObject::elementPath const):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h:
Canonical link: https://commits.webkit.org/311136@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications