Skip to content

Commit e5eeb08

Browse files
committed
[css-syntax] Allow percentages and dimensions to use sci-notation, per WG resolution.
--HG-- extra : rebase_source : d8b5555570a63c3e8ff6a5c3eba51b3d249b963e
1 parent 5e1d37e commit e5eeb08

2 files changed

Lines changed: 184 additions & 42 deletions

File tree

css-syntax/Overview.html

Lines changed: 109 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -254,18 +254,22 @@ <h2 class="no-num no-toc" id=contents> Table of contents</h2>
254254
<li><a href="#set-the-unicode-range-tokens-range"><span class=secno>4.6.
255255
</span> Set the unicode-range token's range</a>
256256

257+
<li><a href="#convert-a-sci-notation-representation-in"><span
258+
class=secno>4.7. </span> Convert a sci-notation representation into a
259+
value</a>
260+
257261
<li><a href="#check-if-two-characters-are-a-valid-esca"><span
258-
class=secno>4.7. </span> Check if two characters are a valid escape</a>
262+
class=secno>4.8. </span> Check if two characters are a valid escape</a>
259263

260264
<li><a href="#check-if-three-characters-would-start-an"><span
261-
class=secno>4.8. </span> Check if three characters would start an
265+
class=secno>4.9. </span> Check if three characters would start an
262266
identifier</a>
263267

264268
<li><a href="#check-if-three-characters-would-start-a-"><span
265-
class=secno>4.9. </span> Check if three characters would start a
269+
class=secno>4.10. </span> Check if three characters would start a
266270
number</a>
267271

268-
<li><a href="#changes-from-css-2.1-tokenizer"><span class=secno>4.10.
272+
<li><a href="#changes-from-css-2.1-tokenizer"><span class=secno>4.11.
269273
</span> Changes from CSS 2.1 Tokenizer</a>
270274
</ul>
271275

@@ -2187,22 +2191,71 @@ <h4 id=sci-notation-state><span class=secno>4.4.11. </span> <dfn
21872191
character</i></a> to the number token's representation. Remain in this
21882192
state.
21892193

2190-
<dt>anything else
2194+
<dt>U+0025 PERCENT SIGN (%)
2195+
2196+
<dd> <a href="#convert-a-sci-notation-representation-in0"><i
2197+
title=sci-not-to-value>Convert the number token's representation to a
2198+
value</i></a>. Emit a percentage token with its value set to the returned
2199+
value. Switch to the <a href="#data-state0"><i>data state</i></a>.
21912200

2192-
<dd> Let <var>base</var> be the result of interpreting the portion of the
2193-
number token's representation preceding the U+0045 LATIN CAPITAL LETTER E
2194-
(E) or U+0065 LATIN SMALL LETTER E (e) as a base-10 number.
2195-
<p> Let <var>power</var> be the result of interpreting the portion of the
2196-
number token's representation following the U+0045 LATIN CAPITAL LETTER
2197-
E (E) or U+0065 LATIN SMALL LETTER E (e) as a base-10 number.
2198-
2199-
<p> Set the number token's value to <code><var>base</var> *
2200-
10<sup><var>power</var></sup></code>. If the number token's value is not
2201-
an integer, set the number token's type flag to "number". Emit the
2202-
number token. Switch to the <a href="#data-state0"><i>data
2201+
<dt>U+002D HYPHEN-MINUS (-)
2202+
2203+
<dd> If the input stream <a
2204+
href="#check-if-three-characters-would-start-an0"><i>starts with an
2205+
identifier</i></a>, create a dimension token with its representation set
2206+
to the number token's representation, its value set to the number
2207+
produced by <a href="#convert-a-sci-notation-representation-in0"><i
2208+
title=sci-not-to-value>converting the number token's representation to a
2209+
value</i></a>, and a unit initially set to the <a
2210+
href="#current-input-character"><i>current input character</i></a>.
2211+
Switch to the <a href="#dimension-state0"><i>dimension state</i></a>.
2212+
<p> Otherwise, set the number token's value to the number produced by <a
2213+
href="#convert-a-sci-notation-representation-in0"><i
2214+
title=sci-not-to-value>converting the number token's representation to a
2215+
value</i></a>, and emit it. Switch to the <a href="#data-state0"><i>data
22032216
state</i></a>. <a
22042217
href="#reconsume-the-current-input-character"><i>Reconsume the current
22052218
input character</i></a>.
2219+
2220+
<dt><a href="#name-start-character"><i>name-start character</i></a>
2221+
2222+
<dd> Create a dimension token with its representation set to the number
2223+
token's representation, its value set to the number produced by <a
2224+
href="#convert-a-sci-notation-representation-in0"><i
2225+
title=sci-not-to-value>converting the number token's representation to a
2226+
value</i></a>, and a unit initially set to the <a
2227+
href="#current-input-character"><i>current input character</i></a>.
2228+
Switch to the <a href="#dimension-state0"><i>dimension state</i></a>.
2229+
2230+
<dt>U+005C REVERSE SOLIDUS (\)
2231+
2232+
<dd> If the input stream <a
2233+
href="#check-if-two-characters-are-a-valid-esca0"><i>starts with a valid
2234+
escape</i></a>, <a href="#consume-an-escaped-character0"><i>consume an
2235+
escaped character</i></a>. Create a dimension token with its
2236+
representation set to the number token's representation, its value set to
2237+
the number produced by <a
2238+
href="#convert-a-sci-notation-representation-in0"><i
2239+
title=sci-not-to-value>converting the number token's representation to a
2240+
value</i></a>, and a unit initially set to the returned character. Switch
2241+
to the <a href="#dimension-state0"><i>dimension state</i></a>.
2242+
<p> Otherwise, set the number token's value to the number produced by <a
2243+
href="#convert-a-sci-notation-representation-in0"><i
2244+
title=sci-not-to-value>converting the number token's representation to a
2245+
value</i></a>, and emit it. Switch to the <a href="#data-state0"><i>data
2246+
state</i></a>. <a
2247+
href="#reconsume-the-current-input-character"><i>Reconsume the current
2248+
input character</i></a>.
2249+
2250+
<dt>anything else
2251+
2252+
<dd> Set the number token's value to the number produced by <a
2253+
href="#convert-a-sci-notation-representation-in0"><i
2254+
title=sci-not-to-value>converting the number token's representation to a
2255+
value</i></a>, and emit it. Switch to the <a href="#data-state0"><i>data
2256+
state</i></a>. <a
2257+
href="#reconsume-the-current-input-character"><i>Reconsume the current
2258+
input character</i></a>.
22062259
</dl>
22072260

22082261
<h4 id=dimension-state><span class=secno>4.4.12. </span> <dfn
@@ -2605,7 +2658,25 @@ <h3 id=set-the-unicode-range-tokens-range><span class=secno>4.6. </span>
26052658
whose codepoint is the <a href="#end-of-the-range"><i>end of the
26062659
range</i></a>.
26072660

2608-
<h3 id=check-if-two-characters-are-a-valid-esca><span class=secno>4.7.
2661+
<h3 id=convert-a-sci-notation-representation-in><span class=secno>4.7.
2662+
</span> <dfn id=convert-a-sci-notation-representation-in0
2663+
title="convert a sci-notation representation into a value|sci-not-to-value">Convert
2664+
a sci-notation representation into a value</dfn></h3>
2665+
2666+
<p> This section describes how to turn a sci-notation representation into a
2667+
numeric value.
2668+
2669+
<p> Let <var>base</var> be the result of interpreting the portion of the
2670+
representation preceding the U+0045 LATIN CAPITAL LETTER E (E) or U+0065
2671+
LATIN SMALL LETTER E (e) as a base-10 number.
2672+
2673+
<p> Let <var>power</var> be the result of interpreting the portion of the
2674+
representation following the U+0045 LATIN CAPITAL LETTER E (E) or U+0065
2675+
LATIN SMALL LETTER E (e) as a base-10 number.
2676+
2677+
<p> Return <code><var>base</var> * 10<sup><var>power</var></sup></code>.
2678+
2679+
<h3 id=check-if-two-characters-are-a-valid-esca><span class=secno>4.8.
26092680
</span> <dfn id=check-if-two-characters-are-a-valid-esca0
26102681
title="check if two characters are a valid escape|are a valid escape|starts with a valid escape">Check
26112682
if two characters are a valid escape</dfn></h3>
@@ -2628,7 +2699,7 @@ <h3 id=check-if-two-characters-are-a-valid-esca><span class=secno>4.7.
26282699

26292700
<p> Otherwise, return true.
26302701

2631-
<h3 id=check-if-three-characters-would-start-an><span class=secno>4.8.
2702+
<h3 id=check-if-three-characters-would-start-an><span class=secno>4.9.
26322703
</span> <dfn id=check-if-three-characters-would-start-an0
26332704
title="check if three characters would start an identifier|starts with an identifier|start with an identifier|would start an identifier">Check
26342705
if three characters would start an identifier</dfn></h3>
@@ -2667,7 +2738,7 @@ <h3 id=check-if-three-characters-would-start-an><span class=secno>4.8.
26672738
escape</i></a>, return true. Otherwise, return false.
26682739
</dl>
26692740

2670-
<h3 id=check-if-three-characters-would-start-a-><span class=secno>4.9.
2741+
<h3 id=check-if-three-characters-would-start-a-><span class=secno>4.10.
26712742
</span> <dfn id=check-if-three-characters-would-start-a-0
26722743
title="check if three characters would start a number|starts with a number|start with a number|would start a number">Check
26732744
if three characters would start a number</dfn></h3>
@@ -2712,7 +2783,7 @@ <h3 id=check-if-three-characters-would-start-a-><span class=secno>4.9.
27122783
<dd> Return false.
27132784
</dl>
27142785

2715-
<h3 id=changes-from-css-2.1-tokenizer><span class=secno>4.10. </span>
2786+
<h3 id=changes-from-css-2.1-tokenizer><span class=secno>4.11. </span>
27162787
Changes from CSS 2.1 Tokenizer</h3>
27172788

27182789
<p> <em>This section is non-normative.</em>
@@ -4166,7 +4237,7 @@ <h2 class=no-num id=index> Index</h2>
41664237
<ul class=indexlist>
41674238
<li>are a valid escape, <a
41684239
href="#check-if-two-characters-are-a-valid-esca0"
4169-
title="section 4.7."><strong>4.7.</strong></a>
4240+
title="section 4.8."><strong>4.8.</strong></a>
41704241

41714242
<li>ASCII case-insensitive, <a href="#ascii-case-insensitive"
41724243
title="section 5.3."><strong>5.3.</strong></a>
@@ -4186,15 +4257,15 @@ <h2 class=no-num id=index> Index</h2>
41864257

41874258
<li>check if three characters would start an identifier, <a
41884259
href="#check-if-three-characters-would-start-an0"
4189-
title="section 4.8."><strong>4.8.</strong></a>
4260+
title="section 4.9."><strong>4.9.</strong></a>
41904261

41914262
<li>check if three characters would start a number, <a
41924263
href="#check-if-three-characters-would-start-a-0"
4193-
title="section 4.9."><strong>4.9.</strong></a>
4264+
title="section 4.10."><strong>4.10.</strong></a>
41944265

41954266
<li>check if two characters are a valid escape, <a
41964267
href="#check-if-two-characters-are-a-valid-esca0"
4197-
title="section 4.7."><strong>4.7.</strong></a>
4268+
title="section 4.8."><strong>4.8.</strong></a>
41984269

41994270
<li>Comment state, <a href="#comment-state0"
42004271
title="section 4.4.5."><strong>4.4.5.</strong></a>
@@ -4230,6 +4301,10 @@ <h2 class=no-num id=index> Index</h2>
42304301
<li>Consume a simple block, <a href="#consume-a-simple-block0"
42314302
title="section 5.5.7."><strong>5.5.7.</strong></a>
42324303

4304+
<li>convert a sci-notation representation into a value, <a
4305+
href="#convert-a-sci-notation-representation-in0"
4306+
title="section 4.7."><strong>4.7.</strong></a>
4307+
42334308
<li>current input character, <a href="#current-input-character"
42344309
title="section 4.3."><strong>4.3.</strong></a>
42354310

@@ -4366,6 +4441,9 @@ <h2 class=no-num id=index> Index</h2>
43664441
<li>Sci-notation state, <a href="#sci-notation-state0"
43674442
title="section 4.4.11."><strong>4.4.11.</strong></a>
43684443

4444+
<li>sci-not-to-value, <a href="#convert-a-sci-notation-representation-in0"
4445+
title="section 4.7."><strong>4.7.</strong></a>
4446+
43694447
<li>Set the unicode-range token's range, <a
43704448
href="#set-the-unicode-range-tokens-range0"
43714449
title="section 4.6."><strong>4.6.</strong></a>
@@ -4381,23 +4459,23 @@ <h2 class=no-num id=index> Index</h2>
43814459

43824460
<li>starts with an identifier, <a
43834461
href="#check-if-three-characters-would-start-an0"
4384-
title="section 4.8."><strong>4.8.</strong></a>
4462+
title="section 4.9."><strong>4.9.</strong></a>
43854463

43864464
<li>starts with a number, <a
43874465
href="#check-if-three-characters-would-start-a-0"
4388-
title="section 4.9."><strong>4.9.</strong></a>
4466+
title="section 4.10."><strong>4.10.</strong></a>
43894467

43904468
<li>starts with a valid escape, <a
43914469
href="#check-if-two-characters-are-a-valid-esca0"
4392-
title="section 4.7."><strong>4.7.</strong></a>
4470+
title="section 4.8."><strong>4.8.</strong></a>
43934471

43944472
<li>start with an identifier, <a
43954473
href="#check-if-three-characters-would-start-an0"
4396-
title="section 4.8."><strong>4.8.</strong></a>
4474+
title="section 4.9."><strong>4.9.</strong></a>
43974475

43984476
<li>start with a number, <a
43994477
href="#check-if-three-characters-would-start-a-0"
4400-
title="section 4.9."><strong>4.9.</strong></a>
4478+
title="section 4.10."><strong>4.10.</strong></a>
44014479

44024480
<li>style sheet
44034481
<ul>
@@ -4439,11 +4517,11 @@ <h2 class=no-num id=index> Index</h2>
44394517

44404518
<li>would start an identifier, <a
44414519
href="#check-if-three-characters-would-start-an0"
4442-
title="section 4.8."><strong>4.8.</strong></a>
4520+
title="section 4.9."><strong>4.9.</strong></a>
44434521

44444522
<li>would start a number, <a
44454523
href="#check-if-three-characters-would-start-a-0"
4446-
title="section 4.9."><strong>4.9.</strong></a>
4524+
title="section 4.10."><strong>4.10.</strong></a>
44474525
</ul>
44484526
<!--end-index-->
44494527

css-syntax/Overview.src.html

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,22 +1471,66 @@ <h4>
14711471
to the number token's representation.
14721472
Remain in this state.
14731473

1474-
<dt>anything else
1474+
<dt>U+0025 PERCENT SIGN (%)
14751475
<dd>
1476-
Let <var>base</var> be the result of interpreting the portion of the number token's representation
1477-
preceding the U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e)
1478-
as a base-10 number.
1476+
<i title="sci-not-to-value">Convert the number token's representation to a value</i>.
1477+
Emit a percentage token
1478+
with its value set to the returned value.
1479+
Switch to the <i>data state</i>.
1480+
1481+
<dt>U+002D HYPHEN-MINUS (-)
1482+
<dd>
1483+
If the input stream <i>starts with an identifier</i>,
1484+
create a dimension token
1485+
with its representation set to the number token's representation,
1486+
its value set to the number
1487+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1488+
and a unit initially set to the <i>current input character</i>.
1489+
Switch to the <i>dimension state</i>.
1490+
14791491
<p>
1480-
Let <var>power</var> be the result of interpreting the portion of the number token's representation
1481-
following the U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e)
1482-
as a base-10 number.
1492+
Otherwise,
1493+
set the number token's value to the number
1494+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1495+
and emit it.
1496+
Switch to the <i>data state</i>.
1497+
<i>Reconsume the current input character</i>.
1498+
1499+
<dt><i>name-start character</i>
1500+
<dd>
1501+
Create a dimension token
1502+
with its representation set to the number token's representation,
1503+
its value set to the number
1504+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1505+
and a unit initially set to the <i>current input character</i>.
1506+
Switch to the <i>dimension state</i>.
1507+
1508+
<dt>U+005C REVERSE SOLIDUS (\)
1509+
<dd>
1510+
If the input stream <i>starts with a valid escape</i>,
1511+
<i>consume an escaped character</i>.
1512+
Create a dimension token
1513+
with its representation set to the number token's representation,
1514+
its value set to the number
1515+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1516+
and a unit initially set to the returned character.
1517+
Switch to the <i>dimension state</i>.
1518+
14831519
<p>
1484-
Set the number token's value to <code><var>base</var> * 10<sup><var>power</var></sup></code>.
1485-
If the number token's value is not an integer,
1486-
set the number token's type flag to "number".
1487-
Emit the number token.
1520+
Otherwise,
1521+
set the number token's value to the number
1522+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1523+
and emit it.
14881524
Switch to the <i>data state</i>.
14891525
<i>Reconsume the current input character</i>.
1526+
1527+
<dt>anything else
1528+
<dd>
1529+
Set the number token's value to the number
1530+
produced by <i title="sci-not-to-value">converting the number token's representation to a value</i>,
1531+
and emit it.
1532+
Switch to the <i>data state</i>.
1533+
<i>Reconsume the current input character</i>.
14901534
</dl>
14911535

14921536
<h4>
@@ -1917,6 +1961,26 @@ <h3>
19171961
the character whose codepoint is the <i>start of the range</i>
19181962
and the character whose codepoint is the <i>end of the range</i>.
19191963

1964+
<h3>
1965+
<dfn title="convert a sci-notation representation into a value|sci-not-to-value">Convert a sci-notation representation into a value</dfn></h3>
1966+
1967+
<p>
1968+
This section describes how to turn a sci-notation representation
1969+
into a numeric value.
1970+
1971+
<p>
1972+
Let <var>base</var> be the result of interpreting the portion of the representation
1973+
preceding the U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e)
1974+
as a base-10 number.
1975+
1976+
<p>
1977+
Let <var>power</var> be the result of interpreting the portion of the representation
1978+
following the U+0045 LATIN CAPITAL LETTER E (E) or U+0065 LATIN SMALL LETTER E (e)
1979+
as a base-10 number.
1980+
1981+
<p>
1982+
Return <code><var>base</var> * 10<sup><var>power</var></sup></code>.
1983+
19201984

19211985
<h3>
19221986
<dfn title="check if two characters are a valid escape|are a valid escape|starts with a valid escape">Check if two characters are a valid escape</dfn></h3>

0 commit comments

Comments
 (0)