Bug 1597433 - part 1: Fix uses of nsIDocShellTreeItem in nsGlobalWindowInner::CallOnChildren. r=kmag
authorTetsuharu OHZEKI <tetsuharu.ohzeki@gmail.com>
Sat, 21 Dec 2019 03:42:25 +0000
changeset 508154 b874f97516f591f72a72676466871f67b43d800b
parent 508153 a34b7b4c3b0b131d9f4d8ab96f31b679d5b1aacd
child 508155 a35c4e0fca3f962f9e1885087162b1f7af160727
push id103846
push usertetsuharu.ohzeki@gmail.com
push dateSat, 21 Dec 2019 04:19:59 +0000
treeherderautoland@a35c4e0fca3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1597433
milestone73.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 1597433 - part 1: Fix uses of nsIDocShellTreeItem in nsGlobalWindowInner::CallOnChildren. r=kmag Differential Revision: https://phabricator.services.mozilla.com/D57749
dom/base/nsGlobalWindowInner.cpp
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -5336,32 +5336,21 @@ CallState nsGlobalWindowInner::CallOnChi
 
   CallState state = CallState::Continue;
 
   nsCOMPtr<nsIDocShell> docShell = GetDocShell();
   if (!docShell) {
     return state;
   }
 
-  int32_t childCount = 0;
-  docShell->GetInProcessChildCount(&childCount);
-
-  // Take a copy of the current children so that modifications to
-  // the child list don't affect to the iteration.
-  AutoTArray<nsCOMPtr<nsIDocShellTreeItem>, 8> children;
-  for (int32_t i = 0; i < childCount; ++i) {
-    nsCOMPtr<nsIDocShellTreeItem> childShell;
-    docShell->GetInProcessChildAt(i, getter_AddRefs(childShell));
-    if (childShell) {
-      children.AppendElement(childShell);
-    }
-  }
-
-  for (nsCOMPtr<nsIDocShellTreeItem> childShell : children) {
-    nsCOMPtr<nsPIDOMWindowOuter> pWin = childShell->GetWindow();
+  BrowsingContext::Children children;
+  GetBrowsingContext()->GetChildren(children);
+
+  for (const RefPtr<BrowsingContext>& bc : children) {
+    nsCOMPtr<nsPIDOMWindowOuter> pWin = bc->GetDOMWindow();
     if (!pWin) {
       continue;
     }
 
     auto* win = nsGlobalWindowOuter::Cast(pWin);
     nsGlobalWindowInner* inner = win->GetCurrentInnerWindowInternal();
 
     // This is a bit hackish. Only freeze/suspend windows which are truly our