diff --git a/tests/layout/test_position.py b/tests/layout/test_position.py index e4126b62e..87bd0df74 100644 --- a/tests/layout/test_position.py +++ b/tests/layout/test_position.py @@ -327,23 +327,30 @@ def test_absolute_positioning_8(): def test_absolute_images(): page, = render_pages('''
+ +
''') html, = page.children body, = html.children div, = body.children - img1, img2 = div.children + img1, img2, img3, img4 = div.children assert div.height == 0 assert (div.position_x, div.position_y) == (0, 0) assert (img1.position_x, img1.position_y) == (10, 10) assert (img1.width, img1.height) == (4, 4) assert (img2.position_x, img2.position_y) == (15, 10) assert (img2.width, img2.height) == (4, 4) + assert (img3.position_x, img3.position_y) == (10, 15) + assert (img3.width, img3.height) == (4, 4) + assert (img4.position_x, img4.position_y) == (10, 21) # (50 - 4) - 25 + assert (img4.width, img4.height) == (4, 4) # TODO: test the various cases in absolute_replaced() diff --git a/weasyprint/layout/absolute.py b/weasyprint/layout/absolute.py index 8bf14ea25..fc63679de 100644 --- a/weasyprint/layout/absolute.py +++ b/weasyprint/layout/absolute.py @@ -318,9 +318,9 @@ def absolute_replaced(context, box, cb_x, cb_y, cb_width, cb_height): box.margin_bottom = 0 remaining = cb_height - box.margin_height() if box.top == 'auto': - box.top = remaining + box.top = remaining - box.bottom if box.bottom == 'auto': - box.bottom = remaining + box.bottom = remaining - box.top elif 'auto' in (box.margin_top, box.margin_bottom): remaining = cb_height - (box.border_height() + box.top + box.bottom) if box.margin_top == box.margin_bottom == 'auto':