Skip to content

Commit

Permalink
Avoid duplication when breaking out-of-flow boxes
Browse files Browse the repository at this point in the history
Fix #2016.
  • Loading branch information
liZe committed Dec 12, 2023
1 parent e8f1418 commit 90441d2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
46 changes: 46 additions & 0 deletions tests/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
@page {
size: 13px;
}
body {
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
p {
break-after: avoid;
}
section {
break-inside: avoid;
float: left;
}
</style>
<article>
oooooo
oooooo
oooooo
oooooo
</article>
<p>xxxxxx</p>
<p>yyyyyy</p>
<section>
<div>aaaaaa</div>
<div>cccccc</div>
</section>
<article>
dddddd
</article>''')

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():
Expand Down
3 changes: 2 additions & 1 deletion weasyprint/layout/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90441d2

Please sign in to comment.