Bug 1301245 - Part 4. Implement nsSVGIDRenderingObserver::Unlink to release useless SVG document resource. draft
authorcku <cku@mozilla.com>
Wed, 26 Jul 2017 12:26:21 +0800
changeset 615572 31c7e87187aa0ea25edb924965d77f526f5e1749
parent 615517 51d8cde5633d578c752657989b48a0afce0518b5
child 639223 1897d66c95b6c47a34520eacf723bf2e3cccc59a
push id70412
push userbmo:cku@mozilla.com
push dateWed, 26 Jul 2017 06:29:28 +0000
bugs1301245
milestone56.0a1
Bug 1301245 - Part 4. Implement nsSVGIDRenderingObserver::Unlink to release useless SVG document resource. MozReview-Commit-ID: 98u6Uz3n3Bk
layout/svg/nsSVGEffects.cpp
layout/svg/nsSVGEffects.h
--- 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
   {