summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-12 23:18:51 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-12 23:18:51 +0200
commit196a3986d68f795db8afbc04afc34d07298d922a (patch)
tree210169c1da34adc7a5ff4668f38213f1ddacede2 /Libraries/LibWeb
parentc5a3d99dd5c03b95c2689898191ce6f5923143c0 (diff)
downloadserenity-196a3986d68f795db8afbc04afc34d07298d922a.zip
LibWeb: First cut of extremely naive table row layout
This first version simply auto-sizes all table cells and then places them on a horizontal line.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/Layout/LayoutTableRow.cpp13
-rw-r--r--Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp1
2 files changed, 12 insertions, 2 deletions
diff --git a/Libraries/LibWeb/Layout/LayoutTableRow.cpp b/Libraries/LibWeb/Layout/LayoutTableRow.cpp
index 44f9209783..e241e642de 100644
--- a/Libraries/LibWeb/Layout/LayoutTableRow.cpp
+++ b/Libraries/LibWeb/Layout/LayoutTableRow.cpp
@@ -39,9 +39,18 @@ LayoutTableRow::~LayoutTableRow()
{
}
-void LayoutTableRow::layout(LayoutMode layout_mode)
+void LayoutTableRow::layout(LayoutMode)
{
- LayoutBox::layout(layout_mode);
+ float tallest_cell_height = 0;
+ float content_width = 0;
+ for_each_child_of_type<LayoutTableCell>([&](auto& cell) {
+ cell.layout(LayoutMode::OnlyRequiredLineBreaks);
+ cell.set_offset(effective_offset().translated(content_width, 0));
+ content_width += cell.width();
+ tallest_cell_height = max(tallest_cell_height, cell.height());
+ });
+ set_width(content_width);
+ set_height(tallest_cell_height);
}
LayoutTableCell* LayoutTableRow::first_cell()
diff --git a/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp b/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp
index 0f60749847..1ae56218a0 100644
--- a/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp
+++ b/Libraries/LibWeb/Layout/LayoutTableRowGroup.cpp
@@ -49,6 +49,7 @@ void LayoutTableRowGroup::layout(LayoutMode layout_mode)
float content_height = 0;
for_each_child_of_type<LayoutTableRow>([&](auto& row) {
+ row.set_offset(0, content_height);
row.layout(layout_mode);
content_height += row.height();
});