`white-space:pre-wrap` does not interact correctly with `text-align:right` or `center`
Categories
(Core :: Layout: Text and Fonts, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox113 | --- | fixed |
People
(Reporter: jfkthame, Assigned: jfkthame)
References
(Blocks 1 open bug, )
Details
Attachments
(3 files)
Testcase: https://codepen.io/jfkthame/pen/rNywVMB
When white-space:pre-wrap
and text-align:right
are in effect, we wrap lines after spaces (correctly), but then the space where the line was wrapped occupies space on the line instead of hanging, and means that the text is not properly flush-right.
This behavior would be correct for white-space:break-spaces
, where it is explicitly called out in the spec as a difference from pre-wrap
behavior; but for pre-wrap
, the end-of-line space should hang.
FTR, Chrome also fails the example in this codepen, whereas Safari handles it correctly.
Assignee | ||
Comment 1•3 years ago
|
||
The same issue applies with text-align:center
, where the preserved end-of-line spaces cause the wrapped lines to appear slightly off-center, though it's less obvious than the flush-right case. Example with centered text: https://codepen.io/jfkthame/pen/KKWqpbP
Again, this renders correctly in Safari but wrong in Chrome.
Assignee | ||
Comment 2•2 years ago
|
||
Of the 15 cases here (combinations of text-align and directionality), mozilla-central
currently fails 9 and passes only 6.
(FTR, a bunch of these tests also currently fail in Chrome, with similar errors to Firefox;
only Safari seems to handle them consistently/correctly.)
Updated•2 years ago
|
Assignee | ||
Comment 3•2 years ago
|
||
Depends on D174726
Assignee | ||
Comment 4•2 years ago
|
||
With the preceding patch, all the new testcases added here now pass, as do several
pre-existing WPT tests that were failing for similar reasons.
Depends on D174728
Comment 5•2 years ago
|
||
only Safari seems to handle them consistently/correctly.
I confirmed this -- though interestingly, WebKit-based Epiphany (aka gnome-web), which I tested before Safari here, doesn't seem to handle the preserved-spaces pieces of your codepens correctly. They render your right-aligned example https://codepen.io/jfkthame/pen/rNywVMB without any visible spaces at the right edge in the bottom section; and they render https://codepen.io/jfkthame/pen/KKWqpbP without the expected leftwards-offsetting at the bottom.
Not sure if this is due to platform-differences on Linux vs. Mac, or gnome-web lacking the WebKit code patch to do this properly, or something else.
Comment 8•2 years ago
|
||
Backed out 3 changesets (Bug 1712703) for causing nsLineLayout related crashes CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=411520709&repo=autoland&lineNumber=9151
https://treeherder.mozilla.org/logviewer?job_id=411521219&repo=autoland&lineNumber=9199
Backout: https://hg.mozilla.org/integration/autoland/rev/049e50697d7c8d63c4ffef301c4cbe0c3c097e12
Comment 10•2 years ago
|
||
Comment 11•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/0c96eb4bdfd1
https://hg.mozilla.org/mozilla-central/rev/d2bee1af043f
https://hg.mozilla.org/mozilla-central/rev/5c2a1049afaa
Assignee | ||
Updated•2 years ago
|
Description
•