Skip to content

Commit

Permalink
Remove more placeholders
Browse files Browse the repository at this point in the history
Fix #1792.
  • Loading branch information
liZe committed May 25, 2024
1 parent 46a7548 commit 60b64c0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
46 changes: 46 additions & 0 deletions tests/layout/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,49 @@ def test_float_fail():
body, = html.children
paragraph, = body.children
line1, line2, line3 = paragraph.children


def test_float_table_aborted_row():
page1, page2 = render_pages('''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {size: 10px 7px}
body {font-family: weasyprint; font-size: 2px; line-height: 1}
div {float: right; orphans: 1}
td {break-inside: avoid}
</style>
<table><tbody>
<tr><td>abc</td></tr>
<tr><td>abc</td></tr>
<tr><td>def <div>f<br>g</div> ghi</td></tr>
</tbody></table>
''')

html, = page1.children
body, = html.children
table_wrapper, = body.children
table, = table_wrapper.children
tbody, = table.children
for tr in tbody.children:
td, = tr.children
line, = td.children
textbox, = line.children
assert textbox.text == 'abc'

html, = page2.children
body, = html.children
table_wrapper, = body.children
table, = table_wrapper.children
tbody, = table.children
tr, = tbody.children
td, = tr.children
line1, line2 = td.children
textbox, div = line1.children
assert textbox.text == 'def '
textbox, = line2.children
assert textbox.text == 'ghi'
line1, line2 = div.children
textbox, br = line1.children
assert textbox.text == 'f'
textbox, = line2.children
assert textbox.text == 'g'
2 changes: 1 addition & 1 deletion weasyprint/layout/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ def block_container_layout(context, box, bottom_space, skip_stack,
if (box_is_fragmented and
avoid_page_break(box.style['break_inside'], context) and
not page_is_empty):
remove_placeholders(context, new_children, absolute_boxes, fixed_boxes)
remove_placeholders(context, box.children[skip:], absolute_boxes, fixed_boxes)
return None, None, {'break': 'any', 'page': None}, [], False, max_lines

for key, value in broken_out_of_flow.items():
Expand Down
1 change: 0 additions & 1 deletion weasyprint/layout/float.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes,
box = find_float_position(context, box, containing_block)

context.excluded_shapes.append(box)

return box, resume_at


Expand Down
4 changes: 1 addition & 3 deletions weasyprint/layout/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ def group_layout(group, position_y, bottom_space, page_is_empty,
# other content on the page.
if not page_is_empty and context.overflows_page(
bottom_space, next_position_y):
for descendant in row.descendants():
if descendant.footnote is not None:
context.unlayout_footnote(descendant.footnote)
remove_placeholders(context, row.children, absolute_boxes, fixed_boxes)
if new_group_children:
previous_row = new_group_children[-1]
page_break = block_level_page_break(previous_row, row)
Expand Down

0 comments on commit 60b64c0

Please sign in to comment.