Commit bbeec228 authored by Fredrik Söderqvist's avatar Fredrik Söderqvist Committed by Commit Bot

Clear filter data when removing resource client

Previously this would be happening via the call to RemoveClient(), which
ended up calling RemoveClientFromCache() on the LayoutObject associated
with the <filter>.

Bug: 1091568
Change-Id: I473321962dd5855e228403ad6bcba96ea6f825ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235078Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#776155}
parent 792beeb8
...@@ -599,14 +599,20 @@ void SVGResources::ClearClipPathFilterMask(SVGElement& element, ...@@ -599,14 +599,20 @@ void SVGResources::ClearClipPathFilterMask(SVGElement& element,
const ComputedStyle* style) { const ComputedStyle* style) {
if (!style) if (!style)
return; return;
SVGResourceClient* client = element.GetSVGResourceClient(); SVGElementResourceClient* client = element.GetSVGResourceClient();
if (!client) if (!client)
return; return;
if (auto* old_reference_clip = if (auto* old_reference_clip =
DynamicTo<ReferenceClipPathOperation>(style->ClipPath())) DynamicTo<ReferenceClipPathOperation>(style->ClipPath()))
old_reference_clip->RemoveClient(*client); old_reference_clip->RemoveClient(*client);
if (style->HasFilter()) if (style->HasFilter()) {
style->Filter().RemoveClient(*client); style->Filter().RemoveClient(*client);
if (client->ClearFilterData()) {
LayoutObject* layout_object = element.GetLayoutObject();
LayoutSVGResourceContainer::MarkClientForInvalidation(
*layout_object, SVGResourceClient::kPaintInvalidation);
}
}
if (StyleSVGResource* masker_resource = style->SvgStyle().MaskerResource()) if (StyleSVGResource* masker_resource = style->SvgStyle().MaskerResource())
masker_resource->RemoveClient(*client); masker_resource->RemoveClient(*client);
} }
......
<!doctype html>
<html class="reftest-wait">
<title>SourceGraphic is invalidated when removing element from the document</title>
<link rel="help" href="https://drafts.fxtf.org/filter-effects-1/#attr-valuedef-in-sourcegraphic">
<link rel="match" href="reference/green-100x100.html">
<script src="/common/rendering-utils.js"></script>
<script src="/common/reftest-wait.js"></script>
<svg>
<filter id="f">
<feMerge><feMergeNode/></feMerge>
</filter>
<rect width="100" height="100" fill="red"/>
<rect id="target" width="50" height="100" fill="green" filter="url(#f)"/>
</svg>
<script>
waitForAtLeastOneFrame().then(() => {
let rect = document.getElementById('target');
let svg = rect.parentNode;
rect.remove();
rect.setAttribute('width', '100');
svg.appendChild(rect);
takeScreenshot();
});
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment