From 5a929f12bc9640fdcf37e938b044d4a21dcb7f89 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Oct 2021 01:29:18 +0200 Subject: [PATCH] LibWeb: Make sure that root of style updates is marked clean The recursive style update function was written a bit strangely and would only mark descendants of the style update root as not needing a style update. With this patch, all nodes in the subtree now have clean style after a style update finishes. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 25 +++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2f92de9182..e575c64128 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -452,18 +452,19 @@ void Document::update_layout() static void update_style_recursively(DOM::Node& node) { - node.for_each_child([&](auto& child) { - if (child.needs_style_update()) { - if (is(child)) - verify_cast(child).recompute_style(); - child.set_needs_style_update(false); - } - if (child.child_needs_style_update()) { - update_style_recursively(child); - child.set_child_needs_style_update(false); - } - return IterationDecision::Continue; - }); + if (is(node)) + static_cast(node).recompute_style(); + node.set_needs_style_update(false); + + if (node.child_needs_style_update()) { + node.for_each_child([&](auto& child) { + if (child.needs_style_update()) + update_style_recursively(child); + return IterationDecision::Continue; + }); + } + + node.set_child_needs_style_update(false); } void Document::update_style()