LibWeb: Improve column width distribution
This commit is contained in:
parent
5966f181f5
commit
025b496616
Notes:
sideshowbarker
2024-07-17 02:42:21 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/025b496616 Pull-request: https://github.com/SerenityOS/serenity/pull/17160
1 changed files with 14 additions and 0 deletions
|
@ -346,6 +346,20 @@ void TableFormattingContext::distribute_width_to_columns()
|
||||||
if (columns_total_used_width() < available_width) {
|
if (columns_total_used_width() < available_width) {
|
||||||
expand_columns_to_fill_available_width(ColumnType::Percent);
|
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)
|
void TableFormattingContext::determine_intrisic_size_of_table_container(AvailableSpace const& available_space)
|
||||||
|
|
Loading…
Add table
Reference in a new issue