Skip to content

Commit bea5ce0

Browse files
committed
Fixed the way I handled negative counter values to be specific to the type.
1 parent 078d00b commit bea5ce0

2 files changed

Lines changed: 113 additions & 74 deletions

File tree

css3-lists/Overview.html

Lines changed: 80 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525

2626
<h1>CSS Lists and Counters Module Level 3</h1>
2727

28-
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 5 December
28+
<h2 class="no-num no-toc" id=longstatus-date>Editor's Draft 6 December
2929
2011</h2>
3030

3131
<dl>
3232
<dt>This version:
3333

34-
<dd><!--<a href="http://www.w3.org/TR/2011/WD-css3-lists-20111205">http://www.w3.org/TR/2011/WD-css3-lists-20111205</a></dd>-->
34+
<dd><!--<a href="http://www.w3.org/TR/2011/WD-css3-lists-20111206">http://www.w3.org/TR/2011/WD-css3-lists-20111206</a></dd>-->
3535
<a
3636
href="http://dev.w3.org/csswg/css3-lists/">http://dev.w3.org/csswg/css3-lists/</a>
3737

@@ -1436,10 +1436,6 @@ <h2 id=counter-style><span class=secno>8. </span> Defining Custom Counter
14361436
title=generate-a-counter>generate a counter representation</i> using the
14371437
counter style's fallback style and the same counter value.
14381438

1439-
<li>If the counter value is negative, set the <a
1440-
href="#descdef-negative"><var>negative</var></a> flag and run the rest of
1441-
this algorithm with the counter value set to its absolute value instead.
1442-
14431439
<li>Using the counter value and the <a href="#algorithm"><i
14441440
title=counter-algorithm>counter algorithm</i></a> for the counter style,
14451441
generate an initial representation for the counter value.
@@ -1601,6 +1597,10 @@ <h4 id=numeric><span class=secno>8.1.2. </span> numeric</h4>
16011597
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to <var>S</var>
16021598
and return <var>S</var>.
16031599

1600+
<li>If <var>value</var> is negative, run the next step of this algorithm
1601+
with <var>value</var> being the absolute value of <var>value</var>
1602+
instead.
1603+
16041604
<li>While <var>value</var> is not equal to 0:
16051605
<ol>
16061606
<li>Prepend <var>symbol( <var>value</var> mod <var>length</var> )</var>
@@ -1610,6 +1610,11 @@ <h4 id=numeric><span class=secno>8.1.2. </span> numeric</h4>
16101610
<var>length</var> )</code>.
16111611
</ol>
16121612

1613+
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
1614+
counter style's <a href="#negative-sign"><i
1615+
title=counter-negative>negative sign</i></a>, as specified in the section
1616+
for the <a href="#counter-style-negative">negative descriptor</a>.
1617+
16131618
<li>Return <var>S</var>.
16141619
</ol>
16151620

@@ -1640,7 +1645,8 @@ <h4 id=alphabetic><span class=secno>8.1.3. </span> alphabetic</h4>
16401645
<p>If the type is <a href="#alphabetic">alphabetic</a>, the &lsquo;<a
16411646
href="#descdef-symbols"><code class=property>symbols</code></a>&rsquo;
16421647
descriptor must contain at least two <a href="#counter-symbol"><i>counter
1643-
symbol</i></a>s. This type is defined only over positive counter values.
1648+
symbol</i></a>s. This type is defined only over strictly positive counter
1649+
values.
16441650

16451651
<p>The <i>alphabetic</i> counter type interprets the list of <i>counter
16461652
symbols</i> as digits to an <em>alphabetic</em> numbering system, similar
@@ -1748,7 +1754,8 @@ <h4 id=symbolic><span class=secno>8.1.4. </span> symbolic</h4>
17481754
<p>If the type is <a href="#symbolic">symbolic</a>, the &lsquo;<a
17491755
href="#descdef-symbols"><code class=property>symbols</code></a>&rsquo;
17501756
descriptor must contain at least one <a href="#counter-symbol"><i>counter
1751-
symbol</i></a>. This type is defined only over positive counter values.
1757+
symbol</i></a>. This type is defined only over strictly positive counter
1758+
values.
17521759

17531760
<p>The <i>symbolic</i> counter type cycles repeatedly through its provided
17541761
symbols, doubling, tripling, etc. the symbols on each successive pass
@@ -1892,8 +1899,8 @@ <h4 id=additive><span class=secno>8.1.6. </span> additive</h4>
18921899
href="#descdef-additive-symbols"><code
18931900
class=property>additive-symbols</code></a>&rsquo; descriptor must contain
18941901
at least one <a href="#additive-tuple"><i>additive tuple</i></a>. This
1895-
type is nominally defined over all positive counter values (see algorithm,
1896-
below, for exact details)
1902+
type is nominally defined over all counter values (see algorithm, below,
1903+
for exact details)
18971904

18981905
<p>The <i>additive</i> counter type takes as many of the largest symbols
18991906
that it can, then as many of the next largest symbol, etc. until the sum
@@ -1902,39 +1909,51 @@ <h4 id=additive><span class=secno>8.1.6. </span> additive</h4>
19021909
of several languages which use different characters for the digits in
19031910
differnt positions.
19041911

1905-
<p>To construct the representation, run this algorithm. let
1912+
<p>To construct the representation, run this algorithm. Let
19061913
<var>value</var> initially be the counter value, <var>S</var> initially be
19071914
the empty string, and <var>symbol list</var> initially be the list of <a
19081915
href="#additive-tuple"><i>additive tuple</i></a>s.
19091916

1910-
<p>If <var>value</var> is initially 0, and there is an <a
1911-
href="#additive-tuple"><i>additive tuple</i></a> with a weight of 0,
1912-
append that tuple's <a href="#counter-symbol"><i>counter symbol</i></a> to
1913-
S and return S.
1917+
<ol>
1918+
<li>If <var>value</var> is initially 0, and there is an <a
1919+
href="#additive-tuple"><i>additive tuple</i></a> with a weight of 0,
1920+
append that tuple's <a href="#counter-symbol"><i>counter symbol</i></a>
1921+
to S and return S.
19141922

1915-
<p>Otherwise, while <var>value</var> is greater than 0 and there are
1916-
elements left in the <var>symbol list</var>:
1923+
<li>If <var>value</var> is negative, run the next step of this algorithm
1924+
with <var>value</var> being the absolute value of <var>value</var>
1925+
instead.
19171926

1918-
<ol>
1919-
<li>Pop the first <a href="#additive-tuple"><i>additive tuple</i></a> from
1920-
the <var>symbol list</var>. This is the <dfn id=current-tuple
1921-
title="current tuple|current tuple's">current tuple</dfn>.
1922-
1923-
<li>Append the <a href="#current-tuple"><i>current
1924-
tuple</i></a>&lsquo;<code class=css>s <a
1925-
href="#counter-symbol"><i>counter symbol</i></a> to <var>S</var>
1926-
<code>floor( <var>value</var> / <a href="#current-tuple"><var><i>current
1927-
tuple</i></var></a></code>&rsquo;s weight )</code> times (this may be 0).
1928-
1929-
<li>Decrement <var>value</var> by the <var><a
1930-
href="#current-tuple"><i>current tuple's</i></a> weight multiplied by the
1931-
number of times the <a href="#current-tuple"><i>current tuple</i></a> was
1932-
appended to <var>S</var> in the previous step.</var>
1933-
</ol>
1927+
<li>While <var>value</var> is greater than 0 and there are elements left
1928+
in the <var>symbol list</var>:
1929+
<ol>
1930+
<li>Pop the first <a href="#additive-tuple"><i>additive tuple</i></a>
1931+
from the <var>symbol list</var>. This is the <dfn id=current-tuple
1932+
title="current tuple|current tuple's">current tuple</dfn>.
1933+
1934+
<li>Append the <a href="#current-tuple"><i>current
1935+
tuple</i></a>&lsquo;<code class=css>s <a
1936+
href="#counter-symbol"><i>counter symbol</i></a> to <var>S</var>
1937+
<code>floor( <var>value</var> / <a
1938+
href="#current-tuple"><var><i>current
1939+
tuple</i></var></a></code>&rsquo;s weight )</code> times (this may be
1940+
0).
1941+
1942+
<li>Decrement <var>value</var> by the <var><a
1943+
href="#current-tuple"><i>current tuple's</i></a> weight multiplied by
1944+
the number of times the <a href="#current-tuple"><i>current
1945+
tuple</i></a> was appended to <var>S</var> in the previous step.</var>
1946+
</ol>
19341947

1935-
<p>If the loop ended because <var>value</var> is 0, return S. Otherwise,
1936-
the given counter value cannot be represented by this counter style, and
1937-
must instead be represented by the fallback counter style.
1948+
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the
1949+
counter style's <a href="#negative-sign"><i
1950+
title=counter-negative>negative sign</i></a>, as specified in the section
1951+
for the <a href="#counter-style-negative">negative descriptor</a>.
1952+
1953+
<li>If the loop ended because <var>value</var> is 0, return S. Otherwise,
1954+
the given counter value cannot be represented by this counter style, and
1955+
must instead be represented by the fallback counter style.
1956+
</ol>
19381957

19391958
<div class=example>
19401959
<p>A "dice" counter style can be defined as:</p>
@@ -2097,12 +2116,12 @@ <h3 id=counter-style-range><span class=secno>8.5. </span> Limiting the
20972116
<tr>
20982117
<th>Value:
20992118

2100-
<td>[ &lt;integer> | infinite ]{2}
2119+
<td>[ &lt;integer> | infinite ]{2} | auto
21012120

21022121
<tr>
21032122
<th>Initial:
21042123

2105-
<td>infinite infinite
2124+
<td>auto
21062125
</table>
21072126

21082127
<p>The &lsquo;<a href="#descdef-range"><code
@@ -2111,13 +2130,29 @@ <h3 id=counter-style-range><span class=secno>8.5. </span> Limiting the
21112130
represent a counter value outside of its range, the counter style instead
21122131
drops down to its fallback counter style.
21132132

2114-
<p>The first value represents the lower bound of the range (with
2115-
&lsquo;<code class=property>infinite</code>&rsquo; representing negative
2116-
infinity), and the second value represents the upper bound of the range
2117-
(with &lsquo;<code class=property>infinite</code>&rsquo; representing
2118-
positive infinity). This is an inclusive range - it includes both the
2119-
lower and upper bound numbers. If the lower bound is higher than the
2120-
higher bound, the descriptor is invalid and must be ignored.
2133+
<p>If the value is not &lsquo;<code class=css>auto</code>&rsquo;, the first
2134+
value represents the lower bound of the range (with &lsquo;<code
2135+
class=property>infinite</code>&rsquo; representing negative infinity), and
2136+
the second value represents the upper bound of the range (with
2137+
&lsquo;<code class=property>infinite</code>&rsquo; representing positive
2138+
infinity). This is an inclusive range - it includes both the lower and
2139+
upper bound numbers. If the lower bound is higher than the higher bound,
2140+
the descriptor is invalid and must be ignored.
2141+
2142+
<p>If the value is &lsquo;<code class=css>auto</code>&rsquo;, the range
2143+
depends on the counter type. For &lsquo;<code
2144+
class=css>repeating</code>&rsquo;, &lsquo;<code
2145+
class=css>numeric</code>&rsquo;, and &lsquo;<code
2146+
class=css>non-repeating</code>&rsquo; types, it must be treated
2147+
identically to specifying &lsquo;<code class=css>infinite
2148+
infinite</code>&rsquo;. For &lsquo;<code
2149+
class=css>alphabetic</code>&rsquo; and &lsquo;<code
2150+
class=css>symbolic</code>&rsquo;, it must be treated identically to
2151+
&lsquo;<code class=css>1 infinite</code>&rsquo;. For &lsquo;<code
2152+
class=css>additive</code>&rsquo;, it must be treated identically to
2153+
&lsquo;<code class=css>0 infinite</code>&rsquo;. For &lsquo;<code
2154+
class=css>override</code>&rsquo;, it must be treated according to the type
2155+
of the counter style it is overriding.
21212156

21222157
<p>Some counter style types have their own implicit ranges, specified above
21232158
in the individual descriptions for each type. The explicit range given by

css3-lists/Overview.src.html

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,6 @@ <h2 id='counter-style'>
869869
style, exit this algorithm and instead <i title='generate-a-counter'>generate a counter representation</i>
870870
using the counter style's fallback style and the same counter value.</li>
871871

872-
<li>If the counter value is negative, set the <var>negative</var> flag and
873-
run the rest of this algorithm with the counter value set to its absolute value instead.</li>
874-
875872
<li>Using the counter value and the <i title='counter-algorithm'>counter algorithm</i>
876873
for the counter style, generate an initial representation for the counter value.</li>
877874

@@ -994,6 +991,8 @@ <h4>
994991
<li>If <var>value</var> is 0, append <var>symbol(0)</var> to
995992
<var>S</var> and return <var>S</var>.</li>
996993

994+
<li>If <var>value</var> is negative, run the next step of this algorithm with <var>value</var> being the absolute value of <var>value</var> instead.</li>
995+
997996
<li>While <var>value</var> is not equal to 0:
998997

999998
<ol>
@@ -1004,6 +1003,8 @@ <h4>
10041003
</ol>
10051004
</li>
10061005

1006+
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the counter style's <i title='counter-negative'>negative sign</i>, as specified in the section for the <a href='#counter-style-negative'>negative descriptor</a>.</li>
1007+
10071008
<li>Return <var>S</var>.</li>
10081009
</ol>
10091010

@@ -1035,7 +1036,7 @@ <h4>
10351036

10361037
<p>If the type is <a href=#alphabetic>alphabetic</a>, the 'symbols' descriptor must contain
10371038
at least two <i>counter symbol</i>s. This type is defined only over
1038-
positive counter values.</p>
1039+
strictly positive counter values.</p>
10391040

10401041
<p>The <i>alphabetic</i> counter type interprets the list of <i>counter symbols</i>
10411042
as digits to an <em>alphabetic</em> numbering system, similar to the default
@@ -1133,7 +1134,7 @@ <h4>
11331134
symbolic</h4>
11341135

11351136
<p>If the type is <a href=#symbolic>symbolic</a>, the 'symbols' descriptor must contain at
1136-
least one <i>counter symbol</i>. This type is defined only over positive
1137+
least one <i>counter symbol</i>. This type is defined only over strictly positive
11371138
counter values.</p>
11381139

11391140
<p>The <i>symbolic</i> counter type cycles repeatedly through its provided symbols,
@@ -1258,8 +1259,7 @@ <h4>
12581259

12591260
<p>If the type is <a href=#additive>additive</a>, the 'additive-symbols' descriptor must
12601261
contain at least one <i>additive tuple</i>. This type is nominally
1261-
defined over all positive counter values (see algorithm, below, for
1262-
exact details)</p>
1262+
defined over all counter values (see algorithm, below, for exact details)</p>
12631263

12641264
<p>The <i>additive</i> counter type takes as many of the largest symbols that
12651265
it can, then as many of the next largest symbol, etc. until the sum of all
@@ -1268,33 +1268,35 @@ <h4>
12681268
several languages which use different characters for the digits in differnt
12691269
positions.</p>
12701270

1271-
<p>To construct the representation, run this algorithm. let <var>value</var>
1271+
<p>To construct the representation, run this algorithm. Let <var>value</var>
12721272
initially be the counter value, <var>S</var> initially be the empty string,
12731273
and <var>symbol list</var> initially be the list of <i>additive tuple</i>s.
12741274

1275-
<p>If <var>value</var> is initially 0, and there is an <i>additive tuple</i>
1276-
with a weight of 0, append that tuple's <i>counter symbol</i> to S
1277-
and return S.</p>
1275+
<ol>
1276+
<li>If <var>value</var> is initially 0, and there is an <i>additive tuple</i> with a weight of 0, append that tuple's <i>counter symbol</i> to S and return S.</li>
12781277

1279-
<p>Otherwise, while <var>value</var> is greater than 0 and there are elements
1280-
left in the <var>symbol list</var>:</p>
1278+
<li>If <var>value</var> is negative, run the next step of this algorithm with <var>value</var> being the absolute value of <var>value</var> instead.</li>
12811279

1282-
<ol>
1283-
<li>Pop the first <i>additive tuple</i> from the <var>symbol list</var>.
1284-
This is the <dfn title="current tuple|current tuple's">current tuple</dfn>.</li>
1280+
<li>While <var>value</var> is greater than 0 and there are elements left in the <var>symbol list</var>:
12851281

1286-
<li>Append the <i>current tuple</i>'s <i>counter symbol</i> to <var>S</var>
1287-
<code>floor( <var>value</var> / <var><i>current tuple's</i> weight</var> )</code>
1288-
times (this may be 0).</li>
1282+
<ol>
1283+
<li>Pop the first <i>additive tuple</i> from the <var>symbol list</var>.
1284+
This is the <dfn title="current tuple|current tuple's">current tuple</dfn>.</li>
12891285

1290-
<li>Decrement <var>value</var> by the <var><i>current tuple's</i> weight multiplied
1291-
by the number of times the <i>current tuple</i> was appended to <var>S</var>
1292-
in the previous step.</li>
1293-
</ol>
1286+
<li>Append the <i>current tuple</i>'s <i>counter symbol</i> to <var>S</var>
1287+
<code>floor( <var>value</var> / <var><i>current tuple's</i> weight</var> )</code>
1288+
times (this may be 0).</li>
12941289

1295-
<p>If the loop ended because <var>value</var> is 0, return S. Otherwise, the
1296-
given counter value cannot be represented by this counter style, and must
1297-
instead be represented by the fallback counter style.</p>
1290+
<li>Decrement <var>value</var> by the <var><i>current tuple's</i> weight multiplied
1291+
by the number of times the <i>current tuple</i> was appended to <var>S</var>
1292+
in the previous step.</li>
1293+
</ol>
1294+
</li>
1295+
1296+
<li>If <var>value</var> was originally negative, wrap <var>S</var> in the counter style's <i title='counter-negative'>negative sign</i>, as specified in the section for the <a href='#counter-style-negative'>negative descriptor</a>.</li>
1297+
1298+
<li>If the loop ended because <var>value</var> is 0, return S. Otherwise, the given counter value cannot be represented by this counter style, and must instead be represented by the fallback counter style.</li>
1299+
</ol>
12981300

12991301
<div class=example>
13001302
<p>A "dice" counter style can be defined as:</p>
@@ -1424,23 +1426,25 @@ <h3 id='counter-style-range'>
14241426
<td><dfn id="descdef-range">range</dfn>
14251427
<tr>
14261428
<th>Value:
1427-
<td>[ &lt;integer> | infinite ]{2}
1429+
<td>[ &lt;integer> | infinite ]{2} | auto
14281430
<tr>
14291431
<th>Initial:
1430-
<td>infinite infinite
1432+
<td>auto
14311433
</table>
14321434

14331435
<p>The 'range' descriptor defines the range over which the counter style is defined.
14341436
If a counter style is used to represent a counter value outside of its range,
14351437
the counter style instead drops down to its fallback counter style.</p>
14361438

1437-
<p>The first value represents the lower bound of the range (with 'infinite'
1439+
<p>If the value is not ''auto'', the first value represents the lower bound of the range (with 'infinite'
14381440
representing negative infinity), and the second value represents the upper bound
14391441
of the range (with 'infinite' representing positive infinity). This is an inclusive
14401442
range - it includes both the lower and upper bound numbers. If the lower
14411443
bound is higher than the higher bound, the descriptor is invalid and must
14421444
be ignored.</p>
14431445

1446+
<p>If the value is ''auto'', the range depends on the counter type. For ''repeating'', ''numeric'', and ''non-repeating'' types, it must be treated identically to specifying ''infinite infinite''. For ''alphabetic'' and ''symbolic'', it must be treated identically to ''1 infinite''. For ''additive'', it must be treated identically to ''0 infinite''. For ''override'', it must be treated according to the type of the counter style it is overriding.</p>
1447+
14441448
<p>Some counter style types have their own implicit ranges, specified above
14451449
in the individual descriptions for each type. The explicit range given
14461450
by the ‘<code class="css">range</code>’ descriptor applies at the same time

0 commit comments

Comments
 (0)