W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2019

[csswg-drafts] [css-gcpm-3] string(nnn, start) definition needs clarification (#4634)

From: Mike Bremford via GitHub <sysbot+gh@w3.org>
Date: Mon, 30 Dec 2019 11:45:07 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-543852024-1577706305-sysbot+gh@w3.org>
faceless2 has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-gcpm-3] string(nnn, start) definition needs clarification ==
The [string()](https://drafts.csswg.org/css-gcpm/#using-named-strings) function in GCPM allows a string, previously set by `string-set`, to be included in the page margin content. Exactly which element to take the string value from is determined by the second parameter, of which the value "start" is defined as follows:

> If the element is the first element on the page, the value of the first assignment is used. Otherwise the entry value is used. The entry value may be empty if the element hasn’t yet appeared.

The definition of "first element on the page" is what I think needs clarifying. To clarify the intention of this function, take a look at the [titus.xml](https://github.com/yeslogic/prince-samples/tree/master/website_samples) example from Prince, which has the following (edited for clarity) CSS:
```css
@page {
  @top-center {
    content: "Titus " string(chapterx, start) ":" string(versex, start)  " - "  string(chapterx, last) ":" string(versex, last);
  }
} 
span {
  counter-increment: verse;
  string-set: versex counter(verse);
}
```
Here's a screenshot:

<kbd><img src="https://user-images.githubusercontent.com/989243/71577872-c3464700-2aed-11ea-8e65-14127ef9ffdf.png"/></kbd>

The paragraph numbered 15 (beginning "Everything", at the end of the first page) continues onto the start of the second page. This means the following paragraph (numbered 16) is _not_ the first element on the page - it's preceded by content from another element - so the value of `string(versex, start)` is 15, not 16. 

So far, so good. However, if you reformat the example in a single column you get this:

<kbd><img align="middle" src="https://user-images.githubusercontent.com/989243/71578142-e45b6780-2aee-11ea-8179-174bd4d74af8.png" /></kbd>

The page opens with verse 15, but the verse is listed as 14 in the margin. The reason this is happening is that the XML looks roughly like this:
```xml
<p>
  <span>Everything is pure... (verse 15)
</p>
<p>
  <span>Such people claim... (verse 16)
```

The first element on the page is the `p` - the block container surrounding the inline `span`. Because of this, verse 15 is _not_ considered the "first element on the page", and the entry alue (14) is used.

---

I think the results from Prince arguably match the specification in this case, but I don't think the specification is correct. I think the desired value in both examples is "15".

I've been working through this for a while now to try and find a way to rephrase this test to get that result, and it's surprisingly complicated. I think there are two practical definitions of "the first element on the page".

1. The first element that is opened on the page - any text content continued from the previous page is ignored. This definition would give "15" as the start value in the first example (the first element opened on the page is the second `p`) and "14" as the start value in the second example (the first element opened is the first `p`).

2. The first element that is opened on the page, provided it's not preceded by any content continued from the previous page. This definition would give "15" as the start value in the first example, and "14" in the second example.

Neither of those give the correct result. Closer is:

3. The first element that is opened on the page, provided it's not preceded by any content continued from the previous page _and_ that contains some form of content (i.e. text) itself. This would give "15" as the start value on both examples.

However, this would fail if the "versex" string was set on the `p` rather than the `span`. It would also fail if the string was set on a span with no content, e.g.

```html
<p>
 <span></span>Everything...
```

To solve for all these situations, I think the definition for how the "start" value is found needs to be changed to not reference the "first element on the page".

> If the first item of content on the page was not continued from the previous page, then use the closest assignment on the page that precedes that content in document order. Otherwise the entry value is used.

This seems to give the correct result in all the above variations.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4634 using your GitHub account
Received on Monday, 30 December 2019 11:45:08 UTC

This archive was generated by hypermail 2.4.0 : Thursday, 24 March 2022 20:27:06 UTC