Skip to content

Conversation

@sakupi01
Copy link
Member

@sakupi01 sakupi01 commented Jun 22, 2025

This attempts to define extended CJK longhand counter styles with clear implementation separation as discussed in #12300.

Closes #12300.

Change

This is mainly copy/pasted from an older version of the spec, which defined counter values outside this limited range and clearly separated required/optional implementations.
https://www.w3.org/TR/2013/WD-css-counter-styles-3-20130718/#extended-cjk

However, I made a slight change for the Korean range.
The former version of the spec defines a range between 0 and 10^16, yet the new version defines it down to a negative range because the current ED spec already defines the Korean negative range. See:
https://drafts.csswg.org/css-counter-styles/#limited-korean

The current browser behaviour

The cross-browser implementation for the limited one is consistent, but the extended one is inconsistent.
The new version of spec makes a clear difference between limited and optional, so that implementation and test separation makes sense.
The current implementation status that I could observe is as follows:

  • ✅ Gecko: Partially supports extended ranges beyond the spec, but not fully up to 10^16
  • ❌ WebKit: Supports spec limited range and fails tests for values > 9999
  • ❌ Chromium: Supports spec limited range and fails tests for values > 9999

The Korean negative range is also supported in all 3 browsers.
FWIW, here's a Chromium implementation, according to the current ED spec (not the former one).
https://chromium.googlesource.com/chromium/src/+/d0be3bc63c34b2a904be717bfa3bf0be4e71eb45

WPT

WPT test will also be updated with:

ref: web-platform-tests/wpt#53312

cc: @nt1m


The Chinese longhand styles are defined out to 10k with a [=Chinese|specialized algorithm=], while the Japanese and Korean longhand styles are defined similarly as ''additive'' styles. However, these styles are defined out to 10<sup>16</sup> in common usage. The following section describes an alternative algorithm for these styles.

All of the Chinese, Japanese, and Korean styles are defined for all numbers between -10<sup>16</sup> and 10<sup>16</sup>, exclusive. For numbers outside this range, the ''cjk-decimal'' style is used. All of the styles are defined by almost identical algorithms (specified as a single algorithm here, with the differences called out when relevant), but use different sets of characters. The list following the algorithm gives the name of each counter style using this algorithm, and the individual character sets used by each style.
Copy link
Member Author

@sakupi01 sakupi01 Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The former version of the spec defines a range between 0 and 10^16 for Korean, yet the new version defines it down to a negative range because the current ED spec already defines the Korean negative range.
https://drafts.csswg.org/css-counter-styles/#limited-korean

FWIW, the Korean negative range has been implemented as well. See: https://issues.chromium.org/issues/40504326#comment75

If there's any clue why the former version was limited to the positive range for Korean, and why it still needs to be regulated in the current extended version, please let me know.

@nt1m
Copy link
Member

nt1m commented Jun 22, 2025

Amazing, thanks! I'll tag @fantasai since she's more familiar with this spec than I am.

@nt1m nt1m requested a review from fantasai June 22, 2025 16:51
@svgeesus
Copy link
Contributor

If this is

  1. What the spec used to say
  2. What (at least one) implementation does
  3. What WPT tests for

Then review should be easy and fast.

@w3cbot
Copy link

w3cbot commented Jun 23, 2025

svgeesus marked as non substantive for IPR from ash-nazg.

@sakupi01
Copy link
Member Author

@svgeesus
I updated the OP with clearer descriptions.
Thank you for your feedback! I hope it makes sense.

@svgeesus
Copy link
Contributor

@fantasai does this look good?

@svgeesus svgeesus requested a review from nt1m July 14, 2025 19:45
Copy link
Collaborator

@fantasai fantasai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The introductory text could maybe be simplified a bit, but that can be done as a follow-up commit. Otherwise it looks pretty good. A few specific comments, and then two general ones on formatting:

</dl>

The Chinese longhand styles are defined by almost identical algorithms
The <dfn dfn>Chinese</dfn> longhand styles are defined by almost identical algorithms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this. If you need a subsection, create one (or more), but turning 'Chinese' into a definition for something that isn't the definition of 'Chinese' as a word is confusing.

counter value.
</li></ol>

For all of these counter styles, the '@counter-style/suffix' is "、" U+3001, the '@counter-style/fallback' is ''cjk-decimal'', and the '@counter-style/negative' is given in the tables below, or else is the initial value of the descriptor. The '@counter-style/range' is ''-9999999999999999 9999999999999999'' (-10<sup>16</sup>+1 and 10<sup>16</sup>-1).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the range, this is all duplicate of the earlier information, so let's just say all the descriptors are the same as for the limited range variants, aside from the range, which you're defining here.

@fantasai
Copy link
Collaborator

(Feel free to contact me directly for re-review; GH notifications are a lost cause currently... Someday maybe I'll dig myself out of that.)

@fantasai
Copy link
Collaborator

Also thank you for drafting this up! <3

@sakupi01
Copy link
Member Author

@fantasai

Thanks for reviewing!
I've added some follow-up commits dealing with your suggestions. Thanks!

@svgeesus svgeesus requested a review from fantasai July 15, 2025 17:03
@svgeesus
Copy link
Contributor

I emailed @fantasai requesting re-review. Thanks both for your patience and for the PR.

Copy link
Collaborator

@fantasai fantasai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits, but otherwise looks great!

Remember to SQUASH when merging (see drop-down on the side of the merge button).

Comment on lines 2388 to 2391
The Chinese longhand styles are defined out to 10k with a [[#limited-chinese|specialized algorithm]],
while the Japanese and Korean longhand styles are defined similarly as ''additive'' styles.
However, these styles are defined out to 10<sup>16</sup> in common usage.
The following section describes an alternative algorithm for these styles.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop this paragraph. It's already explained in the section above.

Co-authored-by: fantasai <fantasai.bugs@inkedblade.net>
tabatkins and others added 2 commits July 18, 2025 11:52
Co-authored-by: fantasai <fantasai.bugs@inkedblade.net>
Co-authored-by: fantasai <fantasai.bugs@inkedblade.net>
@tabatkins tabatkins merged commit 91ea6d1 into w3c:main Jul 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[css-counter-styles] CJK longhand counter styles should support values beyond 9999

6 participants