Skip to content

Commit afafaa5

Browse files
committed
[css-color-4] Add 'parse a css color' algorithm, so non-CSS specs using colors don't have to reinvent the machinery here.
1 parent 710b56c commit afafaa5

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

css-color-4/Overview.bs

+30
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,36 @@ any achromatic color will have a [=powerless=] hue component.
11151115
still treat the hue component as [=powerless=].
11161116
It is intentionally unspecified exactly what "sufficiently close" means for this purpose.
11171117

1118+
<h3 id=parse-color>
1119+
Parsing a <<color>> Value</h3>
1120+
1121+
<div algorithm>
1122+
To <dfn export>parse a CSS <<color>> value</dfn>,
1123+
given a [=string=] |input|,
1124+
and an optional context <l spec=dom>[=/element=]</l> |element|:
1125+
1126+
1. [=CSS/Parse=] |input| as a <<color>>.
1127+
If the result is failure,
1128+
return failure;
1129+
otherwise, let |color| be the result.
1130+
1131+
2. If |element| was passed,
1132+
let |currentcolor| be the [=used value=] of the 'color' property
1133+
on |element|,
1134+
and |color-scheme| be the [=used value=] of the 'color-scheme' property
1135+
on |element|.
1136+
1137+
Otherwise,
1138+
let |currentcolor| and |color-scheme|
1139+
be the [=initial values=] of 'color' and 'color-scheme', respectively.
1140+
1141+
3. Let |used color| be the result of [[#resolving-color-values|resolving]] |color|
1142+
to a [=used color=],
1143+
using the |currentcolor| and |color-scheme| values if necessary.
1144+
1145+
4. Return |used color|.
1146+
</div>
1147+
11181148

11191149

11201150

0 commit comments

Comments
 (0)