Open Bug 1688769 Opened 4 years ago Updated 3 years ago

White space collapsing in list markers seem wrong

Categories

(Core :: Layout: Generated Content, Lists, and Counters, defect)

Firefox 84
Desktop
All
defect

Tracking

()

Tracking Status
firefox85 --- affected
firefox86 --- affected
firefox87 --- affected

People

(Reporter: xiaochengh, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36

Steps to reproduce:

It seems that white spaces in list markers are never collapsed, regardless of the 'white-space' value of the ::marker pseudo-element.

Test case (https://jsfiddle.net/egchkm3o/):

<style>
@counter-style a {
system: fixed;
symbols: 'A A' 'B B' 'C C'; /* two spaces between letters */
suffix: '. ';
}

ol {
list-style-type: a;
list-style-position: inside;
font-family: monospace;
}
</style>

<ol style="list-style-type: a; list-style-position: inside">
<li style="list-style-type: none">01234567890123456789</li>
<li> leading spaces, 'white-space: normal'</li>
<li style="white-space: pre"> leading spaces, 'white-space: pre'</li>
</ol>

Actual results:

White spaces in both list markers are not collapsed. Trailing space of inside list marker does not collapse with leading space of list item text.

It looks like all white spaces in list markers are internally converted to nbsp, which makes 'white-space' property value of ::marker ineffective.

Expected results:

In the first list item (with 'white-space'), white spaces in the first marker should be collapsed. Furthermore, trailing space of the list marker should collapse with the leading space of the list item text. So the first list item should look like:

B B. leading spaces...

Due to this issue, Blink currently fails a number of WPT tests in css/vendor-imports/mozilla/mozilla-central-reftests/counter-styles-3/

For now, I'm adding 'white-space: pre' to list markers in these tests, so that Blink can also pass:

crrev.com/c/2648650

Bug 1542807 should make markers handle whitespace with the usual rules.
Which implies that outside markers will lose the trailing space (bug 1595253), Chromium solves that by enforcing white-space: pre on outside markers.
BTW, in Chromium's legacy LayoutListMarker basically has the same problem as nsBulletFrame. There is no whitespace collapsing inside the marker since they have no actual text, the difference is that Firefox doesn't collapse the trailing marker space with the leading space inside the list item, while legacy Chromium always trims collapsible spaces after an inside marker. Which I guess it's not great if the marker doesn't have a trailing space, or if it's preserved.
The spec says that the behavior should probably be like text-space-collapse: preserve-spaces; text-space-trim: discard-after, but that doesn't seem implemented anywhere.

Component: Untriaged → Layout: Generated Content, Lists, and Counters
Depends on: 1542807
Product: Firefox → Core

Hi,

Thanks for the details. I was able to reproduce the bug on Windows 10 on FF Nightly 87.0a1 (2021-01-10) (64-bit), and Beta 86.0b3, and release 85.0.

Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Unspecified → All
Hardware: Unspecified → Desktop
Severity: -- → S3
You need to log in before you can comment on or make changes to this bug.