From 0ae65b82974996193f6d00b93afb68c661b50063 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Mon, 24 Jan 2022 16:11:18 +0100 Subject: [PATCH] Layout positioned boxes in page margins Fix #1540. --- tests/layout/test_page.py | 1 - weasyprint/layout/page.py | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/layout/test_page.py b/tests/layout/test_page.py index 5366999832..36e9a026fe 100644 --- a/tests/layout/test_page.py +++ b/tests/layout/test_page.py @@ -1362,7 +1362,6 @@ def test_running_img(): ''') -@pytest.mark.xfail @assert_no_logs def test_running_absolute(): # Test regression: https://github.com/Kozea/WeasyPrint/issues/1540 diff --git a/weasyprint/layout/page.py b/weasyprint/layout/page.py index 7990d58170..90f0d8d989 100644 --- a/weasyprint/layout/page.py +++ b/weasyprint/layout/page.py @@ -433,11 +433,16 @@ def make_box(at_keyword, containing_block): def margin_box_content_layout(context, page, box): """Layout a margin box’s content once the box has dimensions.""" + positioned_boxes = [] box, resume_at, next_page, _, _ = block_container_layout( context, box, bottom_space=-float('inf'), skip_stack=None, - page_is_empty=True, absolute_boxes=[], fixed_boxes=[], - adjoining_margins=None, discard=False) + page_is_empty=True, absolute_boxes=positioned_boxes, + fixed_boxes=positioned_boxes, adjoining_margins=None, discard=False) assert resume_at is None + for absolute_box in positioned_boxes: + absolute_layout( + context, absolute_box, box, positioned_boxes, bottom_space=0, + skip_stack=None) vertical_align = box.style['vertical_align'] # Every other value is read as 'top', ie. no change.