From cee0a9c2f5843ac478ceca6a37255d0ab5dc29b7 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 4 Feb 2025 16:59:29 +0100 Subject: [PATCH] Let resolve_percentages handle flex container box-sizing Fix #2053. --- tests/layout/test_flex.py | 23 +++++++++++++++++++++++ weasyprint/layout/flex.py | 7 +------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/layout/test_flex.py b/tests/layout/test_flex.py index 1f4e51d15..fc26b95e3 100644 --- a/tests/layout/test_flex.py +++ b/tests/layout/test_flex.py @@ -216,6 +216,29 @@ def test_flex_direction_column_reverse_rtl(): assert div_1.position_y < div_2.position_y < div_3.position_y +@assert_no_logs +def test_flex_direction_column_box_sizing(): + page, = render_pages(''' + +
+ ''') + html, = page.children + body, = html.children + article, = body.children + assert article.width == 10 + assert article.height == 5 + assert article.padding_top == 5 + + @assert_no_logs def test_flex_row_wrap(): page, = render_pages(''' diff --git a/weasyprint/layout/flex.py b/weasyprint/layout/flex.py index 3410390e3..1ba8fe18c 100644 --- a/weasyprint/layout/flex.py +++ b/weasyprint/layout/flex.py @@ -311,15 +311,10 @@ def flex_layout(context, box, bottom_space, skip_stack, containing_block, # using the rules of the formatting context in which it # participates. For this computation, auto margins on flex items # are treated as 0. - # TODO: The whole step has to be fixed. if axis == 'width': block.block_level_width(box, containing_block) else: - if box.style['height'] != 'auto' and box.style['height'].unit != '%': - box.height = box.style['height'].value - elif box.style['height'] != 'auto' and containing_block.height != 'auto': - box.height = box.style['height'].value / 100 * containing_block.height - else: + if box.height == 'auto': box.height = 0 for index, child in enumerate(children): if not child.is_flex_item: