Skip to content

Commit

Permalink
Don't crash when no baseline can be found in flexbox children
Browse files Browse the repository at this point in the history
Fix #765.
  • Loading branch information
liZe committed Mar 19, 2019
1 parent fd90af6 commit a5e9127
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions weasyprint/layout/flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def flex_layout(context, box, max_position_y, skip_stack, containing_block,
parent_box, device_size, page_is_empty, absolute_boxes,
fixed_boxes, adjoining_margins=[]))

child._baseline = find_in_flow_baseline(new_child)
child._baseline = find_in_flow_baseline(new_child) or 0
if cross == 'height':
child.height = new_child.height
# As flex items margins never collapse (with other flex items
Expand Down Expand Up @@ -853,8 +853,9 @@ def flex_layout(context, box, max_position_y, skip_stack, containing_block,
if axis == 'width': # and main text direction is horizontal
box.baseline = flex_lines[0].lower_baseline if flex_lines else 0
else:
box.baseline = (
find_in_flow_baseline(box.children[0]) if box.children else 0)
box.baseline = ((
find_in_flow_baseline(box.children[0])
if box.children else 0) or 0)

context.finish_block_formatting_context(box)

Expand Down
2 changes: 2 additions & 0 deletions weasyprint/layout/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ def find_in_flow_baseline(box, last=False, baseline_types=(boxes.LineBox,)):
Return the absolute Y position for the first (or last) in-flow baseline
if any, or None.
"""
# TODO: synthetize baseline when needed
# See https://www.w3.org/TR/css-align-3/#synthesize-baseline
if isinstance(box, baseline_types):
return box.position_y + box.baseline
if isinstance(box, boxes.ParentBox) and not isinstance(
Expand Down

0 comments on commit a5e9127

Please sign in to comment.