Skip to content

Commit

Permalink
Remove more placeholders, again and again
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed May 24, 2024
1 parent 82deda4 commit 46a7548
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
52 changes: 52 additions & 0 deletions tests/draw/test_absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,58 @@ def test_absolute_split_11(assert_pixels):
''')


@assert_no_logs
def test_absolute_split_12(assert_pixels):
assert_pixels('''
BBBBBB__
BBBBBB__
________
________
________
________
________
________
BB______
BB______
BBRR____
BBRR____
BBRRRR__
BBRRRR__
BBRRRRRR
BBRRRRRR
''', '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 8px;
}
body {
color: blue;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div {
break-inside: avoid;
}
section {
left: 2px;
position: absolute;
color: red;
}
</style>
aaa
<div>
a
<section>x<br>xx<br>xxx</section>
<br>
a<br>
a<br>
a
</div>
''')


@pytest.mark.xfail
@assert_no_logs
def test_absolute_next_page(assert_pixels):
Expand Down
8 changes: 4 additions & 4 deletions weasyprint/layout/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def _break_line(context, box, line, new_children, lines_iterator,
if over_orphans < 0 and not page_is_empty:
# Reached the bottom of the page before we had
# enough lines for orphans, cancel the whole box.
remove_placeholders(context, line.children, absolute_boxes, fixed_boxes)
return True, False, resume_at
# How many lines we need on the next page to satisfy widows
# -1 for the current line.
Expand All @@ -313,6 +314,7 @@ def _break_line(context, box, line, new_children, lines_iterator,
break
if needed > over_orphans and not page_is_empty:
# Total number of lines < orphans + widows
remove_placeholders(context, line.children, absolute_boxes, fixed_boxes)
return True, False, resume_at
if needed and needed <= over_orphans:
# Remove lines to keep them for the next page
Expand Down Expand Up @@ -765,10 +767,8 @@ 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):
for footnote in all_footnotes:
context.unlayout_footnote(footnote)
return (
None, None, {'break': 'any', 'page': None}, [], False, max_lines)
remove_placeholders(context, new_children, absolute_boxes, fixed_boxes)
return None, None, {'break': 'any', 'page': None}, [], False, max_lines

for key, value in broken_out_of_flow.items():
context.broken_out_of_flow[key] = value
Expand Down

0 comments on commit 46a7548

Please sign in to comment.