Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/layout/test_float.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,27 @@ def test_floats_page_breaks_2():
assert positions_y == [[10], [10]]


@assert_no_logs
def test_floats_page_breaks_side_by_side():
# Don’t move an overflowing float when it’s next to another float.
page, = render_pages('''
<style>
@page { size: 100px; margin: 10px }
div { height: 81px; float: left }
.left { width: 20% }
.right { width: 80% }
</style>
<div class="left">left</div>
<div class="right">right</div>
''')

divs = [
box for box in page.descendants()
if box.element_tag == 'div' and box.is_floated()]
assert [(div.position_x, div.position_y) for div in divs] == [
(10, 10), (26, 10)]


@assert_no_logs
def test_floats_page_breaks_3():
# Tests floated images shorter than the page
Expand Down
3 changes: 2 additions & 1 deletion weasyprint/layout/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def _out_of_flow_layout(context, box, index, child, new_children,
page_overflow = context.overflows_page(
bottom_space, new_child.position_y + new_child.height)
add_child = (
(page_is_empty and not new_children) or
(page_is_empty and (
not new_children or new_child.position_y == box.content_box_y())) or
not page_overflow or
box.is_monolithic())
if add_child:
Expand Down