Re: setting counter values without opening a scope..

On Thu, Jul 24, 2008 at 12:40 PM, Grant, Melinda <melinda.grant@hp.com>
wrote:

>  Ludger said:
> > I.e. I'd expect something like the following to be possible:
>
> > chapter {
> >   page-break-before: always;
> >   counter-reset: chapterPageCounter 1;
> >   string-set: chapterName self;
> > }
>
> > @page {
> >  counter-increment: chapterPageCounter;
> >  @bottom-right {
> >     Content: "Page " counter(chapterPageCounter) "of section " open-quote
> string(chapterName) close-quote;
> >  }
> > }
>
> See http://dev.w3.org/csswg/css3-page/#page-based-counters, in particular:
> "If a counter that has not been reset or incremented within the margin
> context or the page context is used by counter() or counters() in the margin
> context, then the resultant value is exactly as if the margin box were an
> element within the document at the start of the page, inside the deepest
> element in the normal flow that spans the page break. Use of the counter in
> this way does not affect the calculation of the counter's value."
>
> You can declare your counter in 'document space' and reference it within
> 'page space'.
>

You can do so, but I don't think the spec supports doing what  Ludger
actually wants.  That line appears to address the case when you have a
purely document-space counter that you want to show in page-space (frex,
printing the chapter number in the margin).  Ludger wants a counter that is
incremented in page-space, but is reset in document-space.  Contrary to what
I said before about it being undefined, it looks like this is actually
covered by:

"If a counter is reset or incremented within the page context, it is in
scope for all margin boxes and obscures all counters of the same name within
the document."
(Just above the line you quote in your email.)

The chapterPageCounter counter is incremented within the page context, and
so would obscure the same counter in document context.  In particular, it
would ignore the counter-resets, as they only reset the document-context
version of the counter.  If his original CSS was used, the result would be
that he simply prints the current page number in the margin of each page
(not the number of pages since the start of the chapter).

In order to do what Ludger wants, you need to deal with the counter entirely
within the page context, and go with something like what I suggested in my
previous email.

Received on Thursday, 24 July 2008 17:59:21 UTC