mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibWeb: Include SVG-as-image isolated contexts in layout/DOM tree dumps
This allows us to see the inside of SVG-as-image in layout tests. :^)
This commit is contained in:
parent
24ea78c613
commit
94a26e2715
3 changed files with 43 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -22,15 +22,19 @@
|
|||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/HTML/HTMLTemplateElement.h>
|
||||
#include <LibWeb/HTML/ImageRequest.h>
|
||||
#include <LibWeb/Layout/BlockContainer.h>
|
||||
#include <LibWeb/Layout/FormattingContext.h>
|
||||
#include <LibWeb/Layout/FrameBox.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/SVGBox.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
#include <LibWeb/Layout/Viewport.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/TextPaintable.h>
|
||||
#include <LibWeb/SVG/SVGDecodedImageData.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -70,6 +74,19 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node)
|
|||
dump_tree(builder, *shadow_root);
|
||||
}
|
||||
}
|
||||
if (is<HTML::HTMLImageElement>(node)) {
|
||||
if (auto image_data = static_cast<HTML::HTMLImageElement const&>(node).current_request().image_data()) {
|
||||
if (is<SVG::SVGDecodedImageData>(*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<SVG::SVGDecodedImageData>(*image_data);
|
||||
dump_tree(builder, svg_data.svg_document());
|
||||
--indent;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is<DOM::ParentNode>(node)) {
|
||||
if (!is<HTML::HTMLTemplateElement>(node)) {
|
||||
static_cast<DOM::ParentNode const&>(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<HTML::HTMLImageElement>(*layout_node.dom_node())) {
|
||||
if (auto image_data = static_cast<HTML::HTMLImageElement const&>(*layout_node.dom_node()).current_request().image_data()) {
|
||||
if (is<SVG::SVGDecodedImageData>(*image_data)) {
|
||||
auto& svg_data = verify_cast<SVG::SVGDecodedImageData>(*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::BlockContainer>(layout_node) && static_cast<Layout::BlockContainer const&>(layout_node).children_are_inline()) {
|
||||
auto& block = static_cast<Layout::BlockContainer const&>(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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue