mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:45:07 +00:00
LibWeb: Reorganize layout system in terms of formatting contexts
This is a first (huge) step towards modernizing the layout architecture and bringing it closer to spec language. Layout is now performed by a stack of formatting contexts, operating on the box tree (or layout tree, if you will.) There are currently three types of formatting context: - BlockFormattingContext (BFC) - InlineFormattingContext (IFC) - TableFormattingContext (TFC) Document::layout() creates the initial BlockFormattingContext (BFC) which lays out the initial containing block (ICB), and then we recurse through the tree, creating BFC, IFC or TFC as appropriate and handing over control at the context boundaries. The majority of this patch is just refactoring the old logic spread out in LayoutBlock and LayoutTableRowGroup, and turning into these context classes instead. A lot more cleanup will be needed. There are many architectural wins here, the main one being that layout is no longer performed by boxes themselves, which gives us much greater flexibility in the outer/inner layout of a given box.
This commit is contained in:
parent
00aac65af5
commit
e1a24edfa9
46 changed files with 1360 additions and 882 deletions
|
@ -53,27 +53,4 @@ size_t LayoutTableRowGroup::column_count() const
|
|||
return table_column_count;
|
||||
}
|
||||
|
||||
void LayoutTableRowGroup::layout(LayoutMode)
|
||||
{
|
||||
compute_width();
|
||||
|
||||
auto column_count = this->column_count();
|
||||
Vector<float> column_widths;
|
||||
column_widths.resize(column_count);
|
||||
|
||||
for_each_child_of_type<LayoutTableRow>([&](auto& row) {
|
||||
row.calculate_column_widths(column_widths);
|
||||
});
|
||||
|
||||
float content_height = 0;
|
||||
|
||||
for_each_child_of_type<LayoutTableRow>([&](auto& row) {
|
||||
row.set_offset(0, content_height);
|
||||
row.layout_row(column_widths);
|
||||
content_height += row.height();
|
||||
});
|
||||
|
||||
set_height(content_height);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue