diff options
author | martinfalisse <martinmotteditfalisse@gmail.com> | 2023-01-02 22:53:19 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-03 20:02:47 +0100 |
commit | 25f612f32be3154300c640ecf3e838de748b4cdf (patch) | |
tree | ec0a3a285b370e2e87a62fafcb64036446346092 /Userland | |
parent | c88aa21302138d350f8413761e8a5ad4aca6b5a0 (diff) | |
download | serenity-25f612f32be3154300c640ecf3e838de748b4cdf.zip |
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.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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; } |