mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-03 23:48:07 +03:00
Merge branch '62.x'
This commit is contained in:
commit
4d2f93238c
2
.github/workflows/exe.yml
vendored
2
.github/workflows/exe.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
- name: Install requirements
|
||||
run: python -m pip install . pyinstaller
|
||||
- name: Generate executable
|
||||
run: python -m PyInstaller weasyprint/__main__.py -n weasyprint -F
|
||||
run: python -m PyInstaller weasyprint/__main__.py -n weasyprint -F --hidden-import "fontTools.ttLib.tables.V_A_R_C_"
|
||||
- name: Test executable
|
||||
run: dist/weasyprint --info
|
||||
- name: Store executable
|
||||
|
@ -164,6 +164,15 @@ def test_variable_chain_root_missing():
|
||||
''')
|
||||
|
||||
|
||||
def test_variable_chain_root_missing_inherited():
|
||||
# Regression test for https://github.com/Kozea/WeasyPrint/issues/2164
|
||||
page, = render_pages('''
|
||||
<style>
|
||||
html { --var1: var(--var-missing); font: var(--var1) }
|
||||
</style>a
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_variable_shorthand_margin():
|
||||
page, = render_pages('''
|
||||
|
@ -399,6 +399,58 @@ def test_absolute_split_11(assert_pixels):
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_absolute_split_12(assert_pixels):
|
||||
assert_pixels('''
|
||||
BBBBBB__
|
||||
BBBBBB__
|
||||
________
|
||||
________
|
||||
________
|
||||
________
|
||||
________
|
||||
________
|
||||
BB______
|
||||
BB______
|
||||
BBRR____
|
||||
BBRR____
|
||||
BBRRRR__
|
||||
BBRRRR__
|
||||
BBRRRRRR
|
||||
BBRRRRRR
|
||||
''', '''
|
||||
<style>
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
@page {
|
||||
size: 8px;
|
||||
}
|
||||
body {
|
||||
color: blue;
|
||||
font-family: weasyprint;
|
||||
font-size: 2px;
|
||||
line-height: 1;
|
||||
}
|
||||
div {
|
||||
break-inside: avoid;
|
||||
}
|
||||
section {
|
||||
left: 2px;
|
||||
position: absolute;
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
aaa
|
||||
<div>
|
||||
a
|
||||
<section>x<br>xx<br>xxx</section>
|
||||
<br>
|
||||
a<br>
|
||||
a<br>
|
||||
a
|
||||
</div>
|
||||
''')
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
@assert_no_logs
|
||||
def test_absolute_next_page(assert_pixels):
|
||||
|
@ -623,7 +623,6 @@ def test_float_split_9(assert_pixels):
|
||||
<div>bbbbb bb</div>''')
|
||||
|
||||
|
||||
@pytest.mark.xfail
|
||||
@assert_no_logs
|
||||
def test_float_split_10(assert_pixels):
|
||||
assert_pixels('''
|
||||
|
@ -769,3 +769,49 @@ def test_float_fail():
|
||||
body, = html.children
|
||||
paragraph, = body.children
|
||||
line1, line2, line3 = paragraph.children
|
||||
|
||||
|
||||
def test_float_table_aborted_row():
|
||||
page1, page2 = render_pages('''
|
||||
<style>
|
||||
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||
@page {size: 10px 7px}
|
||||
body {font-family: weasyprint; font-size: 2px; line-height: 1}
|
||||
div {float: right; orphans: 1}
|
||||
td {break-inside: avoid}
|
||||
</style>
|
||||
<table><tbody>
|
||||
<tr><td>abc</td></tr>
|
||||
<tr><td>abc</td></tr>
|
||||
<tr><td>def <div>f<br>g</div> ghi</td></tr>
|
||||
</tbody></table>
|
||||
''')
|
||||
|
||||
html, = page1.children
|
||||
body, = html.children
|
||||
table_wrapper, = body.children
|
||||
table, = table_wrapper.children
|
||||
tbody, = table.children
|
||||
for tr in tbody.children:
|
||||
td, = tr.children
|
||||
line, = td.children
|
||||
textbox, = line.children
|
||||
assert textbox.text == 'abc'
|
||||
|
||||
html, = page2.children
|
||||
body, = html.children
|
||||
table_wrapper, = body.children
|
||||
table, = table_wrapper.children
|
||||
tbody, = table.children
|
||||
tr, = tbody.children
|
||||
td, = tr.children
|
||||
line1, line2 = td.children
|
||||
textbox, div = line1.children
|
||||
assert textbox.text == 'def '
|
||||
textbox, = line2.children
|
||||
assert textbox.text == 'ghi'
|
||||
line1, line2 = div.children
|
||||
textbox, br = line1.children
|
||||
assert textbox.text == 'f'
|
||||
textbox, = line2.children
|
||||
assert textbox.text == 'g'
|
||||
|
@ -725,7 +725,7 @@ class ComputedStyle(dict):
|
||||
try:
|
||||
value = value.solve(solved_tokens, original_key)
|
||||
except InvalidValues:
|
||||
if key in INHERITED:
|
||||
if key in INHERITED and parent_style is not None:
|
||||
# Values in parent_style are already computed.
|
||||
self[key] = value = parent_style[key]
|
||||
else:
|
||||
|
@ -275,6 +275,7 @@ def _out_of_flow_layout(context, box, index, child, new_children,
|
||||
last_in_flow_child = find_last_in_flow_child(new_children)
|
||||
page_break = block_level_page_break(last_in_flow_child, child)
|
||||
resume_at = {index: None}
|
||||
out_of_flow_resume_at = None
|
||||
stop = True
|
||||
if new_children and avoid_page_break(page_break, context):
|
||||
# Can’t break inside float, find an earlier page break.
|
||||
@ -283,7 +284,7 @@ def _out_of_flow_layout(context, box, index, child, new_children,
|
||||
if result:
|
||||
# Earlier page break found, drop whole child rendering.
|
||||
new_children[:], resume_at = result
|
||||
new_child = out_of_flow_resume_at = None
|
||||
new_child = None
|
||||
|
||||
# Running element layout.
|
||||
elif child.is_running():
|
||||
@ -301,6 +302,7 @@ def _break_line(context, box, line, new_children, lines_iterator,
|
||||
if over_orphans < 0 and not page_is_empty:
|
||||
# Reached the bottom of the page before we had
|
||||
# enough lines for orphans, cancel the whole box.
|
||||
remove_placeholders(context, line.children, absolute_boxes, fixed_boxes)
|
||||
return True, False, resume_at
|
||||
# How many lines we need on the next page to satisfy widows
|
||||
# -1 for the current line.
|
||||
@ -312,6 +314,7 @@ def _break_line(context, box, line, new_children, lines_iterator,
|
||||
break
|
||||
if needed > over_orphans and not page_is_empty:
|
||||
# Total number of lines < orphans + widows
|
||||
remove_placeholders(context, line.children, absolute_boxes, fixed_boxes)
|
||||
return True, False, resume_at
|
||||
if needed and needed <= over_orphans:
|
||||
# Remove lines to keep them for the next page
|
||||
@ -764,10 +767,9 @@ def block_container_layout(context, box, bottom_space, skip_stack,
|
||||
if (box_is_fragmented and
|
||||
avoid_page_break(box.style['break_inside'], context) and
|
||||
not page_is_empty):
|
||||
for footnote in all_footnotes:
|
||||
context.unlayout_footnote(footnote)
|
||||
return (
|
||||
None, None, {'break': 'any', 'page': None}, [], False, max_lines)
|
||||
remove_placeholders(
|
||||
context, [*new_children, *box.children[skip:]], absolute_boxes, fixed_boxes)
|
||||
return None, None, {'break': 'any', 'page': None}, [], False, max_lines
|
||||
|
||||
for key, value in broken_out_of_flow.items():
|
||||
context.broken_out_of_flow[key] = value
|
||||
|
@ -82,7 +82,6 @@ def float_layout(context, box, containing_block, absolute_boxes, fixed_boxes,
|
||||
box = find_float_position(context, box, containing_block)
|
||||
|
||||
context.excluded_shapes.append(box)
|
||||
|
||||
return box, resume_at
|
||||
|
||||
|
||||
|
@ -302,9 +302,7 @@ def table_layout(context, table, bottom_space, skip_stack, containing_block,
|
||||
# other content on the page.
|
||||
if not page_is_empty and context.overflows_page(
|
||||
bottom_space, next_position_y):
|
||||
for descendant in row.descendants():
|
||||
if descendant.footnote is not None:
|
||||
context.unlayout_footnote(descendant.footnote)
|
||||
remove_placeholders(context, row.children, absolute_boxes, fixed_boxes)
|
||||
if new_group_children:
|
||||
previous_row = new_group_children[-1]
|
||||
page_break = block_level_page_break(previous_row, row)
|
||||
|
Loading…
Reference in New Issue
Block a user