@@ -2880,72 +2880,79 @@ with the subclasses representing individual CSS color functions.
28802880<xmp class='idl'>
28812881[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
28822882interface CSSColorValue : CSSStyleValue {
2883- CSSRGB toRGB();
2884- CSSHSL toHSL();
2885- CSSHWB toHWB();
2886- CSSGray toGray();
2887- CSSLCH toLCH();
2888- CSSLab toLab();
2889- CSSColor toColor(CSSKeywordish colorspace);
2890- CSSDeviceCMYK toDeviceCMYK();
2891-
2883+ readonly attribute CSSKeywordValue colorSpace;
2884+ CSSColorValue to(CSSKeywordish colorSpace);
28922885 [Exposed=Window] static CSSColorValue parse(USVString cssText);
28932886};
28942887</xmp>
28952888
2896- <div algorithm="CSSColorValue.to*()">
2897- The <dfn method for=CSSColorValue>toRGB()</dfn> method
2898- of {{CSSColorValue}} objects must,
2899- when called on |this|,
2900- convert |this| into an sRGB color,
2901- and return a new {{CSSRGB}} object
2902- with its {{CSSRGB/r}} , {{CSSRGB/g}} , {{CSSRGB/b}} , and {{CSSRGB/alpha}} internal slots
2903- set appropriately to represent that color.
2904-
2905- The <dfn method for=CSSColorValue>toHSL()</dfn>
2906- and <dfn method for=CSSColorValue>toHWB()</dfn> methods
2907- of {{CSSColorValue}} objects
2908- must do the same as {{toRGB()}} ,
2909- but return a {{CSSHSL}} or {{CSSHWB}} object, respectively,
2910- with their corresponding internal slots set appropriately.
2911-
2912- The <dfn method for=CSSColorValue>toGray()</dfn> ,
2913- <dfn method for=CSSColorValue>toLCH()</dfn> ,
2914- and <dfn method for=CSSColorValue>toLab()</dfn> methods
2915- of {{CSSColorValue}} objects must,
2916- when called on |this|,
2917- convert |this| into a CIE L*a*b* color [[CIELAB]] ,
2918- and return a new {{CSSGray}} , {{CSSLCH}} , or {{CSSLab}} object, respectively,
2919- with their corresponding internal slots set appropriately.
2889+ <div algorithm=CSSColorValue.colorSpace>
2890+ The <dfn attribute for=CSSColorValue>colorSpace</dfn> attribute
2891+ must reflect the color space of the value.
2892+ For every class but {{CSSColor}} ,
2893+ it is a static {{CSSKeywordValue}} ,
2894+ with the value given by the following table:
2895+
2896+ <table class=data>
2897+ <thead>
2898+ <tr><th> |colorspace|<th> {{CSSColorValue}} subclass
2899+ </thead>
2900+ <tr><td> "rgb"<td> {{CSSRGB}}
2901+ <tr><td> "hsl"<td> {{CSSHSL}}
2902+ <tr><td> "hwb"<td> {{CSSHWB}}
2903+ <tr><td> "gray"<td> {{CSSGray}}
2904+ <tr><td> "lch"<td> {{CSSLCH}}
2905+ <tr><td> "lab"<td> {{CSSLab}}
2906+ <tr><td> "device-cmyk"<td> {{CSSDeviceCMYK}}
2907+ </table>
2908+
2909+ {{CSSColor}} defines its behavior for this attribute further down.
29202910</div>
29212911
2922- <div algorithm="CSSColorValue.toColor ()">
2923- The <dfn method for=CSSColorValue>toColor(|colorspace| )</dfn> method
2912+ <div algorithm="CSSColorValue.to ()">
2913+ The <dfn method for=CSSColorValue>to(colorSpace )</dfn> method
29242914 of {{CSSColorValue}} objects must,
2925- when called on |this|,
2926- perform the following steps:
2927-
2928- 1. Replace |colorspace| with the result of [=rectifying a keywordish value=] .
2929-
2930- 2. If |colorspace|'s value is not one of the [[css-color-4#predefined|predefined colorspaces]] ,
2931- [=throw=] a {{SyntaxError}} .
2932-
2933- 3. Convert |this| into a color in the colorspace specified by |colorspace|,
2934- and return a new {{CSSColor}} object
2935- with TODO.
2915+ when called on |this|:
2916+
2917+ 1. [=Rectify a keywordish value=] from |colorspace|,
2918+ then set |colorspace| to the result's value.
2919+
2920+ 2. If |colorspace| is not in the table below,
2921+ [=throw=] a "{{SyntaxError}} " {{DOMException}} .
2922+
2923+ 3. If |this| is a {{CSSColor}} value,
2924+ and its {{CSSColor/colorSpace}} attribute is not a [[css-color-4#predefined|predefined colorspace]] ,
2925+ [=throw=] an "{{InvalidModificationError}} " {{DOMException}} .
2926+
2927+ 2. Convert |this| into the color space indicated by |colorspace|,
2928+ and return a new object of the appropriate {{CSSColorValue}} subclass
2929+ with its internal slots set appropriately to represent the color.
2930+
2931+ The valid |colorspace| values,
2932+ and the classes they cause this method to return,
2933+ are indicated by the following table.
2934+ Each of these values is [=ASCII case-insensitive=] .
2935+
2936+ <table class=data>
2937+ <thead>
2938+ <tr><th> |colorspace|<th> {{CSSColorValue}} subclass
2939+ </thead>
2940+ <tr><td> "rgb"<td> {{CSSRGB}}
2941+ <tr><td> "hsl"<td> {{CSSHSL}}
2942+ <tr><td> "hwb"<td> {{CSSHWB}}
2943+ <tr><td> "gray"<td> {{CSSGray}}
2944+ <tr><td> "lch"<td> {{CSSLCH}}
2945+ <tr><td> "lab"<td> {{CSSLab}}
2946+ <tr><td> "device-cmyk"<td> {{CSSDeviceCMYK}}
2947+ <tr><td> any [[css-color-4#predefined|predefined colorspace]] <td> {{CSSColor}}
2948+ </table>
2949+
2950+ Issue: Currently, only predefined colorspaces can be converted to or from;
2951+ ''@color-profile'' -defined ones can't be,
2952+ because it's not clear what context we should be looking in for the ''@color-profile'' ,
2953+ when shadow DOM might be involved.
29362954</div>
29372955
2938- <div algorithm="CSSColorValue.toDeviceCMYK()">
2939- The <dfn method for=CSSColorValue>toDeviceCMYK()</dfn> method
2940- of {{CSSColorValue}} object must,
2941- when called on |this|,
2942- convert |this| into an sRGB color,
2943- then [=naively convert from RGBA to CMYK=]
2944- and return a new {{CSSDeviceCMYK}} object
2945- with its {{CSSDeviceCMYK/c}} , {{CSSDeviceCMYK/m}} , {{CSSDeviceCMYK/y}} , {{CSSDeviceCMYK/k}} , and {{CSSDeviceCMYK/alpha}} internal slots
2946- set appropriately to represent that color.<
2947- /div>
2948-
29492956<div algorithm="CSSColorValue.parse()">
29502957 The <dfn method for=CSSColorValue>parse(|cssText|)</dfn> method,
29512958 when called,
@@ -3202,8 +3209,8 @@ The {{CSSLab}} class represents the CSS ''lab()'' function.
32023209<xmp class=idl>
32033210[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
32043211interface CSSColor : CSSColorValue {
3205- constructor(CSSKeywordish colorspace , sequence<CSSNumberish> channels, optional CSSNumberish alpha = 1);
3206- attribute CSSKeywordish colorspace ;
3212+ constructor(CSSKeywordish colorSpace , sequence<CSSNumberish> channels, optional CSSNumberish alpha = 1);
3213+ attribute CSSKeywordish colorSpace ;
32073214 attribute CSSPercentishArray channels;
32083215 attribute CSSNumberish alpha;
32093216};
@@ -3212,7 +3219,7 @@ interface CSSColor : CSSColorValue {
32123219The {{CSSColor}} class represents the CSS ''color()'' function.
32133220
32143221<div algorithm="CSSColor()">
3215- The <dfn constructor for=CSSColor>CSSColor(|colorspace |, |channels|, optional |alpha|)</dfn> constructor
3222+ The <dfn constructor for=CSSColor>CSSColor(|colorSpace |, |channels|, optional |alpha|)</dfn> constructor
32163223 must, when invoked,
32173224 perform the following steps:
32183225
@@ -3236,7 +3243,7 @@ The {{CSSColor}} class represents the CSS ''color()'' function.
32363243
32373244 The <dfn attribute for=CSSColor>channels</dfn> attribute of a {{CSSColor}} value
32383245 must, on setting to a new value |val|,
3239- [=rectify a percentish array=] from |val"
3246+ [=rectify a percentish array=] from |val|
32403247 and set the corresponding internal slot to the result of that.
32413248
32423249 The <dfn attribute for=CSSColor>alpha</dfn> attribute of a {{CSSColor}} value
0 commit comments