mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 03:09:08 +00:00
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:
committed by
Andreas Kling
parent
604400f758
commit
327dc8e82a
@@ -508,8 +508,12 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
||||
// :has() cannot be nested in a :has()
|
||||
if (selector_kind == SelectorKind::Relative)
|
||||
return false;
|
||||
if (context.collect_per_element_selector_involvement_metadata && &element == context.subject) {
|
||||
const_cast<DOM::Element&>(element).set_affected_by_has_pseudo_class_in_subject_position(true);
|
||||
if (context.collect_per_element_selector_involvement_metadata) {
|
||||
if (&element == context.subject) {
|
||||
const_cast<DOM::Element&>(element).set_affected_by_has_pseudo_class_in_subject_position(true);
|
||||
} else {
|
||||
const_cast<DOM::Element&>(element).set_affected_by_has_pseudo_class_in_non_subject_position(true);
|
||||
}
|
||||
}
|
||||
// These selectors should be relative selectors (https://drafts.csswg.org/selectors-4/#relative-selector)
|
||||
for (auto& selector : pseudo_class.argument_selector_list) {
|
||||
|
||||
Reference in New Issue
Block a user