LibWeb: Avoid full tree traversal for non-subject :has() invalidation

Instead of checking all elements in a document for containment in
`:has()` invalidation set, we could narrow this down to ancestors and
ancestor siblings, like we already do for subject `:has()` invalidation.

This change brings great improvement on GitHub that has selectors with
non-subject `:has()` and sibling combinators (e.g., `.a:has(.b) ~ .c`)
which prior to this change meant style invalidation for whole document.
This commit is contained in:
Aliaksandr Kalenik 2025-02-12 16:33:24 +01:00 committed by Andreas Kling
commit 327dc8e82a
Notes: github-actions[bot] 2025-02-13 15:25:48 +00:00
6 changed files with 42 additions and 54 deletions

View file

@ -309,7 +309,6 @@ public:
[[nodiscard]] bool entire_subtree_needs_style_update() const { return m_entire_subtree_needs_style_update; }
void set_entire_subtree_needs_style_update(bool b) { m_entire_subtree_needs_style_update = b; }
void invalidate_ancestors_affected_by_has_in_subject_position();
void invalidate_style(StyleInvalidationReason);
struct StyleInvalidationOptions {
bool invalidate_self { false };