1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-08 06:47:34 +00:00

LibHTML: Get rid of the style tree

We now create a layout tree directly from the DOM tree.
This way we don't actually lose text nodes ^)
This commit is contained in:
Sergey Bugaev 2019-09-21 15:32:17 +03:00 committed by Andreas Kling
parent a9ebd676e5
commit fd0aa5dd43
22 changed files with 126 additions and 261 deletions

View file

@ -1,5 +1,4 @@
#include <LibHTML/CSS/StyleSheet.h>
#include <LibHTML/CSS/StyledNode.h>
#include <LibHTML/DOM/Document.h>
#include <LibHTML/DOM/Element.h>
#include <LibHTML/DOM/Text.h>
@ -37,7 +36,7 @@ void dump_tree(const LayoutNode& layout_node)
{
static int indent = 0;
for (int i = 0; i < indent; ++i)
printf(" ");
printf(" ");
String tag_name;
if (layout_node.is_anonymous())
@ -83,40 +82,15 @@ void dump_tree(const LayoutNode& layout_node)
printf(" \"%s\"", static_cast<const LayoutText&>(layout_node).text().characters());
printf("\n");
++indent;
layout_node.for_each_child([](auto& child) {
dump_tree(child);
});
--indent;
}
void dump_tree(const StyledNode& styled_node)
{
static int indent = 0;
for (int i = 0; i < indent; ++i)
printf(" ");
String tag_name;
auto& node = *styled_node.node();
if (node.is_text())
tag_name = "#text";
else if (node.is_document())
tag_name = "#document";
else if (node.is_element())
tag_name = static_cast<const Element&>(node).tag_name();
else
tag_name = "???";
printf("%s", tag_name.characters());
printf("\n");
styled_node.for_each_property([&](auto& key, auto& value) {
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());
});
++indent;
styled_node.for_each_child([](auto& child) {
layout_node.for_each_child([](auto& child) {
dump_tree(child);
});
--indent;