-
Notifications
You must be signed in to change notification settings - Fork 714
[css-color-5] Behavior of none
in relative color syntax
#10151
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
Comments
Both nones should be preserved. The intent is that none is only converted to 0 when you absolutely need to get a value out of it — this is not one of these cases. For example |
I am unsure if preserving as If we want to preserve No calculation, only a channel keyword: Calculation: Calculation where Explicit Explicit None of these make a lot of sense when written hard coded like this, but imagine a lot of indirection with custom properties. One option could be to preserve Then |
No, but it does require a very close reading of the entire RCS section, including a snippet of text buried between two large examples, to see this. In contrast to
RCS mentions this only in passing, near the end of section 4
This needs to be much more visible, and mentioned up at the front of the section. In conclusion the spec already says what to do, but it is easy to not notice that it does so. |
…es two colors, but not the only one. #10151
The various scattered normative text snippets have been collected together and thsyntactic changes have been separated from the conceptual processing model: This also helps with |
Thank you @svgeesus, However this question is less about So the question is if these are the same or not:
The first While the second does and therefor matches this phrase:
|
Yes I just spotted that phrase, which I had not collected together with the others and, as you say, it contradicts the other wording. I guess there are three options on what can be done here:
and from what @LeaVerou was saying, the third option is the most useful. Which implies that this statement should be deleted? |
I don't agree the 3rd is the most useful, but I might be missing the utility :)
That is an interpolation between :
I think it would be a stretch if I am not even sure what such an effect might be. I think the specification got it right and that |
Hmm that line was added here in response to and, earlier, Re-reading this issue, @mirisuzanne supported the proposal by @nex to have the result be @tabatkins argued that
(which is incorrect; I suspect that understanding was not informed by (or predated) the concept of analogous components and carrying-forward). @mirisuzanne argued that
which is persuasive (and the model I used in this refactoring), and also @weinig argued that
and
In conclusion, if five people argue one position while one argues the contrary, then there wasn't consensus and the issue should not have been closed. In terms of the utility, I know @LeaVerou has been working in that area for responsive color scales that cope with dark/light mode, so invite her to comment further. |
hehe, I need to be careful that I am fully following everything here. When you write
Because passing |
I plan to write a blog post soonish, but like I said above, |
I think that’s pretty straightforward:
I think preserving it in calculations would make The intent behind the thing about converting it to 0 was that when converting between color spaces, there's no reasonable way to preserve it. With calculations there is. The more I think about it, the more I think we should explicitly clarify that color space conversion is the only case when
@svgeesus thoughts? |
This issue is not about what happens to It is also not about the utility of I took a weird turn somewhere and started imagining preserving
I like this, but it is separate from this issue. https://drafts.csswg.org/css-color-5/#relative-syntax
But https://drafts.csswg.org/css-values-4/#numbers So even if color space conversions preserve This applies to all channel keywords, regardless of the presence of math expressions. https://drafts.csswg.org/css-color-5/#relative-syntax
This is specifically for usage in math expressions. These two phrases make it so that I think that the first (typing as The second however is less simple. For example it was recently added that This is work that should be done for the css-values spec. |
Er, yes, that is the correct final value. Obviously, that is not useful by itself, but it becomes concrete once you interpolate.
Yeah, we need to fix this in the spec, but I would consider it editorial.
Yes.
Yes, it can be argued that the second is not editorial, though the spirit of the prose has always been what I described above: the only reason to ever convert
Yes, this is something we need to keep in mind when defining math expressions, but we should have a rule about which type of none "wins" in these cases. For |
But what is that meaning in the context of math expressions? A channel value of I don't have any preference or objection. But I am really not seeing what Can you provide examples of inputs/outputs?
How? For example :
What is result of this? A:
B:
C:
Also keep in mind that there should not be any practical difference between manually writing hsl(from hsl(none 50% 50%) calc(h + 20) s l)
hsl(calc(none + 20) s l) --foo: calc(none + 20)
hsl(var(--foo) s l) |
The value of
To me, that seems like expected behavior. |
🤔 But that isn't how these features are currently specified or implemented.
This would be a very large change and one that opens up more questions than it answers. How does it work when channel keywords are used in different positions?
vs.
vs.
vs.
|
I honestly have no idea what is confusing you here. Yes,
Yup.
Yup.
|
If anything is hairy, it's things like:
I can see two interpretations:
I think 1 makes more sense, but we need to clarify. |
What is confusing me is that, by my interpretation,
But this proposed change would change the specification so that
I agree, if the concept is to preserve I would also like to have @tabatkins opinion on this as this has a wider impact than only css colors. And I also think implementers would need to weigh in on this to make sure that this is even possible. |
color-mix(
in lab,
oklch(50% none none),
oklch(50% calc(none + .1) calc(none + 180))
) Not a single This is mixing in What happens when you convert between I don't think it should. The |
From what I understand, carry forward applies during a forced conversion in interpolation. Since they are not converting to a space with analogous components, all channels should be forced to be evaluated before conversion. There shouldn't be any I've never been a huge fan of carry forward due to it feeling a bit magical as often color channels are not completely independent when converting, but preserving |
I guess you could rationalize that if "both" chroma and hue are I don't see how either |
That was a typo, the interpolation space should have been That said, I did propose earlier that we expand the concept of carry forward to the other channels as a whole, in which case
It's the lesser of two evils though, the other one being converting |
Do the edits made earlier resolve the "needs edits" or does the subsequent discussion mean that more changes are needed? Do any wpt need to be altered in consequence? |
I think the original issue is still present. https://drafts.csswg.org/css-color-5/#relative-syntax
This implies that I think this is just an oversight and changing the paragraph to this would be sufficient:
https://drafts.csswg.org/css-color-5/#relative-syntax Same section, but only after all the examples :
Regardless of if this still reflects the current intentions of everyone here, it isn't ideal that this placed after all the examples. Placing it after "The channel keywords return a |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> lea: We have this concept of "none", which defines a missing color component<emilio> lea, can you use a mic? <fantasai> lea: when you interpolate with another color, and the other color has an actual number <fantasai> lea: then that component will take its value from the other color <fantasai> lea: This concept started for representing achromatic colors <fantasai> lea: but it also allows specifying parts of color and adding in by interpolation, which is useful <fantasai> lea: we recently resolved to preserve none in calculations <fantasai> lea: previously computed to zero, in order to avoid exposing color space math <ChrisL> q+ to ask if the edits suggested in https://github.com//issues/10151#issuecomment-2140647146 are sufficient, or is more needed <fantasai> lea: but implementers interpreted as "any time you do any math, compute to zero" which isn't needed <fantasai> lea: in April we resolved to preserve "none" in calculations <astearns> ack lea <fserb> +1 <fantasai> ChrisL: Suggest we adopt changes proposed by Romain Menke <fantasai> ChrisL: idk if we need more changes to close the issue <fantasai> -> https://github.com//issues/10151#issuecomment-2140647146 <fantasai> lea: that's a problem from a different issue <lea> https://github.com//issues/10211#issuecomment-2083735046 <fantasai> lea: right now we have concept of analogous color spaces <fantasai> lea: can convert to a different color space, can convert none <fantasai> lea: e.g. lch and oklch, a lightness of none will be preserved <fantasai> lea: you make the none's zeroes, you convert to other color space, you plug the none's back to the alogous components <fantasai> lea: but wouldn't work if you preserve calculations if different scales <fantasai> lea: e.g. rgb and color(rgb) <fantasai> lea: in color function range is 0-1 <fantasai> lea: in rgb the range is 0-255 <fantasai> lea: so adding 50 to rgb color is 20%, but srgb using color function is nonsensical <fantasai> lea: I think that should be allowed <fantasai> lea: not sure what the solution is here <fantasai> lea: but preserving calculations when converting to differnet color space is iffy <fantasai> lea: preserve for other operations, but maybe not converting colors <astearns> ack ChrisL <Zakim> ChrisL, you wanted to ask if the edits suggested in https://github.com//issues/10151#issuecomment-2140647146 are sufficient, or is more needed <fantasai> lea: either preserve none as a whole or drop ti <fantasai> ChrisL: I'm not sure <fantasai> ChrisL: I think preserving none is the right thing, but I'm not sufficiently sure <fantasai> lea: when converting color spcaes, numbers mean different thing <fantasai> lea: having a whole component as none made sense, but calculations if converting it's ... <fantasai> lea: anything we come up with would be way too weird <miriam> +1 preserve none unless converting spaces <emilio> nope <fantasai> fserb: when crossing function boundaries where maybe stop making sense, you need to convert none <fantasai> lea: agree, anythng else seems super weird <fantasai> fserb: think about those boundaries and resolve at them <lea> PROPOSED RESOLUTION: `none` in calculations is converted to 0 when converting a color to a different color space. It is still preserved otherwise, and is still preserved when used as the whole value of a component. <lea> RESOLVED: `none` in calculations is converted to 0 when converting a color to a different color space. It is still preserved otherwise, and is still preserved when used as the whole value of a component. |
I wonder if we could preserve it for analogous components that have the same reference range. E.g. there is no reason to drop it when converting a |
I can't re-read all the relevant spec sections at this time, but I think that this resolution doesn't solve the issue at hand. It was already well specified how to handle This issue was solely about some contradictions that slowly crept into the spec after some recent edits. The current resolution would actually mean we preseve Can we undo this resolution and re-visit my proposed edits? Edit: upon re-reading the resolution it seems that maybe it just isn't that related to this issue? Hence my confusion. This issue isn't about color space conversion or the behavior of I don't mind extra resolutions here but we should also fix the issue at hand. My proposed edits would resolve this issue :) |
Agreed, and applied |
see : https://drafts.csswg.org/css-color-4/#valdef-color-none
There is a note still in the WPT tests for relative color about
none
:https://github.com/web-platform-tests/wpt/blob/master/css/css-color/parsing/color-computed-relative-color.html#L336-L340
As I understand it there are two possible cases:
none
was used in the origin color (e.g.hsl(from hsl(none 50% 50%) h s l)
)none
was used in the relative color (e.g.hsl(from green none s l)
)When
none
was used in the origin color then it should be treated as0
because channel keywords have typenumber
.When
none
was used in the relative color then it should behave exactly the same as it does in absolute colors.Is this correct?
The text was updated successfully, but these errors were encountered: