Bug 1203423 - Move call to AddClone outside nsMutationReceiver constructor; r=smaug
authorBrian Birtles <birtles@gmail.com>
Fri, 11 Sep 2015 15:02:04 +0900
changeset 261887 23b49acf7cc0db646ceab92bb1a739637eb25150
parent 261886 1af4761b27bb25c4c71e28547f6e23f09a7ac6ac
child 261888 991e80fcdd03ef4472c8cc0f2bee70fe39f8374a
push id64870
push userbbirtles@mozilla.com
push dateFri, 11 Sep 2015 06:03:06 +0000
treeherdermozilla-inbound@b2d47f9818ce [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1203423
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203423 - Move call to AddClone outside nsMutationReceiver constructor; r=smaug This is to avoid performing an AddRef on a potentially derived object where the subclass constructors have yet to run.
dom/base/nsDOMMutationObserver.h
--- a/dom/base/nsDOMMutationObserver.h
+++ b/dom/base/nsDOMMutationObserver.h
@@ -319,16 +319,17 @@ public:
     r->AddObserver();
     return r;
   }
 
   static nsMutationReceiver* Create(nsINode* aRegisterTarget,
                                     nsMutationReceiverBase* aParent)
   {
     nsMutationReceiver* r = new nsMutationReceiver(aRegisterTarget, aParent);
+    aParent->AddClone(r);
     r->AddObserver();
     return r;
   }
 
   nsMutationReceiver* GetParent()
   {
     return static_cast<nsMutationReceiver*>(mParent.get());
   }
@@ -380,17 +381,16 @@ public:
 protected:
   nsMutationReceiver(nsINode* aTarget, nsDOMMutationObserver* aObserver);
 
   nsMutationReceiver(nsINode* aRegisterTarget, nsMutationReceiverBase* aParent)
   : nsMutationReceiverBase(aRegisterTarget, aParent)
   {
     NS_ASSERTION(!static_cast<nsMutationReceiver*>(aParent)->GetParent(),
                  "Shouldn't create deep observer hierarchies!");
-    aParent->AddClone(this);
   }
 
   virtual void AddMutationObserver() override
   {
     mRegisterTarget->AddMutationObserver(this);
   }
 };
 
@@ -404,16 +404,17 @@ public:
     r->AddObserver();
     return r;
   }
 
   static nsAnimationReceiver* Create(nsINode* aRegisterTarget,
                                      nsMutationReceiverBase* aParent)
   {
     nsAnimationReceiver* r = new nsAnimationReceiver(aRegisterTarget, aParent);
+    aParent->AddClone(r);
     r->AddObserver();
     return r;
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIANIMATIONOBSERVER_ANIMATIONADDED
   NS_DECL_NSIANIMATIONOBSERVER_ANIMATIONCHANGED