LibWeb: Fix bug in maybe_add_column()

Fixes a bug in the maybe_add_column() implementation of the
OccupationGrid. Previously were checking for the width of the grid based
off of the first row, and so when augmenting the column count row-by-row
the latter rows would have differing column counts.

Also, were doing an unnecessary + 1 which I imagine comes from before
when I wasn't quite clear on whether I was referring to columns by
index or by the css-value of the column (column 1 in the css is
column index 0).
This commit is contained in:
martinfalisse 2022-10-08 14:27:20 +02:00 committed by Andreas Kling
parent 829186af7d
commit 994d996ab2
Notes: sideshowbarker 2024-07-17 08:25:15 +09:00

View file

@ -1145,8 +1145,9 @@ void OccupationGrid::maybe_add_column(int needed_number_of_columns)
{ {
if (needed_number_of_columns <= column_count()) if (needed_number_of_columns <= column_count())
return; return;
auto column_count_before_modification = column_count();
for (auto& occupation_grid_row : m_occupation_grid) for (auto& occupation_grid_row : m_occupation_grid)
for (int idx = 0; idx < (needed_number_of_columns + 1) - column_count(); idx++) for (int idx = 0; idx < needed_number_of_columns - column_count_before_modification; idx++)
occupation_grid_row.append(false); occupation_grid_row.append(false);
} }