1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-04 07:57:52 +03:00

Fix column height with column-span content

Fix #1094.
This commit is contained in:
Guillaume Ayoub 2021-11-10 21:20:30 +01:00
parent ed20d94c49
commit f46e254107
2 changed files with 33 additions and 3 deletions

View File

@ -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 }
@ -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('''

View File

@ -139,6 +139,7 @@ def columns_layout(context, box, max_position_y, skip_stack, containing_block,
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)
@ -160,7 +161,7 @@ def columns_layout(context, box, max_position_y, skip_stack, containing_block,
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:
@ -226,7 +227,7 @@ def columns_layout(context, box, max_position_y, skip_stack, containing_block,
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