GetRenderedText with white-space:pre-line does not properly respect all newlines
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox134 | --- | fixed |
People
(Reporter: jfkthame, Assigned: jfkthame)
References
Details
Attachments
(1 file)
(See https://github.com/web-platform-tests/wpt/pull/48678#issuecomment-2438706928.)
The recent fix for nsTextFrame::GetRenderedText in bug 1923829 (and the associated WPT test) was not quite correct, in that it fails to preserve blank lines in the white-space: pre-line content. The second assertion in https://wpt.live/html/dom/elements/the-innertext-and-outertext-properties/innertext-whitespace-pre-line.html is therefore currently wrong.
Given
<div id="c" style="white-space: pre-line">
one
two
<!-- comment -->
three
four
</div>
we should expect c.innerText to return "\none\ntwo\n\nthree\nfour\n", preserving the initial newline and the blank line in the middle. This matches Chrome's result, and corresponds to
the element's text content "as rendered"
which is what the spec calls for.
The problem occurs because when the line is empty, we fail to set trimmedSignificantNewline here; and even if we had set that flag, we then return early from here so we'd fail to restore the required newline at the end of the method.
| Assignee | ||
Comment 1•1 year ago
|
||
This makes innerText better reflect the actual rendered text, and matches the result
seen in Blink for the testcase.
Updated•1 year ago
|
Comment 4•1 year ago
|
||
Backed out for causing failures at browser_textleafpoint.js.
Backout link: https://hg.mozilla.org/integration/autoland/rev/4e464842e53849beaeb1667ce3afc2d10860841e
Failure log: https://treeherder.mozilla.org/logviewer?job_id=480311051&repo=autoland&lineNumber=5969
| Assignee | ||
Comment 6•1 year ago
|
||
Ah, I see the issue -- accessibility code calls GetRenderedText with TrailingWhitespace::NoTrim, in which case we don't need the "fix" here because the trailing newline isn't getting trimmed. So we need to make the change conditional on the TrailingWhitespace option, otherwise we end up adding unwanted extra newlines to the a11y TextLeaf nodes.
I'll run the fixed version through tryserver again before re-landing...
Updated•1 year ago
|
Updated•1 year ago
|
Comment 8•1 year ago
|
||
| bugherder | ||
Description
•