W3C home > Mailing lists > Public > www-style@w3.org > July 2014

Re: [css-color] Exposing browser color parsing to JS

From: Simon Sapin <simon.sapin@exyr.org>
Date: Wed, 09 Jul 2014 17:27:42 +0100
Message-ID: <53BD6D7E.2080007@exyr.org>
To: www-style@w3.org
On 08/07/14 00:27, Tab Atkins Jr. wrote:
> Here's my first draft of a proposal for it:
> <http://wiki.csswg.org/ideas/color-object>

I think the general idea is good. On the specifics:

> partial interface CSS {
>   CSSColor parseColor(DOMString color, optional Element el);
> };
>
> If parseColor is called with a color that depends on the element on
> which it is used, such as currentcolor or inherit, but no el argument
> was passed, throw a XXX error.

Should the CSSColor return type be RGBAColor?


I’m not convinced the element parameter is useful. 'inherit' is not a 
<color>. The only <color> value that would depend on the element is 
'currentcolor', and parsing 'currentcolor' is not that interesting.

I think the Color spec should define:

<color> = <rgba-compatible-color> | <device-cmyk()> | currentcolor
<rgba-compatible-color> = (every other value)

And parseColor() could parse just <rgba-compatible-color>.

-- 
Simon Sapin
Received on Wednesday, 9 July 2014 16:28:09 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 9 July 2014 16:28:10 UTC