Files
ladybird/Tests/LibWeb/Text/expected/css/property-driven-sibling-invalidation.txt
Aliaksandr Kalenik 9df1372452 LibWeb: Implement sibling invalidation sets
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.
2026-03-09 18:35:46 +01:00

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)