Skip to content

Commit 16cf66c

Browse files
committed
Don’t crash when out-of-flow box is split in out-of-flow parent
This code is not handled correctly. This commit avoids the crash, but it doesn’t give a correct result. We have two different problems to solve: - floats in floats are broken; - split out-of-flow elements in split out-of-flow elements are broken. Fix #1807 (but doesn’t give the right result).
1 parent 9d1dbe5 commit 16cf66c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tests/draw/test_float.py

+37
Original file line numberDiff line numberDiff line change
@@ -821,3 +821,40 @@ def test_float_split_14(assert_pixels):
821821
a
822822
<div style="float: left"><p>aa<p>aa</div>
823823
<div style="float: right"><p>bb<p>bb</div>''')
824+
825+
826+
@pytest.mark.xfail
827+
@assert_no_logs
828+
def test_float_split_15(assert_pixels):
829+
assert_pixels('''
830+
BB__RRRRRRRRRR__
831+
BB__RRRRRRRRRR__
832+
BB__RRRRRRRRRR__
833+
BB__RRRRRRRRRR__
834+
GGBBRRRRRRRRRR__
835+
GGBBRRRRRRRRRR__
836+
GGBBRRRRRRRRRR__
837+
GGBBRRRRRRRRRR__
838+
RRRRRRRRRR______
839+
RRRRRRRRRR______
840+
''', '''
841+
<style>
842+
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
843+
@page {
844+
size: 16px 2px;
845+
}
846+
body {
847+
color: red;
848+
font-family: weasyprint;
849+
font-size: 2px;
850+
line-height: 1;
851+
}
852+
</style>
853+
<div style="float: left; position: relative; color: blue; width: 4px">
854+
a a a
855+
<div style="float: left; color: lime; width: 2px">
856+
a a
857+
</div>
858+
a a
859+
</div>
860+
<div>bbbbb bbbbb bbbbb bbbbb bbbbb</div>''')

weasyprint/layout/page.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,7 @@ def make_page(context, root_box, page_type, resume_at, page_number,
567567
out_of_flow_boxes = []
568568
broken_out_of_flow = {}
569569
context_out_of_flow = context.broken_out_of_flow.values()
570+
context.broken_out_of_flow = broken_out_of_flow
570571
for box, containing_block, skip_stack in context_out_of_flow:
571572
box.position_y = root_box.content_box_y()
572573
if box.is_floated():
@@ -582,7 +583,6 @@ def make_page(context, root_box, page_type, resume_at, page_number,
582583
if out_of_flow_resume_at:
583584
broken_out_of_flow[out_of_flow_box] = (
584585
box, containing_block, out_of_flow_resume_at)
585-
context.broken_out_of_flow = broken_out_of_flow
586586
root_box, resume_at, next_page, _, _, _ = block_level_layout(
587587
context, root_box, 0, resume_at, initial_containing_block,
588588
page_is_empty, positioned_boxes, positioned_boxes, adjoining_margins)

0 commit comments

Comments
 (0)