Re: [css-houdini-drafts] [css-paint-api][css-typed-om] Current Color as an input to paint worklets (#921)

We have two factors at this point to consider:

- Web compat with existing content built for the shipped Chrome implementation, that expect the `toString()` result of the [`CSSStyleValue`](https://drafts.css-houdini.org/css-typed-om/#cssstylevalue) object for color properties to always return an `rgb()` or `rgba()` function.  (Most such content wouldn't need to *parse* the function like my demo did, but they would need it to be valid when used directly to set a canvas API color property.)

- The long-term goals of (a) having `currentColor` inherit as a keyword on all browsers, and (b) having a useful `CSSColorValue` object that can represent all color syntaxes (keywords and functions) and maybe do useful things like converting between function types.

I think these constraints can be satisfied if we say that:

- `currentColor` is first and formost a _color_ value, rather than a generic keyword. In Typed OM, it will be represented by `CSSColorValue`, just like other color keywords will be, not by `CSSKeywordValue`.

- the future `CSSColorValue` type will have some way of associating it (maybe an internal slot, maybe exposed by the API) with an palette of resolvable values for `currentColor` and the system color keywords, and these values will automatically be filled in when the color value is part of a computed style.

- the stringifier for `CSSColorValue` should return resolved rgb/rgba values whenever possible, using the associated element palette if it exists.

> Worst case, we can offer a special-purpose API to the PaintWorklet that resolves colors for you.

This is an alternative. Or just allow the paint context APIs to take contextual color keywords and resolve them against the element being painted.

-- 
GitHub Notification of comment by AmeliaBR
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/921#issuecomment-547722821 using your GitHub account

Received on Wednesday, 30 October 2019 03:23:41 UTC