Skip to content

Commit 5566a7d

Browse files
committed
Fix last row detection for grid cells with span
1 parent 8cc2cbf commit 5566a7d

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

weasyprint/layout/grid.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,17 +1303,25 @@ def _add_page_children(max_row=inf):
13031303
page_is_empty, absolute_boxes, fixed_boxes)[:3]
13041304
if new_child:
13051305
page_is_empty = False
1306-
if child_resume_at or resume_row == y:
1307-
# Child is broken.
1306+
broken_child = False
1307+
span = _get_span(child.style['grid_row_start'])
1308+
if child_resume_at:
1309+
broken_child = True
1310+
elif resume_row is not None and y + span >= resume_row + 1:
1311+
broken_child = True
1312+
if broken_child:
1313+
# Child is broken, add row to resume_at.
13081314
if resume_at is None:
13091315
resume_at = {}
13101316
if y not in resume_at:
13111317
resume_at[y] = {}
13121318
if child_resume_at:
1313-
# There is some content left for next page.
1319+
# There is some content left for next page, save the cell’s resume_at.
13141320
resume_at[y][i] = child_resume_at
1315-
elif resume_row == y:
1316-
# Only display the bottom of an empty cell.
1321+
elif broken_child:
1322+
# Everything fits but the cell overflows. Only display the bottom of an
1323+
# empty cell on next page, set the cell’s resume_at after the cell’s
1324+
# last child.
13171325
assert isinstance(new_child, boxes.ParentBox)
13181326
previous_skip_child = max(child_skip_stack) if child_skip_stack else 0
13191327
resume_at[y][i] = {previous_skip_child + len(new_child.children): None}

0 commit comments

Comments
 (0)