소스 검색

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.
Andreas Kling 3 년 전
부모
커밋
5a929f12bc
1개의 변경된 파일13개의 추가작업 그리고 12개의 파일을 삭제
  1. 13 12
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 13 - 12
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<Element>(child))
-                verify_cast<Element>(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<Element>(node))
+        static_cast<Element&>(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()