Skip to content

Commit

Permalink
Don’t try to increase column width when there’s no extra width
Browse files Browse the repository at this point in the history
Fix #2306.
  • Loading branch information
liZe committed Nov 19, 2024
1 parent 9d028fb commit a2e0bbd
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_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3378,3 +3378,21 @@ def test_border_collapse_5():
[None, black_3, black_3],
[black_3, black_3, black_3],
]


@assert_no_logs
def test_table_zero_width():
# Test regression: https://github.com/Kozea/WeasyPrint/issues/2306
page, = render_pages('''
<table style="font-family: weasyprint">
<thead>
<tr>
<th colspan="2">aaaaaaaaaaaaaaaaaa</th>
</tr>
<tr>
<th style="width:80px"></th>
<th style="width:80px">rrrrr</th>
</tr>
</thead>
</table>
''')
2 changes: 1 addition & 1 deletion weasyprint/layout/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def auto_table_layout(context, box, containing_block):
# width.
min_content_specified_guess[i] = column_max_content_widths[i]

if assignable_width <= sum(max_content_guess):
if assignable_width < sum(max_content_guess):
# Default values shouldn't be used, but we never know.
# See https://github.com/Kozea/WeasyPrint/issues/770
lower_guess = guesses[0]
Expand Down

0 comments on commit a2e0bbd

Please sign in to comment.