Skip to content

Commit c887d10

Browse files
committed
Nested identical filters are not rendered.
https://bugs.webkit.org/show_bug.cgi?id=302900 rdar://165163823 Reviewed by Simon Fraser. Pushing a transparency layer causes any current filter style (or shadow, or composite operation) to be applied to the layer when popped, and don't apply to the content in the layer. Make sure we clear those states from the GraphicsContext tracking, to match the behaviour of what CG is doing. If they're not cleared, then a nested filter (or second filter primitive of the same filter property) that is identical is incorrectly considered a no-op, and doesn't get forwarded to the platform code. Test: css3/filters/nested-identical-filters.html * LayoutTests/css3/filters/nested-identical-filters-expected.html: Added. * LayoutTests/css3/filters/nested-identical-filters.html: Added. * Source/WebCore/platform/graphics/GraphicsContextState.cpp: (WebCore::GraphicsContextState::repurpose): Canonical link: https://commits.webkit.org/304143@main
1 parent 2135c96 commit c887d10

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype HTML>
2+
<html>
3+
<head>
4+
<style>
5+
div {
6+
position: relative;
7+
width: 200px;
8+
height: 200px;
9+
background: green;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<div>
15+
</div>
16+
</body>
17+
</html>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype HTML>
2+
<html>
3+
<head>
4+
<style>
5+
div {
6+
position: relative;
7+
width: 200px;
8+
height: 200px;
9+
filter: invert(100%);
10+
}
11+
#inner {
12+
background: green;
13+
}
14+
</style>
15+
</head>
16+
<body>
17+
<div id=outer>
18+
<div id=inner>
19+
</div>
20+
</div>
21+
</body>
22+
</html>

Source/WebCore/platform/graphics/GraphicsContextState.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ void GraphicsContextState::repurpose(Purpose purpose)
4444

4545
#if USE(CG)
4646
// CGContextBeginTransparencyLayer() sets the CG global alpha to 1. Keep the clone's alpha in sync.
47-
if (purpose == Purpose::TransparencyLayer)
47+
if (purpose == Purpose::TransparencyLayer) {
4848
m_alpha = 1;
49+
m_style = std::nullopt;
50+
m_dropShadow = std::nullopt;
51+
m_compositeMode = { CompositeOperator::SourceOver, BlendMode::Normal };
52+
}
4953
#endif
5054

5155
m_purpose = purpose;

0 commit comments

Comments
 (0)