Skip to content

Commit

Permalink
Update y position when table cells are broken
Browse files Browse the repository at this point in the history
Fix #1523.
  • Loading branch information
liZe committed Dec 20, 2021
1 parent ea317e5 commit 8d2c549
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
22 changes: 22 additions & 0 deletions tests/draw/test_table.py
Expand Up @@ -1176,3 +1176,25 @@ def test_tables_18():
td { border: 1px red solid; padding: 1px; line-height: 1; }
</style>
<table><tr><td>a a a a</td></tr>''')


@assert_no_logs
def test_tables_19():
# Regression test: https://github.com/Kozea/WeasyPrint/issues/1523
assert_pixels('table_split_crash', 2, 8, '''
RR
RR
RR
RR
RR
RR
RR
RR
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {size: 2px 4px}
table {border-collapse: collapse; color: red}
body {font-size: 2px; font-family: weasyprint; line-height: 1}
</style>
<table><tr><td>a a a a</td></tr></table>''')
15 changes: 7 additions & 8 deletions weasyprint/layout/table.py
Expand Up @@ -261,25 +261,21 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
next_position_y += border_spacing_y

# Break if one cell was broken
break_cell = False
if resume_at:
values, = list(resume_at.values())
if len(row.children) == len(values):
for cell_resume_at in values.values():
if cell_resume_at != {0: None}:
new_group_children.append(row)
if table.style['border_collapse'] == 'collapse':
table.skip_cell_border_bottom = True
break_cell = True
break
else:
# No cell was displayed, give up row
next_position_y = float('inf')
page_is_empty = False
resume_at = None
else:
new_group_children.append(row)
if table.style['border_collapse'] == 'collapse':
table.skip_cell_border_bottom = True
break
break_cell = True

# Break if this row overflows the page, unless there is no
# other content on the page.
Expand Down Expand Up @@ -308,7 +304,10 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
page_is_empty = False
skip_stack = None

if resume_at:
if break_cell and table.style['border_collapse'] == 'collapse':
table.skip_cell_border_bottom = True

if break_cell or resume_at:
break

# Do not keep the row group if we made a page break
Expand Down

0 comments on commit 8d2c549

Please sign in to comment.