summaryrefslogtreecommitdiff
path: root/Libraries/LibHTML
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-08 07:24:15 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-08 07:24:15 +0200
commit0ccad4208fedbb69f10e05f88f82931b8494900e (patch)
treec6a9e776967e50a2bb7aab3c6f5b358b3d752f06 /Libraries/LibHTML
parent9526b0e13a8c0192d74c8433b5441be86834a415 (diff)
downloadserenity-0ccad4208fedbb69f10e05f88f82931b8494900e.zip
LibHTML: Move layout tree building to a separate function.
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r--Libraries/LibHTML/Frame.cpp18
-rw-r--r--Libraries/LibHTML/Frame.h1
2 files changed, 12 insertions, 7 deletions
diff --git a/Libraries/LibHTML/Frame.cpp b/Libraries/LibHTML/Frame.cpp
index 6936d0d2c2..4e88b03a75 100644
--- a/Libraries/LibHTML/Frame.cpp
+++ b/Libraries/LibHTML/Frame.cpp
@@ -52,13 +52,8 @@ RefPtr<StyledNode> Frame::generate_style_tree()
return styled_root;
}
-void Frame::layout()
+RefPtr<LayoutNode> Frame::generate_layout_tree(const StyledNode& styled_root)
{
- if (!m_document)
- return;
-
- auto styled_root = generate_style_tree();
-
auto create_layout_node = [](const StyledNode& styled_node) -> RefPtr<LayoutNode> {
if (styled_node.node() && styled_node.node()->is_document())
return adopt(*new LayoutDocument(static_cast<const Document&>(*styled_node.node()), styled_node));
@@ -88,7 +83,16 @@ void Frame::layout()
return layout_node;
};
- auto layout_root = resolve_layout(*styled_root, nullptr);
+ return resolve_layout(styled_root, nullptr);
+}
+
+void Frame::layout()
+{
+ if (!m_document)
+ return;
+
+ auto styled_root = generate_style_tree();
+ auto layout_root = generate_layout_tree(*styled_root);
layout_root->style().size().set_width(m_size.width());
diff --git a/Libraries/LibHTML/Frame.h b/Libraries/LibHTML/Frame.h
index 89abbc454e..1ceef02564 100644
--- a/Libraries/LibHTML/Frame.h
+++ b/Libraries/LibHTML/Frame.h
@@ -17,6 +17,7 @@ public:
private:
RefPtr<StyledNode> generate_style_tree();
+ RefPtr<LayoutNode> generate_layout_tree(const StyledNode&);
RefPtr<Document> m_document;
Size m_size;