Skip to content

Commit 446bba4

Browse files
committed
[css-properties-values-api] Rewrite the computed value stuff to be more correct and lean more on external definitions.
1 parent b62ac70 commit 446bba4

File tree

1 file changed

+31
-38
lines changed

1 file changed

+31
-38
lines changed

css-properties-values-api/Overview.bs

Lines changed: 31 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ The registered syntax of the property is <em>not</em> checked at parse time.
113113
Note: However,
114114
the syntax is checked at computed-value time,
115115
before substitution via ''var()''.
116-
See [[#computed-value]].
116+
See [[#calculation-of-computed-values]].
117117

118118
<details class=note>
119119
<summary>Why aren't custom properties syntax-checked?</summary>
@@ -163,7 +163,7 @@ See [[#computed-value]].
163163
Calculation of Computed Values {#calculation-of-computed-values}
164164
----------------------------------------------------------------
165165

166-
The [=computed value=] of a [=registered property=]
166+
The [=computed value=] of a [=registered custom property=]
167167
is determined by the syntax it's registered with.
168168

169169
Note: All properties, regardless of registered syntax,
@@ -172,26 +172,30 @@ such as ''inherit'' or ''revert''.
172172
These are handled at [=specified value=] time,
173173
as defined in [[css-cascade-4#defaulting-keywords]].
174174

175-
For <code>"&lt;length>"</code> values,
176-
the computed value is the absolute length expressed in pixels.
177-
178-
For <code>"&lt;length-percentage>"</code> values,
179-
the computed value is one of the following:
180-
181-
* if the specified value contains only length units,
182-
the computed value is the absolute length expressed in pixels.
183-
* if the specified value contains only percentages,
184-
the computed value is a simple percentage.
185-
* otherwise, the computed value is a calc expression
186-
containing an absolute length expressed in pixels,
187-
and a percentage value.
188-
189-
For <code>"&lt;angle>"</code>, <code>"&lt;time>"</code> and <code>"&lt;resolution>"</code> values,
190-
the computed value is the value expressed in its [=canonical unit=],
191-
with ''calc()'' expressions evaluated [[css-values-4#calc-computed-value|as described in CSS Values]].
175+
For <code>"&lt;length>"</code>,
176+
<code>"&lt;length-percentage>"</code>,
177+
<code>"&lt;angle>"</code>,
178+
<code>"&lt;time>"</code>,
179+
<code>"&lt;resolution>"</code>,
180+
<code>"&lt;integer>"</code>,
181+
<code>"&lt;number>"</code>,
182+
and <code>"&lt;percentage>"</code> values:
183+
184+
* If the specified value is a [=dimension=] literal
185+
(such as ''50em'' or ''.2s''),
186+
the computed value is the same value,
187+
but with the unit converted to the corresponding [=canonical unit=]
188+
for the type of value.
189+
* If the specified value is any other numeric literal
190+
(such as ''5'' or ''20%''),
191+
the computed value is as specified.
192+
(In particular, percentages are never resolved against anything.)
193+
* If the specified value is a function that evaluates to one of those types
194+
(such as a [=math function=]),
195+
the computed value is defined by that function.
192196

193197
For <code>"&lt;color>"</code> values,
194-
the value is computed as described in [[css-color-4#resolving-color-values]].
198+
the value is computed by [=resolving color values=].
195199

196200
For <code>"&lt;custom-ident>"</code>, ident, or <code>"*"</code> values,
197201
the computed value is as specified.
@@ -204,28 +208,17 @@ the computed value is one of the following:
204208
* otherwise, the computed value is as specified.
205209

206210
For <code>"&lt;image>"</code> values,
207-
the computed value is as specified,
208-
except that relative URLs that appear in the value are resolved to absolute URLs
209-
as described in [[!css3-values]],
210-
and all lengths are resolved to their computed values.
211+
the computed value is the [=computed &lt;image>=].
211212

212-
For <code>"&lt;integer>"</code>, <code>"&lt;number>"</code> and <code>"&lt;percentage>"</code> values,
213-
the computed value is one of the following:
214-
215-
* if the specified value is a ''calc()'' expression,
216-
the computed value is the evaluated result of that expression.
217-
* otherwise, the computed value is as specified.
218-
219-
For <code>"&lt;transform-function>"</code> values
220-
(including those contained in <code>"&lt;transform-list>"</code> values),
213+
For <code>"&lt;transform-function>"</code> and <code>"&lt;transform-list>"</code> values,
221214
the computed value is as specified but with all lengths resolved to their computed values.
222215

223-
For values specified by a syntax string that include "|" clauses,
224-
the computed value is given by applying the calculation rules
225-
for the first clause that matches to the specified value.
216+
For values with [[#multipliers|multipliers]],
217+
the computed value is a list of the computed values of the base type.
226218

227-
For list values,
228-
the computed value is a list of the computed values of the primitives in the list.
219+
For syntaxes specified with [[#combinator|the | combinator]],
220+
the computed value is given by applying the computed-value rules
221+
for the first clause that matches to the specified value.
229222

230223

231224
Animation Behavior of Custom Properties {#animation-behavior-of-custom-properties}

0 commit comments

Comments
 (0)