mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-05 00:21:15 +03:00
Handle adjoining margins in flex layout
Top border is handled by collapsing_with_children set to False when the box is a flex item. Bottom border is handled at the end of the flex item layout, by adding the collapsed adjoining margins to the child's bottom border. Fix #673.
This commit is contained in:
parent
1dbe26af01
commit
4667a6b159
@ -482,7 +482,7 @@ def block_container_layout(context, box, max_position_y, skip_stack,
|
||||
this_box_adjoining_margins = adjoining_margins
|
||||
|
||||
collapsing_with_children = not (
|
||||
box.border_top_width or box.padding_top or
|
||||
box.border_top_width or box.padding_top or box.is_flex_item or
|
||||
establishes_formatting_context(box) or box.is_for_root_element)
|
||||
if collapsing_with_children:
|
||||
# XXX not counting margins in adjoining_margins, if any
|
||||
|
@ -420,14 +420,20 @@ def flex_layout(context, box, max_position_y, skip_stack, containing_block,
|
||||
if child_copy.margin_bottom == 'auto':
|
||||
child_copy.margin_bottom = 0
|
||||
blocks.block_level_width(child_copy, box)
|
||||
new_child = blocks.block_level_layout_switch(
|
||||
context, child_copy, float('inf'),
|
||||
child_skip_stack, box, device_size, page_is_empty,
|
||||
absolute_boxes, fixed_boxes, adjoining_margins=[])[0]
|
||||
new_child, _, _, adjoining_margins, _ = (
|
||||
blocks.block_level_layout_switch(
|
||||
context, child_copy, float('inf'),
|
||||
child_skip_stack, box, device_size, page_is_empty,
|
||||
absolute_boxes, fixed_boxes, adjoining_margins=[]))
|
||||
|
||||
child._baseline = find_in_flow_baseline(new_child)
|
||||
if cross == 'height':
|
||||
child.height = new_child.height
|
||||
# As flex items margins never collapse (with other flex items
|
||||
# or with the flex container), we can add the adjoining margins
|
||||
# to the child bottom margin.
|
||||
child.margin_bottom += blocks.collapse_margin(
|
||||
adjoining_margins)
|
||||
else:
|
||||
child.width = min_content_width(context, child, outer=False)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user