Skip to content

Commit dc7c2cb

Browse files
committed
Don’t crash when fixed elements aren’t displayed yet in aborted line
Fix #1806.
1 parent 16cf66c commit dc7c2cb

File tree

2 files changed

+99
-2
lines changed

2 files changed

+99
-2
lines changed

tests/draw/test_absolute.py

+98
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,101 @@ def test_absolute_pages_counter_orphans(assert_pixels):
672672
</style>
673673
a a a <div>a a a</div> a <div>a a a</div>
674674
''')
675+
676+
677+
@assert_no_logs
678+
def test_absolute_in_inline(assert_pixels):
679+
assert_pixels('''
680+
______
681+
_GG___
682+
_GG___
683+
_GG___
684+
_GG___
685+
______
686+
______
687+
______
688+
______
689+
690+
______
691+
_RR___
692+
_RR___
693+
_RR___
694+
_RR___
695+
_BB___
696+
_BB___
697+
______
698+
______
699+
''', '''
700+
<style>
701+
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
702+
@page {
703+
margin: 1px;
704+
size: 6px 9px;
705+
}
706+
body {
707+
color: red;
708+
font-family: weasyprint;
709+
font-size: 2px;
710+
line-height: 1;
711+
orphans: 2;
712+
widows: 2;
713+
}
714+
p {
715+
color: lime;
716+
}
717+
div {
718+
color: blue;
719+
position: absolute;
720+
}
721+
</style>
722+
<p>a a</p> a a <div>a</div>
723+
''')
724+
725+
726+
@assert_no_logs
727+
def test_fixed_in_inline(assert_pixels):
728+
assert_pixels('''
729+
______
730+
_GG___
731+
_GG___
732+
_GG___
733+
_GG___
734+
_BB___
735+
_BB___
736+
______
737+
______
738+
739+
______
740+
_RR___
741+
_RR___
742+
_RR___
743+
_RR___
744+
_BB___
745+
_BB___
746+
______
747+
______
748+
''', '''
749+
<style>
750+
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
751+
@page {
752+
margin: 1px;
753+
size: 6px 9px;
754+
}
755+
body {
756+
color: red;
757+
font-family: weasyprint;
758+
font-size: 2px;
759+
line-height: 1;
760+
orphans: 2;
761+
widows: 2;
762+
}
763+
p {
764+
color: lime;
765+
}
766+
div {
767+
color: blue;
768+
position: fixed;
769+
}
770+
</style>
771+
<p>a a</p> a a <div>a</div>
772+
''')

weasyprint/layout/block.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1032,9 +1032,8 @@ def remove_placeholders(context, box_list, absolute_boxes, fixed_boxes):
10321032
remove_placeholders(
10331033
context, box.children, absolute_boxes, fixed_boxes)
10341034
if box.style['position'] == 'absolute' and box in absolute_boxes:
1035-
# box is not in absolute_boxes if its parent has position: relative
10361035
absolute_boxes.remove(box)
1037-
elif box.style['position'] == 'fixed':
1036+
elif box.style['position'] == 'fixed' and box in fixed_boxes:
10381037
fixed_boxes.remove(box)
10391038
if box.footnote:
10401039
context.unlayout_footnote(box.footnote)

0 commit comments

Comments
 (0)