diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-08 07:24:15 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-08 07:24:15 +0200 |
commit | 0ccad4208fedbb69f10e05f88f82931b8494900e (patch) | |
tree | c6a9e776967e50a2bb7aab3c6f5b358b3d752f06 /Libraries/LibHTML | |
parent | 9526b0e13a8c0192d74c8433b5441be86834a415 (diff) | |
download | serenity-0ccad4208fedbb69f10e05f88f82931b8494900e.zip |
LibHTML: Move layout tree building to a separate function.
Diffstat (limited to 'Libraries/LibHTML')
-rw-r--r-- | Libraries/LibHTML/Frame.cpp | 18 | ||||
-rw-r--r-- | Libraries/LibHTML/Frame.h | 1 |
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; |