[css-lists] Implicitly set counter-reset by `reversed`, `start` [chromium/src : main]

0 views
Skip to first unread message

Minseong Kim (Gerrit)

unread,
Dec 24, 2025, 2:28:24 AM (4 days ago) Dec 24
to AyeAye, Rune Lillesveen, Daniil Sakhapov, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org

Minseong Kim added 1 comment

File third_party/blink/renderer/core/style/computed_style_extra_fields.json5
Line 1245, Patchset 8: name: "IsOrderedListReversed",
field_template: "primitive",
type_name: "bool",
field_group: "*",
default_value: "false",
Minseong Kim . unresolved

I checked Firefox's devtools with below HTML file, it converts `reversed` attribute to `counter-reset: reversed(list-item)` style.

```
<!doctype html>
<title>Overriding reversed attribute of ol by counter-reset: reversed(counter)</title>
<ol reversed>
<li>One
<li>Two
<li>Three
</ol>
```

I think I need to use CounterDirectives rather than the extra field?

Daniil Sakhapov

I think so, yes.
But, please, note that most people are out for holdiays (at least this week), so there won't be much review (this week)

Minseong Kim

Thanks for the heads-up. I'll request a review when this change is ready. Merry Christmas!

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ic2dc0661b9c57dfbd021c0f52b6e7ec0a2070c9d
Gerrit-Change-Number: 7233512
Gerrit-PatchSet: 11
Gerrit-Owner: Minseong Kim <jja0...@gmail.com>
Gerrit-Reviewer: Daniil Sakhapov <sakh...@chromium.org>
Gerrit-Reviewer: Minseong Kim <jja0...@gmail.com>
Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
Gerrit-CC: Menard, Alexis <alexis...@intel.com>
Gerrit-Comment-Date: Wed, 24 Dec 2025 07:27:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Daniil Sakhapov <sakh...@chromium.org>
Comment-In-Reply-To: Minseong Kim <jja0...@gmail.com>
satisfied_requirement
unsatisfied_requirement
open
diffy

Minseong Kim (Gerrit)

unread,
Dec 25, 2025, 9:57:58 PM (2 days ago) Dec 25
to AyeAye, Rune Lillesveen, Daniil Sakhapov, Chromium LUCI CQ, Menard, Alexis, chromium...@chromium.org, blink-rev...@chromium.org, blink-re...@chromium.org, apavlo...@chromium.org, blink-re...@chromium.org, blink-rev...@chromium.org, blink-revie...@chromium.org, blink-...@chromium.org
Attention needed from Daniil Sakhapov and Rune Lillesveen

Minseong Kim added 3 comments

Patchset-level comments
File-level comment, Patchset 4:
Daniil Sakhapov . resolved

I think the correct approach here would be to override the reversed attribute with style info during style recalc, e.g. in Element::RecalcOwnStyle. @fut...@chromium.org, wdyt?

Rune Lillesveen

I don't know at which level of the CSS cascade things happen here. Would it make sense to do this as a CSS cascade thing that sets some value/flag on the ComputedStyle instead? That is, the `reversed` attribute causes some presentation style which is overridable by the CSS property?

And that computed CSS value is the source of truth for reversing instead of the attribute?

Daniil Sakhapov

Yes, you got that right.
In this case, will a CSS cascade thing make sense?
If we detect this need to override, we need to call UpdateItems() for HTMLOListElement, which causes calls to SetNeedsLayoutAndIntrinsicWidthsRecalcAndFullPaintInvalidation(), so doing it from RecalcOwnStyle should by fine?

Rune Lillesveen

When is UpdateItems() called (lifecycle-wise)?

Could you spell out all the cascade-dependencies here?

Daniil Sakhapov

So `reversed` on <ol> is called from Element::ParseAttribute (so, html parsing time?) and it sets SetNeedsLayoutAndIntrinsicWidthsRecalcAndFullPaintInvalidation() for <li>s via UpdateItems().
Then we have our `counter-reset`, which should override `reset` and call UpdateItems() for <ol>.
I guess that's it.

Rune Lillesveen

That didn't answer my questions.

When, in the lifecycle, is UpdateItems called? Related to CSS counters?

And the cascade part:

Is it possible to express this behavior as presentation style for `reversed`, so that UpdateItems rely on computed styles instead of the attribute directly? (This is why I ask about when UpdateItems() is called).

Minseong Kim

When, in the lifecycle, is UpdateItems called? Related to CSS counters?


IIUC, as @sakh...@chromium.org said, it's only called from `Element::ParseAttribute` when the element set/add/remove attributes. So, I think the call site of `UpdateItemValues()` has no relations with the CSS counters.. right?

And that computed CSS value is the source of truth for reversing instead of the attribute?


I totally agree with you. I'll test that it is possible to make `UpdateItemValues()` rely on computed styles instead of the attribute directly.

Minseong Kim

FYI, `UpdateItemValues` is a method on `HTMLOListElement` that is called when the `start` or `reversed` attributes of an <ol> are modified. Its primary role is to invalidate the cached numerical values (ordinals) of the list items. This forces a recalculation during the next layout phase. The recalculation logic, found in `ListItemOrdinal` class (specifically the `CalcValue` method), directly considers CSS properties like counter-set and counter-increment alongside the HTML attributes.

Rune Lillesveen

FYI, `UpdateItemValues` is a method on `HTMLOListElement` that is called when the `start` or `reversed` attributes of an <ol> are modified. Its primary role is to invalidate the cached numerical values (ordinals) of the list items. This forces a recalculation during the next layout phase. The recalculation logic, found in `ListItemOrdinal` class (specifically the `CalcValue` method), directly considers CSS properties like counter-set and counter-increment alongside the HTML attributes.

Right. It's confusing that it's called UpdateItemValues(). It should probably be named InvalidateItemValues() instead.

Minseong Kim

Done. Thanks for the guidance!

File-level comment, Patchset 16 (Latest):
Minseong Kim . resolved

I updated this CL to use `counter-reset` as the source of truth. PTAL when you have a moment.

File third_party/blink/renderer/core/style/computed_style_extra_fields.json5
Line 1245, Patchset 8: name: "IsOrderedListReversed",
field_template: "primitive",
type_name: "bool",
field_group: "*",
default_value: "false",
Minseong Kim . resolved

I checked Firefox's devtools with below HTML file, it converts `reversed` attribute to `counter-reset: reversed(list-item)` style.

```
<!doctype html>
<title>Overriding reversed attribute of ol by counter-reset: reversed(counter)</title>
<ol reversed>
<li>One
<li>Two
<li>Three
</ol>
```

I think I need to use CounterDirectives rather than the extra field?

Daniil Sakhapov

I think so, yes.
But, please, note that most people are out for holdiays (at least this week), so there won't be much review (this week)

Minseong Kim

Thanks for the heads-up. I'll request a review when this change is ready. Merry Christmas!

Minseong Kim

Done

Open in Gerrit

Related details

Attention is currently required from:
  • Daniil Sakhapov
  • Rune Lillesveen
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ic2dc0661b9c57dfbd021c0f52b6e7ec0a2070c9d
    Gerrit-Change-Number: 7233512
    Gerrit-PatchSet: 16
    Gerrit-Owner: Minseong Kim <jja0...@gmail.com>
    Gerrit-Reviewer: Daniil Sakhapov <sakh...@chromium.org>
    Gerrit-Reviewer: Minseong Kim <jja0...@gmail.com>
    Gerrit-Reviewer: Rune Lillesveen <fut...@chromium.org>
    Gerrit-CC: Menard, Alexis <alexis...@intel.com>
    Gerrit-Attention: Daniil Sakhapov <sakh...@chromium.org>
    Gerrit-Attention: Rune Lillesveen <fut...@chromium.org>
    Gerrit-Comment-Date: Fri, 26 Dec 2025 02:57:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Daniil Sakhapov <sakh...@chromium.org>
    Comment-In-Reply-To: Rune Lillesveen <fut...@chromium.org>
    Comment-In-Reply-To: Minseong Kim <jja0...@gmail.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages