mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Skip invalidating :first-child and :last-child if possible
There is no need to invalidate siblings affected by these pseudo classes if invalidation reason is not insertion or removal of tree nodes.
This commit is contained in:
parent
0e057d3a36
commit
92a3419799
|
|
@ -461,8 +461,16 @@ void Node::invalidate_style(StyleInvalidationReason reason)
|
|||
}
|
||||
|
||||
for (auto* sibling = next_sibling(); sibling; sibling = sibling->next_sibling()) {
|
||||
if (auto* element = as_if<Element>(sibling); element && element->style_affected_by_structural_changes())
|
||||
element->set_entire_subtree_needs_style_update(true);
|
||||
if (auto* element = as_if<Element>(sibling)) {
|
||||
bool needs_to_invalidate = false;
|
||||
if (reason == StyleInvalidationReason::NodeInsertBefore || reason == StyleInvalidationReason::NodeRemove) {
|
||||
needs_to_invalidate = element->style_affected_by_structural_changes();
|
||||
} else {
|
||||
needs_to_invalidate = element->affected_by_sibling_combinator() || element->affected_by_nth_child_pseudo_class();
|
||||
}
|
||||
if (needs_to_invalidate)
|
||||
element->set_entire_subtree_needs_style_update(true);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host())
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user