LibWeb: Improve adjustment of automatic table width with percentages

Use the max-width of percentage cells instead of min-width as the
reference to be used to compute the total table width. The specification
only suggests that the UA should try to satisfy percentage constraints
and this behavior is more consistent with other browsers.
This commit is contained in:
Andi Gallo 2023-08-04 23:09:02 +00:00 committed by Alexander Kalenik
commit 7b0b501418
Notes: sideshowbarker 2024-07-17 07:43:44 +09:00
5 changed files with 99 additions and 34 deletions

View file

@ -598,7 +598,7 @@ void TableFormattingContext::compute_table_width()
for (auto& cell : m_cells) {
auto const& cell_width = cell.box->computed_values().width();
if (cell_width.is_percentage()) {
adjusted_used_width = 100 / cell_width.percentage().value() * cell.outer_min_width;
adjusted_used_width = ceil(100 / cell_width.percentage().value() * cell.outer_max_width.to_double());
used_width = min(max(used_width, adjusted_used_width), width_of_table_containing_block);
}
}