Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 5520eab83264747fb8a678d3a69ed4deaf774dfb
https://github.com/WebKit/WebKit/commit/5520eab83264747fb8a678d3a69ed4deaf774dfb
Author: Chris Dumez <[email protected]>
Date: 2026-04-15 (Wed, 15 Apr 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
Log Message:
-----------
innerText getter: improve handling of replaced elements at block boundaries
https://bugs.webkit.org/show_bug.cgi?id=312261
Reviewed by Anne van Kesteren.
Fix three innerText getter failures related to replaced elements:
1. Whitespace between <input> and a block element was not being collapsed.
handleReplacedElement() unconditionally set m_hasEmitted even when no
character was actually emitted, causing shouldRepresentNodeOffsetZero()
to emit a spurious newline before the subsequent block. Move m_hasEmitted
to only the paths that actually produce output (emitCharacter already sets
it; only the image alt text path needed an explicit set).
2. Replaced elements with display:block (e.g. <img style='display:block'>)
were not treated as block-level. Route non-inline replaced elements
through handleNonTextNode instead of handleReplacedElement so they get
proper block boundary newlines. Also extend
shouldEmitNewlinesBeforeAndAfterNode
to recognize RenderReplaced in addition to RenderBlock.
Gate the new behavior on the TextIteratorBehavior::EmitsNewlinesPerInnerTextSpec
flag so that it only impacts Element.innerText and not regular tests text
dump. This would require rebaselining a lot of tests otherwise.
No new tests, rebaseline existing WPT tests. The subtests that are newly
passing are already passing in Chrome and Firefox.
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt:
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
(WebCore::TextIterator::handleReplacedElement):
(WebCore::isBlockLevelReplacedElement):
(WebCore::TextIterator::representNodeOffsetZero):
(WebCore::TextIterator::exitNode):
(WebCore::SimplifiedBackwardsTextIterator::advance):
Canonical link: https://commits.webkit.org/311269@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications