From 126abd3347fe16faaf8b623c7d4d557b0770a9f0 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Thu, 11 Jul 2024 08:49:12 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20break=20rows=20with=20atomic=20?= =?UTF-8?q?cells?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #1868. --- tests/layout/test_table.py | 33 +++++++++++++++++++++++++++++++++ weasyprint/layout/table.py | 9 +++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/tests/layout/test_table.py b/tests/layout/test_table.py index 2feff40aa..b77e1a7e6 100644 --- a/tests/layout/test_table.py +++ b/tests/layout/test_table.py @@ -2145,6 +2145,39 @@ def test_table_page_breaks(html, rows, positions): assert rows_position_y == positions +@assert_no_logs +def test_table_page_breaks_in_cell(): + page1, page2 = render_pages(''' + +

Dummy title

+ + + + +
r1c1l1r1c2l1
r2c1l1r2c2l1
r2c2l2
r3c1l1r3l1
+ ''') + html, = page1.children + body, = html.children + h1, table_wrapper = body.children + table, = table_wrapper.children + group, = table.children + row, = group.children + assert len(row.children) == 2 + + html, = page2.children + body, = html.children + table_wrapper, = body.children + table, = table_wrapper.children + group, = table.children + row1, row2 = group.children + assert len(row1.children) == len(row2.children) == 2 + + @assert_no_logs def test_table_page_breaks_complex_1(): pages = render_pages(''' diff --git a/weasyprint/layout/table.py b/weasyprint/layout/table.py index c418f2b91..f0272dcc9 100644 --- a/weasyprint/layout/table.py +++ b/weasyprint/layout/table.py @@ -204,8 +204,13 @@ def group_layout(group, position_y, bottom_space, page_is_empty, skip_stack): new_row_children.append(cell) if resume_at and not page_is_empty: - if avoid_page_break(row.style['break_inside'], context): - # Don’t break in row with break-inside: avoid, abort row. + # Avoid break when "break-inside: avoid" is set on row or any + # on its cells. + avoid_break = ( + avoid_page_break(row.style['break_inside'], context) or any( + avoid_page_break(cell.style['break_inside'], context) + for cell in row.children)) + if avoid_break: resume_at = {index_row: {}} remove_placeholders( context, new_row_children, absolute_boxes, fixed_boxes)