Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-counter-styles] range fallback is neither widely implemented nor sensible as specified #2479

Closed
liamquin opened this issue Mar 28, 2018 · 13 comments

Comments

@liamquin
Copy link

https://drafts.csswg.org/css-counter-styles/#counter-style-range

The range property falls back (eventually, through other fallbacks as needed) to decimal.

The normative stylesheet limits a bunch of languages to -9999 ... +9999, e.g. Armenian, and uses a single rule so that user agents are required to fall back to decimal. This is also true for Hebrew, Arabic, and CJK scripts, where roman decimal numbers don't use the same script (or direction?).

The range feature has practical uses that are helpful, but requiring that the UA fall back to roman numerals isn't one of them.

We have only one implementation of range, since only firefox implements @counter-style at all.

I propose
(1) change range so that it only falls back to explicitly mentioned fallback styles (so that you can chain rules, or say you want to fall back to Roman) - if you specify range without a fallback, the UA is to ignore the range property. You can still get the old (current) behaviour by specifying fallback to roman.

This will give some awkward results for numbers > 10,000 but see the next part of this proposal...

(2) remove range properties from the normative stylesheets and allow UAs to do better than 10,000

optional:
(3) move range and fallback to level 4, and stylesheet authors would just have to define numbering (or use predefined numbering) if they needed higher values - without requiring the UA to fail at 10,000.

(4) move the corresponding tests for range/fallback (maybe a dozen or so) to level 4

Of course, we still only have one implementation of the basic counter-style at-rule as far as i can tell, but this would simplify the spec, remove some tests that actually fail everywhere, and allow better results than the normative stylesheet allows.

@tabatkins
Copy link
Member

(2) remove range properties from the normative stylesheets and allow UAs to do better than 10,000

Removing range from the stylesheets doesn't make sense; styles like Armenian are only defined over certain ranges. The rule can technically generate higher values, but it would just be total nonsense. If you wanted UAs to be able to do better than the specified range, that's something we could do with an explicit allowance, but the rule as written needs 'range'.

(3) move range and fallback to level 4, and stylesheet authors would just have to define numbering (or use predefined numbering) if they needed higher values - without requiring the UA to fail at 10,000.

So what do you get when you do use a larger number than it's intended for? Just a really really huge representation? That seems like a bad thing to have happen by default.


We also still need some rule for what happens when a counter style simply can't generate a representation for a particular value, like an additive style where all the weights are even (can't generate reprs for odd values). This falls back to decimal today, and I can't see any other possible way to do this.

@liamquin
Copy link
Author

liamquin commented Mar 28, 2018 via email

@tabatkins
Copy link
Member

Adding higher numbers to Armenian actually looks doable with the
current rule

Again, we could allow that if we wanted with explicit callouts - we already do that with Hebrew (check the end of section 6.1), we just require that they reflect the expanded range correctly.

However, it makes testing more difficult, for obvious reasons.

Falling back to "number out of
range" in the user's language might be an improvement actually.

I strongly disagree that refusing to render at all is an improvement over just rendering in decimal.

@tabatkins tabatkins added the css-counter-styles-3 Current Work label Mar 28, 2018
@liamquin
Copy link
Author

liamquin commented Mar 29, 2018 via email

@frivoal
Copy link
Collaborator

frivoal commented Mar 29, 2018

Actually, having said that, in the case that the user's language isn't the same as the documents, falling back to the user's number system might work too.

I would push back against that. This introduces a risk that authors may accidentally depend on the language of their computer to get the expected results, forget to language tag their pages appropriately, and then having the pages do "the wrong thing" when viewed from a different computer. Whether we always fall back to the same thing, or to something that's language dependent, I don't have a strong opinion. But if it is language dependent, it should be dependent on the language in the document, not in the environment.

@upsuper
Copy link
Member

upsuper commented Mar 29, 2018

The normative stylesheet limits a bunch of languages to -9999 ... +9999, e.g. Armenian, and uses a single rule so that user agents are required to fall back to decimal. This is also true for Hebrew, Arabic, and CJK scripts, where roman decimal numbers don't use the same script (or direction?).

FWIW, Firefox support hebrew in [1, 999999], and complex CJK styles for the whole number range we can count (range of signed 32bit integer). And that is allowed by the spec. Also, CJK scripts fallback to cjk-decimal rather than decimal for non-negatives.

And I agree with what @tabatkins said.

If you are concerning that some counter styles may look weird when they go out of the range, someone can probably create something similar to cjk-decimal to cover the whole range using the same style of characters. Not sure how other people would feel about creating nonexisting numeric system just for fallback...

@fantasai
Copy link
Collaborator

@liamquin Falling back to decimal is far less disruptive than reporting an error. From the reader's perspective, decimal might look odd in certain context, but is fine: no information is lost. Error messages might be useful for authors, but not for readers--they are useless to harmful for readers: the reader doesn't care to see the message, but if it takes up unexpected amounts of space, then it disrupts the layout. As for why decimal, European numbers are practically universal these days. And as @frivoal writes, it's important for interop that we do not depend on OS language.

@liamquin
Copy link
Author

liamquin commented Mar 30, 2018 via email

@upsuper
Copy link
Member

upsuper commented Mar 30, 2018

On the other hand i'd still like to see the UA allowed (as per Hebrew) to go beyond 10,000 wihout resorting to decimal, even if it complicated testing.

It is allowed, and at least Firefox does so, as I've mentioned in my previous comment.

@liamquin
Copy link
Author

@upsuper yes, it's allowed for Hebrew and CJK. I'm asking that it be allowed for other languages.

@tabatkins
Copy link
Member

Both Hebrew and the CJK styles have the "UAs can implement higher if they want" because there is a reasonable way to number at least somewhat higher in those systems, it just doesn't have widespread agreement (CJK) and/or is complex (Hebrew). In both cases, particularly in CJK, I'd like everyone to implement the same range and have it specified in the spec.

Other styles, based on my current knowledge, do not have a reasonable display strategy for higher values. Some can be done (anything additive), but it's doesn't produce reasonable results (a very very long Armenian string, for example).

If someone has evidence of a higher range being reasonably supported in the wild, and can tell me how it works, I'm happy to adjust the spec to account for it. I'm not willing, however, to offer a blanket "or you can do whatever you want, if you think it's right" for values outside the range.

@fantasai
Copy link
Collaborator

@liamquin would you mind confirming if Tab's response is acceptable or not?

@liamquin
Copy link
Author

Yes, it's acceptable, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants