Skip to content

Commit d535310

Browse files
committed
[css-style-attr] Parse at-rules in declarations lists, like @page.
(No such at-rule is defined yet, this is only for error handling purpose.) Working Group resolution: http://lists.w3.org/Archives/Public/www-style/2013May/0783.html
1 parent 74123c8 commit d535310

File tree

2 files changed

+70
-11
lines changed

2 files changed

+70
-11
lines changed

css-style-attr/Overview.html

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ <h2 class="no-num no-toc" id=contents>Table of contents</h2>
235235
<li><a href="#interpret"><span class=secno>4. </span>Cascading and
236236
Interpretation</a>
237237

238-
<li><a href="#ack"><span class=secno>5. </span>Acknowledgments</a>
238+
<li><a href="#changes"><span class=secno>5. </span>Changes</a>
239239

240-
<li><a href="#references"><span class=secno>6. </span>References </a>
240+
<li><a href="#ack"><span class=secno>6. </span>Acknowledgments</a>
241+
242+
<li><a href="#references"><span class=secno>7. </span>References </a>
241243
<ul class=toc>
242244
<li class=no-num><a href="#normative-references">Normative
243245
references</a>
@@ -325,25 +327,45 @@ <h2 id=syntax><span class=secno>3. </span>Syntax and Parsing</h2>
325327

326328
<pre>
327329
declaration-list
328-
: S* declaration? [ ';' S* declaration? ]*
330+
: S* declaration-list-next
329331
;
332+
333+
declaration-list-next
334+
: declaration [ ';' S* declaration-list-next ]?
335+
| at-rule declaration-list-next
336+
| /* empty */
337+
;
330338
</pre>
331339

332340
<p class=note>Note that following the CSS2.1 convention, comment tokens are
333341
not shown in the rule above.
334342

335343
<p>The interpreter must parse the style attribute's value using the same
336344
forward-compatible parsing rules that apply to parsing declaration block
337-
contents in a normal CSS style sheet. See <a
345+
contents in a normal CSS style sheet (see <a
338346
href="http://www.w3.org/TR/CSS21/syndata.html">chapter 4 of the CSS2.1
339-
specification</a> for details. <a href="#CSS21"
340-
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>
347+
specification</a> <a href="#CSS21"
348+
rel=biblioentry>[CSS21]<!--{{!CSS21}}--></a>), with the following
349+
addition: when the UA expects the start of a declaration or at-rule (i.e.,
350+
an IDENT token or an ATKEYWORD token) but finds an unexpected token
351+
instead, that token is considered to be the first token of a malformed
352+
declaration. I.e., the rule for malformed declarations, rather than
353+
malformed statements, is used to determine which tokens to ignore in that
354+
case.
341355

342356
<p class=note>Note that because there is no open brace delimiting the
343357
declaration list in the CSS style attribute syntax, a close brace
344358
(<code>}</code>) in the style attribute's value does not terminate the
345359
style data: it is merely an invalid token.
346360

361+
<div class=note>
362+
<p>Although the grammar allows it, no at-rule valid in style attributes is
363+
define at the moment. The forward-compatible parsing rules are such that
364+
a declaration following an at-rule is not ignored:
365+
366+
<pre>&lt;span style="@unsupported { splines: reticulating } color: green"></pre>
367+
</div>
368+
347369
<h2 id=interpret><span class=secno>4. </span>Cascading and Interpretation</h2>
348370

349371
<p>The declarations in a style attribute apply to the element to which the
@@ -367,7 +389,17 @@ <h2 id=interpret><span class=secno>4. </span>Cascading and Interpretation</h2>
367389
independently and treated as a separate style rule, the ordering of which
368390
should be defined by the document language, else is undefined.
369391

370-
<h2 id=ack><span class=secno>5. </span>Acknowledgments</h2>
392+
<h2 id=changes><span class=secno>5. </span>Changes</h2>
393+
394+
<p>Changes since the <a
395+
href="http://www.w3.org/TR/2013/PR-css-style-attr-20131003/">2013-10-03
396+
Proposed Recommendation</a> are:
397+
398+
<ul>
399+
<li>Parse at-rules in declaration lists to allow future extension.
400+
</ul>
401+
402+
<h2 id=ack><span class=secno>6. </span>Acknowledgments</h2>
371403

372404
<p>Thanks to feedback from <span class=vcard><span class=fn>Daniel
373405
Glazman</span></span>, <span class=vcard><span class=fn>Ian
@@ -376,7 +408,7 @@ <h2 id=ack><span class=secno>5. </span>Acknowledgments</h2>
376408
class=family-name>Meyer</span></span></span>, <span class=vcard><span
377409
class=fn>Björn Höhrmann</span></span>.
378410

379-
<h2 id=references><span class=secno>6. </span>References</h2>
411+
<h2 id=references><span class=secno>7. </span>References</h2>
380412

381413
<h3 class=no-num id=normative-references>Normative references</h3>
382414
<!--begin-normative-->

css-style-attr/Overview.src.html

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,43 @@ <h2 id="syntax">Syntax and Parsing</h2>
211211

212212
<pre>
213213
declaration-list
214-
: S* declaration? [ ';' S* declaration? ]*
214+
: S* declaration-list-next
215215
;
216+
217+
declaration-list-next
218+
: declaration [ ';' S* declaration-list-next ]?
219+
| at-rule declaration-list-next
220+
| /* empty */
221+
;
216222
</pre>
217223

218224
<p class="note">Note that following the CSS2.1 convention, comment tokens
219225
are not shown in the rule above.
220226

221227
<p>The interpreter must parse the style attribute's value using the
222228
same forward-compatible parsing rules that apply to parsing declaration block
223-
contents in a normal CSS style sheet. See
229+
contents in a normal CSS style sheet (see
224230
<a href="http://www.w3.org/TR/CSS21/syndata.html">chapter 4 of the CSS2.1
225-
specification</a> for details. [[!CSS21]]
231+
specification</a> [[!CSS21]]),
232+
with the following addition: when the UA expects the start of a declaration or at-rule
233+
(i.e., an IDENT token or an ATKEYWORD token) but finds an unexpected token instead,
234+
that token is considered to be the first token of a malformed declaration.
235+
I.e., the rule for malformed declarations, rather than malformed statements,
236+
is used to determine which tokens to ignore in that case.
226237

227238
<p class="note">Note that because there is no open brace delimiting the
228239
declaration list in the CSS style attribute syntax, a close brace
229240
(<code>}</code>) in the style attribute's value does not terminate the
230241
style data: it is merely an invalid token.</p>
231242

243+
<div class="note">
244+
<p>Although the grammar allows it,
245+
no at-rule valid in style attributes is define at the moment.
246+
The forward-compatible parsing rules are such that a declaration following an at-rule
247+
is not ignored:
248+
<pre>&lt;span style="@unsupported { splines: reticulating } color: green"></pre>
249+
</div>
250+
232251
<h2 id="interpret">Cascading and Interpretation</h2>
233252

234253
<p>The declarations in a style attribute apply to the element to which
@@ -250,6 +269,14 @@ <h2 id="interpret">Cascading and Interpretation</h2>
250269
independently and treated as a separate style rule, the ordering of which
251270
should be defined by the document language, else is undefined.
252271

272+
<h2 id="changes">Changes</h2>
273+
274+
Changes since the <a href="http://www.w3.org/TR/2013/PR-css-style-attr-20131003/">2013-10-03 Proposed Recommendation</a> are:
275+
276+
<ul>
277+
<li>Parse at-rules in declaration lists to allow future extension.
278+
</ul>
279+
253280
<h2 id="ack">Acknowledgments</h2>
254281

255282
<p>Thanks to feedback from <span class="vcard"><span class="fn">Daniel Glazman</span></span>, <span class="vcard"><span class="fn">Ian Hickson</span></span>, <span class="vcard"><span class="fn n"><span class="given-name">Eric</span> <abbr class="additional-name">A.</abbr> <span class="family-name">Meyer</span></span></span>,

0 commit comments

Comments
 (0)