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

> The child list items would show "3.1a" and "0.1b" respectively, no?

I guess the increments would be delayed until we leave the subtree. So they would show "5.1a" and "3.1b". But yeah, that would be like a different model for reversed counters, which probably is not worth it. Just matches my intuition better.

> it would be surprising if the list doesn't end with the value 2 in this case.

The last value could be decided with `ol > :last-child { counter-set: list-item 2 }` and then generate the start value from there using increments.

> I think option 2 would need a second pass

I don't see why.

> Option 2 also needs a way to gracefully deal with `counter-set` nodes

That should be analogous to option 1:

1. Let `num` be 0.
2. Let `incrementNegated` be 0.
3. For each element or pseudo-element `el` that increments or sets the same counter in the same scope:
   1. Set `incrementNegated` to `el`’s `counter-increment` integer value for this counter, multiplied by -1.
   2. If `el` sets this counter with `counter-set`, then add that integer value to `num` and break this loop.
   3. Add `incrementNegated` to `num`.
4. Add `incrementNegated` to `num`.
5. Return `num`.

> I don't see any obvious advantages from switching to option 2

The advantage is that (if there is no `counter-set`) the value of the last item depends on its own `counter-increment`, not the one of the 1st item, which probably is totally unrelated. Maybe it's clearer in:

| | Option 1 | Option 2 | Option 3 |
| ------------- | ------------- | ------------- | ------------- |
| `<ol reversed>` | -(-2*2 -1 -1 -1) = 7 | -(-2 -1 -1 -1*2) = 6 | -(-2 -1 -1 -1) +1 = 6 |
| `<li style="counter-increment: list-item -2">` | 5 | 4 | 4 |
| `<li style="counter-increment: list-item -1">` | 4 | 3 | 3 |
| `<li style="counter-increment: list-item -1">` | 3 | 2 | 2 |
| `<li style="counter-increment: list-item -1">` | 2 | 1 | 1 |
| `</ol>` | | |

Basically, in a non-reversed list, if you add items at the end, the former ones don't change. So in a reversed list, if you add items at the beginning (with no `counter-set`), the the latter ones shouldn't change either. That's provided by options 2 and 3, not by option 1.

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


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

Received on Tuesday, 19 October 2021 13:44:14 UTC