1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibHTML: Move layout tree building to a LayoutTreeBuilder class

Building a whole layout tree shouldn't be a concern of Node, so this
patch moves it to a separate class.
This commit is contained in:
Andreas Kling 2019-10-15 12:22:41 +02:00
parent d14b60533f
commit f7cd5662ef
6 changed files with 70 additions and 39 deletions

View file

@ -11,6 +11,7 @@
#include <LibHTML/DOM/HTMLTitleElement.h>
#include <LibHTML/Frame.h>
#include <LibHTML/Layout/LayoutDocument.h>
#include <LibHTML/Layout/LayoutTreeBuilder.h>
#include <stdio.h>
Document::Document()
@ -153,8 +154,10 @@ URL Document::complete_url(const String& string) const
void Document::layout()
{
if (!m_layout_root)
m_layout_root = create_layout_tree(style_resolver(), nullptr);
if (!m_layout_root) {
LayoutTreeBuilder tree_builder;
m_layout_root = tree_builder.build(*this);
}
m_layout_root->layout();
}
@ -209,4 +212,3 @@ void Document::set_hovered_node(Node* node)
if (m_hovered_node)
m_hovered_node->invalidate_style();
}