mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibWeb: Use the DOM::Node::node_name() a bit more in dumps
This commit is contained in:
parent
70bd1724db
commit
bbce1ab1c1
1 changed files with 5 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -32,7 +32,6 @@
|
||||||
#include <LibWeb/DOM/Comment.h>
|
#include <LibWeb/DOM/Comment.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/DocumentFragment.h>
|
#include <LibWeb/DOM/DocumentFragment.h>
|
||||||
#include <LibWeb/DOM/DocumentType.h>
|
|
||||||
#include <LibWeb/DOM/Element.h>
|
#include <LibWeb/DOM/Element.h>
|
||||||
#include <LibWeb/DOM/Text.h>
|
#include <LibWeb/DOM/Text.h>
|
||||||
#include <LibWeb/Dump.h>
|
#include <LibWeb/Dump.h>
|
||||||
|
@ -49,9 +48,7 @@ void dump_tree(const DOM::Node& node)
|
||||||
static int indent = 0;
|
static int indent = 0;
|
||||||
for (int i = 0; i < indent; ++i)
|
for (int i = 0; i < indent; ++i)
|
||||||
dbgprintf(" ");
|
dbgprintf(" ");
|
||||||
if (is<DOM::Document>(node)) {
|
if (is<DOM::Element>(node)) {
|
||||||
dbgprintf("*Document*\n");
|
|
||||||
} else if (is<DOM::Element>(node)) {
|
|
||||||
dbgprintf("<%s", downcast<DOM::Element>(node).local_name().characters());
|
dbgprintf("<%s", downcast<DOM::Element>(node).local_name().characters());
|
||||||
downcast<DOM::Element>(node).for_each_attribute([](auto& name, auto& value) {
|
downcast<DOM::Element>(node).for_each_attribute([](auto& name, auto& value) {
|
||||||
dbgprintf(" %s=%s", name.characters(), value.characters());
|
dbgprintf(" %s=%s", name.characters(), value.characters());
|
||||||
|
@ -59,12 +56,8 @@ void dump_tree(const DOM::Node& node)
|
||||||
dbgprintf(">\n");
|
dbgprintf(">\n");
|
||||||
} else if (is<DOM::Text>(node)) {
|
} else if (is<DOM::Text>(node)) {
|
||||||
dbgprintf("\"%s\"\n", downcast<DOM::Text>(node).data().characters());
|
dbgprintf("\"%s\"\n", downcast<DOM::Text>(node).data().characters());
|
||||||
} else if (is<DOM::DocumentType>(node)) {
|
} else {
|
||||||
dbgprintf("<!DOCTYPE html>\n");
|
dbgprintf("%s\n", node.node_name().characters());
|
||||||
} else if (is<DOM::Comment>(node)) {
|
|
||||||
dbgprintf("<!--%s-->\n", downcast<DOM::Comment>(node).data().characters());
|
|
||||||
} else if (is<DOM::DocumentFragment>(node)) {
|
|
||||||
dbgprintf("#document-fragment\n");
|
|
||||||
}
|
}
|
||||||
++indent;
|
++indent;
|
||||||
if (is<DOM::ParentNode>(node)) {
|
if (is<DOM::ParentNode>(node)) {
|
||||||
|
@ -96,14 +89,10 @@ void dump_tree(StringBuilder& builder, const Layout::Node& layout_node, bool sho
|
||||||
FlyString tag_name;
|
FlyString tag_name;
|
||||||
if (layout_node.is_anonymous())
|
if (layout_node.is_anonymous())
|
||||||
tag_name = "(anonymous)";
|
tag_name = "(anonymous)";
|
||||||
else if (is<DOM::Text>(layout_node.dom_node()))
|
|
||||||
tag_name = "#text";
|
|
||||||
else if (is<DOM::Document>(layout_node.dom_node()))
|
|
||||||
tag_name = "#document";
|
|
||||||
else if (is<DOM::Element>(layout_node.dom_node()))
|
else if (is<DOM::Element>(layout_node.dom_node()))
|
||||||
tag_name = downcast<DOM::Element>(*layout_node.dom_node()).local_name();
|
tag_name = downcast<DOM::Element>(*layout_node.dom_node()).local_name();
|
||||||
else
|
else
|
||||||
tag_name = "???";
|
tag_name = layout_node.dom_node()->node_name();
|
||||||
|
|
||||||
String identifier = "";
|
String identifier = "";
|
||||||
if (layout_node.dom_node() && is<DOM::Element>(*layout_node.dom_node())) {
|
if (layout_node.dom_node() && is<DOM::Element>(*layout_node.dom_node())) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue