From 90441d2ab094d9bb83190c3e96d5157ff3b8fc05 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 12 Dec 2023 00:01:02 +0100 Subject: [PATCH] Avoid duplication when breaking out-of-flow boxes Fix #2016. --- tests/test_float.py | 46 ++++++++++++++++++++++++++++++++++++++ weasyprint/layout/block.py | 3 ++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/test_float.py b/tests/test_float.py index b3be60b261..b813c112ff 100644 --- a/tests/test_float.py +++ b/tests/test_float.py @@ -695,6 +695,52 @@ def test_float_text_indent_3(): assert p2.width == 12 * 20 # p text +@assert_no_logs +def test_float_previous_break(): + page1, page2 = render_pages(''' + +
+ oooooo + oooooo + oooooo + oooooo +
+

xxxxxx

+

yyyyyy

+
+
aaaaaa
+
cccccc
+
+
+ dddddd +
''') + + html, = page1.children + body, = html.children + article, = body.children + + html, = page2.children + body, = html.children + p1, p2, section, article = body.children + + @pytest.mark.xfail @assert_no_logs def test_float_fail(): diff --git a/weasyprint/layout/block.py b/weasyprint/layout/block.py index 2e1dc99582..34cd762910 100644 --- a/weasyprint/layout/block.py +++ b/weasyprint/layout/block.py @@ -264,8 +264,9 @@ def _out_of_flow_layout(context, box, index, child, new_children, result = find_earlier_page_break( context, new_children, absolute_boxes, fixed_boxes) if result: - new_children, resume_at = result stop = True + new_children[:], resume_at = result + new_child = out_of_flow_resume_at = None elif child.is_running(): running_name = child.style['position'][1] page = context.current_page