Skip to content

Commit 85be5fe

Browse files
authored
Merge pull request #871 from frivoal/resolving-colors
Resolving colors
2 parents 73df229 + d2e2e5d commit 85be5fe

File tree

1 file changed

+84
-17
lines changed

1 file changed

+84
-17
lines changed

css-color/Overview.bs

Lines changed: 84 additions & 17 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,81 @@ 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+
If ''<color>/currentcolor'' is the specified value of the 'color' property,
174+
it is treated as if the specified value was ''inherit''.
175+
176+
For all other properties that accept a <<color>>,
177+
the computed value of the ''<color>/currentcolor'' keyword is ''<color>/currentcolor'',
178+
and 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+
Issue: Gecko disagrees, and serializes any <<color>> with an alpha channel of 0 as transparent.
190+
No other browser does that though.
191+
192+
<li>
193+
The computed value and used value of
194+
<a>named colors</a> (including <<deprecated-system-color>> colors),
195+
3 and 6 digits <a>hex colors</a>,
196+
4 and 8 digits <a>hex colors</a> with an explicitly opaque alpha channel,
197+
comma separated ''rgb()'' colors without an alpha channel,
198+
comma separated ''rgba()'' colors with an explicitly opaque alpha channel,
199+
comma separated ''hsl()'' colors without an alpha channel,
200+
and comma separated ''hsla()'' colors with an explicitly opaque alpha channel,
201+
is the equivalent numeric value in comma separated ''rgb()'' notation omitting the alpha value.
202+
203+
<li>
204+
The computed value and used value of
205+
4 and 8 digits <a>hex colors</a> with a non opaque alpha channel,
206+
comma separated ''rgba()'' colors with a non opaque alpha channel,
207+
and comma separated ''hsla()'' colors with a non opaque alpha channel,
208+
is the equivalent numeric value in comma separated ''rgba()'' notation with the alpha value.
209+
210+
</ul>
211+
212+
<div class=issue>
213+
The above defines values that are already implemented
214+
based on the most interoperable behavior.
215+
We still need to define how newer syntaxes work:
216+
* comma-less with slash separated optional alpha variants of ''rgb()'', ''rgba()'', ''hsl()'', ''hsla()''
217+
* comma separated with optional alpha variants of ''rgb()'', ''rgba()'', ''hsl()'', ''hsla()''
218+
* ''device-cmyk()''
219+
* ''hwb()''
220+
* ''lab()'' and ''lch()''
221+
* ''gray()''
222+
* ''color()''
223+
* ''color-mod()''
224+
</div>
225+
226+
Issue: Define if changing the working color space should have any impact on the above.
227+
228+
Issue: Various parts of the spec define
229+
the kind of clamping that should happen to the various numeric notations
230+
when the numbers specified are out of range,
231+
and do so with varrying precision, sometimes saying that this happens at computed value time,
232+
sometimes not saying when it happens,
233+
and sometimes not saying anything at all.
234+
Maybe this should be consolidated here.
235+
236+
Any future specification extending the syntax of <<color>>
237+
must define the how to <a>resolve color values</a> for the new extensions.
164238

165239
<h2 id='numeric-rgb'>
166240
RGB Colors</h2>
@@ -308,7 +382,7 @@ Named Colors</h2>
308382
Most of the rest
309383
come from one version of the X11 color system,
310384
used in Unix-derived systems to specify colors for the console.
311-
(Two special color values, ''transparent'' and ''currentcolor'',
385+
(Two special color values, ''transparent'' and ''<color>/currentcolor'',
312386
are specially defined in their own sections.)
313387

314388
Note: The history of the X11 color system is interesting,
@@ -639,20 +713,13 @@ The ''transparent'' keyword</h3>
639713

640714

641715
<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.
716+
The ''<color>/currentcolor'' keyword</h3>
650717

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.
718+
The keyword <dfn value for="<color>">currentcolor</dfn> represents value of the 'color' property on the same element.
719+
Its <a>computed value</a> and <a>used values</a> are determined by <a>resolving color values</a>.
653720

654721
<div class='example'>
655-
Here's a simple example showing how to use the ''currentcolor'' keyword:
722+
Here's a simple example showing how to use the ''<color>/currentcolor'' keyword:
656723

657724
<pre class="lang-css">
658725
.foo {
@@ -673,7 +740,7 @@ The ''currentcolor'' keyword</h3>
673740

674741
<div class='example'>
675742
For example, the 'text-emphasis-color' property [[CSS3-TEXT-DECOR]],
676-
whose initial value is ''currentcolor'',
743+
whose initial value is ''<color>/currentcolor'',
677744
by default matches the text color
678745
even as the 'color' property changes across elements.
679746

@@ -691,7 +758,7 @@ The ''currentcolor'' keyword</h3>
691758
</div>
692759

693760
Note: Multi-word keywords in CSS usually separate their component words with hyphens.
694-
''currentcolor'' doesn't, because it was originally introduced in SVG
761+
''<color>/currentcolor'' doesn't, because it was originally introduced in SVG
695762
as a special attribute value spelled "currentColor",
696763
rather than a CSS value.
697764
Only later did CSS pick it up,

0 commit comments

Comments
 (0)