From cb9540ba3b434e83c4b2e973e5be8780c2a84526 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 7 Jul 2022 10:45:24 +0200 Subject: [PATCH] Correctly detect empty split lines at the end of tables The previous detection was failing when some cells were empty (or fully rendered) and when the current rendering position was not overflowing the page. In this case, the line with empty cells was rendered and was visible for example when cells had padding. --- tests/draw/test_table.py | 37 +++++++++++++++++++++++++++++++++++++ weasyprint/layout/table.py | 16 +++++----------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/tests/draw/test_table.py b/tests/draw/test_table.py index c53e32949..d253a676c 100644 --- a/tests/draw/test_table.py +++ b/tests/draw/test_table.py @@ -1198,3 +1198,40 @@ def test_tables_20(assert_pixels): ''') + + +@assert_no_logs +def test_tables_21(assert_pixels): + assert_pixels(''' + _________________________ + _rrrrrrrrrrrrrrrrrrrrrrr_ + _rBBBBBBBBBBrBBBBBBBBBBr_ + _rBKKKKKKBBBrBKKKKKKBBBr_ + _rBKKKKKKBBBrBKKKKKKBBBr_ + _rBBBBBBBBBBrBBBBBBBBBBr_ + _rrrrrrrrrrrrrrrrrrrrrrr_ + _________________________ + _________________________ + _________________________ + _________________________ + _________________________ + _rrrrrrrrrrrrrrrrrrrrrrr_ + _rBBBBBBBBBBrBBBBBBBBBBr_ + _rBKKKKKKBBBrBBBBBBBBBBr_ + _rBKKKKKKBBBrBBBBBBBBBBr_ + _rBBBBBBBBBBrBBBBBBBBBBr_ + _rrrrrrrrrrrrrrrrrrrrrrr_ + _________________________ + _________________________ + _________________________ + _________________________ + ''', ''' + + + + ''') diff --git a/weasyprint/layout/table.py b/weasyprint/layout/table.py index 086242577..edc05b51e 100644 --- a/weasyprint/layout/table.py +++ b/weasyprint/layout/table.py @@ -272,17 +272,11 @@ def group_layout(group, position_y, bottom_space, page_is_empty, # 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}: - break_cell = True - break - else: - # No cell was displayed, give up row - next_position_y = inf - page_is_empty = False - resume_at = None + if all(child.empty for child in row.children): + # No cell was displayed, give up row + next_position_y = inf + page_is_empty = False + resume_at = None else: break_cell = True
abcabc
abc