mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
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.
4 lines
125 B
Plaintext
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)
|