Skip to content

[css-color-4] When do color space conversions happen? #867

@frivoal

Description

@frivoal

Maybe I missed something, but as far as I can tell css-color-4 is silent about whether converting colors expressed in different profiles/spaces (using color(), lab(), lch(), or gray()) to the working color space is something that happens at computed value time, used value time, or some other time, and how that affects serialization.

Given that for color properties, the resolved value returned by getComputedStyle() is the used value, the serialization should be the same if the conversion happens at computed or used value time: the converted value. However, when the working color space is (for instance) sRGB, if we expect color(rec2020 0 255 127) to serialize as color(rec2020 0 255 127) rather than as rgb( x, y, z) (or color(srgb x y z)) then supposedly, the conversion must happen after used value time.

On the other hand, if the conversion is handled after computed value time, presumably this means we cannot animate from color(foo 1 2 3) to color(bar 4 5 6).

I think that being able to animate between all sorts of colors is more valuable than a more literal serialization (and we already do all sorts of changes to the computed value anyway), so I'd lead towards doing the conversion at computed value time.

I'm guessing this is the intent of the spec already, but I have not found a clear statement one way or the other.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions