mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibWeb: Distribute the width of a table cell spanning multiple columns
This commit is contained in:
parent
4fe154bd6a
commit
9b3229da17
Notes:
sideshowbarker
2024-07-17 16:37:53 +09:00
Author: https://github.com/skyrising Commit: https://github.com/SerenityOS/serenity/commit/9b3229da17 Pull-request: https://github.com/SerenityOS/serenity/pull/13314
|
@ -91,9 +91,26 @@ void TableFormattingContext::calculate_column_widths(Box const& row, Vector<floa
|
|||
} else {
|
||||
(void)layout_inside(cell, LayoutMode::Normal);
|
||||
}
|
||||
column_widths[column_index] = max(column_widths[column_index], cell_state.border_box_width());
|
||||
if (cell.colspan() == 1)
|
||||
column_widths[column_index] = max(column_widths[column_index], cell_state.border_box_width());
|
||||
column_index += cell.colspan();
|
||||
});
|
||||
column_index = 0;
|
||||
row.for_each_child_of_type<TableCellBox>([&](auto& cell) {
|
||||
auto& cell_state = m_state.get_mutable(cell);
|
||||
size_t colspan = cell.colspan();
|
||||
if (colspan != 1) {
|
||||
float missing = cell_state.border_box_width();
|
||||
for (size_t i = 0; i < colspan; ++i)
|
||||
missing -= column_widths[column_index + i];
|
||||
if (missing > 0) {
|
||||
float extra = missing / (float)colspan;
|
||||
for (size_t i = 0; i < colspan; ++i)
|
||||
column_widths[column_index + i] += extra;
|
||||
}
|
||||
}
|
||||
column_index += colspan;
|
||||
});
|
||||
}
|
||||
|
||||
void TableFormattingContext::layout_row(Box const& row, Vector<float>& column_widths)
|
||||
|
|
Loading…
Reference in a new issue