瀏覽代碼

LibWeb: Don't lay out light DOM children of elements with a shadow root

This fixes the "last changed" time for files on GitHub. Note that this
appears to be in accordance with the shadow DOM specification, but I
can't find a line that neatly says it. Though on Google's post about
shadow DOM v1 it says:

> "the element's shadow DOM is rendered in place of its children."
https://web.dev/shadowdom-v1/#creating-shadow-dom-for-a-custom-element
MacDue 1 年之前
父節點
當前提交
24c848607c
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp

+ 4 - 4
Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp

@@ -288,11 +288,11 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
             for (auto* node = shadow_root->first_child(); node; node = node->next_sibling()) {
             for (auto* node = shadow_root->first_child(); node; node = node->next_sibling()) {
                 TRY(create_layout_tree(*node, context));
                 TRY(create_layout_tree(*node, context));
             }
             }
+        } else {
+            // This is the same as verify_cast<DOM::ParentNode>(dom_node).for_each_child
+            for (auto* node = verify_cast<DOM::ParentNode>(dom_node).first_child(); node; node = node->next_sibling())
+                TRY(create_layout_tree(*node, context));
         }
         }
-
-        // This is the same as verify_cast<DOM::ParentNode>(dom_node).for_each_child
-        for (auto* node = verify_cast<DOM::ParentNode>(dom_node).first_child(); node; node = node->next_sibling())
-            TRY(create_layout_tree(*node, context));
         pop_parent();
         pop_parent();
     }
     }