浏览代码

LibWeb: Force paintable to exist for SVG <g> elements

This (along with the previous commit) fixes the missing tears on the
sad Duolingo owl.
MacDue 2 年之前
父节点
当前提交
40fa07a6e1

+ 2 - 2
Tests/LibWeb/Layout/expected/svg-transforms-and-viewboxes.txt

@@ -21,12 +21,12 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
         frag 0 from SVGSVGBox start: 0, length: 0, rect: [50,450 200x200]
         frag 0 from SVGSVGBox start: 0, length: 0, rect: [50,450 200x200]
       SVGSVGBox <svg> at (50,150) content-size 200x100 [SVG] children: inline
       SVGSVGBox <svg> at (50,150) content-size 200x100 [SVG] children: inline
         TextNode <#text>
         TextNode <#text>
-        SVGGraphicsBox <g> (not painted) children: inline
+        SVGGraphicsBox <g> at (50,150) content-size 0x0 children: inline
           TextNode <#text>
           TextNode <#text>
           SVGGeometryBox <path> at (45.693222,199.830932) content-size 118.782173x47.453796 children: not-inline
           SVGGeometryBox <path> at (45.693222,199.830932) content-size 118.782173x47.453796 children: not-inline
           TextNode <#text>
           TextNode <#text>
         TextNode <#text>
         TextNode <#text>
-        SVGGraphicsBox <g> (not painted) children: inline
+        SVGGraphicsBox <g> at (50,150) content-size 0x0 children: inline
           TextNode <#text>
           TextNode <#text>
           SVGGeometryBox <path> at (84.5,159.504878) content-size 81x80.995117 children: not-inline
           SVGGeometryBox <path> at (84.5,159.504878) content-size 81x80.995117 children: not-inline
           TextNode <#text>
           TextNode <#text>

+ 1 - 1
Tests/LibWeb/Layout/expected/svg/svg-inside-svg.txt

@@ -4,7 +4,7 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline
       line 0 width: 24, height: 24, bottom: 24, baseline: 24
       line 0 width: 24, height: 24, bottom: 24, baseline: 24
         frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 24x24]
         frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 24x24]
       SVGSVGBox <svg> at (8,8) content-size 24x24 [SVG] children: inline
       SVGSVGBox <svg> at (8,8) content-size 24x24 [SVG] children: inline
-        SVGGraphicsBox <g> (not painted) children: inline
+        SVGGraphicsBox <g> at (8,8) content-size 0x0 children: inline
           SVGSVGBox <svg> at (8,8) content-size 24x24 [SVG] children: not-inline
           SVGSVGBox <svg> at (8,8) content-size 24x24 [SVG] children: not-inline
             SVGGeometryBox <rect> at (8,8) content-size 24x24 children: not-inline
             SVGGeometryBox <rect> at (8,8) content-size 24x24 children: not-inline
         TextNode <#text>
         TextNode <#text>

+ 5 - 0
Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp

@@ -192,6 +192,11 @@ void SVGFormattingContext::run(Box const& box, LayoutMode layout_mode, Available
             auto const& svg_text_box = static_cast<SVGTextBox const&>(descendant);
             auto const& svg_text_box = static_cast<SVGTextBox const&>(descendant);
             // NOTE: This hack creates a layout state to ensure the existence of a paintable box node in LayoutState::commit(), even when none of the values from UsedValues impact the SVG text.
             // NOTE: This hack creates a layout state to ensure the existence of a paintable box node in LayoutState::commit(), even when none of the values from UsedValues impact the SVG text.
             m_state.get_mutable(svg_text_box);
             m_state.get_mutable(svg_text_box);
+        } else if (is<SVGGraphicsBox>(descendant)) {
+            // Same hack as above.
+            // FIXME: This should be sized based on its children.
+            auto const& svg_graphics_box = static_cast<SVGGraphicsBox const&>(descendant);
+            m_state.get_mutable(svg_graphics_box);
         }
         }
 
 
         return IterationDecision::Continue;
         return IterationDecision::Continue;