Skip to content

Commit

Permalink
Fix column height with column-span content
Browse files Browse the repository at this point in the history
Fix #1094.
  • Loading branch information
liZe committed Nov 10, 2021
1 parent ed20d94 commit f46e254
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
31 changes: 30 additions & 1 deletion tests/layout/test_column.py
Expand Up @@ -80,7 +80,7 @@ def test_column_gap(value, width):


@assert_no_logs
def test_column_span():
def test_column_span_1():
page, = render_pages('''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
Expand Down Expand Up @@ -110,6 +110,35 @@ def test_column_span():
assert column1.height == 16


@assert_no_logs
def test_column_span_2():
page, = render_pages('''
<style>
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
body { margin: 0; font-family: weasyprint; line-height: 1 }
div { columns: 2; width: 10em; column-gap: 0 }
section { column-span: all; margin: 1em 0 }
</style>
<div>
<section>test</section>
abc def
ghi jkl
mno pqr
stu vwx
</div>
''')
html, = page.children
body, = html.children
div, = body.children
section1, column1, column2 = div.children
assert (section1.content_box_x(), section1.content_box_y()) == (0, 16)
assert (column1.position_x, column1.position_y) == (0, 3 * 16)
assert (column2.position_x, column2.position_y) == (5 * 16, 3 * 16)

assert column1.height == column2.height == 16 * 4


@assert_no_logs
def test_columns_multipage():
page1, page2 = render_pages('''
Expand Down
5 changes: 3 additions & 2 deletions weasyprint/layout/column.py
Expand Up @@ -139,6 +139,7 @@ def create_column_box(children):
current_position_y += collapse_margin(adjoining_margins)
adjoining_margins = []
column_box = create_column_box(column_children)
column_box.position_y = current_position_y
new_child, _, _, _, _ = block_box_layout(
context, column_box, float('inf'), skip_stack, containing_block,
page_is_empty, [], [], [], discard=False)
Expand All @@ -160,7 +161,7 @@ def create_column_box(children):
for i in range(count):
# Render the column
new_box, resume_at, next_page, _, _ = block_box_layout(
context, column_box, box.content_box_y() + height,
context, column_box, current_position_y + height,
column_skip_stack, containing_block, page_is_empty,
[], [], [], discard=False)
if new_box is None:
Expand Down Expand Up @@ -226,7 +227,7 @@ def create_column_box(children):
column_skip_stack = skip_stack

# TODO: check box.style['max']-height
max_position_y = min(max_position_y, box.content_box_y() + height)
max_position_y = min(max_position_y, current_position_y + height)

# Replace the current box children with columns
i = 0
Expand Down

0 comments on commit f46e254

Please sign in to comment.