- From: Andreu Botella via GitHub <sysbot+gh@w3.org>
- Date: Tue, 19 Dec 2023 10:01:36 +0000
- To: public-css-archive@w3.org
andreubotella has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-text] What does the `white-space-collapse` apply to when white-space trimming/positioning == [CSS-TEXT section 4.1.2](https://drafts.csswg.org/css-text-4/#white-space-phase-2) talks about the rendering and hanging of spaces *in each line*, and step 4 talks about whether a sequence of trailing spaces at the end of the line hangs, which depends on the values of `white-space-collapse` (and `text-wrap-mode`). However, when you look at it in detail, it's not clear what value should be used here. This whole section applies to the line as a whole, and a sequence of trailing spaces can span inlines. Should then each preserved space in the sequence of the line's trailing spaces hang or not depending on its `white-space-collapse` value? This doesn't seem to make sense, since this would allow for some spaces to hang when not at the end of the line, which doesn't seem to make sense, and [is not allowed by the definition of hanging](https://drafts.csswg.org/css-text-4/#hanging). ```html <div style="white-space-collapse: continue"> foo&x#3000;&x#3000;&x#3000;<span style="white-space-collapse: break-spaces"> </span> </div> ``` In this example, if the entirety of the div fits within the line, the ideographic spaces would hang (since they're not collapsed in phase I, so they count as preserved, but they're still `white-space-collapse: continue`), but the spaces inside the span wouldn't. Because of this, when fixing hanging in Blink to align with the spec, I understood the `white-space-collapse` (and `text-wrap-mode`) values as applying to *the line*, rather than the spaces. Blink has a concept of a line box's style, which apparently is not in the spec (although I was not aware of that at the time of implementing this), which seems to be the same as the containing block box's computed style, except maybe including `::first-line` styles in the first line box – and that is what I used in my implementation. This led to differences with other browsers in cases like this: ```html <div style="white-space-collapse: collapse; text-align: center"> Something.<span style="white-space-collapse: preserve; text-wrap-mode: nowrap;"> </span> </div> ``` If the relevant `white-space-collapse` (and `text-wrap-mode`) values should be those corresponding to each preserved space character, then the trailing spaces inside the span conditionally hang (since this is the last line), and therefore the "Something." text will be off-center (as is the case in Firefox and Webkit). However, if the relevant values should be the containing block box's, then the spaces should hang (unconditionally) and the "Something." text will appear centered (as in Chrome since version 119). cc @kojiishi @jfkthame @fantasai @frivoal Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9724 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 19 December 2023 10:01:39 UTC