Closed Bug 1308113 Opened 8 years ago Closed 3 years ago

'tab-size' should account for letter and word spacing

Categories

(Core :: CSS Parsing and Computation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: sebo, Assigned: jfkthame)

References

()

Details

Attachments

(3 files, 1 obsolete file)

According to the CSSWG resolution from 2016-10-05[1] 'tab-size' should account for letter spacing and word spacing. '-moz-tab-size' should be changed accordingly. Sebastian [1] https://lists.w3.org/Archives/Public/www-style/2016Oct/0068.html
The proposal[1] says this: >tab stops are calculated as > n*( width of U+0020 plus letter-spacing plus word-spacing) But this seems strange to me, as tab characters are already affected by letter-spacing, aren't they? (That's what I'm seeing while playing around in devtools in Firefox and Chrome). Why count letter-spacing twice for tabs? In addition, tabs aren't word-separators in the spec[2], which also states: >If there are no word-separator characters, or if a word-separating character has a zero advance width >(such as the zero width space U+200B) then the user agent must not create an additional spacing between words. How is this meant to be reconciled? Should the word-spacing be applied regardless of whether there are word-separator characters in the run? [1] https://lists.w3.org/Archives/Public/www-style/2015Jan/0548.html [2] https://drafts.csswg.org/css-text-3/#letter-spacing-property
Flags: needinfo?(dbaron)
That's a fair point. Do you mind raising an issue in https://github.com/w3c/csswg-drafts/issues ?
Flags: needinfo?(dbaron) → needinfo?(wisniewskit)
Not at all. I just raised it as issue 643: https://github.com/w3c/csswg-drafts/issues/643
Flags: needinfo?(wisniewskit)
dbaron, do you think it's worth waiting for this spec-issue to be resolved before unprefixing -moz-tab-size? (Chrome is shipping tab-size without it, so I suspect not?)
Flags: needinfo?(dbaron)
Not necessarily -- but given that this bug should be easy enough to fix, I think the best approach would be: * fix this bug in the way that seems to be correct, and describe what we did in the spec issue * then unprefix.
Flags: needinfo?(dbaron)
Sure, but based on the discussion for the resolution, my understanding is that tab characters in <pre> should now just be affected by word-spacing (as well as letter-spacing, which they are already affected by). I'm not 100% sure if that might affect existing content in some negative way, given that word-spacing is an inherited property. I'm game for trying it out, though. Here's a patch to do that; I can add a reftest to it if you feel that's the way to go.
Attachment #8820482 - Flags: review?(dbaron)
So I think your assertion that tabs are already affected by letter-spacing isn't quite right. In particular, I think integer values N of tab-size should add in (N-1) times the letter-spacing so that a tab remains equal to N spaces. The -1 is because the tab already gets *one* letter-spacing for being there. I guess I don't understand what the intent of the word-spacing change is, though. So it's not at all clear to me that the change you've posted for review actually makes sense.
Comment on attachment 8820482 [details] [diff] [review] 1308113-ensure-tabs-in-pre-elements-are-affected-by-word-spacing.diff Marking review- for now because I don't understand why this is a sensible thing to do. I'd be happy to review a patch to fix letter-spacing, though. (And if you can explain what adjusting for word-spacing accounts for, happy to re-review a word-spacing patch too.)
Attachment #8820482 - Flags: review?(dbaron) → review-
dbaron, it looks as though fantasai has replied in the thread at https://github.com/w3c/csswg-drafts/issues/643 Do you think he's answered our questions to your satisfaction so we can continue here?
Flags: needinfo?(dbaron)
OK, I guess her response says we can continue here. The above patch is wrong, since we actually *should* be considering letter-spacing. And https://dbaron.org/css/test/2017/tabs seems to show we currently don't. And I guess the word-spacing thing does make more sense to me now, assuming that it results in the x's always lining up with the 9's in that test. (It's probably worth a little comparison to other browsers, though, and consideration of whether you're getting styles from the block rather than the inline.)
Flags: needinfo?(dbaron)
Attached image screenshot.png
>And I guess the word-spacing thing does make more sense to me now, assuming that it results in the x's always lining up with the 9's in that test. Nope. At least, I just adjusted the patch to do this instead: > return spaces * (spaceWidthAppUnits + WordSpacing(aFrame, aTextRun, textStyle) + > LetterSpacing(aFrame, textStyle)); And I get the result in the attached screenshot. I haven't checked whether I'm getting styles from the block, though. >It's probably worth a little comparison to other browsers, though I don't think any browser does this yet, as it was a recent resolution. Chrome and WebKit render similarly to Firefox nightly for me on your test, though WebKit seems to nudge the X's a bit more to the right in the letter/word spacing cases than Fx/Chrome).
Hmm. Even when I adjust the code to ensure it uses the nearest block frame (hopefully I'm doing so correctly in this new version of the patch), the testcase still renders similarly to my previous screenshot.
Attachment #8820482 - Attachment is obsolete: true
Priority: -- → P3
This bug is blocking support for the "text-size" property. It's currently prioritized as an enhancement, and as such I suspect it has been back-burnered, so text-size support is now stalled. Should it be re-prioritized to account for that blockage?
Severity: enhancement → normal
Note: Just glanced at this to see if anything had changed and noticed I had done a Freudian slip above. It's not "text-size" that's blocked; it's "tab-size". See: bug 737785

You are also welcome to submit a patch, fwiw :)

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/26fa8cc71f85 Account for letter- and word-spacing when resolving tab-size <number>. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
Regressions: 1731010
No longer regressions: 1731010
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: