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-colors-5] Serialization of a relative color functions as component of specified values #9464

Closed
cdoublev opened this issue Oct 12, 2023 · 6 comments
Assignees
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-5 Color modification

Comments

@cdoublev
Copy link
Collaborator

I do not expect the following to apply in a specified value:

The serialization of the result of a relative color function is the resolved value.

https://drafts.csswg.org/css-color-5/#serial-relative-color

But the WPT tests do. Perhaps the intention is actually to test resolved values (getComputedStyle()) instead of specified values (getPropertyValue()).

In these tests, relative sRGB functions serialize as resolved color(srgb ...) and other relative functions serialize as the corresponding resolved function: lab(from <color> ...) as lab(...), lch(from <color> ...) as lch(...), etc. currentcolor prevents resolving.

Math functions are resolved whereas they are preserved when serializing an "absolute" color functions.

color-mix() serializes as is:

The serialization of the specified value of a color-mix() function is the string "color-mix(in ", followed by [...]

So I am not sure what is the expected serialized value for eg. rgb(from color-mix(...) ...).

If these tests are actually a work in progress, I suggest preserving the details of the value as specified by its author, and being consistent with the serialization of "absolute" color functions:

  1. map <percentage>, <hue>, <alpha-value>, to <number>, excluding in math functions, which are preserved
  2. clamp <number> when required
  3. normalize <number> representing a <hue> in [0,360)
  4. normalize xyz to xyz-d65
@cdoublev cdoublev added the css-color-5 Color modification label Oct 12, 2023
@svgeesus
Copy link
Contributor

Serializing color-mix() clearly distinguishes between serializing the specified value and serializing the computed value. You are correct that Serializing Relative Color Functions does not (and it is actually only discussing the computed value). And the WPT, as you say, reflect that interpretation.

@cdoublev
Copy link
Collaborator Author

I guess this issue depends on these (which need to be created):

  • how to determine the type of a math function including a color channel keyword?
  • how to simplify a math function including a color channel keyword?

Now that Chrome 119 supports the relative color syntax (apparently), maybe CSS Values 4 (and CSS Typed OM) could specify this in determine the type of a calculation and simplify a calculation tree?

@svgeesus svgeesus added the css-values-4 Current Work label Oct 17, 2023
@tabatkins
Copy link
Member

I've slightly restructured the numeric constants section of Values 4 and added a subsection to talk about keyword variables specifically.

Simplification is already well-defined - a keyword, once it has the information necessary to resolve, is handled by step 2.1, same as any other function that resolves to a numeric value.

@tabatkins tabatkins removed the css-values-4 Current Work label Oct 23, 2023
@tabatkins
Copy link
Member

@svgeesus Now that I've specified precisely how variables work, you'll want to add a tiny bit more detail to Color 5 to specify that the channel keywords resolve at the same time as the source color does, so from red, r g b resolves them all immediately but from currentcolor, r g b waits until currentcolor is resolveable.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 24, 2023

I think determine the type of a calculation also requires this change:

- <calc-constant>: the type is «[ ]» (empty map)
+ <calc-keyword>: the type defined by the corresponding specification for the keyword

In simplify a calculation tree (steps 1, 8, 9), <calc-keyword> should be excluded from numeric values than can be combined, noting that step 1 handles <calc-keyword> (currently <calc-constant>) as a numeric value.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Dec 3, 2023

I think your commit fixed this issue. Thanks!

I edited my previous comment to remove questions that it answers or that the specs already answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted as Obvious Bugfix Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-5 Color modification
Projects
None yet
Development

No branches or pull requests

3 participants