@@ -401,47 +401,13 @@ GC::Ptr<HTML::Navigable> Node::navigable() const
401
401
}
402
402
}
403
403
404
- void Node::invalidate_elements_affected_by_has ()
405
- {
406
- Vector<CSS::InvalidationSet::Property, 1 > changed_properties;
407
- changed_properties.append ({ .type = CSS::InvalidationSet::Property::Type::PseudoClass, .value = CSS::PseudoClass::Has });
408
- auto invalidation_set = document ().style_computer ().invalidation_set_for_properties (changed_properties);
409
- for_each_shadow_including_inclusive_descendant ([&](Node& node) {
410
- if (!node.is_element ())
411
- return TraversalDecision::Continue;
412
- auto & element = static_cast <Element&>(node);
413
- bool needs_style_recalculation = false ;
414
- // There are two cases in which an element must be invalidated, depending on the position of :has() in a selector:
415
- // 1) In the subject position, i.e., ".a:has(.b)". In that case, invalidation sets are not helpful
416
- // for narrowing down the set of elements that need to be invalidated. Instead, we invalidate
417
- // all elements that were tested against selectors with :has() in the subject position during
418
- // selector matching.
419
- // 2) In the non-subject position, i.e., ".a:has(.b) > .c". Here, invalidation sets can be used to
420
- // determine that only elements with the "c" class have to be invalidated.
421
- if (element.affected_by_has_pseudo_class_in_subject_position ()) {
422
- needs_style_recalculation = true ;
423
- } else if (invalidation_set.needs_invalidate_whole_subtree ()) {
424
- needs_style_recalculation = true ;
425
- } else if (element.includes_properties_from_invalidation_set (invalidation_set)) {
426
- needs_style_recalculation = true ;
427
- }
428
-
429
- if (needs_style_recalculation) {
430
- element.set_needs_style_update (true );
431
- } else {
432
- element.set_needs_inherited_style_update (true );
433
- }
434
- return TraversalDecision::Continue;
435
- });
436
- }
437
-
438
404
void Node::invalidate_style (StyleInvalidationReason reason)
439
405
{
440
406
if (is_character_data ())
441
407
return ;
442
408
443
409
if (document ().style_computer ().may_have_has_selectors ()) {
444
- document ().invalidate_elements_affected_by_has ( );
410
+ document ().set_needs_invalidate_elements_affected_by_has ( true );
445
411
}
446
412
447
413
if (!needs_style_update () && !document ().needs_full_style_update ()) {
@@ -503,7 +469,7 @@ void Node::invalidate_style(StyleInvalidationReason, Vector<CSS::InvalidationSet
503
469
properties_used_in_has_selectors |= document ().style_computer ().invalidation_property_used_in_has_selector (property);
504
470
}
505
471
if (properties_used_in_has_selectors) {
506
- document ().invalidate_elements_affected_by_has ( );
472
+ document ().set_needs_invalidate_elements_affected_by_has ( true );
507
473
}
508
474
509
475
auto invalidation_set = document ().style_computer ().invalidation_set_for_properties (properties);
0 commit comments