From 24c848607ce0004554d0a504a72a6f6480bc4e5d Mon Sep 17 00:00:00 2001 From: MacDue Date: Tue, 1 Aug 2023 22:34:49 +0100 Subject: [PATCH] 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 --- Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index 765733f786..dd6ec7a093 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -288,11 +288,11 @@ ErrorOr TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder:: for (auto* node = shadow_root->first_child(); node; node = node->next_sibling()) { TRY(create_layout_tree(*node, context)); } + } else { + // This is the same as verify_cast(dom_node).for_each_child + for (auto* node = verify_cast(dom_node).first_child(); node; node = node->next_sibling()) + TRY(create_layout_tree(*node, context)); } - - // This is the same as verify_cast(dom_node).for_each_child - for (auto* node = verify_cast(dom_node).first_child(); node; node = node->next_sibling()) - TRY(create_layout_tree(*node, context)); pop_parent(); }