From 9b3229da174d9a4159a9530c65ee4d6aa2c13014 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Mon, 28 Mar 2022 14:39:37 +0200 Subject: [PATCH] LibWeb: Distribute the width of a table cell spanning multiple columns --- .../LibWeb/Layout/TableFormattingContext.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 036b89221a..a2c15ce779 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -91,9 +91,26 @@ void TableFormattingContext::calculate_column_widths(Box const& row, Vector([&](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& column_widths)