Bug 872774. r=bz, a=lsblakk
authorDavid Zbarsky <dzbarsky@gmail.com>
Thu, 16 May 2013 11:06:21 -0700
changeset 142693 7e250ccb7a9bc09e6b48b8986ee852c20ec6905e
parent 142692 72f386b8c46b970ec945e48c2ff328f31c6f727e
child 142694 01fe1133726a5f9b9f46aa1abb71e0803e7a026c
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, lsblakk
bugs872774
milestone23.0a2
Bug 872774. r=bz, a=lsblakk
content/svg/content/src/SVGIRect.h
content/svg/content/src/SVGRect.cpp
content/svg/content/src/SVGRect.h
content/svg/content/src/nsSVGViewBox.cpp
content/svg/content/src/nsSVGViewBox.h
--- a/content/svg/content/src/SVGIRect.h
+++ b/content/svg/content/src/SVGIRect.h
@@ -18,53 +18,46 @@ class nsSVGElement;
 
 namespace mozilla {
 namespace dom {
 
 class SVGIRect : public nsISupports,
                  public nsWrapperCache
 {
 public:
-  SVGIRect(nsIContent* aParent)
-    : mParent(aParent)
+  SVGIRect()
   {
     SetIsDOMBinding();
   }
 
   virtual ~SVGIRect()
   {
   }
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
   {
     return SVGRectBinding::Wrap(aCx, aScope, this);
   }
 
-  nsIContent* GetParentObject() const
-  {
-    return mParent;
-  }
+  virtual nsIContent* GetParentObject() const = 0;
 
   virtual float X() const = 0;
 
   virtual void SetX(float aX, ErrorResult& aRv) = 0;
 
   virtual float Y() const = 0;
 
   virtual void SetY(float aY, ErrorResult& aRv) = 0;
 
   virtual float Width() const = 0;
 
   virtual void SetWidth(float aWidth, ErrorResult& aRv) = 0;
 
   virtual float Height() const = 0;
 
   virtual void SetHeight(float aHeight, ErrorResult& aRv) = 0;
-
-private:
-  nsCOMPtr<nsIContent> mParent;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif //mozilla_dom_SVGIRect_h
 
--- a/content/svg/content/src/SVGRect.cpp
+++ b/content/svg/content/src/SVGRect.cpp
@@ -12,27 +12,30 @@ DOMCI_DATA(SVGRect, mozilla::dom::SVGRec
 
 namespace mozilla {
 namespace dom {
 
 //----------------------------------------------------------------------
 // implementation:
 
 SVGRect::SVGRect(nsIContent* aParent, float x, float y, float w, float h)
-  : SVGIRect(aParent), mX(x), mY(y), mWidth(w), mHeight(h)
+  : SVGIRect(), mParent(aParent), mX(x), mY(y), mWidth(w), mHeight(h)
 {
 }
 
 //----------------------------------------------------------------------
 // nsISupports methods:
 
-NS_IMPL_ADDREF(SVGRect)
-NS_IMPL_RELEASE(SVGRect)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(SVGRect, mParent)
 
-NS_INTERFACE_MAP_BEGIN(SVGRect)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(SVGRect)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(SVGRect)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGRect)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 } // namespace dom
 } // namespace mozilla
 
 ////////////////////////////////////////////////////////////////////////
 // Exported creation functions:
--- a/content/svg/content/src/SVGRect.h
+++ b/content/svg/content/src/SVGRect.h
@@ -17,18 +17,18 @@ namespace mozilla {
 namespace dom {
 
 class SVGRect MOZ_FINAL : public SVGIRect
 {
 public:
   SVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f, float w=0.0f,
           float h=0.0f);
 
-  // nsISupports interface:
-  NS_DECL_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(SVGRect)
 
   // WebIDL
   virtual float X() const MOZ_OVERRIDE MOZ_FINAL
   {
     return mX;
   }
 
   virtual void SetX(float aX, ErrorResult& aRv) MOZ_FINAL
@@ -61,17 +61,23 @@ public:
     return mHeight;
   }
 
   virtual void SetHeight(float aHeight, ErrorResult& aRv) MOZ_FINAL
   {
     mHeight = aHeight;
   }
 
+  virtual nsIContent* GetParentObject() const
+  {
+    return mParent;
+  }
+
 protected:
+  nsCOMPtr<nsIContent> mParent;
   float mX, mY, mWidth, mHeight;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 already_AddRefed<mozilla::dom::SVGRect>
 NS_NewSVGRect(nsIContent* aParent, float x=0.0f, float y=0.0f,
--- a/content/svg/content/src/nsSVGViewBox.cpp
+++ b/content/svg/content/src/nsSVGViewBox.cpp
@@ -29,30 +29,32 @@ nsSVGViewBoxRect::operator==(const nsSVG
      x == aOther.x &&
      y == aOther.y &&
      width == aOther.width &&
      height == aOther.height);
 }
 
 /* Cycle collection macros for nsSVGViewBox */
 
-NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGViewBox::DOMBaseVal, mSVGElement)
-NS_SVG_VAL_IMPL_CYCLE_COLLECTION(nsSVGViewBox::DOMAnimVal, mSVGElement)
+NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(nsSVGViewBox::DOMBaseVal, mSVGElement)
+NS_SVG_VAL_IMPL_CYCLE_COLLECTION_WRAPPERCACHED(nsSVGViewBox::DOMAnimVal, mSVGElement)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGViewBox::DOMBaseVal)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGViewBox::DOMBaseVal)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSVGViewBox::DOMAnimVal)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSVGViewBox::DOMAnimVal)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGViewBox::DOMBaseVal)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSVGViewBox::DOMAnimVal)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 static nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMBaseVal>
   sBaseSVGViewBoxTearoffTable;
 static nsSVGAttrTearoffTable<nsSVGViewBox, nsSVGViewBox::DOMAnimVal>
   sAnimSVGViewBoxTearoffTable;
 nsSVGAttrTearoffTable<nsSVGViewBox, mozilla::dom::SVGAnimatedRect>
--- a/content/svg/content/src/nsSVGViewBox.h
+++ b/content/svg/content/src/nsSVGViewBox.h
@@ -94,20 +94,20 @@ private:
   nsSVGViewBoxRect mBaseVal;
   nsAutoPtr<nsSVGViewBoxRect> mAnimVal;
   bool mHasBaseVal;
 
 public:
   struct DOMBaseVal MOZ_FINAL : public mozilla::dom::SVGIRect
   {
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS(DOMBaseVal)
+    NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMBaseVal)
 
     DOMBaseVal(nsSVGViewBox *aVal, nsSVGElement *aSVGElement)
-      : mozilla::dom::SVGIRect(aSVGElement)
+      : mozilla::dom::SVGIRect()
       , mVal(aVal)
       , mSVGElement(aSVGElement)
     {}
     virtual ~DOMBaseVal();
 
     nsSVGViewBox* mVal; // kept alive because it belongs to content
     nsRefPtr<nsSVGElement> mSVGElement;
 
@@ -130,25 +130,30 @@ public:
     {
       return mVal->GetBaseValue().height;
     }
 
     void SetX(float aX, mozilla::ErrorResult& aRv) MOZ_FINAL;
     void SetY(float aY, mozilla::ErrorResult& aRv) MOZ_FINAL;
     void SetWidth(float aWidth, mozilla::ErrorResult& aRv) MOZ_FINAL;
     void SetHeight(float aHeight, mozilla::ErrorResult& aRv) MOZ_FINAL;
+
+    virtual nsIContent* GetParentObject() const
+    {
+      return mSVGElement;
+    }
   };
 
   struct DOMAnimVal MOZ_FINAL : public mozilla::dom::SVGIRect
   {
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-    NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimVal)
+    NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMAnimVal)
 
     DOMAnimVal(nsSVGViewBox *aVal, nsSVGElement *aSVGElement)
-      : mozilla::dom::SVGIRect(aSVGElement)
+      : mozilla::dom::SVGIRect()
       , mVal(aVal)
       , mSVGElement(aSVGElement)
     {}
     virtual ~DOMAnimVal();
 
     nsSVGViewBox* mVal; // kept alive because it belongs to content
     nsRefPtr<nsSVGElement> mSVGElement;
 
@@ -192,16 +197,21 @@ public:
     {
       aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     }
 
     void SetHeight(float aHeight, mozilla::ErrorResult& aRv) MOZ_FINAL
     {
       aRv.Throw(NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR);
     }
+
+    virtual nsIContent* GetParentObject() const
+    {
+      return mSVGElement;
+    }
   };
 
   struct SMILViewBox : public nsISMILAttr
   {
   public:
     SMILViewBox(nsSVGViewBox* aVal, nsSVGElement* aSVGElement)
       : mVal(aVal), mSVGElement(aSVGElement) {}