1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

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.
This commit is contained in:
martinfalisse 2023-01-02 22:53:19 +01:00 committed by Andreas Kling
parent c88aa21302
commit 25f612f32b

View file

@ -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;
}