瀏覽代碼

LibWeb: Move SVG mask/clip layout node creation under DOM::Element

This is a non-functional change, but makes it clearer other element
properties (like `display=none`) apply to these too.
MacDue 1 年之前
父節點
當前提交
561beb5e95
共有 1 個文件被更改,包括 12 次插入12 次删除
  1. 12 12
      Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp

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

@@ -340,7 +340,18 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
         display = style->display();
         if (display.is_none())
             return;
-        layout_node = element.create_layout_node(*style);
+        if (context.layout_svg_mask_or_clip_path) {
+            if (is<SVG::SVGMaskElement>(dom_node))
+                layout_node = document.heap().allocate_without_realm<Layout::SVGMaskBox>(document, static_cast<SVG::SVGMaskElement&>(dom_node), *style);
+            else if (is<SVG::SVGClipPathElement>(dom_node))
+                layout_node = document.heap().allocate_without_realm<Layout::SVGClipBox>(document, static_cast<SVG::SVGClipPathElement&>(dom_node), *style);
+            else
+                VERIFY_NOT_REACHED();
+            // Only layout direct uses of SVG masks/clipPaths.
+            context.layout_svg_mask_or_clip_path = false;
+        } else {
+            layout_node = element.create_layout_node(*style);
+        }
     } else if (is<DOM::Document>(dom_node)) {
         style = style_computer.create_document_style();
         display = style->display();
@@ -350,17 +361,6 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
         display = CSS::Display(CSS::DisplayOutside::Inline, CSS::DisplayInside::Flow);
     }
 
-    if (context.layout_svg_mask_or_clip_path) {
-        if (is<SVG::SVGMaskElement>(dom_node))
-            layout_node = document.heap().allocate_without_realm<Layout::SVGMaskBox>(document, static_cast<SVG::SVGMaskElement&>(dom_node), *style);
-        else if (is<SVG::SVGClipPathElement>(dom_node))
-            layout_node = document.heap().allocate_without_realm<Layout::SVGClipBox>(document, static_cast<SVG::SVGClipPathElement&>(dom_node), *style);
-        else
-            VERIFY_NOT_REACHED();
-        // Only layout direct uses of SVG masks/clipPaths.
-        context.layout_svg_mask_or_clip_path = false;
-    }
-
     if (!layout_node)
         return;