Skip to content

Commit

Permalink
LibWeb: Stop traversal early when marking nodes for child style update
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
awesomekling committed Oct 19, 2024
1 parent d21c563 commit f106aa9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/DOM/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f106aa9

Please sign in to comment.