Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0db1abc4325425550f7948871cb1c3d78b9dcd83
https://github.com/WebKit/WebKit/commit/0db1abc4325425550f7948871cb1c3d78b9dcd83
Author: Chris Dumez <[email protected]>
Date: 2026-04-13 (Mon, 13 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: fix whitespace handling at inline-block boundaries
https://bugs.webkit.org/show_bug.cgi?id=312143
Reviewed by Darin Adler.
The TextIterator tracks collapsed whitespace via
m_lastTextNodeEndedWithCollapsedSpace to emit spaces between text runs.
However, this flag was leaking across inline-block boundaries in both
directions:
1. Trailing collapsed whitespace inside an inline-block (at its block
end boundary) leaked into the outer flow, causing a spurious extra
space after the inline-block's content.
2. Leading collapsed whitespace inside an inline-block (at its block
start boundary) was emitted as a visible space, because the
TextIterator didn't know it had entered a new block formatting context.
For normal block-level elements, these issues don't arise: entering a
block emits '\n' (which suppresses leading whitespace since '\n' is
collapsible), and exiting emits '\n' (which resets the collapsed space
flag). Inline-blocks are inline-level, so no '\n' is emitted in either
direction.
Fix this by:
- In exitNode(), resetting m_lastTextNodeEndedWithCollapsedSpace when
exiting any RenderBlock, so trailing collapsed whitespace from an inner
BFC doesn't leak outward.
- In representNodeOffsetZero(), setting m_lastCharacter to '\n' when
entering an inline-level RenderBlock (excluding inline-tables which
have their own handling), to suppress leading collapsed whitespace
inside the BFC — mimicking the effect of the '\n' emitted for normal
blocks without producing visible output.
No new tests, rebaselined existing test.
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt:
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::representNodeOffsetZero):
(WebCore::TextIterator::exitNode):
Canonical link: https://commits.webkit.org/311163@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications