LibWeb: Use fast CSS selector matching in default matches() code path

Before this change, checking if fast selector matching could be used was
only enabled in style recalculation and hover invalidation. With this
change it's enabled for all callers of SelectorEngine::matches() by
default. This way APIs like `Element.matches()` and `querySelector()`
could take advantage of this optimization.
This commit is contained in:
Aliaksandr Kalenik
2025-02-02 20:35:29 +01:00
committed by Jelle Raaijmakers
parent 17c0d4469c
commit 0f17ad9ebc
7 changed files with 59 additions and 66 deletions

View File

@@ -595,13 +595,8 @@ Vector<MatchingRule const*> StyleComputer::collect_matching_rules(DOM::Element c
if (context.did_match_any_hover_rules)
did_match_any_hover_rules = true;
};
if (rule_to_run.can_use_fast_matches) {
if (!SelectorEngine::fast_matches(selector, element, shadow_host_to_use, context))
continue;
} else {
if (!SelectorEngine::matches(selector, element, shadow_host_to_use, context, pseudo_element))
continue;
}
if (!SelectorEngine::matches(selector, element, shadow_host_to_use, context, pseudo_element))
continue;
matching_rules.append(&rule_to_run);
}
@@ -2686,7 +2681,6 @@ void StyleComputer::make_rule_cache_for_cascade_origin(CascadeOrigin cascade_ori
selector.specificity(),
cascade_origin,
false,
SelectorEngine::can_use_fast_matches(selector),
false,
};