Skip to content

Commit

Permalink
[Filters] Filters with outsets have to repaint all the filterRegion i…
Browse files Browse the repository at this point in the history
…f GraphicsStyles are used

https://bugs.webkit.org/show_bug.cgi?id=261856
rdar://115817290

Reviewed by Simon Fraser.

The bounding box of a target element might all be clipped. But a filter effect,
like drop shadow, may still be visible in the current viewport. If GraphicsStyles
are used, we need to redraw the whole filterRegion.

* LayoutTests/css3/filters/drop-shadow-target-clipped-expected.html: Added.
* LayoutTests/css3/filters/drop-shadow-target-clipped.html: Added.
* Source/WebCore/rendering/RenderLayerFilters.cpp:
(WebCore::RenderLayerFilters::needsRedrawSourceImage const):
(WebCore::RenderLayerFilters::beginFilterEffect):
* Source/WebCore/rendering/RenderLayerFilters.h:

Canonical link: https://commits.webkit.org/268282@main
  • Loading branch information
shallawa authored and Said Abou-Hallawa committed Sep 21, 2023
1 parent 3e1f054 commit 39763b0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
28 changes: 28 additions & 0 deletions LayoutTests/css3/filters/drop-shadow-target-clipped-expected.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<style>
.box {
width: 300px;
height: 300px;
position: absolute;
}
.background-red {
top: 0;
left: 0;
background-color: red;
}
.background-green {
top: -100px;
left: -100px;
background-color: green;
}
.background-blue {
top: -200px;
left: -200px;
background-color: blue;
}
</style>
<body>
Three overlapping boxes should be displayed.
<div class="box background-red"></div>
<div class="box background-green"></div>
<div class="box background-blue"></div>
</body>
30 changes: 30 additions & 0 deletions LayoutTests/css3/filters/drop-shadow-target-clipped.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- webkit-test-runner [ GraphicsContextFiltersEnabled=true ] -->
<style>
.box {
width: 300px;
height: 300px;
position: absolute;
background-color: black;
}
.drop-shadow-red {
top: -1000px;
left: -1000px;
filter: drop-shadow(1000px 1000px 0 red);
}
.drop-shadow-green {
top: -1000px;
left: -1000px;
filter: drop-shadow(900px 900px 0 green);
}
.drop-shadow-blue {
top: -1000px;
left: -1000px;
filter: drop-shadow(800px 800px 0 blue);
}
</style>
<body>
Three overlapping boxes should be displayed.
<div class="box drop-shadow-red"></div>
<div class="box drop-shadow-green"></div>
<div class="box drop-shadow-blue"></div>
</body>
7 changes: 6 additions & 1 deletion Source/WebCore/rendering/RenderLayerFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ bool RenderLayerFilters::hasFilterThatShouldBeRestrictedBySecurityOrigin() const
return m_filter && m_filter->hasFilterThatShouldBeRestrictedBySecurityOrigin();
}

bool RenderLayerFilters::needsRedrawSourceImage() const
{
return m_targetSwitcher && m_targetSwitcher->needsRedrawSourceImage();
}

void RenderLayerFilters::notifyFinished(CachedResource&, const NetworkLoadMetrics&)
{
// FIXME: This really shouldn't have to invalidate layer composition,
Expand Down Expand Up @@ -173,7 +178,7 @@ GraphicsContext* RenderLayerFilters::beginFilterEffect(RenderElement& renderer,

if (!filter.hasFilterThatMovesPixels())
m_repaintRect = dirtyRect;
else if (hasUpdatedBackingStore)
else if (hasUpdatedBackingStore || needsRedrawSourceImage())
m_repaintRect = filterRegion;
else {
m_repaintRect = dirtyRect;
Expand Down
2 changes: 2 additions & 0 deletions Source/WebCore/rendering/RenderLayerFilters.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class RenderLayerFilters final : private CachedSVGDocumentClient {
void applyFilterEffect(GraphicsContext& destinationContext);

private:
bool needsRedrawSourceImage() const;

void notifyFinished(CachedResource&, const NetworkLoadMetrics&) final;
void resetDirtySourceRect() { m_dirtySourceRect = LayoutRect(); }

Expand Down

0 comments on commit 39763b0

Please sign in to comment.