Skip to content

Commit

Permalink
Let resolve_percentages handle flex container box-sizing
Browse files Browse the repository at this point in the history
Fix #2053.
  • Loading branch information
liZe committed Feb 4, 2025
1 parent 8aa2848 commit 95612eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
23 changes: 23 additions & 0 deletions tests/layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('''
<style>
article {
box-sizing: border-box;
display: flex;
flex-direction: column;
height: 10px;
padding-top: 5px;
width: 10px;
}
</style>
<article></article>
''')
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('''
Expand Down
7 changes: 1 addition & 6 deletions weasyprint/layout/flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 95612eb

Please sign in to comment.