1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00

Fix percentage max-height without a containing block height.

This commit is contained in:
Simon Sapin 2012-06-01 10:47:29 +02:00
parent 491299f668
commit 41d3cd3287
2 changed files with 43 additions and 1 deletions

View File

@ -79,7 +79,7 @@ def resolve_percentages(box, containing_block):
assert height.unit == 'px'
box.height = height.value
resolve_one_percentage(box, 'min_height', 0)
resolve_one_percentage(box, 'max_height', None)
resolve_one_percentage(box, 'max_height', float('inf'))
else:
resolve_one_percentage(box, 'height', cb_height)
resolve_one_percentage(box, 'min_height', cb_height)

View File

@ -323,6 +323,48 @@ def test_block_heights():
heights = [div.height for div in body_children(page)]
assert heights == [90, 90 * 3, 20, 120, 20, 120, 90, 90]
page, = parse('''
<style>
body { height: 200px }
</style>
<div>
<img src=pattern.png style="height: 40px">
</div>
<div style="height: 10%">
<img src=pattern.png style="height: 40px">
</div>
<div style="max-height: 20px">
<img src=pattern.png style="height: 40px">
</div>
<div style="max-height: 10%">
<img src=pattern.png style="height: 40px">
</div>
<div style="min-height: 20px"></div>
<div style="min-height: 10%"></div>
''')
heights = [div.height for div in body_children(page)]
assert heights == [40, 20, 20, 20, 20, 20]
# Same but with no height on body: percentage *-height is ignored
page, = parse('''
<div>
<img src=pattern.png style="height: 40px">
</div>
<div style="height: 10%">
<img src=pattern.png style="height: 40px">
</div>
<div style="max-height: 20px">
<img src=pattern.png style="height: 40px">
</div>
<div style="max-height: 10%">
<img src=pattern.png style="height: 40px">
</div>
<div style="min-height: 20px"></div>
<div style="min-height: 10%"></div>
''')
heights = [div.height for div in body_children(page)]
assert heights == [40, 40, 20, 40, 20, 0]
@assert_no_logs
def test_block_percentage_heights():