mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 19:47:17 +02:00
Replace flat InvalidationSet with recursive InvalidationPlan trees
that preserve selector combinator structure. Previously, selectors
with sibling combinators (+ and ~) fell back to whole-subtree
invalidation. Now the StyleInvalidator walks the DOM following
combinator-specific rules, so ".a + .b" only invalidates the
adjacent sibling matching ".b" rather than the entire subtree.
Plans are compiled at stylesheet parse time by walking selector
compounds right-to-left. For ".a .b + .c":
```
[.c]: plan = { invalidate_self }
register: "c" → plan
[.b]: wrap("+", righthand)
plan = { sibling_rules: [match ".c", adjacent, {self}] }
register: "b" → plan
[.a]: wrap(" ", righthand)
plan = { descendant_rules: [match ".b", <sibling plan>] }
register: "a" → plan
```
Changing class "a" produces a plan that walks descendants for ".b",
checks ".b"'s adjacent sibling for ".c", and invalidates only that
element.
15 lines
485 B
Plaintext
15 lines
485 B
Plaintext
.a + .b before: rgba(0, 0, 0, 0)
|
|
.a + .b after: rgb(0, 128, 0)
|
|
.a ~ .b .c before: rgba(0, 0, 0, 0)
|
|
.a ~ .b .c after: rgb(0, 128, 0)
|
|
.a .b + .c before: rgba(0, 0, 0, 0)
|
|
.a .b + .c after: rgb(0, 128, 0)
|
|
.a + * + .c before: rgba(0, 0, 0, 0)
|
|
.a + * + .c after: rgb(0, 128, 0)
|
|
[attr] + .b before: rgba(0, 0, 0, 0)
|
|
[attr] + .b after: rgb(0, 128, 0)
|
|
#id ~ .b before: rgba(0, 0, 0, 0)
|
|
#id ~ .b after: rgb(0, 128, 0)
|
|
.a + :where(*) before: rgba(0, 0, 0, 0)
|
|
.a + :where(*) after: rgb(0, 128, 0)
|