From bbce1ab1c12837f18daf0c05299887481af3e055 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Feb 2021 17:13:08 +0100 Subject: [PATCH] LibWeb: Use the DOM::Node::node_name() a bit more in dumps --- Userland/Libraries/LibWeb/Dump.cpp | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/Userland/Libraries/LibWeb/Dump.cpp b/Userland/Libraries/LibWeb/Dump.cpp index 9124ad51e3..006bc8165e 100644 --- a/Userland/Libraries/LibWeb/Dump.cpp +++ b/Userland/Libraries/LibWeb/Dump.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -49,9 +48,7 @@ void dump_tree(const DOM::Node& node) static int indent = 0; for (int i = 0; i < indent; ++i) dbgprintf(" "); - if (is(node)) { - dbgprintf("*Document*\n"); - } else if (is(node)) { + if (is(node)) { dbgprintf("<%s", downcast(node).local_name().characters()); downcast(node).for_each_attribute([](auto& name, auto& value) { dbgprintf(" %s=%s", name.characters(), value.characters()); @@ -59,12 +56,8 @@ void dump_tree(const DOM::Node& node) dbgprintf(">\n"); } else if (is(node)) { dbgprintf("\"%s\"\n", downcast(node).data().characters()); - } else if (is(node)) { - dbgprintf("\n"); - } else if (is(node)) { - dbgprintf("\n", downcast(node).data().characters()); - } else if (is(node)) { - dbgprintf("#document-fragment\n"); + } else { + dbgprintf("%s\n", node.node_name().characters()); } ++indent; if (is(node)) { @@ -96,14 +89,10 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho FlyString tag_name; if (layout_node.is_anonymous()) tag_name = "(anonymous)"; - else if (is(layout_node.dom_node())) - tag_name = "#text"; - else if (is(layout_node.dom_node())) - tag_name = "#document"; else if (is(layout_node.dom_node())) tag_name = downcast(*layout_node.dom_node()).local_name(); else - tag_name = "???"; + tag_name = layout_node.dom_node()->node_name(); String identifier = ""; if (layout_node.dom_node() && is(*layout_node.dom_node())) {