mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 23:05:07 +00:00
LibHTML: Reorganize layout tree build so that parents add their children.
This will allow us to insert anonymous blocks with ease.
This commit is contained in:
parent
0ccad4208f
commit
8812b35c5e
1 changed files with 8 additions and 6 deletions
|
@ -69,21 +69,23 @@ RefPtr<LayoutNode> Frame::generate_layout_tree(const StyledNode& styled_root)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Function<RefPtr<LayoutNode>(const StyledNode&, LayoutNode*)> resolve_layout = [&](const StyledNode& styled_node, LayoutNode* parent_layout_node) -> RefPtr<LayoutNode> {
|
Function<RefPtr<LayoutNode>(const StyledNode&, LayoutNode*)> build_layout_tree;
|
||||||
|
build_layout_tree = [&](const StyledNode& styled_node, LayoutNode* parent_layout_node) -> RefPtr<LayoutNode> {
|
||||||
auto layout_node = create_layout_node(styled_node);
|
auto layout_node = create_layout_node(styled_node);
|
||||||
if (!layout_node)
|
if (!layout_node)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (parent_layout_node)
|
|
||||||
parent_layout_node->append_child(*layout_node);
|
|
||||||
if (styled_node.has_children()) {
|
if (styled_node.has_children()) {
|
||||||
for (auto* child = styled_node.first_child(); child; child = child->next_sibling()) {
|
for (auto* styled_child = styled_node.first_child(); styled_child; styled_child = styled_child->next_sibling()) {
|
||||||
resolve_layout(*child, layout_node.ptr());
|
auto layout_child = build_layout_tree(*styled_child, layout_node.ptr());
|
||||||
|
if (!layout_child)
|
||||||
|
continue;
|
||||||
|
layout_node->append_child(*layout_child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return layout_node;
|
return layout_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
return resolve_layout(styled_root, nullptr);
|
return build_layout_tree(styled_root, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Frame::layout()
|
void Frame::layout()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue