Re: color parsing from web manifest spec

On Wed, Apr 17, 2019 at 10:10 PM Marcos Caceres <marcos@marcosc.com> wrote:
> Folks working on the web manifest spec are seeking guidance on how to correctly process a CSS Color value from outside the context of a stylesheet.
>
> The Web Manifest spec defines members like:
>
> ```JSON
> {
>   "theme_color": "aliceblue",
>   "background_color": "rgb(200,2,23)",
> }
> ```
>
> To process those members, we'd like to send them into the CSS parsing/processing machinery and get back either a parsing error or possibly a value in a canonical form (e.g., in Gecko, we convert to these members to hex value to pass to the Android subsystem). We could use some guidance on the appropriate entry points and the kinds of normalization's we should do on those values, if any.
>
> Happy to discuss here or on GitHub:
> https://github.com/w3c/manifest/issues/760

You want to invoke the CSS/parse algorithm
<https://drafts.csswg.org/css-syntax/#parse-grammar>, parsing the
string as a <color>. You can then specify that you want the value
canonicalized to an sRGB triple, and do what you want with it.

Note that `currentcolor` (and possibly the system colors, depending on
the resolution of an issue we opened today) need more information
about the element they're being used on to turn into RGB; you can
explicitly exclude those. `device-cmyk()` can't be turned into RGB at
all without information from the output device; you can either exclude
that or specify that it gets "naively converted"
<https://drafts.csswg.org/css-color/#naively-convert-from-cmyk-to-rgba>
to RGB.

Received on Friday, 19 April 2019 04:31:57 UTC