LibWeb: Stop traversal early when marking nodes for child style update

These flags always propagate to the root, so once we encounter an
ancestor with the flag set, we can stop traversal since everything above
it will already be set as well.

(cherry picked from commit f106aa9e8a8f3a98b498e0f9324123963fad6ca2)
This commit is contained in:
Andreas Kling 2024-10-19 17:16:59 +02:00 committed by Nico Weber
parent 72227066c6
commit 880b6b1375

View file

@ -1174,6 +1174,8 @@ void Node::set_needs_style_update(bool value)
if (m_needs_style_update) {
for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) {
if (ancestor->m_child_needs_style_update)
break;
ancestor->m_child_needs_style_update = true;
}
document().schedule_style_update();