diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index eac9c1e424a1..636210ccc5b3 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13464,35 +13464,6 @@ nsCommandManager* nsDocShell::GetCommandManager() { return mCommandManager; } -NS_IMETHODIMP -nsDocShell::GetIsOnlyToplevelInTabGroup(bool* aResult) { - MOZ_ASSERT(aResult); - - nsPIDOMWindowOuter* outer = GetWindow(); - MOZ_ASSERT(outer); - - // If we are not toplevel then we are not the only toplevel window in the - // tab group. - if (outer->GetInProcessScriptableParentOrNull()) { - *aResult = false; - return NS_OK; - } - - // If we have any other toplevel windows in our tab group, then we are not - // the only toplevel window in the tab group. - nsTArray toplevelWindows = - outer->TabGroup()->GetTopLevelWindows(); - if (toplevelWindows.Length() > 1) { - *aResult = false; - return NS_OK; - } - MOZ_ASSERT(toplevelWindows.Length() == 1); - MOZ_ASSERT(toplevelWindows[0] == outer); - - *aResult = true; - return NS_OK; -} - NS_IMETHODIMP nsDocShell::GetAwaitingLargeAlloc(bool* aResult) { MOZ_ASSERT(aResult); diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 7dd8692e3427..2841d3a1abd8 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -1055,20 +1055,6 @@ interface nsIDocShell : nsIDocShellTreeItem */ [infallible] attribute nsIDocShell_MetaViewportOverride metaViewportOverride; - /** - * This value is `true` if its corresponding unit of related browsing contexts - * (TabGroup) contains only 1 toplevel window, and that window is the outer - * window corresponding to this docshell. - * - * The value is `false` otherwise. This is the case if the docshell is an - * iframe, has window.opener set, or another window with window.opener - * referring to this window exists. - * - * If this value is `false`, it would be web content visible for a load - * occuring in this docshell to be performed within a different docshell. - */ - [infallible] readonly attribute boolean isOnlyToplevelInTabGroup; - /** * Returns `true` if this docshell was created due to a Large-Allocation * header, and has not seen the initiating load yet. diff --git a/dom/base/TabGroup.cpp b/dom/base/TabGroup.cpp index 2efcbb041408..7af4257d3806 100644 --- a/dom/base/TabGroup.cpp +++ b/dom/base/TabGroup.cpp @@ -204,20 +204,6 @@ void TabGroup::MaybeDestroy() { } } -nsTArray TabGroup::GetTopLevelWindows() const { - MOZ_ASSERT(NS_IsMainThread()); - nsTArray array; - - for (nsPIDOMWindowOuter* outerWindow : mWindows) { - if (outerWindow->GetDocShell() && - !outerWindow->GetInProcessScriptableParentOrNull()) { - array.AppendElement(outerWindow); - } - } - - return array; -} - TabGroup::HashEntry::HashEntry(const nsACString* aKey) : nsCStringHashKey(aKey), mDocGroup(nullptr) {} diff --git a/dom/base/TabGroup.h b/dom/base/TabGroup.h index a8b080ad6972..0e9bc9520028 100644 --- a/dom/base/TabGroup.h +++ b/dom/base/TabGroup.h @@ -101,7 +101,6 @@ class TabGroup final : public SchedulerGroup, // Count with 'aActiveOnly' = true uint32_t Count(bool aActiveOnly = false) const; - nsTArray GetTopLevelWindows() const; const nsTArray& GetWindows() { return mWindows; } // This method is always safe to call off the main thread. The nsIEventTarget diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 6300598c88aa..a3cd66e2dcd1 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -45,6 +45,8 @@ #include "mozilla/DebugOnly.h" #include "mozilla/LoadInfo.h" #include "mozilla/dom/BlobURLProtocolHandler.h" +#include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/BrowsingContextGroup.h" #include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/CustomElementRegistry.h" @@ -9243,7 +9245,11 @@ bool nsContentUtils::AttemptLargeAllocationLoad(nsIHttpChannel* aChannel) { } nsIDocShell* docShell = outer->GetDocShell(); - if (!docShell->GetIsOnlyToplevelInTabGroup()) { + BrowsingContext* browsingContext = docShell->GetBrowsingContext(); + bool isOnlyToplevelBrowsingContext = + !browsingContext->GetParent() && + browsingContext->Group()->Toplevels().Length() == 1; + if (!isOnlyToplevelBrowsingContext) { outer->SetLargeAllocStatus(LargeAllocStatus::NOT_ONLY_TOPLEVEL_IN_TABGROUP); return false; } diff --git a/toolkit/modules/E10SUtils.jsm b/toolkit/modules/E10SUtils.jsm index 7803a4e748c5..af15de4f7202 100644 --- a/toolkit/modules/E10SUtils.jsm +++ b/toolkit/modules/E10SUtils.jsm @@ -659,11 +659,14 @@ var E10SUtils = { // to change processes, we want to load into a new process so that we can throw // this one out. We don't want to move into a new process if we have post data, // because we would accidentally throw out that data. + let isOnlyToplevelBrowsingContext = + !aDocShell.browsingContext.parent && + aDocShell.browsingContext.group.getToplevels().length == 1; if ( !aHasPostData && Services.appinfo.remoteType == LARGE_ALLOCATION_REMOTE_TYPE && !aDocShell.awaitingLargeAlloc && - aDocShell.isOnlyToplevelInTabGroup + isOnlyToplevelBrowsingContext ) { return false; }