Bug 1438541 P4 De-duplicate code in DOMEventTargetHelper::BindToOwner() methods. r=smaug
authorBen Kelly <ben@wanderview.com>
Wed, 21 Feb 2018 10:53:53 -0800
changeset 404785 5675db58f9e9b343067a3afa12bb0d6b788875ab
parent 404784 26cad18f73fa3286a302abd18d648e2f577a26f0
child 404786 9cc657edcd0e015bd37ad2ec13c6db4f61bda7d3
push id33490
push userdluca@mozilla.com
push dateThu, 22 Feb 2018 10:00:20 +0000
treeherdermozilla-central@ea3da643422c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1438541
milestone60.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 1438541 P4 De-duplicate code in DOMEventTargetHelper::BindToOwner() methods. r=smaug
dom/events/DOMEventTargetHelper.cpp
--- a/dom/events/DOMEventTargetHelper.cpp
+++ b/dom/events/DOMEventTargetHelper.cpp
@@ -125,36 +125,22 @@ DOMEventTargetHelper::BindToOwner(nsIGlo
       mHasOrHasHadOwnerWindow = true;
     }
   }
 }
 
 void
 DOMEventTargetHelper::BindToOwner(DOMEventTargetHelper* aOther)
 {
-  if (mParentObject) {
-    mParentObject->RemoveEventTargetObject(this);
-  }
-  if (mOwnerWindow) {
-    mOwnerWindow = nullptr;
-    mParentObject = nullptr;
-    mHasOrHasHadOwnerWindow = false;
+  if (!aOther) {
+    BindToOwner(static_cast<nsIGlobalObject*>(nullptr));
+    return;
   }
-  if (aOther) {
-    mHasOrHasHadOwnerWindow = aOther->HasOrHasHadOwner();
-    mParentObject = aOther->GetParentObject();
-    if (mParentObject) {
-      mParentObject->AddEventTargetObject(this);
-      // Let's cache the result of this QI for fast access and off main thread usage
-      mOwnerWindow = nsCOMPtr<nsPIDOMWindowInner>(do_QueryInterface(mParentObject)).get();
-      if (mOwnerWindow) {
-        mHasOrHasHadOwnerWindow = true;
-      }
-    }
-  }
+  BindToOwner(aOther->GetParentObject());
+  mHasOrHasHadOwnerWindow = aOther->HasOrHasHadOwner();
 }
 
 void
 DOMEventTargetHelper::DisconnectFromOwner()
 {
   if (mParentObject) {
     mParentObject->RemoveEventTargetObject(this);
   }