Skip to content

Commit

Permalink
Don’t limit the opacity groups to the original box size
Browse files Browse the repository at this point in the history
It doesn’t work when elements are displayed outside or when the box is
transformed.
  • Loading branch information
liZe committed Jul 5, 2022
1 parent 1a4d2a7 commit 3bd9a8e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
22 changes: 22 additions & 0 deletions tests/draw/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,25 @@ def test_2d_transform_13(assert_pixels):
font-size: 0 }
</style>
<div><img src="pattern.png"></div>''')


@assert_no_logs
def test_2d_transform_opacity(assert_pixels):
assert_pixels('''
__________
__________
__________
_ss_______
_ss_______
__________
__________
__________
__________
__________
''', '''
<style>
@page { size: 10px; margin: 2px; }
div { transform: translate(-1px, 1px); background: red;
height: 2px; width: 2px; opacity: 0.5 }
</style>
<div></div>''')
5 changes: 1 addition & 4 deletions weasyprint/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ def draw_stacking_context(stream, stacking_context):

if box.style['opacity'] < 1:
original_stream = stream
stream = stream.add_group([
box.border_box_x(), box.border_box_y(),
box.border_box_x() + box.border_width(),
box.border_box_y() + box.border_height()])
stream = stream.add_group(stream.page_rectangle)

if box.transformation_matrix:
if box.transformation_matrix.determinant:
Expand Down

0 comments on commit 3bd9a8e

Please sign in to comment.