Closed Bug 1957384 Opened 4 months ago Closed 4 months ago

Follow the spec more fully for ::first-letter range

Categories

(Core :: Layout: Text and Fonts, defect)

defect

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox139 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

Details

Attachments

(2 files)

In bug 1944779 we made a change due to the recent CSSWG resolution to allow intervening space between punctuation and the actual letter when determining the range of the ::first-letter pseudo.

However, more careful reading of the spec text reveals that the change was incomplete: the pattern described in the spec allows potentially multiple space-separated punctuation elements before the letter, and similarly after it, all to be included in the ::first-letter pseudo. (With the caveat that after the letter, a word-separating space will end the ::first-letter pseudo; but other Unicode whitespace may be included.)

Thus, in an extreme (and somewhat silly) example,

data:text/html;charset=utf-8,<style>::first-letter{background:cyan;font-size:2em}</style>
    <p> - – — (&%23x2008;“&%23x2009;T&%23x2009;”&%23x2008;)&%23x2008;est

my understanding is that ::first-letter should match everything up to and including the ")" character (but not the U+2008 "punctuation space" character following it).

(There isn't currently WPT coverage for stuff like this, but I notice that https://github.com/web-platform-tests/wpt/pull/51361 proposes to substantially extend ::first-letter coverage, including some cases with intervening space.)

And allow multiple punctuation elements, with potential intervening whitespace,
both before and after the letter.

Tests to be added once https://github.com/web-platform-tests/wpt/pull/51361 is merged.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

The above patch seems to work as expected in local testing. Once the existing WPT PR mentioned in comment 0 is merged, I'll look into adding some more test coverage if needed.

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a59c7ce8c81e Allow Unicode whitespace characters intervening between punctuation and letter in ::first-letter range. r=dshin

Backed out for causing first-letter failures

Backout link

Push with failures

Failure log Wr
Failure log Reftest

Flags: needinfo?(jfkthame)

Ah, right -- this is an expected behavior change. Back in bug 399941, we see:

From http://www.w3.org/TR/CSS21/selector.html#first-letter :
'Punctuation (i.e, characters defined in Unicode in the "open" (Ps), "close" (Pe), "initial" (Pi). "final" (Pf) and "other" (Po) punctuation classes), that > precedes or follows the first letter should be included'

but the spec has since been further refined, and https://drafts.csswg.org/css-pseudo-4/#first-letter-pattern refers to:

Any punctuation other than opening punctuation and dashes—​i.e. characters that belong to the Punctuation (P*) Unicode general category, excluding Open Punctuation (Ps) and Dash Punctuation (Pd)—​that follows the first letter

Note the excluded subcategories of punctuation. So these tests need updating.

Flags: needinfo?(jfkthame)

These tests are based on the CSS2 spec for ::first-letter, and no longer match the current
CSS Pseudos spec. Once the new and more comprehensive collection of tests in
https://github.com/web-platform-tests/wpt/pull/51361 is merged, it would probably make sense
to remove these as being obsolete, but for the time being I'm marking them as expected-fail.

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5d0057a8beb9 Allow Unicode whitespace characters intervening between punctuation and letter in ::first-letter range. r=dshin https://hg.mozilla.org/integration/autoland/rev/d6b789099b1f Update metadata for old CSS2 first-letter-punctuation tests that no longer pass. r=jwatt
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 139 Branch
QA Whiteboard: [qa-triage-done-c140/b139]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: