RE: setting counter values without opening a scope..

Yes, Tj, you are right, thanks for clarifying this.

 

You correctly provided a solution for the sample use case I mentioned,
so I could go with your approach and would be happy.

 

 

However I actually see a problem with every counter-reset always forcing
the creation of a new scope, which was my original proposal.

 

Currently counter-reset and opening a new scope is tightly coupled

 

I can not set a counter to a specific value without creating a scope
(and vice versa, if a vice versa makes sense - maybe it does but I am
not sure here).

What I am missing is a way to set a counter to a specific value while
maintaining the current scope.

 

I believe this is problematic because there are use cases where you do
not intend to open a new scope when setting a counter value - I
mentioned a use case as an example. 

 

And this is not a paged media issue - I do also have others use cases at
hand which do not involve paged media at all.

 

 

 

From: Tab Atkins Jr. [mailto:jackalmage@gmail.com] 
Sent: Thursday, July 24, 2008 7:59 PM
To: Grant, Melinda
Cc: Ludger Buenger; www-style@w3.org
Subject: 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 18:29:25 UTC