Re: [css3-gcpm] [css3-page] Named page lists

On Friday 11 July 2008 13:46, Håkon Wium Lie wrote:
> Also sprach Bert Bos:
>  > > > I support the idea of changing 'page' from being inherited to
>  > > > not being inherited. If we do so, we can probably address the
>  > > > issue that the named page lists in GCPM is (unsuccessfully)
>  > > > trying to address; setting a different style on the first page
>  > > > in a series of pages. For example, the chapter title is often
>  > > > printed on the first page of the chapter and the chapter title
>  > > > should therefore not be printed in the running header of that
>  > > > first page.
>  >
>  > I've probably forgotten something, but I suddenly wondered why
>  > there is a 'page' property at all. Why doesn't 'page-break-before'
>  > accept the name of a named page? It already accepts 'left', it
>  > could also accept 'my-foo-page'.
>
> How would you express that you want 'my-foo-page' to be a left or
> right page?

Here is another idea...

What if the @page itself says whether it is a left or right page? And 
similarly, the @page itself can say what the name of the next page is:

    @page chapter-start
    {
        ... margins and stuff...
        page-side: right;             /* Force a right-hand page */
        next-page: chapter            /* Next page is of type chapter */
    }

    @page chapter
    {
        ... margins and stuff...
        page-side: auto;              /* = Default */
        next-page: chapter            /* Next page is of same type */
    }

    H1 {page-break-before: chapter-start}

Furthermore:

1) Page selectors consisting of a name and a pseudo-class are possible 
(with or without a space) and mean the following:

    @page foo :first
        A page of type foo that is either the first page of the document
        or preceded by a page that is not of type foo.
    @page foo :left
        A page of type foo that falls on a left page
    @page foo :right
        A page of type foo that falls on a right page

2) Page selectors can be grouped:

    @page chapter, chapter-start, :first
    {
        margin-top: 3cm
    }

3) @page rules cascade in an analogous way to normal rules with element 
names and pseudo-classes.

4) The 'page-side' property accepts: auto | left | right. Default 
is 'auto'. It forces pages of the type it is applied to to be always on 
the given side. If that causes an empty page, that empty page is of the 
type that is given by the 'next-page' of the preceding page if that is 
defined, or a nameless page otherwise.

E.g., if a page is defined as

    @page foo {
        page-side: right;
        next-page: foo}

then the left-hand page after a foo page is not defined and thus 
defaults to being a nameless page.

The 'page-side' property does not apply to @page rules with a 
pseudo-class. I.e., the following rule

    @page foo :left {
        page-side: right
    }

is interpreted as

    @page foo :left {}

5) The 'next-page' property accepts: auto | <identifier>. Default 
is 'auto'. Where 'auto' means the next page is unnamed and <identifier> 
means the next page is of that type.

The next page is only of the given type if it is the result of an 
implicit page break. If the page break was explicit (result of a 
page-break-after/before other than 'auto'), then the next page type is 
determined by those page-break-after/before properties (see next 
section).

An <identifier> for which there is no @page rule is not an error. It 
just means a page with the same properties as the nameless page, except 
that it has a name.

6) The 'page-break-before' and 'page-break-after' accept: auto | 
always | avoid | left | right | <identifier>

    always: start a new *unnamed* page.
    left: start a new *unnamed* left page (i.e., a ':left' page).
    right: start a new *unnamed* right page (i.e., a ':right' page).
    <identifier>: start a new page of that type.

As for 'next-page', an <identifier> doesn't need to be "declared" with 
an @page rule.

7) A sequence of two or more page breaks without any intervening content 
that all call for pages on the same side (left or right) or without a 
side preference (auto), causes at most two page breaks and creates a 
page of the type given by the last page break in the sequence. If any 
page break in that sequence mentions a specific side, than the page is 
on that side. Example:

    Previous content... <!-- ends on a left "chapter" page -->
    <div style="page-break-before: left">
      <div style="page-break-before: right">
        <div style="page-break-before: chapter-start">
          <div style="page-break-before: always">
            <!-- empty -->
          </div>
        </div>
      </div>
    </div>
    <div style="page-break-before: chapter">
      Some content here...
    </div>

This gives two sequences of page breaks:

    Sequence 1: left
    Sequence 2: right chapter-start always chapter

The first sequence causes two page breaks and starts a nameless, left 
page. The second sequence causes one page break and starts a right-hand 
page of type "chapter." The result is

    :left (Previous content...)
    :right (empty)
    :left (empty)
    chapter (Some content here...)

In the same way as explained for 'page-side' (see 4): Any empty pages 
created by forcing a left or right page are of the type that is given 
by the 'next-page' of their preceding page, or are nameless if 
that 'next-page' designates a page of the wrong page side.

In the example above, the first empty page was the result of forcing a 
left page. Its preceding page is of type "chapter" and has 
a 'next-page' property with value 'chapter' and thus this empty page is 
of type chapter, too. The sequence of pages is thus

    chapter :left  (Previous content...)
    chapter :right (empty)
    :left          (empty)
    chapter :right (Some content here...)

8) There is no 'page' property.

        

Here is a bigger example: a document with several chapters that each 
start with an H1 on a right-hand page with specific running headers, 
and with occasional special pages that are printed in landscape mode.

By default, a nameless page is followed by another nameless page; a 
chapter-start page is followed by a nameless page; and a special page 
is followed by another special page.

    @page {
        ... common properties and margin boxes of all pages...
    }
    @page chapter-start {
        ... overrides for the first page of a chapter...
        page-side: right;
    }
    @page special {
        size: landscape;
        next-page: special
    }
    @page special :left {
        margin-right: 1cm
    }
    @page special :right {
        margin-left: 1cm
    }
        
    H1 {
        page-break-before: chapter-start
    }
    DIV.special {
        page-break-before: special;
        page-break-after: chapter
    }



Bert

PS. What I don't like about this proposal is that it requires you to 
invent names. The 'page' property that this replaces (see 
http://www.w3.org/TR/2007/WD-css3-gcpm-20070504/#named3) also requires 
that, of course, but still I feel as if the best solution has not yet 
been invented...

E.g., if I compare Template Layout 
(http://www.w3.org/TR/2007/WD-css3-layout-20070809/) to Frame-based 
Layout from 1996 (http://www.w3.org/TR/NOTE-layout), the big difference 
is that the former doesn't require you to invent names, and, probably 
as a result, is much shorter. (It still requires letters, but there is 
not much to invent, a b c works fine.)

-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Friday, 18 July 2008 19:06:37 UTC