Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4d337656617bce75dc9af62100298354a0a6944d
https://github.com/WebKit/WebKit/commit/4d337656617bce75dc9af62100298354a0a6944d
Author: Chris Dumez <[email protected]>
Date: 2026-05-08 (Fri, 08 May 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt
M Source/WebCore/editing/TextIterator.cpp
M Source/WebCore/editing/TextIterator.h
Log Message:
-----------
innerText on tables emits spurious trailing newlines and drops row-exit
newlines after empty rows
https://bugs.webkit.org/show_bug.cgi?id=314399
Reviewed by Anne van Kesteren.
Two related failures in the WPT getter.html innerText test when
iterating tables via TextIterator with EmitsNewlinesPerInnerTextSpec:
1. "<div><table><tfoot>x</tfoot><tbody>y</tbody></table>" produced
"xy\n" instead of "xy". The HTML parser foster-parents "x" and "y"
out of the table, leaving the table empty. Entering the (empty)
table emits a leading block newline in representNodeOffsetZero(),
but that emit was not flagged as a block newline, so plainText()'s
trailing-block-newline stripper could not remove it.
2. "<table><tfoot><tr><td>footer</tfoot><thead><tr><td
style='visibility:collapse'>thead</thead><tbody><tr><td>tbody
</tbody></table>" produced "footer\ntbody" instead of
"footer\n\ntbody". Per the innerText spec, every non-last table row
appends a literal '\n' independent of surrounding content. exitNode()
suppressed this emit whenever m_lastCharacter was already '\n', so
the collapsed thead row between tfoot and tbody contributed no line
break of its own.
No new tests, rebaselined existing tests. The 2 subtests that started
passing in WebKit were already passing in Blink and Gecko.
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::representNodeOffsetZero): Mark the entry-block
'\n' (both the standard block-before case and the extra <p> blank-line
case) as a block newline so plainText() can strip it when it becomes
trailing.
(WebCore::TextIterator::exitNode): When exiting a RenderTableRow whose
row-exit '\n' has not yet been emitted, emit it even if m_lastCharacter
is '\n'. Record the row in m_lastTableRowEmittedExitNewlineFor so the
second visit to the same row (going to its sibling) does not
double-emit.
Canonical link: https://commits.webkit.org/312941@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications