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

Copy boxes when using them in stacking contexts

If we don’t copy the boxes, rendering pages twice will fail because creating
stacking contexts can change the boxes’ children.

Fix #1473.
This commit is contained in:
Guillaume Ayoub 2021-11-14 19:35:08 +01:00
parent 58c9dbc231
commit aafb119e29
2 changed files with 10 additions and 1 deletions

View File

@ -975,3 +975,12 @@ def test_http():
assert HTML(root_url + '/deflate').etree_element.get('test') == 'ok'
assert HTML(
root_url + '/raw-deflate').etree_element.get('test') == 'ok'
@assert_no_logs
def test_page_copy_relative():
# Regression test for https://github.com/Kozea/WeasyPrint/issues/1473
document = FakeHTML(string='<div style="position: relative">a').render()
duplicated_pages = document.copy([*document.pages, *document.pages])
pngs = duplicated_pages.write_png(split_images=True)
assert pngs[0] == pngs[1]

View File

@ -136,7 +136,7 @@ class StackingContext:
result = dispatch(child)
if result is not None:
new_children.append(result)
box.children = new_children
box = box.copy_with_children(new_children)
return box
box = dispatch_children(box)