Bug 1301245 - Part 4. Implement nsSVGIDRenderingObserver::Unlink to release useless SVG document resource.
MozReview-Commit-ID: 98u6Uz3n3Bk
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -697,16 +697,21 @@ nsSVGEffects::EffectProperties::GetMaskF
if (!ok) {
// We can not find the specific SVG mask resource in the downloaded SVG
// document. There are two possibilities:
// 1. The given resource id is invalid.
// 2. The given resource id refers to a viewbox.
//
// Hand it over to the style image.
mMask->ResolveImage(i);
+
+ // Since we can not get SVG mask resource from props[i], calls
+ // nsSVGIDRenderingObserver::Unlink to release the internal resource of
+ // it.
+ props[i]->Unlink();
}
result.AppendElement(maskFrame);
}
return result;
}
bool
--- a/layout/svg/nsSVGEffects.h
+++ b/layout/svg/nsSVGEffects.h
@@ -112,16 +112,18 @@ protected:
class nsSVGIDRenderingObserver : public nsSVGRenderingObserver
{
public:
typedef mozilla::dom::Element Element;
nsSVGIDRenderingObserver(nsIURI* aURI, nsIContent* aObservingContent,
bool aReferenceImage);
virtual ~nsSVGIDRenderingObserver();
+ void Unlink() { mElement.Unlink(); }
+
protected:
Element* GetTarget() override { return mElement.get(); }
// This is called when the referenced resource changes.
virtual void DoUpdate() override;
class SourceReference : public nsReferencedElement
{