Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 870b45452df25c3624ea8fc6341b5c2c1ce3d36f
      
https://github.com/WebKit/WebKit/commit/870b45452df25c3624ea8fc6341b5c2c1ce3d36f
  Author: Andres Gonzalez <[email protected]>
  Date:   2026-07-23 (Thu, 23 Jul 2026)

  Changed paths:
    A 
LayoutTests/accessibility/mac/range-for-line-trailing-blank-line-expected.txt
    A LayoutTests/accessibility/mac/range-for-line-trailing-blank-line.html
    M Source/WebCore/accessibility/AXTextMarker.cpp
    M Source/WebCore/accessibility/AccessibilityRenderObject.cpp

  Log Message:
  -----------
  AX: Line APIs mishandle the trailing blank line of a textarea whose value 
ends in a newline
https://bugs.webkit.org/show_bug.cgi?id=319984
rdar://182912872

Reviewed by Dominic Mazzoni and Tyler Wilcock.

When a text control's value ends in a line break, HTMLTextFormControlElement::
setInnerTextValue appends a placeholder <br> so the empty final line renders.
That placeholder contributes a "\n" text run, so the accessibility string is one
character longer than the value and the empty final line looks like a line whose
content is a newline. Both the isolated-tree and the legacy line APIs mishandled
it:

Isolated tree (AXTextMarker):
- characterRangeForLine reported the trailing blank line as {docEnd, 1} (the
  placeholder newline) instead of an empty range at the document end. VoiceOver
  then rendered the newline on the empty last line and, because the line looked
  non-empty, skipped the previous line when panning left in braille.
- lineNumberForIndex, which counted line-ID transitions with findMarker, 
resolved
  an index at a line's start (right after a hard line break) to the previous 
line.
  That made VoiceOver skip a line when panning through content lines. Its
  index >= length - 1 clamp also rejected the last content character of a value
  that does not end in a newline.

Live tree (AccessibilityRenderObject):
- doAXRangeForLine returned an empty range {0, 0} for the trailing blank line,
  because its lineEndIndex <= lineStartIndex guard treats an empty line at the
  document end as "no such line".

Fix all three so the two trees agree and the trailing blank line reads as an 
empty
range at the document end:

- characterRangeForLine returns an empty range at the document end for that 
line,
  detecting it by content (a lone newline with no following text runs) rather 
than
  object role, which differs between the <br> (LineBreak) and text node
  (StaticText) representations.
- lineNumberForIndex walks line ranges the same way characterRangeForLine does, 
so
  an index at a line's start resolves to that line, and returns -1 for an index 
on
  the trailing blank line, matching the legacy contract.
- doAXRangeForLine reports the trailing blank line of a value ending in a line
  break as an empty range at the document end.

Because the isolated-tree and legacy paths now agree, the test passes with
IsAccessibilityIsolatedTreeEnabled on and off, so it no longer forces the 
isolated
tree on.

* Source/WebCore/accessibility/AXTextMarker.cpp:
(WebCore::isOnTrailingPlaceholderBlankLine):
(WebCore::nextLineRange):
(WebCore::AXTextMarker::characterRangeForLine):
(WebCore::AXTextMarker::markerRangeForLineIndex):
(WebCore::AXTextMarker::lineNumberForIndex):
* Source/WebCore/accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::doAXRangeForLine):
* LayoutTests/accessibility/mac/range-for-line-trailing-blank-line.html: Added.
* 
LayoutTests/accessibility/mac/range-for-line-trailing-blank-line-expected.txt: 
Added.

Canonical link: https://commits.webkit.org/317784@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to