Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 87ee373497a302ba1bb60904474d2c7d037ce31b
https://github.com/WebKit/WebKit/commit/87ee373497a302ba1bb60904474d2c7d037ce31b
Author: Chris Dumez <[email protected]>
Date: 2026-04-13 (Mon, 13 Apr 2026)
Changed paths:
M LayoutTests/accessibility/combobox/aria-combobox-hierarchy-expected.txt
M
LayoutTests/editing/pasteboard/line-feed-between-br-and-b-should-not-reorder-pasted-content-expected.txt
M LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration-expected.txt
M LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration.html
M LayoutTests/fast/dom/inner-text-001-expected.txt
M LayoutTests/fast/dom/inner-text-first-letter-expected.txt
M LayoutTests/fast/dom/inner-text-first-letter.html
M
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-tests.js
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-object-element/object-in-display-none-load-event-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-object-element/object-in-display-none-load-event.html
M
LayoutTests/platform/glib/accessibility/combobox/aria-combobox-hierarchy-expected.txt
M Source/WebCore/dom/Element.cpp
M Source/WebCore/editing/TextIterator.cpp
M Source/WebCore/editing/TextIterator.h
M Source/WebCore/editing/TextIteratorBehavior.h
M Source/WebCore/editing/cocoa/EditingHTMLConverter.h
M Source/WebKit/WebProcess/WebPage/WebFrame.cpp
M Source/WebKitLegacy/mac/WebView/WebFrame.mm
M Source/WebKitLegacy/mac/WebView/WebFramePrivate.h
M Tools/DumpRenderTree/mac/DumpRenderTree.mm
Log Message:
-----------
innerText getter: fix blank line handling for <p> and headings, and strip
trailing block newlines
https://bugs.webkit.org/show_bug.cgi?id=311808
Reviewed by Darin Adler.
Align the innerText getter with the WHATWG spec and match Chrome/Firefox
behavior, gated behind a new EmitsNewlinesPerInnerTextSpec TextIterator
behavior flag so that other TextIterator consumers (accessibility,
selection, test runners) are unaffected.
The flag enables three behavioral changes:
1. shouldEmitExtraNewlineForNode() unconditionally returns true for <p>
and false for <h1>-<h6>. The spec gives <p> a required line break
count of 2 regardless of margin, while headings use 1. Without the
flag, the original margin-based heuristic is preserved.
2. representNodeOffsetZero() emits an extra newline *before* <p>
elements, not just after. A new m_consecutiveNewlineCount counter
prevents over-emitting when line breaks from adjacent blocks already
provide enough newlines.
3. plainText() strips trailing block-boundary newlines from the result.
TextIterator now tracks m_isBlockNewline to distinguish newlines
emitted by exitNode() from intentional ones (e.g. <br>), so only
the former are stripped.
To avoid rebaselining hundreds of layout tests whose text dump would
change, WebFrame::frameTextForTesting() (WebKit2) and a new
WebFrame._plainTextForTesting (WebKitLegacy) now call plainText()
directly without the flag, preserving the old output for test runners.
* LayoutTests/accessibility/combobox/aria-combobox-hierarchy-expected.txt:
*
LayoutTests/editing/pasteboard/line-feed-between-br-and-b-should-not-reorder-pasted-content-expected.txt:
* LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration-expected.txt:
* LayoutTests/fast/dom/NodeList/childNodes-reverse-iteration.html:
* LayoutTests/fast/dom/inner-text-001-expected.txt:
* LayoutTests/fast/dom/inner-text-first-letter-expected.txt:
* LayoutTests/fast/dom/inner-text-first-letter.html:
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/dom/elements/the-innertext-and-outertext-properties/getter-tests.js:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-object-element/object-in-display-none-load-event-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-object-element/object-in-display-none-load-event.html:
*
LayoutTests/platform/glib/accessibility/combobox/aria-combobox-hierarchy-expected.txt:
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::innerText):
* Source/WebCore/editing/TextIterator.cpp:
(WebCore::TextIterator::advance):
(WebCore::shouldEmitExtraNewlineForNode):
(WebCore::TextIterator::representNodeOffsetZero):
(WebCore::TextIterator::exitNode):
(WebCore::TextIterator::emitCharacter):
(WebCore::TextIterator::emitText):
(WebCore::plainText):
* Source/WebCore/editing/TextIterator.h:
(WebCore::TextIterator::isBlockNewline const):
* Source/WebCore/editing/TextIteratorBehavior.h:
* Source/WebCore/editing/cocoa/EditingHTMLConverter.h:
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::frameTextForTesting):
* Source/WebKitLegacy/mac/WebView/WebFrame.mm:
(-[WebFrame _plainTextForTesting]):
* Source/WebKitLegacy/mac/WebView/WebFramePrivate.h:
* Tools/DumpRenderTree/mac/DumpRenderTree.mm:
(dumpFramesAsText):
Canonical link: https://commits.webkit.org/311057@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications