Skip to content

Commit 193d58b

Browse files
committed
[css-color] Define "resolving color values"
This is a first pass at providing a centralized definition of how all <<color>> values are treated at computed value and used value time. This relates to w3c#741, w3c#480, w3c#867
1 parent 861c205 commit 193d58b

File tree

1 file changed

+66
-13
lines changed

1 file changed

+66
-13
lines changed

css-color/Overview.bs

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ Foreground Color: the 'color' property</h2>
6060
Inherited: yes
6161
Percentages: N/A
6262
Media: visual
63-
Computed value: an RGBA color
63+
Computed value: See <a>resolving color values</a>
6464
</pre>
6565

6666
This property describes the foreground fill color of an element's text content.
67-
In addition, it provides the value that ''currentcolor'' resolves to.
68-
If the ''currentcolor'' keyword is set on the 'color' property itself, it is treated as ''color: inherit''.
67+
In addition, it provides the value that ''<color>/currentcolor'' resolves to.
6968

7069
The initial value of this property is ''black''.
7170

@@ -161,6 +160,67 @@ Notes On Using Colors</h3>
161160
Really? Isn't HD video in Rec.709? Shouldn't video be consistent with images?
162161
Or do implementations really do this differently?
163162

163+
<h2 id='resolving-color-values'>
164+
Resolving Color values</h2>
165+
166+
Various properties accept <<color>> values.
167+
Unless an exception is explicitly defined,
168+
all such properties must <dfn lt="resolve color values|resolving color values">resolve color values</dfn> as defined below
169+
to determine the <a>computed value</a> and the <a>used value</a> for <<color>>.
170+
171+
<ul>
172+
<li>
173+
The computed value of the ''<color>/currentcolor'' keyword is ''<color>/currentcolor''.
174+
175+
If ''<color>/currentcolor'' is used as the value of the 'color' property,
176+
the used value is the same as if ''inherit'' had been specified instead.
177+
For all other properties that accept a <<color>>,
178+
the used value of ''<color>/currentcolor'' is the same as
179+
the used value of the 'color' property on the same element.
180+
181+
Note: This means that if the ''<color>/currentcolor'' value is inherited,
182+
it’s inherited as a keyword,
183+
not as the value of the 'color' property,
184+
so descendants will use their own 'color' property to resolve it.
185+
186+
<li>
187+
The computed value and used value of ''<color>/transparent'' is ''rgba(0,0,0,0)''.
188+
189+
<li>
190+
The computed value and used value of
191+
<a>named colors</a> (including <<deprecated-system-color>> colors),
192+
3 and 6 digits <a>hex colors</a>,
193+
comma separated ''rgb()'' colors without an alpha channel,
194+
and comma separated ''hsl()'' colors without an alpha channel,
195+
is the equivalent numeric value in comma separated ''rgb()'' notation omitting the alpha value.
196+
197+
<li>
198+
The computed value and used value of
199+
4 and 8 digits <a>hex colors</a>,
200+
comma separated ''rgba()'' colors with an alpha channel,
201+
and comma separated ''hsla()'' colors with an alpha channel,
202+
is the equivalent numeric value in comma separated ''rgba()'' notation with the alpha value.
203+
204+
</ul>
205+
206+
<div class=issue>
207+
The above defines values that are already implemented
208+
based on the most interoperable behavior.
209+
We still need to define how newer syntaxes work:
210+
* comma-less with slash separated optional alpha variants of ''rgb()'', ''rgba()'', ''hsl()'', ''hsla()''
211+
* comma separated with optional alpha variants of ''rgb()'', ''rgba()'', ''hsl()'', ''hsla()''
212+
* ''device-cmyk()''
213+
* ''hwb()''
214+
* ''lab()'' and ''lch()''
215+
* ''gray()''
216+
* ''color()''
217+
* ''color-mod()''
218+
</div>
219+
220+
Issue: Define if changing the working color space should have any impact on the above.
221+
222+
Any future specification extending the syntax of <<color>>
223+
must define the how to <a>resolve color values</a> for the new extensions.
164224

165225
<h2 id='numeric-rgb'>
166226
RGB Colors</h2>
@@ -639,17 +699,10 @@ The ''transparent'' keyword</h3>
639699

640700

641701
<h3 id='currentcolor-color'>
642-
The ''currentcolor'' keyword</h3>
643-
644-
The keyword <dfn value for="<color>">currentcolor</dfn> takes its value from the value of the 'color' property on the same element.
645-
This happens at <strong>used-value time</strong>,
646-
which means that if the value is inherited,
647-
it's inherited as ''currentcolor'',
648-
not as the value of the 'color' property,
649-
so descendants will use their <em>own</em> 'color' property to resolve it.
702+
The ''<color>/currentcolor'' keyword</h3>
650703

651-
If ''currentcolor'' is used as the value of the 'color' property,
652-
it instead takes its value from the inherited value of the 'color' property.
704+
The keyword <dfn value for="<color>">currentcolor</dfn> represents value of the 'color' property on the same element.
705+
Its <a>computed value</a> and <a>used values</a> are determined by <a>resolving color values</a>.
653706

654707
<div class='example'>
655708
Here's a simple example showing how to use the ''currentcolor'' keyword:

0 commit comments

Comments
 (0)