LibWeb: Fix early return condition in Node::invalidate_style()

When checking whether an early return is possible because some ancestor
already has the whole subtree invalidation flag set, the check should
begin with the current node's parent rather than with the node itself.
Otherwise, if a node already has the whole subtree invalidation flag
set and is subsequently invalidated for the reason `NodeInsertBefore`
or `NodeRemove`, we will skip the sibling invalidation required for
these operations

This fix is required for optimizations in subsequent commits.
This commit is contained in:
Aliaksandr Kalenik 2025-02-06 01:51:27 +01:00 committed by Andreas Kling
parent 61c952fb43
commit daf7c1ef60
Notes: github-actions[bot] 2025-02-06 19:08:30 +00:00

View file

@ -423,7 +423,7 @@ void Node::invalidate_style(StyleInvalidationReason reason)
}
// If any ancestor is already marked for an entire subtree update, there's no need to do anything here.
for (auto* ancestor = this; ancestor; ancestor = ancestor->parent_or_shadow_host()) {
for (auto* ancestor = this->parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) {
if (ancestor->entire_subtree_needs_style_update())
return;
}