From 25f612f32be3154300c640ecf3e838de748b4cdf Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Mon, 2 Jan 2023 22:53:19 +0100 Subject: [PATCH] LibWeb: Prevent column sizing errors for html table Previously when there was no difference between the sum of the max and min-widths of all columns of a table, it would result in a NaN value being set as the column's width as there was a division by 0. This would result in 2+ column tables being reduced to only 1 column. --- Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index bbe91b1959..f57377f17a 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -190,6 +190,9 @@ void TableFormattingContext::distribute_width_to_columns(float extra_width) for (auto& column : m_columns) grid_max += column.max_width - column.min_width; + if (grid_max == 0) + return; + for (auto& column : m_columns) column.used_width += ((column.max_width - column.min_width) / grid_max) * extra_width; }