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.
This commit is contained in:
Andreas Kling 2024-10-19 17:16:59 +02:00 committed by Andreas Kling
commit f106aa9e8a
Notes: github-actions[bot] 2024-10-19 19:14:52 +00:00

View file

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