W3C home > Mailing lists > Public > www-style@w3.org > May 2011

Re: [CSS21][css3-content] counters and table-column / table-column-group

From: Peter Moulder <peter.moulder@monash.edu>
Date: Fri, 20 May 2011 12:42:33 +1000
To: www-style@w3.org
Message-id: <20110520024233.GA18251@bowman.infotech.monash.edu.au>
On Thu, May 19, 2011 at 09:52:07AM -0700, Tab Atkins Jr. wrote:
> On Thu, May 19, 2011 at 1:57 AM, Peter Moulder <peter.moulder@monash.edu> wrote:
> > A very tentative proposal would be:
> >
> >  - Change "are not rendered (exactly as if ...)" to
> >    "do not generate any boxes"; and be explicit either
> >    that 'counter-reset' and 'counter-increment' still have effect,
> >    or that their behaviour is undefined.
> >
> >  - Change "that is not displayed (...)" to
> >    "whose 'display' has value 'none'".
> >
> >  - In section 17.2.1, be explicit that those suppressed children
> >    cannot affect counters.
> >
> > Those first couple of changes are a bit risky to change at this point
> > in CSS 2.1.  An alternative would be just to add a sentence to each
> > that deals just with the interaction between counters and
> > table-column[-group].
> 
> A third alternative would be to just file bugs on the browsers and get
> them to change their behavior wrt table-column elements and counter-*.
>  This sounds like the sort of behavior that only comes up when you're
> explicitly testing for it.

I believe that these browsers' behaviour [excluding Konqueror] is a
reasonable interpretation of the existing text.

(Gérard Talbot has pointed out that Konqueror does already have
 bugs filed regarding its strange handling of counters in tables:
 https://bugs.kde.org/show_bug.cgi?id=197680
 https://bugs.kde.org/show_bug.cgi?id=169634 .)

One can reasonably interpret

  # are not rendered (exactly as if they had 'display: none')

in CSS 2.1 section 17.2 as merely describing how that element is
rendered, rather than describing their behaviour in general as exactly
equivalent to 'none': quite evidently the display values 'table-column'
and 'table-column-group' are not equivalent to 'none', as the section
goes on to describe.

Meanwhile, the provision in CSS 2.1 section 12.4.3 and css3-content
section 8.3

  # An element that is not displayed ('display' set to 'none')

occurs in each case as the first sentence of a section entitled
"Counters in elements with 'display: none'".  In such a context, one
can reasonably interpret the parenthesis as giving the more precise
version of an informal first half.  More evidence that "is not
displayed" is informal is that the section goes on to say that
visibility:hidden elements do increment counters [presumably so long as
they don't also have display:none, though the specification doesn't say
so].  Yet more evidence that "is not displayed" is informal is that for
an element that is not displayed merely because of 'overflow' or 'clip'
properties, a UA can't in general determine whether or not it's
displayed until rendering at a given width; it would be bad for counter
values to depend on viewport width, fonts chosen etc.

However, it's not clear that "'display' set to 'none'" is intended to
be the exact rule either: the fact that both phrasings are given
could well be because neither version by itself completely captures
the intended behaviour.  In fact I think that may well be why the
"not displayed" version was also included, because of concerns that
"'display' set to 'none'" might not capture some cases (such as
descendents of display:none elements, or indeed suppressed descendents
of display:table-column and display:table-column-group elements if we
accept that as correct behaviour).  Other borderline cases (with more
varying UA interpretations) are replaced elements and their :before &
:after pseudo-elements and display:list-item replaced elements.  (I was
going to write about these cases in a separate message.)

That's why I went to the trouble of testing the behaviour, and
that's why I believe that the spec should state explicitly whether
'counter-increment' and 'counter-reset' on table-column-group,
table-column or their children that are suppressed by the rules of
CSS 2.1 section 17.2.1.

(And incidentally I would also suggest changing the visibility:hidden
wording to more like "is not enough to prevent ...", or in some other
way changing it so that it no longer says that visibility:hidden
display:none elements do increment counters.  No UA I've tested
increments counters for visibility:hidden that have display:none or
whose parent is display:none.)

I append the document I've used for testing,
which is also available at
http://bowman.infotech.monash.edu.au/~pmoulder/html-tests/counter-suppression.html

The UAs I've tested are Gecko, some WebKit based browsers (including
Chromium but not Safari), Konqueror, and a ~2005 version of Opera.
Versions are probably 1-2 years old, though I have also tested
2-month old development versions of Gecko & Chromium.

pjrm.


<!DOCTYPE html>
<html>
<head>
<title>Test of what node suppressions affect counter increment</title>
<style type="text/css" media="all">
body>div { counter-reset: c 5; margin-left:40px; }
body>div:after { content: " c=" counter(c); }

img:before { content: "[before]"; counter-increment: c 100; }
.c100:before { content: "[before]"; counter-increment: c 100; }
* { list-style-type: decimal; }
</style>
</head>
<body>
<p>img: 1105 and 1,2,3,4 if child increment honoured (like Gecko &amp; Opera), 1005 and 1,2,3 if not (like WebKit); or 5 and 1,2,3 if the img itself ignores counters (like Konqueror).</p>
<div>
 <div>
  <ol>
   <p style="display:list-item;">These p's and the below img are all display:list-item.</p>
   <img src="" alt="img alt" style="display:list-item; counter-increment: c 1000;"/>
   <p style="display:list-item;">These p's and the above img are all display:list-item.</p>
   <p style="display:list-item;">These p's and the above img are all display:list-item.</p>
  </ol>
 </div>
</div>
<hr />
<p>Same as above but with list-style-position:inside:</p>
<div>
 <div>
  <ol>
   <p style="display:list-item; list-style-position:inside;">These p's and the below img are all display:list-item.</p>
   <img src="" alt="img alt" style="display:list-item; list-style-position:inside; counter-increment: c 1000;"/>
   <p style="display:list-item; list-style-position:inside;">These p's and the above img are all display:list-item.</p>
   <p style="display:list-item; list-style-position:inside;">These p's and the above img are all display:list-item.</p>
  </ol>
 </div>
</div>
<hr />
<p>table-column-group: should suppress 100 and 10000, leaving 1101018.</p>
<div>
 <div style="display:table; counter-increment: c 1;">
  <div class="c100" style="display:table-column-group; counter-increment: c 10; ">
   <p style="counter-increment: c 100;">Suppressed child.</p>
   <div class="c100" style="display:table-column; counter-increment: c 1000;">
    <p style="counter-increment: c 10000;">Suppressed child.</p>
   </div>
  </div>
  <div style="display:table-row; counter-increment: c 100000;">
   <div style="display:table-cell; counter-increment: c 1000000;"><span style="counter-increment: c 2;">Cell</span></div>
  </div>
 </div>
</div>
<hr />
<p>table-column: should suppress 100 and 10000, leaving either 5 if table-column itself ignores counters (like Konqueror) otherwise 15 like (Gecko, Opera &amp; WebKit).</p>
<div>
 <div class="c100" style="display:table-column; counter-increment: c 10; ">
  <p style="counter-increment: c 10000;">Suppressed child.</p>
 </div>
</div>
<hr />
<p>Check that visibility:hidden display:none don't increment counters, contrary to what the spec literally says.  c should be 15 if they don't increment counters, or 1115 if the literal reading is followed.</p>
<div>
 <span style="visibility:hidden; counter-increment: c 10;">+10</span>
 <span style="visibility:hidden; counter-increment: c 100; display:none;">
   +100
   <span style="visibility:hidden; counter-increment: c 1000;">+1000</span>
 </span>
</div>
</body>
</html>
Received on Friday, 20 May 2011 02:42:59 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:40 GMT