Re: [csswg-drafts] [css-lists] automatic start value of reversed list is affected by 'counter-increment: <counter> 0' nodes (#6738)

I'm not sure special-casing 0 is the way to go. What if there is a positive `counter-increment`, that could be confusing too.

In general,

```html
<ol reversed>
  <li style="counter-increment: list-item k1"></li>
  <li style="counter-increment: list-item k2"></li>
  ...
  <li style="counter-increment: list-item kn"></li>
</ol>
```

Then it's clear that:
 - The counter should be initialized to some value `v0`
 - The 1st item should have value `v1 := v0 + k1`
 - The 2nd item should have value `v2 := v0 + k1 + k2`
 - ...
 - The n-th item should have value `vn := v0 + k1 + k2 + ... + kn`

But basically `v0` is free in `reversed()` with no start value, we need an additional constraint to determine it. Examples:
 - `vn + k1 = 0`. This is what the spec says now. Adding an initial `counter-increment: list-item 0` item changes values.
    ```html
    <ol reversed><!-- 7 -->
      <li style="counter-increment: list-item -2"><!-- 5 --></li>
      <li style="counter-increment: list-item -3"><!-- 2 --></li>
    </ol>
    <ol reversed><!-- 5 -->
      <li style="counter-increment: list-item 0"><!-- 5 --></li>
      <li style="counter-increment: list-item -2"><!-- 3 --></li>
      <li style="counter-increment: list-item -3"><!-- 0 --></li>
    </ol>
    ```
 - `vn + kn = 0`. Adding a final `counter-increment: list-item 0` item changes values.
    ```html
    <ol reversed><!-- 8 -->
      <li style="counter-increment: list-item -2"><!-- 6 --></li>
      <li style="counter-increment: list-item -3"><!-- 3 --></li>
    </ol>
    <ol reversed><!-- 5 -->
      <li style="counter-increment: list-item -2"><!-- 3 --></li>
      <li style="counter-increment: list-item -3"><!-- 0 --></li>
      <li style="counter-increment: list-item 0"><!-- 0 --></li>
    </ol>
    ```
 - `vn = 1`. Adding `counter-increment: list-item 0` items doesn't change values.
    ```html
    <ol reversed><!-- 6 -->
      <li style="counter-increment: list-item -2"><!-- 4 --></li>
      <li style="counter-increment: list-item -3"><!-- 1 --></li>
    </ol>
    <ol reversed><!-- 6 -->
      <li style="counter-increment: list-item 0"><!-- 6 --></li>
      <li style="counter-increment: list-item -2"><!-- 4 --></li>
      <li style="counter-increment: list-item -3"><!-- 1 --></li>
    </ol>
    <ol reversed><!-- 6 -->
      <li style="counter-increment: list-item -2"><!-- 4 --></li>
      <li style="counter-increment: list-item -3"><!-- 1 --></li>
      <li style="counter-increment: list-item 0"><!-- 1 --></li>
    </ol>
    <ol reversed><!-- 6 -->
      <li style="counter-increment: list-item 0"><!-- 6 --></li>
      <li style="counter-increment: list-item -2"><!-- 4 --></li>
      <li style="counter-increment: list-item -3"><!-- 1 --></li>
      <li style="counter-increment: list-item 0"><!-- 1 --></li>
    </ol>
    ```

IMO `vn + kn = 0` is more intuitive than `vn + k1 = 0`. And `vn = 1` seems the way to go if we want to prevent `list-item 0` from messing the others.

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6738#issuecomment-945866363 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 18 October 2021 15:01:30 UTC