Skip to content

Commit

Permalink
Fix the y position of split absolute boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Apr 25, 2022
1 parent 2a8ca14 commit 3802f88
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
47 changes: 47 additions & 0 deletions tests/draw/test_absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,53 @@ def test_absolute_split_9():
assert_pixels('absolute_split_9', 6, 8, expected_pixels, html)


@assert_no_logs
def test_absolute_split_10():
expected_pixels = '''
BB____
BB____
__RR__
__RR__
__RR__
__RR__
BBRR__
BBRR__
__RR__
__RR__
______
______
'''
html = '''
<style>
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
@page {
size: 6px;
}
body {
color: blue;
font-family: weasyprint;
font-size: 2px;
line-height: 1;
}
div {
color: red;
position: absolute;
left: 2px;
top: 2px;
width: 2px;
}
div + article {
break-before: page;
}
</style>
<article>a</article>
<div>a a a a</div>
<article>a</article>
'''
assert_pixels('absolute_split_10', 6, 12, expected_pixels, html)


@pytest.mark.xfail
@assert_no_logs
def test_absolute_next_page():
Expand Down
7 changes: 5 additions & 2 deletions weasyprint/layout/absolute.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ def absolute_block(context, box, containing_block, fixed_boxes, bottom_space,

translate_box_width, translate_x = absolute_width(
box, context, containing_block)
translate_box_height, translate_y = absolute_height(
box, context, containing_block)
if skip_stack:
translate_box_height, translate_y = False, 0
else:
translate_box_height, translate_y = absolute_height(
box, context, containing_block)

bottom_space += translate_y

Expand Down

0 comments on commit 3802f88

Please sign in to comment.