Skip to content

LibWeb: Make @counter-style tree-scoped and improve invalidation#8815

Open
Calme1709 wants to merge 10 commits intoLadybirdBrowser:masterfrom
Calme1709:tree-scoped-counter-styles
Open

LibWeb: Make @counter-style tree-scoped and improve invalidation#8815
Calme1709 wants to merge 10 commits intoLadybirdBrowser:masterfrom
Calme1709:tree-scoped-counter-styles

Conversation

@Calme1709
Copy link
Copy Markdown
Contributor

See individual commits for details.

@Calme1709 Calme1709 requested a review from AtkinsSJ as a code owner April 7, 2026 09:57
Copy link
Copy Markdown
Member

@AtkinsSJ AtkinsSJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits really, plus a build issue. Otherwise I'm happy with this. (I really need to be more aware of StyleScope too. It's a good place for storing things.)

This was a pretty straightforward change of storing registered counter
styles on the relevant `StyleScope`s and resolving by following the
process to dereference a global tree-scoped name, the only things of
note are:
 - We only define predefined counter styles (e.g. decimal) on the
   document's scope (since otherwise overrides in outer scopes would
   themselves be overriden).
 - When registering counter styles we don't have the full list of
   extendable styles so we defer fallback to "decimal" for undefined
   styles until `CounterStyle::from_counter_style_definition`.
This makes `ValueComparingRefPtr<CounterStyle>` work
In a later commit we can use the null state for an optimization.
The counter style used for an element (in either the `content` or
`list-style-type`) may change despite the computed values of properties
on that element remaining the same (e.g. if a new rule is inserted with
higher cascade precedence).
Copy link
Copy Markdown
Contributor Author

@Calme1709 Calme1709 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied those requested changes.

Looks like I managed to break both GCC and Windows compilation with separate mistakes, think those are fixed now as well but will double check once CI runs.

@Calme1709 Calme1709 force-pushed the tree-scoped-counter-styles branch from fe79e37 to 91a38fa Compare April 9, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants