Files
ladybird/Tests/LibWeb/Text/expected/css/pseudo-class-invalidation-scoped-to-common-ancestor.txt
Andreas Kling 6b9797f480 LibWeb: Scope pseudo-class invalidation to common ancestor
When a pseudo-class state changed, we always walked the entire
document (or shadow root) tree to find affected elements, even
though only the subtree rooted at the old/new common ancestor
can be affected.

Narrow the tree walk to start from old_new_common_ancestor
instead of the root. To ensure ancestor-dependent selectors are
still correctly evaluated, we seed the style computer's ancestor
filter by walking up from the common ancestor to the root before
the invalidation walk.

This reduces the work from O(total elements) to
O(subtree elements) + O(tree depth), which is a large improvement
on pages where pseudo-class changes (hover, focus, active, target)
occur deep in the DOM.

This was extremely hot (10%+) when hovering mailboxes on GMail.
2026-01-27 10:58:47 +01:00

4 lines
125 B
Plaintext

Case 1 (ancestor selector): rgb(0, 128, 0)
Case 2 (sibling combinator): rgb(0, 128, 0)
Case 3 (deep nesting): rgb(0, 128, 0)