mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-26 19:32:06 -05:00
LibHTML: Let's put debug output on the debugger stream
This commit is contained in:
parent
786494b62d
commit
9290117b77
3 changed files with 23 additions and 23 deletions
|
@ -48,7 +48,7 @@ NonnullRefPtrVector<StyleRule> StyleResolver::collect_matching_rules(const Eleme
|
|||
}
|
||||
|
||||
#ifdef HTML_DEBUG
|
||||
printf("Rules matching Element{%p}\n", &element);
|
||||
dbgprintf("Rules matching Element{%p}\n", &element);
|
||||
for (auto& rule : matching_rules) {
|
||||
dump_rule(rule);
|
||||
}
|
||||
|
|
|
@ -11,17 +11,17 @@ void dump_tree(const Node& node)
|
|||
{
|
||||
static int indent = 0;
|
||||
for (int i = 0; i < indent; ++i)
|
||||
printf(" ");
|
||||
dbgprintf(" ");
|
||||
if (node.is_document()) {
|
||||
printf("*Document*\n");
|
||||
dbgprintf("*Document*\n");
|
||||
} else if (node.is_element()) {
|
||||
printf("<%s", static_cast<const Element&>(node).tag_name().characters());
|
||||
dbgprintf("<%s", static_cast<const Element&>(node).tag_name().characters());
|
||||
static_cast<const Element&>(node).for_each_attribute([](auto& name, auto& value) {
|
||||
printf(" %s=%s", name.characters(), value.characters());
|
||||
dbgprintf(" %s=%s", name.characters(), value.characters());
|
||||
});
|
||||
printf(">\n");
|
||||
dbgprintf(">\n");
|
||||
} else if (node.is_text()) {
|
||||
printf("\"%s\"\n", static_cast<const Text&>(node).data().characters());
|
||||
dbgprintf("\"%s\"\n", static_cast<const Text&>(node).data().characters());
|
||||
}
|
||||
++indent;
|
||||
if (node.is_parent_node()) {
|
||||
|
@ -36,7 +36,7 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
{
|
||||
static int indent = 0;
|
||||
for (int i = 0; i < indent; ++i)
|
||||
printf(" ");
|
||||
dbgprintf(" ");
|
||||
|
||||
String tag_name;
|
||||
if (layout_node.is_anonymous())
|
||||
|
@ -50,7 +50,7 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
else
|
||||
tag_name = "???";
|
||||
|
||||
printf("%s {%s} at (%d,%d) size %dx%d",
|
||||
dbgprintf("%s {%s} at (%d,%d) size %dx%d",
|
||||
layout_node.class_name(),
|
||||
tag_name.characters(),
|
||||
layout_node.rect().x(),
|
||||
|
@ -59,7 +59,7 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
layout_node.rect().height());
|
||||
|
||||
// Dump the horizontal box properties
|
||||
printf(" [%d+%d+%d %d %d+%d+%d]",
|
||||
dbgprintf(" [%d+%d+%d %d %d+%d+%d]",
|
||||
layout_node.style().margin().left.to_px(),
|
||||
layout_node.style().border().left.to_px(),
|
||||
layout_node.style().padding().left.to_px(),
|
||||
|
@ -69,7 +69,7 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
layout_node.style().margin().right.to_px());
|
||||
|
||||
// And the vertical box properties
|
||||
printf(" [%d+%d+%d %d %d+%d+%d]",
|
||||
dbgprintf(" [%d+%d+%d %d %d+%d+%d]",
|
||||
layout_node.style().margin().top.to_px(),
|
||||
layout_node.style().border().top.to_px(),
|
||||
layout_node.style().padding().top.to_px(),
|
||||
|
@ -80,15 +80,15 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
|
||||
if (layout_node.is_text()) {
|
||||
const LayoutText& layout_text = static_cast<const LayoutText&>(layout_node);
|
||||
printf(" \"%s\", %d runs", layout_text.text().characters(), layout_text.runs().size());
|
||||
dbgprintf(" \"%s\", %d runs", layout_text.text().characters(), layout_text.runs().size());
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
dbgprintf("\n");
|
||||
|
||||
layout_node.style_properties().for_each_property([&](auto& key, auto& value) {
|
||||
for (int i = 0; i < indent; ++i)
|
||||
printf(" ");
|
||||
printf(" (%s: %s)\n", key.characters(), value.to_string().characters());
|
||||
dbgprintf(" ");
|
||||
dbgprintf(" (%s: %s)\n", key.characters(), value.to_string().characters());
|
||||
});
|
||||
|
||||
++indent;
|
||||
|
@ -100,9 +100,9 @@ void dump_tree(const LayoutNode& layout_node)
|
|||
|
||||
void dump_rule(const StyleRule& rule)
|
||||
{
|
||||
printf("Rule:\n");
|
||||
dbgprintf("Rule:\n");
|
||||
for (auto& selector : rule.selectors()) {
|
||||
printf(" Selector:\n");
|
||||
dbgprintf(" Selector:\n");
|
||||
for (auto& component : selector.components()) {
|
||||
const char* type_description = "Unknown";
|
||||
switch (component.type) {
|
||||
|
@ -119,18 +119,18 @@ void dump_rule(const StyleRule& rule)
|
|||
type_description = "TagName";
|
||||
break;
|
||||
}
|
||||
printf(" %s:%s\n", type_description, component.value.characters());
|
||||
dbgprintf(" %s:%s\n", type_description, component.value.characters());
|
||||
}
|
||||
}
|
||||
printf(" Declarations:\n");
|
||||
dbgprintf(" Declarations:\n");
|
||||
for (auto& property : rule.declaration().properties()) {
|
||||
printf(" '%s': '%s'\n", property.name.characters(), property.value->to_string().characters());
|
||||
dbgprintf(" '%s': '%s'\n", property.name.characters(), property.value->to_string().characters());
|
||||
}
|
||||
}
|
||||
|
||||
void dump_sheet(const StyleSheet& sheet)
|
||||
{
|
||||
printf("StyleSheet{%p}: %d rule(s)\n", &sheet, sheet.rules().size());
|
||||
dbgprintf("StyleSheet{%p}: %d rule(s)\n", &sheet, sheet.rules().size());
|
||||
|
||||
for (auto& rule : sheet.rules()) {
|
||||
dump_rule(rule);
|
||||
|
|
|
@ -32,7 +32,7 @@ void HtmlView::set_document(Document* document)
|
|||
|
||||
#ifdef HTML_DEBUG
|
||||
if (document != nullptr) {
|
||||
printf("\033[33;1mLayout tree before layout:\033[0m\n");
|
||||
dbgprintf("\033[33;1mLayout tree before layout:\033[0m\n");
|
||||
::dump_tree(*m_layout_root);
|
||||
}
|
||||
#endif
|
||||
|
@ -51,7 +51,7 @@ void HtmlView::layout_and_sync_size()
|
|||
set_content_size(m_layout_root->rect().size());
|
||||
|
||||
#ifdef HTML_DEBUG
|
||||
printf("\033[33;1mLayout tree after layout:\033[0m\n");
|
||||
dbgprintf("\033[33;1mLayout tree after layout:\033[0m\n");
|
||||
::dump_tree(*m_layout_root);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue