From 33ac9a600d3da9cf06dcaf26002f863f90d06b02 Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 7 Feb 2025 11:59:38 +0100 Subject: [PATCH] Use min width of atomic children when defining min width of line Fix #1652. --- tests/layout/test_flex.py | 18 ++++++++++++++++++ weasyprint/layout/preferred.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/layout/test_flex.py b/tests/layout/test_flex.py index 1b8bb1a96..4dcaa1b73 100644 --- a/tests/layout/test_flex.py +++ b/tests/layout/test_flex.py @@ -940,3 +940,21 @@ def test_flex_item_overflow(): text2, = line2.children assert text1.text == 'c d' assert text2.text == 'e' + + +@assert_no_logs +def test_flex_direction_row_inline_block(): + # Regression test for https://github.com/Kozea/WeasyPrint/issues/1652 + page, = render_pages(''' +
+
A B C D E F
+
+ ''') + html, = page.children + body, = html.children + article, = body.children + div, = article.children + assert div.width == 14 + line1, = div.children + assert line1.children[0].children[0].children[0].text == 'A B C D' + assert line1.children[0].children[1].children[0].text == 'E F' diff --git a/weasyprint/layout/preferred.py b/weasyprint/layout/preferred.py index 105c1f871..11dea7d7b 100644 --- a/weasyprint/layout/preferred.py +++ b/weasyprint/layout/preferred.py @@ -338,7 +338,7 @@ def inline_line_widths(context, box, outer, is_line_start, minimum, skip_stack=N # "By default, there is a break opportunity # both before and after any inline object." if minimum: - lines = [0, max_content_width(context, child), 0] + lines = [0, min_content_width(context, child), 0] else: lines = [max_content_width(context, child)] # The first text line goes on the current line