diff --git a/Tests/LibWeb/Layout/expected/svg/svg-as-image.txt b/Tests/LibWeb/Layout/expected/svg/svg-as-image.txt index 0592f36d88..e4f6f5a22f 100644 --- a/Tests/LibWeb/Layout/expected/svg/svg-as-image.txt +++ b/Tests/LibWeb/Layout/expected/svg/svg-as-image.txt @@ -2,3 +2,9 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline BlockContainer at (0,0) content-size 800x1584 [BFC] children: not-inline BlockContainer at (8,8) content-size 784x1568 children: not-inline ImageBox at (8,8) content-size 784x1568 children: not-inline + (SVG-as-image isolated context) + Viewport <#document> at (0,0) content-size 0x0 children: inline + SVGSVGBox at (0,0) content-size 0x0 [SVG] children: inline + TextNode <#text> + SVGGeometryBox at (0,0) content-size 0x0 children: not-inline + TextNode <#text> diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 6c594cba1e..66141fe2ba 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -22,15 +22,19 @@ #include #include #include +#include #include +#include #include #include #include #include #include #include +#include #include #include +#include #include namespace Web { @@ -70,6 +74,19 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) dump_tree(builder, *shadow_root); } } + if (is(node)) { + if (auto image_data = static_cast(node).current_request().image_data()) { + if (is(*image_data)) { + ++indent; + for (int i = 0; i < indent; ++i) + builder.append(" "sv); + builder.append("(SVG-as-image isolated context)\n"sv); + auto& svg_data = verify_cast(*image_data); + dump_tree(builder, svg_data.svg_document()); + --indent; + } + } + } if (is(node)) { if (!is(node)) { static_cast(node).for_each_child([&](auto& child) { @@ -264,6 +281,23 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho builder.append("\n"sv); } + if (layout_node.dom_node() && is(*layout_node.dom_node())) { + if (auto image_data = static_cast(*layout_node.dom_node()).current_request().image_data()) { + if (is(*image_data)) { + auto& svg_data = verify_cast(*image_data); + if (svg_data.svg_document().layout_node()) { + ++indent; + for (size_t i = 0; i < indent; ++i) + builder.append(" "sv); + builder.append("(SVG-as-image isolated context)\n"sv); + + dump_tree(builder, *svg_data.svg_document().layout_node(), show_box_model, show_specified_style, interactive); + --indent; + } + } + } + } + if (is(layout_node) && static_cast(layout_node).children_are_inline()) { auto& block = static_cast(layout_node); for (size_t line_box_index = 0; block.paintable_with_lines() && line_box_index < block.paintable_with_lines()->line_boxes().size(); ++line_box_index) { diff --git a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h index 355e954614..d2a34e9fd8 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h +++ b/Userland/Libraries/LibWeb/SVG/SVGDecodedImageData.h @@ -27,6 +27,8 @@ public: virtual size_t loop_count() const override { return 0; } virtual bool is_animated() const override { return false; } + DOM::Document const& svg_document() const { return *m_document; } + private: class SVGPageClient; SVGDecodedImageData(NonnullOwnPtr, NonnullOwnPtr, JS::Handle, JS::Handle);