mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibWeb: Distribute the width of a table cell spanning multiple columns
This commit is contained in:
parent
4fe154bd6a
commit
9b3229da17
1 changed files with 18 additions and 1 deletions
|
@ -91,9 +91,26 @@ void TableFormattingContext::calculate_column_widths(Box const& row, Vector<floa
|
||||||
} else {
|
} else {
|
||||||
(void)layout_inside(cell, LayoutMode::Normal);
|
(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 += 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)
|
void TableFormattingContext::layout_row(Box const& row, Vector<float>& column_widths)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue