Skip to content

Commit

Permalink
Use min width of atomic children when defining min width of line
Browse files Browse the repository at this point in the history
Fix #1652.
  • Loading branch information
liZe committed Feb 7, 2025
1 parent f573f20 commit 33ac9a6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('''
<article style="display: flex; font: 2px weasyprint; width: 14px">
<div style="display: inline-block">A B C D E F</div>
</article>
''')
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'
2 changes: 1 addition & 1 deletion weasyprint/layout/preferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 33ac9a6

Please sign in to comment.