Bug 1281762 - nsWindowRoot::mPopupNode may keep otherwise closed documents alive, r=enn
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 23 Jun 2016 17:14:19 +0300
changeset 302493 8a1a3f39c99bb847bc4c9fa2428fa0bf5e45ebba
parent 302492 45a6a74c46ea709d4e6af586e9227f8b626bf595
child 302494 45fb2585696d35cf628486eac7022aaed16d9939
push id30363
push usercbook@mozilla.com
push dateFri, 24 Jun 2016 09:14:27 +0000
treeherdermozilla-central@939ecc4e9d05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenn
bugs1281762
milestone50.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 1281762 - nsWindowRoot::mPopupNode may keep otherwise closed documents alive, r=enn
dom/base/nsWindowRoot.cpp
dom/base/nsWindowRoot.h
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -53,17 +53,16 @@ nsWindowRoot::~nsWindowRoot()
   if (mListenerManager) {
     mListenerManager->Disconnect();
   }
 }
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsWindowRoot,
                                       mWindow,
                                       mListenerManager,
-                                      mPopupNode,
                                       mParent)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWindowRoot)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsPIWindowRoot)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
@@ -367,23 +366,24 @@ nsWindowRoot::GetEnabledDisabledCommands
     nsGlobalWindow* win = nsGlobalWindow::Cast(focusedWindow);
     focusedWindow = win->GetPrivateParent();
   }
 }
 
 nsIDOMNode*
 nsWindowRoot::GetPopupNode()
 {
-  return mPopupNode;
+  nsCOMPtr<nsIDOMNode> popupNode = do_QueryReferent(mPopupNode);
+  return popupNode;
 }
 
 void
 nsWindowRoot::SetPopupNode(nsIDOMNode* aNode)
 {
-  mPopupNode = aNode;
+  mPopupNode = do_GetWeakReference(aNode);
 }
 
 nsIGlobalObject*
 nsWindowRoot::GetParentObject()
 {
   return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
 }
 
--- a/dom/base/nsWindowRoot.h
+++ b/dom/base/nsWindowRoot.h
@@ -8,16 +8,17 @@
 #define nsWindowRoot_h__
 
 class nsIDOMEvent;
 class nsIGlobalObject;
 
 #include "mozilla/Attributes.h"
 #include "mozilla/EventListenerManager.h"
 #include "nsIDOMEventTarget.h"
+#include "nsIWeakReferenceUtils.h"
 #include "nsPIWindowRoot.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 
 class nsWindowRoot final : public nsPIWindowRoot
 {
 public:
@@ -98,17 +99,17 @@ protected:
                                                 nsTHashtable<nsCharPtrHashKey>& aCommandsHandled,
                                                 nsTArray<nsCString>& aEnabledCommands,
                                                 nsTArray<nsCString>& aDisabledCommands);
 
   // Members
   nsCOMPtr<nsPIDOMWindowOuter> mWindow;
   // We own the manager, which owns event listeners attached to us.
   RefPtr<mozilla::EventListenerManager> mListenerManager; // [Strong]
-  nsCOMPtr<nsIDOMNode> mPopupNode; // [OWNER]
+  nsWeakPtr mPopupNode;
 
   // True if focus rings and accelerators are enabled for this
   // window hierarchy.
   bool mShowAccelerators;
   bool mShowFocusRings;
 
   nsCOMPtr<mozilla::dom::EventTarget> mParent;