From afafaa523fc38ad4607e0905506424b949dd8461 Mon Sep 17 00:00:00 2001 From: Tab Atkins-Bittner Date: Mon, 20 Nov 2023 11:27:56 -0800 Subject: [PATCH] [css-color-4] Add 'parse a css color' algorithm, so non-CSS specs using colors don't have to reinvent the machinery here. --- css-color-4/Overview.bs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/css-color-4/Overview.bs b/css-color-4/Overview.bs index d20e1399a4b7..e172eec54060 100644 --- a/css-color-4/Overview.bs +++ b/css-color-4/Overview.bs @@ -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. +

+Parsing a <> Value

+ +
+ To parse a CSS <> value, + given a [=string=] |input|, + and an optional context [=/element=] |element|: + + 1. [=CSS/Parse=] |input| as a <>. + 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|. +
+