@@ -120,8 +120,8 @@ Some particular considerations:
120
120
<xmp class='idl'>
121
121
interface CSSStyleValue {
122
122
stringifier;
123
- static CSSStyleValue? parse(DOMString property, DOMString cssText);
124
- static sequence<CSSStyleValue>? parseAll(DOMString property, DOMString cssText);
123
+ static CSSStyleValue parse(DOMString property, DOMString cssText);
124
+ static sequence<CSSStyleValue> parseAll(DOMString property, DOMString cssText);
125
125
};
126
126
</xmp>
127
127
@@ -136,50 +136,78 @@ return a normalized representation
136
136
(see [[#stylevalue-normalization]] )
137
137
of the value the {{CSSStyleValue}} object represents.
138
138
139
- The <dfn method for=CSSStyleValue>parse(DOMString <var>property</var>, DOMString <var>cssText</var>)</dfn> ,
140
- when invoked, must [=parse a CSSStyleValue=] with property <var> property</var> , cssText <var> cssText</var> ,
141
- and parseMultiple set to false.
139
+ The <dfn method for=CSSStyleValue>parse(|property|, |cssText|)</dfn> method,
140
+ when invoked,
141
+ must [=parse a CSSStyleValue=]
142
+ with property |property|, cssText |cssText|, and parseMultiple set to false.
142
143
143
- The <dfn method for=CSSStyleValue>parseAll(DOMString <var>property</var>, DOMString <var>cssText</var>)</dfn> ,
144
- when invoked, must [=parse a CSSStyleValue=] with property <var> property</var> , cssText <var> cssText</var> ,
145
- and parseMultiple set to true.
144
+ The <dfn method for=CSSStyleValue>parseAll(|property|, |cssText|)</dfn> ,
145
+ when invoked,
146
+ must [=parse a CSSStyleValue=]
147
+ with property |property|, cssText |cssText|, and parseMultiple set to true.
146
148
147
149
<div algorithm="parse a CSSStyleValue">
148
- To <dfn>parse a CSSStyleValue</dfn> given a <var> property</var> , <var> cssText</var> , and a
149
- <var> parseMultiple</var> flag, run these steps:
150
+ To <dfn>parse a CSSStyleValue</dfn> given a [=string=] | property|, a [=string=] | cssText|,
151
+ and a | parseMultiple| flag, run these steps:
150
152
151
- 1. Attempt to parse |property| as an <<ident>> .
152
- If this fails,
153
- [=throw=] a {{TypeError}} and exit this algorithm.
154
- Otherwise, let |property| be the parsed result.
155
- If |property| does not start with two dashes (U+002D HYPHEN),
153
+ 1. If |property| is not a [=custom property name string=] ,
156
154
let |property| be |property| [=ASCII lowercased=] .
157
155
158
- 2. If |property| is not a [[=valid CSS property=] ,
156
+ 2. If |property| is not a [=valid CSS property=] ,
157
+ [=throw=] a {{TypeError}} and exit this algorithm.
158
+
159
+ 3. If |parseMultiple| is true,
160
+ but |property| is a [=single-valued property=] ,
159
161
[=throw=] a {{TypeError}} and exit this algorithm.
160
162
161
- 3. Attempt to <a lt="parse something according to a CSS grammar">parse</a> |cssText| according to |property|’s grammar.
163
+ 3. Attempt to [= CSS/parse=] |cssText| according to |property|’s grammar.
162
164
If this fails,
163
165
[=throw=] a {{TypeError}} and exit this algorithm.
164
166
Otherwise,
165
- let |value| be the parsed result.
167
+ let |whole value| be the parsed result.
166
168
167
- 4. If |parseMultiple| is true,
168
- subdivide |value| into a list of {{CSSStyleValue}} objects,
169
- each representing one [=list-valued property iteration=] ,
170
- and let |value| be the result. Return |value| as a sequence of
171
- {{CSSStyleValue}} objects.
169
+ 4. [=Subdivide into iterations=] |whole value|,
170
+ according to |property|,
171
+ and let |values| be the result.
172
172
173
- 5. If |parseMultiple| is false
174
- subdivide |value| into a list of {{CSSStyleValue}} objects,
175
- each representing one [=list-valued property iteration=] ,
176
- and let |value| be the first entry in this list.
177
-
178
- 6. return a {{CSSStyleValue}} representing |value|.
173
+ 5. [=list/For each=] |value| in |values|,
174
+ replace it with the result of [=normalize a CSS value|normalizing=] |value| for |property|.
179
175
176
+ 6. If |parseMultiple| is false,
177
+ return |values|[0] .
178
+ Otherwise, return |values|.
180
179
</div>
181
180
182
- Issue(305): appropriate failure indicators for this algorithm
181
+ <div algorithm>
182
+ To <dfn export>subdivide into iterations</dfn>
183
+ a CSS value |whole value|
184
+ for a property |property|,
185
+ execute the following steps:
186
+
187
+ 1. If |property| is a [=single-valued property=] ,
188
+ return a [=list=] containing |whole value|.
189
+
190
+ 2. Otherwise,
191
+ divide |whole value| into individual iterations,
192
+ as appropriate for |property|,
193
+ and return a [=list=] containing the iterations in order.
194
+
195
+ <div class=note>
196
+ How to divide a [=list-valued property=] into iterations
197
+ is intentionally undefined and hand-wavey at the moment.
198
+ <em> Generally</em> ,
199
+ you just split it on top-level commas
200
+ (corresponding to a top-level `<foo> #` term in the grammar),
201
+ but some legacy properties (such as 'counter-reset' )
202
+ don't separate their iterations with commas,
203
+ and some properties (such as 'animation' )
204
+ use a special singular value (generally ''animation/none'' )
205
+ to indicate <strong> zero</strong> iterations.
206
+
207
+ It's expected to be rigorously defined in the future,
208
+ but at the moment is explicitly a "you know what we mean" thing.
209
+ </div>
210
+ </div>
183
211
184
212
<!--
185
213
██████ ████████ ██ ██ ██ ████████ ██ ██ ███ ████████
@@ -377,7 +405,7 @@ probably in an appendix.
377
405
2. If |property| is not a [[=valid CSS property=] ,
378
406
[=throw=] a {{TypeError}} and exit this algorithm.
379
407
380
- 3. If |property| is a [=single-valued property=] and |values| has more than one [=list/entry =] ,
408
+ 3. If |property| is a [=single-valued property=] and |values| has more than one [=list/item =] ,
381
409
[=throw=] a {{TypeError}} and exit this algorithm.
382
410
383
411
4. Let |props| be |this|’s [=StylePropertyMap/map entries=] .
@@ -2479,10 +2507,11 @@ Issue(159): Spec up ColorValue
2479
2507
{{CSSStyleValue}} normalization {#stylevalue-normalization}
2480
2508
===========================================================
2481
2509
2482
- This section describes how Typed OM objects are constructed from CSS values.
2510
+ This section describes how Typed OM objects are constructed from abstract CSS values
2511
+ (aka how to <dfn export>normalize a CSS value</dfn> for a given property).
2483
2512
2484
2513
If a property's grammar is more complex than one of the types listed here,
2485
- it produces a raw {{CSSStyleValue}} ,
2514
+ it [=normalizes=] to a raw {{CSSStyleValue}} ,
2486
2515
with a <a for=CSSStyleValue>stringification behavior</a>
2487
2516
that produces the CSSOM serialization of the property.
2488
2517
0 commit comments