-
Notifications
You must be signed in to change notification settings - Fork 675
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-color-5] Clarification on how channel keywords
with multiple specified types work
#7876
Comments
I think this is a case of the editors not appreciating the impact of other changes. At the time it was introduced to CSS, CIE L was a Following the advice that @LeaVerou gives in her CSS Variables talks:
Then I suggest resolving this such that So --base: oklab(50% 0.2 -12%);
--darker: oklab(from var(--base) calc(l * 0.8) a b); Using the percent reference ranges for oklab the value of --base becomes Converting the |
channel keywords
with multiple specified types workchannel keywords
with multiple specified types work
Yeah, this appears to have been some sort of mass change.
As a general principle, we should not be designing the language long-term based on short-term UA limitations. |
Another point is that forcing users to convert from percentage form themselves requires them to memorize or look up the percentage reference ranges for each component. 100% maps to 100 for CIE L, 1.0 for Oklab L, 125 for CIE a, 0.4 for Oklab a. Having the implementation do this will reduce errors. |
Correct, though it may make operations easier, e.g. |
|
Yes, but they do different things. Both are useful. |
Perhaps we can make it |
There is no more |
Yeah, number-percentage doesn't exist (and can't - it breaks the typing system). We do need to decide on one or the other. I'm fine with making it number. |
So:
No-one has argued for In the interest of having concrete text to discuss on the call today, I am going to do the edits to make all channel keywords resolve to |
For clarity, this only applies to channel keywords which are currently specified as multiple types, like Channel keywords which use other (single) types, like |
Ok so now:
In particular, I added an explicit:
|
Erm, hue is |
Again, this is not about what types are valid for input, but rather what type the channel keywords are as output - those have to be a single known type or else the type of a calculation is completely undefined. |
@svgeesus in hwb() you're still specifying the w and b keywords as percentages. Otherwise the edits look good. |
I’m aware, but the rule we are discussing is "RCS keywords return |
Yes, because in CSS Color 4
and
So percentage is required and number is not allowed. Should that be changed? |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> Topic: channel keywords<fantasai> github: https://github.com//issues/7876 <fantasai> chris: main issue raised was that the keywords could have two possible types, doesn't work <fantasai> chris: either number or percentage <fantasai> chris: went with number to be consistent with serialization <fantasai> TabAtkins: nit, you accidentaly did percentage for wmb, but otherwise it's great <fantasai> chris: It's because color-4 it only takes a percentage <fantasai> TabAtkins: Ah, in that case it's completely fine <fantasai> chris: any other comments? <fantasai> chris: anyone need more time? <fantasai> ntim: didn't have a chance to look at it <fantasai> lea: does that mean for rgb they resolve to 0-255 range? <fantasai> chris: yes, but remember it's 0.0 to 255.0 so you don't lose precision <fantasai> lea: but inconsistent with rgb models <fantasai> chris: because it was invented poorly <fantasai> lea: I agree but does that mean we don't need relative color syntax for rgb? <Rossen_> q? <fantasai> chris: I have a lot of trouble coming up with use cases <Rossen_> ack ntim <fantasai> chris: I haven't found a good example <fantasai> lea: I think it's primarily for ocmpletenes, but maybe we should not do it just for completeness <fantasai> lea: restrict to color()? <fantasai> chris: I wouldn't go that far <fantasai> chris: let's resolve this and deal in other issues? <fantasai> chris: get consensus on going to number? <fantasai> Rossen_: So do we have enough consensus? <lea> s/ocmpletenes, but maybe we should not do it/completeness, but we don't generally do things/ <fantasai> lea: consensus is about every component that's "number or something else" resolves to number? <fantasai> lea: so hues resolve to numbers? <fantasai> chris: yeah, all examples treat hues as number <fantasai> chris: so I think most ppl are treating as numbers <fantasai> lea: yes, that's what authors do <fantasai> [...] <argyle> +1 to number <fantasai> chris: Proposal, keywords with multiple specified types result in number <fantasai> Rossen_: Any additional feedback or objections? <fantasai> jensimmons: this is fine with us from Apple <fantasai> RESOLVED: keywords with multiple specified types result in number |
@tabatkins @svgeesus Maybe this issue should be re-opened. |
This is an unfortunate breaking change for folks using pre-processors that already support this syntax. It means that something like It's even less intuitive depending on the channel, since each one has a different percentage basis. For example, with Why can't we have it be a number or percentage depending on which one type checks? That's how I had implemented it in Lightning CSS - it first tries the calculation where |
CSS used to have a
For 10% lighter I would probably do But I do see your point, and sorry for the breaking change. |
Another question about this – WPT has this test: https://github.com/web-platform-tests/wpt/blob/7c0ad5dcce2aa7a073b6f09b99213325b0c4574a/css/css-color/parsing/color-computed-relative-color.html#L90 test_computed_value(`color`, `rgb(from rebeccapurple b alpha r / g)`, `rgba(153, 255, 102, 0.2)`); This implies either that Is this the intentional behavior or should the output actually be |
The WPT tests were never updated after the changes from mixed types to percentages or numbers.
That should be correct |
This seems quite unintuitive vs treating all channels consistently as percentages, because you have to account for different ranges yourself in any calculations. The behavior of something like Also given that Safari 16.4 already shipped, and matches WPT as it is now, would it not be a breaking change for them also to switch to this new interpretation? |
I don't know why Components as specified can have these types in RCS :
It is much harder to effectively write If
even It would also be much more intuitive because |
A downside of percentages is that it limits the possible operations. For example multiplying channels by alpha becomes impossible because percentages can not be multiplied. I think that what I actually want is to be able to use numbers but have all number ranges have the same scales, which is just not how the different number notations work. |
also multiplying by
The first is 110% of the original |
They have now all been updated. |
In the relative color syntax section of CSS Color 5, some of the
channel keywords
specify more than one type. For instance, the channel colorl
for thelab()
relative color syntax states:(http://w3c.github.io/csswg-drafts/css-color-5/##valdef-lab-l)
I am unclear on what this means with respect to using
l
in acalc()
expression. For instance, in the following contrived case:should I be interpreting
l
as a<percentage>
or a<number>
? (or am I missing something fundamental about calc that makes this not an issue?)Edit: linked to stable drafts, and corrected to CSS Color 5, not 4
The text was updated successfully, but these errors were encountered: