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

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