Skip to content

Commit 3802f88

Browse files
committed
Fix the y position of split absolute boxes
1 parent 2a8ca14 commit 3802f88

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

tests/draw/test_absolute.py

+47
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,53 @@ def test_absolute_split_9():
349349
assert_pixels('absolute_split_9', 6, 8, expected_pixels, html)
350350

351351

352+
@assert_no_logs
353+
def test_absolute_split_10():
354+
expected_pixels = '''
355+
BB____
356+
BB____
357+
__RR__
358+
__RR__
359+
__RR__
360+
__RR__
361+
362+
BBRR__
363+
BBRR__
364+
__RR__
365+
__RR__
366+
______
367+
______
368+
'''
369+
html = '''
370+
<style>
371+
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
372+
@page {
373+
size: 6px;
374+
}
375+
body {
376+
color: blue;
377+
font-family: weasyprint;
378+
font-size: 2px;
379+
line-height: 1;
380+
}
381+
div {
382+
color: red;
383+
position: absolute;
384+
left: 2px;
385+
top: 2px;
386+
width: 2px;
387+
}
388+
div + article {
389+
break-before: page;
390+
}
391+
</style>
392+
<article>a</article>
393+
<div>a a a a</div>
394+
<article>a</article>
395+
'''
396+
assert_pixels('absolute_split_10', 6, 12, expected_pixels, html)
397+
398+
352399
@pytest.mark.xfail
353400
@assert_no_logs
354401
def test_absolute_next_page():

weasyprint/layout/absolute.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,11 @@ def absolute_block(context, box, containing_block, fixed_boxes, bottom_space,
204204

205205
translate_box_width, translate_x = absolute_width(
206206
box, context, containing_block)
207-
translate_box_height, translate_y = absolute_height(
208-
box, context, containing_block)
207+
if skip_stack:
208+
translate_box_height, translate_y = False, 0
209+
else:
210+
translate_box_height, translate_y = absolute_height(
211+
box, context, containing_block)
209212

210213
bottom_space += translate_y
211214

0 commit comments

Comments
 (0)