mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibWeb: Treat width:auto on tables as fit-content
Tables, unlike other block-level elements, should not stretch to fit their containing block by default.
This commit is contained in:
parent
52a1be5eae
commit
df3cd2fd56
1 changed files with 9 additions and 0 deletions
|
@ -29,6 +29,7 @@ void TableFormattingContext::run(Box& box, LayoutMode)
|
||||||
{
|
{
|
||||||
compute_width(box);
|
compute_width(box);
|
||||||
|
|
||||||
|
float total_content_width = 0;
|
||||||
float total_content_height = 0;
|
float total_content_height = 0;
|
||||||
|
|
||||||
box.for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) {
|
box.for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) {
|
||||||
|
@ -41,20 +42,28 @@ void TableFormattingContext::run(Box& box, LayoutMode)
|
||||||
calculate_column_widths(row, column_widths);
|
calculate_column_widths(row, column_widths);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
float content_width = 0;
|
||||||
float content_height = 0;
|
float content_height = 0;
|
||||||
|
|
||||||
row_group_box.template for_each_child_of_type<TableRowBox>([&](auto& row) {
|
row_group_box.template for_each_child_of_type<TableRowBox>([&](auto& row) {
|
||||||
row.set_offset(0, content_height);
|
row.set_offset(0, content_height);
|
||||||
layout_row(row, column_widths);
|
layout_row(row, column_widths);
|
||||||
|
content_width = max(content_width, row.width());
|
||||||
content_height += row.height();
|
content_height += row.height();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (row_group_box.computed_values().width().is_auto())
|
||||||
|
row_group_box.set_width(content_width);
|
||||||
row_group_box.set_height(content_height);
|
row_group_box.set_height(content_height);
|
||||||
|
|
||||||
row_group_box.set_offset(0, total_content_height);
|
row_group_box.set_offset(0, total_content_height);
|
||||||
total_content_height += content_height;
|
total_content_height += content_height;
|
||||||
|
total_content_width = max(total_content_width, row_group_box.width());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (box.computed_values().width().is_auto())
|
||||||
|
box.set_width(total_content_width);
|
||||||
|
|
||||||
// FIXME: This is a total hack, we should respect the 'height' property.
|
// FIXME: This is a total hack, we should respect the 'height' property.
|
||||||
box.set_height(total_content_height);
|
box.set_height(total_content_height);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue