Skip to content

Commit

Permalink
[css-color-4] Add 'parse a css color' algorithm, so non-CSS specs usi…
Browse files Browse the repository at this point in the history
…ng colors don't have to reinvent the machinery here.
  • Loading branch information
tabatkins committed Nov 20, 2023
1 parent 710b56c commit afafaa5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions css-color-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,36 @@ any achromatic color will have a [=powerless=] hue component.
still treat the hue component as [=powerless=].
It is intentionally unspecified exactly what "sufficiently close" means for this purpose.

<h3 id=parse-color>
Parsing a <<color>> Value</h3>

<div algorithm>
To <dfn export>parse a CSS <<color>> value</dfn>,
given a [=string=] |input|,
and an optional context <l spec=dom>[=/element=]</l> |element|:

1. [=CSS/Parse=] |input| as a <<color>>.
If the result is failure,
return failure;
otherwise, let |color| be the result.

2. If |element| was passed,
let |currentcolor| be the [=used value=] of the 'color' property
on |element|,
and |color-scheme| be the [=used value=] of the 'color-scheme' property
on |element|.

Otherwise,
let |currentcolor| and |color-scheme|
be the [=initial values=] of 'color' and 'color-scheme', respectively.

3. Let |used color| be the result of [[#resolving-color-values|resolving]] |color|
to a [=used color=],
using the |currentcolor| and |color-scheme| values if necessary.

4. Return |used color|.
</div>




Expand Down

0 comments on commit afafaa5

Please sign in to comment.