diff --git a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp index 40e0c4cccc..b21b183b65 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGFormattingContext.cpp @@ -7,8 +7,10 @@ */ #include +#include #include #include +#include #include namespace Web::Layout { @@ -31,6 +33,19 @@ void SVGFormattingContext::run(Box const& box, LayoutMode, [[maybe_unused]] Avai auto& svg_svg_element = verify_cast(*box.dom_node()); + auto root_offset = m_state.get(box).offset; + + box.for_each_child_of_type([&](BlockContainer const& child_box) { + if (is(child_box.dom_node())) { + Layout::BlockFormattingContext bfc(m_state, child_box, this); + bfc.run(child_box, LayoutMode::Normal, available_space); + + auto& child_state = m_state.get_mutable(child_box); + child_state.set_content_offset(child_state.offset.translated(root_offset)); + } + return IterationDecision::Continue; + }); + box.for_each_in_subtree_of_type([&](SVGBox const& descendant) { if (is(descendant)) { auto const& geometry_box = static_cast(descendant); diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp index c0deb7af22..9500d3488c 100644 --- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp +++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace Web::Layout { @@ -130,6 +131,8 @@ void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node, return ancestor; if (!ancestor.display().is_flow_inside()) return ancestor; + if (ancestor.dom_node() && is(*ancestor.dom_node())) + return ancestor; } VERIFY_NOT_REACHED(); }();