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 294506 23b49acf7cc0db646ceab92bb1a739637eb25150
parent 294505 1af4761b27bb25c4c71e28547f6e23f09a7ac6ac
child 294507 991e80fcdd03ef4472c8cc0f2bee70fe39f8374a
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [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