Content-Length: 285793 | pFad | https://github.com/w3c/csswg-drafts/issues/3524

5C [css-gcpm-3] page group example is incorrect and specificity of nth() is undefined · Issue #3524 · w3c/csswg-drafts · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-gcpm-3] page group example is incorrect and specificity of nth() is undefined #3524

Open
faceless2 opened this issue Jan 16, 2019 · 6 comments
Assignees
Labels
css-gcpm-3 Current Work css-page-3 Current Work

Comments

@faceless2
Copy link

faceless2 commented Jan 16, 2019

https://drafts.csswg.org/css-gcpm-3/#document-page-selectors has this to say on page groups:

When the page property is applied to an element that also has a forced break property applied, a page group is created.

But examples 13 and 14 immediately below that don't show a forced-break. Without this, neighbouring div elements with the same page attribute could be on the same page.

To fix example 13:

  • Change div { page: A } to div { page: A; break-before: page }

To fix example 14:

  • Change div.Chapter { page: body; } to div.chapter { page: body; break-before: page } (note case-change of "chapter")

Also, the specificity of the "nth" selector is undefined. I presume :nth(5) is (0,1,0) and :nth(5 of A) is (1,1,0)?

@faceless2 faceless2 changed the title [css-gcpm-3] page group example is incorrect [css-gcpm-3] page group example is incorrect and specifity of nth() is undefined Jan 16, 2019
@faceless2 faceless2 changed the title [css-gcpm-3] page group example is incorrect and specifity of nth() is undefined [css-gcpm-3] page group example is incorrect and specificity of nth() is undefined Jan 16, 2019
@fantasai fantasai added css-gcpm-3 Current Work css-page-3 Current Work labels Jan 16, 2019
@dauwhe dauwhe self-assigned this Feb 18, 2020
@dauwhe
Copy link
Contributor

dauwhe commented Feb 25, 2020

As I'm investigating this, it seems that at least some implementations force a page break when a named page is invoked. The example works as expected in both PrinceXML and WeasyPrint without adding a page-break property.

I think GCPM is wrong here. CSS Pages says that implementations introduce a forced page break if necessary:

The page property is used to specify a particular type of page (called a named page
) on which an element must be displayed. If necessary, a forced page break is introduced and a new page generated of the specified type.

I would propose deleting the text " that also has a forced break property applied" from GCPM.

@faceless2
Copy link
Author

I don't think the the current wording is problematic - we've implemented it as currently specced, so I know it's possible to do (with bugs, but they're all ours). My reason for opening this issue was purely the lack of a visible forced break in the examples!

But I can see why it might look like a problem if we presume page always forces a page break. I don't think it's either necessary or correct to do this.

We have break-before: page if we want to force a page break, and as example 28 explicitly states, there are cases where multiple elements need to be on a landscape page but not each on their own landscape page. So I agree that the CSS-Pages definition is preferred, and I think Prince and WeasyPrint behaviour is incorrect in this instance. A page break is only necessary if explicit, i.e. with break-before: page, or if the current page is not of the correct type.

With your proposed change, the text is to read like this?

When the page property is applied to an element, a page group is created. The page group is the collection of all pages created by an instance of that element. When a new instance of the element is rendered, a new page group is started.

I think that may be problematic. Restarting the page group whenever you simply use the page property makes things ambiguous. For example:

table { page: landscape }

<table id="table1"> ... </table>
<table id="table2"> ... </table>
...
<table id="table95"> ... </table>

With this change to the text, you'd be restarting the page group for each table, and with multiple items specifying page potentially on the same page, it gets complex. For example, if "table1" ended halfway through the second page and "table2" started immediately after on the same page, is that page the first page in the "landscape" group or the second?

To sum up: I don't think a change to the spec is warranted. But those examples could use a break-before: page

@liZe
Copy link

liZe commented Feb 25, 2020

The example works as expected in both PrinceXML and WeasyPrint without adding a page-break property.

WeasyPrint does not break pages between consecutive blocks with the same page value. This example:

<style>article { page: a } div { page: b }</style>
<article>a</article>
<div>b</div>
<div>b</div>
<article>a</article>

gives:

  • page 1: a
  • page 2: b b
  • page 3: a

Page groups are not supported by WeasyPrint.

So I agree that the CSS-Pages definition is preferred

I agree too.

To sum up: I don't think a change to the spec is warranted. But those examples could use a break-before: page

👍


Also, the specificity of the "nth" selector is undefined. I presume :nth(5) is (0,1,0) and :nth(5 of A) is (1,1,0)?

Looks good to me.

dauwhe added a commit that referenced this issue Feb 26, 2020
[css-gcpm-3] add break-before properties to examples 13 and 14 per #3524
@dauwhe
Copy link
Contributor

dauwhe commented Feb 26, 2020

I've added break-before properties to the examples, and fixed the selector typos.

@faceless2
Copy link
Author

This sounds terribly ungrateful - first, thank you for making the change! But always isn't a valid value for break-before. See https://drafts.csswg.org/css-break-3/#break-between

You could go for page-break-before: always, which is a compatibility option, or break-before: page which is the correct value.

However the intention is clear, which is the main thing. So thanks again.


The specificity of nth() is still undefined (I should have opened a separate issue for this, but as we're here...). I'm almost certain no-one implements this yet (we do but aren't yet public) so you've got no compatibility issues to worry about.

For reference, here's the text from css-page:

The specificity of page a selector is computed in a manner analogous to the computations defined in the Selectors module:

Count the number of page type names (= f)
Count the number of ':first' or ':blank' pseudo-classes (= g)
Count the number of ':left' or ':right' pseudo-classes (= h)

If you want @page:nth(1 of name) to have at least the same specificity as @page name, which I think is pretty hard to argue against, then there are exactly three possibilities left:

  1. :nth(1), :nth(2n) and :nth(2n + 1) are all the same specificity as :first
  2. :nth(1), :nth(2n) and :nth(2n + 1) are all the same specificity as :left
  3. :nth(1) has the same specificity as :first, and :nth(2n) has the same specificity as :left. :nth(2n + 1) has a higher specificity than both of them.

I think option 2 is wrong - this selector should certainly override :left or :right. Between the others I don't really have a strong opinion, except to say that it does need a decision before anyone can implement it with confidence.

(and once decided, I'm more than happy to do a pull request with proposed wording Dave if it will help take the load off you)

dlibby- pushed a commit to dlibby-/csswg-drafts that referenced this issue Feb 27, 2020
[css-gcmp-3] fix incorrect value for break-before per w3c#3524
@dauwhe
Copy link
Contributor

dauwhe commented Feb 27, 2020

The break-before issue should be fixed. GitHub has been strange today; the Overview.bs file appears to be correct but Bikeshed has not yet updated the editor's draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-gcpm-3 Current Work css-page-3 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/w3c/csswg-drafts/issues/3524

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy