LibWeb: Don't rebuild rule cache so eagerly to check for :has/:defined

Instead, change the APIs from "has :foo" to "may have :foo" and return
true if we don't have a valid rule cache at the moment.

This allows us to defer the rebuilding of the rule cache until a later
time, for the cost of a wider invalidation at the moment.

Do note that if our rule cache is invalid, the whole document has
invalid style anyway! So this is actually always less work. :^)

Knocks ~1 second of loading time off of https://wpt.fyi/
This commit is contained in:
Andreas Kling
2025-01-24 10:29:51 +01:00
committed by Andreas Kling
parent 3b3f06ca68
commit 4bef0d0aea
5 changed files with 13 additions and 12 deletions

View File

@@ -1617,7 +1617,7 @@ void Document::invalidate_style_for_elements_affected_by_hover_change(Node& old_
return;
auto& invalidation_root = [&] -> Node& {
if (style_computer().has_has_selectors())
if (style_computer().may_have_has_selectors())
return old_new_hovered_common_ancestor;
return old_new_hovered_common_ancestor;
}();