diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp index 3cb3aece9cf..b6768b22d53 100644 --- a/Libraries/LibWeb/Layout/Node.cpp +++ b/Libraries/LibWeb/Layout/Node.cpp @@ -236,6 +236,9 @@ bool Node::establishes_stacking_context() const if (computed_values().mask().has_value() || computed_values().clip_path().has_value() || computed_values().mask_image()) return true; + if (is_svg_foreign_object_box()) + return true; + // https://drafts.fxtf.org/compositing/#propdef-isolation // For CSS, setting isolation to isolate will turn the element into a stacking context. if (computed_values().isolation() == CSS::Isolation::Isolate) diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h index 14da3d78b0b..cb3ff619455 100644 --- a/Libraries/LibWeb/Layout/Node.h +++ b/Libraries/LibWeb/Layout/Node.h @@ -107,6 +107,7 @@ public: virtual bool is_svg_mask_box() const { return false; } virtual bool is_svg_svg_box() const { return false; } virtual bool is_svg_graphics_box() const { return false; } + virtual bool is_svg_foreign_object_box() const { return false; } virtual bool is_label() const { return false; } virtual bool is_replaced_box() const { return false; } virtual bool is_list_item_box() const { return false; } diff --git a/Libraries/LibWeb/Layout/SVGForeignObjectBox.h b/Libraries/LibWeb/Layout/SVGForeignObjectBox.h index ce8ebd96cc4..c462c891d32 100644 --- a/Libraries/LibWeb/Layout/SVGForeignObjectBox.h +++ b/Libraries/LibWeb/Layout/SVGForeignObjectBox.h @@ -25,6 +25,12 @@ public: SVG::SVGForeignObjectElement const& dom_node() const { return static_cast(*BlockContainer::dom_node()); } virtual GC::Ptr create_paintable() const override; + +private: + virtual bool is_svg_foreign_object_box() const override { return true; } }; +template<> +inline bool Node::fast_is() const { return is_svg_foreign_object_box(); } + } diff --git a/Tests/LibWeb/Layout/expected/svg/svg-foreign-object-with-block-element.txt b/Tests/LibWeb/Layout/expected/svg/svg-foreign-object-with-block-element.txt index d45657e389b..3fea9196012 100644 --- a/Tests/LibWeb/Layout/expected/svg/svg-foreign-object-with-block-element.txt +++ b/Tests/LibWeb/Layout/expected/svg/svg-foreign-object-with-block-element.txt @@ -18,4 +18,5 @@ ViewportPaintable (Viewport<#document>) [0,0 800x600] TextPaintable (TextNode<#text>) SC for Viewport<#document> [0,0 800x600] [children: 1] (z-index: auto) - SC for BlockContainer [0,0 800x116] [children: 0] (z-index: auto) + SC for BlockContainer [0,0 800x116] [children: 1] (z-index: auto) + SC for SVGForeignObjectBox [8,8 100x100] [children: 0] (z-index: auto)