diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-01-24 17:20:24 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-24 20:47:11 +0100 |
commit | 025b49661655dfba5d50f94c9948c5c3b3fd416b (patch) | |
tree | 190a954879a4d7f9010219558602ae2b54b9a01a | |
parent | 5966f181f516061dbbcf6ff4dd6e82924cd81a0c (diff) | |
download | serenity-025b49661655dfba5d50f94c9948c5c3b3fd416b.zip |
LibWeb: Improve column width distribution
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index de232faf31..23f1572ca8 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -346,6 +346,20 @@ void TableFormattingContext::distribute_width_to_columns() if (columns_total_used_width() < available_width) { expand_columns_to_fill_available_width(ColumnType::Percent); } + + if (columns_total_used_width() < available_width) { + // NOTE: if all columns got their max width and there is still width to distribute left + // it should be assigned to columns proportionally to their max width + CSSPixels grid_max = 0.0f; + for (auto& column : m_columns) { + grid_max += column.max_width; + } + + auto width_to_distribute = available_width - columns_total_used_width(); + for (auto& column : m_columns) { + column.used_width += width_to_distribute * column.max_width / grid_max; + } + } } void TableFormattingContext::determine_intrisic_size_of_table_container(AvailableSpace const& available_space) |