Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Kozea/WeasyPrint
Browse files Browse the repository at this point in the history
  • Loading branch information
grewn0uille committed Sep 9, 2019
2 parents e9ff909 + 4cb6045 commit 03edd01
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions weasyprint/layout/columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def create_column_box(children):
adjoining_margins.append(new_child.margin_bottom)
continue

excluded_shapes = context.excluded_shapes[:]

# We have a list of children that we have to balance between columns.
column_children = column_children_or_block

Expand All @@ -152,6 +154,12 @@ def create_column_box(children):
column_skip_stack = skip_stack
lost_space = float('inf')
while True:
# Remove extra excluded shapes introduced during previous loop
new_excluded_shapes = (
len(context.excluded_shapes) - len(excluded_shapes))
for i in range(new_excluded_shapes):
context.excluded_shapes.pop()

for i in range(count):
# Render the column
new_box, resume_at, next_page, _, _ = block_box_layout(
Expand All @@ -165,16 +173,23 @@ def create_column_box(children):
continue
column_skip_stack = resume_at

# Get the empty space at the bottom of the column box
empty_space = height - (
new_box.children[-1].position_y - box.content_box_y() +
new_box.children[-1].margin_height())

# Get the minimum size needed to render the next box
next_box, _, _, _, _ = block_box_layout(
context, column_box, box.content_box_y(),
column_skip_stack, containing_block, True, [], [], [])
next_box_size = next_box.children[0].margin_height()
in_flow_children = [
child for child in new_box.children
if child.is_in_normal_flow()]

if in_flow_children:
# Get the empty space at the bottom of the column box
empty_space = height - (
in_flow_children[-1].position_y - box.content_box_y() +
in_flow_children[-1].margin_height())

# Get the minimum size needed to render the next box
next_box, _, _, _, _ = block_box_layout(
context, column_box, box.content_box_y(),
column_skip_stack, containing_block, True, [], [], [])
next_box_size = next_box.children[0].margin_height()
else:
empty_space = next_box_size = 0

# Append the size needed to render the next box in this
# column.
Expand Down

0 comments on commit 03edd01

Please sign in to comment.