diff --git a/tests/layout/test_grid.py b/tests/layout/test_grid.py index 20e354621..2d627deae 100644 --- a/tests/layout/test_grid.py +++ b/tests/layout/test_grid.py @@ -988,3 +988,35 @@ def test_grid_template_areas_extra_span_column_dense(): assert div_e.height == 4 assert article.height == 4 assert article.width == 12 + + +@assert_no_logs +def test_grid_gap_explicit_grid_column(): + # Regression test for https://github.com/Kozea/WeasyPrint/issues/2187 + page, = render_pages(''' + +
+
a
+
b
+
+ ''') + html, = page.children + body, = html.children + article, = body.children + div_a, div_b = article.children + assert div_a.position_x == div_b.position_x == 0 + assert div_a.position_y == 0 + assert div_b.position_y == 4 + assert article.height == 6 + assert article.width == 12 diff --git a/weasyprint/layout/grid.py b/weasyprint/layout/grid.py index c052573b1..ebd3f2dd8 100644 --- a/weasyprint/layout/grid.py +++ b/weasyprint/layout/grid.py @@ -797,10 +797,7 @@ def grid_layout(context, box, bottom_space, skip_stack, containing_block, break first_diff = first_i + first_size - implicit_first_2 if first_diff > 0: - for _ in range(first_diff): - first_tracks.append(next(auto_tracks)) - first_tracks.append([]) - implicit_first_2 = first_i + first_size + implicit_first_2 += first_diff # 3. Set the item’s row-start line. if first_flow == 'row': x, y = second_i, first_i @@ -912,10 +909,7 @@ def grid_layout(context, box, bottom_space, skip_stack, containing_block, break first_diff = first_i + first_size - implicit_first_2 if first_diff > 0: - for _ in range(first_diff): - first_tracks.append(next(auto_tracks)) - first_tracks.append([]) - implicit_first_2 = y + height + implicit_first_2 += first_diff # 3. Set the item’s row-start line. children_positions[child] = (x, y, width, height) else: