From 8e267c90dfefe068b331c8196d4a0d6482e1d39f Mon Sep 17 00:00:00 2001 From: grewn0uille Date: Mon, 16 Sep 2019 16:33:13 +0200 Subject: [PATCH] Make blocks with 'overflow' different from 'visible' grow to include floating children. Fix #661. --- weasyprint/layout/blocks.py | 5 +++++ weasyprint/tests/test_layout/test_block.py | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/weasyprint/layout/blocks.py b/weasyprint/layout/blocks.py index b7cb4eeb..89b2843c 100644 --- a/weasyprint/layout/blocks.py +++ b/weasyprint/layout/blocks.py @@ -638,6 +638,11 @@ def block_container_layout(context, box, max_position_y, skip_stack, # http://www.w3.org/TR/CSS21/visudet.html#normal-block # TODO: See float.float_layout if new_box.height == 'auto': + if context.excluded_shapes and new_box.style['overflow'] != 'visible': + max_float_position_y = max( + float_box.position_y + float_box.margin_height() + for float_box in context.excluded_shapes) + position_y = max(max_float_position_y, position_y) new_box.height = position_y - new_box.content_box_y() if new_box.style['position'] == 'relative': diff --git a/weasyprint/tests/test_layout/test_block.py b/weasyprint/tests/test_layout/test_block.py index 8bfff017..88da0264 100644 --- a/weasyprint/tests/test_layout/test_block.py +++ b/weasyprint/tests/test_layout/test_block.py @@ -705,3 +705,15 @@ def test_box_decoration_break_slice_bottom_padding(): assert article.height == 20 div, = article.children assert div.position_y == 0 + + +@assert_no_logs +def test_overflow_auto(): + page, = parse(''' +
+
bla bla bla
+ toto toto''') + html, = page.children + body, = html.children + article, = body.children + assert article.height == 50 + 10 + 10