@@ -2880,72 +2880,79 @@ with the subclasses representing individual CSS color functions.
2880
2880
<xmp class='idl'>
2881
2881
[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
2882
2882
interface 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);
2892
2885
[Exposed=Window] static CSSColorValue parse(USVString cssText);
2893
2886
};
2894
2887
</xmp>
2895
2888
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.
2920
2910
</div>
2921
2911
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
2924
2914
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.
2936
2954
</div>
2937
2955
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
-
2949
2956
<div algorithm="CSSColorValue.parse()">
2950
2957
The <dfn method for=CSSColorValue>parse(|cssText|)</dfn> method,
2951
2958
when called,
@@ -3202,8 +3209,8 @@ The {{CSSLab}} class represents the CSS ''lab()'' function.
3202
3209
<xmp class=idl>
3203
3210
[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
3204
3211
interface 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 ;
3207
3214
attribute CSSPercentishArray channels;
3208
3215
attribute CSSNumberish alpha;
3209
3216
};
@@ -3212,7 +3219,7 @@ interface CSSColor : CSSColorValue {
3212
3219
The {{CSSColor}} class represents the CSS ''color()'' function.
3213
3220
3214
3221
<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
3216
3223
must, when invoked,
3217
3224
perform the following steps:
3218
3225
@@ -3236,7 +3243,7 @@ The {{CSSColor}} class represents the CSS ''color()'' function.
3236
3243
3237
3244
The <dfn attribute for=CSSColor>channels</dfn> attribute of a {{CSSColor}} value
3238
3245
must, on setting to a new value |val|,
3239
- [=rectify a percentish array=] from |val"
3246
+ [=rectify a percentish array=] from |val|
3240
3247
and set the corresponding internal slot to the result of that.
3241
3248
3242
3249
The <dfn attribute for=CSSColor>alpha</dfn> attribute of a {{CSSColor}} value
0 commit comments