Skip to content

Commit 3bd9a8e

Browse files
committed
Don’t limit the opacity groups to the original box size
It doesn’t work when elements are displayed outside or when the box is transformed.
1 parent 1a4d2a7 commit 3bd9a8e

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

tests/draw/test_transform.py

+22
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,25 @@ def test_2d_transform_13(assert_pixels):
285285
font-size: 0 }
286286
</style>
287287
<div><img src="pattern.png"></div>''')
288+
289+
290+
@assert_no_logs
291+
def test_2d_transform_opacity(assert_pixels):
292+
assert_pixels('''
293+
__________
294+
__________
295+
__________
296+
_ss_______
297+
_ss_______
298+
__________
299+
__________
300+
__________
301+
__________
302+
__________
303+
''', '''
304+
<style>
305+
@page { size: 10px; margin: 2px; }
306+
div { transform: translate(-1px, 1px); background: red;
307+
height: 2px; width: 2px; opacity: 0.5 }
308+
</style>
309+
<div></div>''')

weasyprint/draw.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,7 @@ def draw_stacking_context(stream, stacking_context):
108108

109109
if box.style['opacity'] < 1:
110110
original_stream = stream
111-
stream = stream.add_group([
112-
box.border_box_x(), box.border_box_y(),
113-
box.border_box_x() + box.border_width(),
114-
box.border_box_y() + box.border_height()])
111+
stream = stream.add_group(stream.page_rectangle)
115112

116113
if box.transformation_matrix:
117114
if box.transformation_matrix.determinant:

0 commit comments

Comments
 (0)