1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibWeb: Fix empty slot finding in table formation algorithm

The algorithm which finds the first free slot must run for every cell,
not for every row.
This commit is contained in:
Andi Gallo 2023-06-19 05:55:08 +00:00 committed by Andreas Kling
parent 282e8357ed
commit 205f9c75d9
3 changed files with 122 additions and 2 deletions

View file

@ -98,16 +98,19 @@ void TableFormattingContext::calculate_row_column_grid(Box const& box)
size_t x_width = 0, y_height = 0;
size_t x_current = 0, y_current = 0;
// Implements https://html.spec.whatwg.org/multipage/tables.html#algorithm-for-processing-rows
auto process_row = [&](auto& row) {
if (y_height == y_current)
y_height++;
x_current = 0;
while (x_current < x_width && grid.contains(GridPosition { x_current, y_current }))
x_current++;
for (auto* child = row.first_child(); child; child = child->next_sibling()) {
if (child->display().is_table_cell()) {
// Cells: While x_current is less than x_width and the slot with coordinate (x_current, y_current) already has a cell assigned to it, increase x_current by 1.
while (x_current < x_width && grid.contains(GridPosition { x_current, y_current }))
x_current++;
Box const* box = static_cast<Box const*>(child);
if (x_current == x_width)
x_width++;