diff --git a/accessible/android/DocAccessibleWrap.cpp b/accessible/android/DocAccessibleWrap.cpp index fd8a5ae911d6..a9331bfc39da 100644 --- a/accessible/android/DocAccessibleWrap.cpp +++ b/accessible/android/DocAccessibleWrap.cpp @@ -29,7 +29,7 @@ DocAccessibleWrap::DocAccessibleWrap(Document* aDocument, PresShell* aPresShell) nsCOMPtr treeItem(aDocument->GetDocShell()); nsCOMPtr parentTreeItem; - treeItem->GetParent(getter_AddRefs(parentTreeItem)); + treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem)); if (treeItem->ItemType() == nsIDocShellTreeItem::typeContent && (!parentTreeItem || diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index 6a9035b8f843..e87e5aae23f4 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -449,7 +449,7 @@ DocAccessible* DocManager::CreateDocOrRootAccessible(Document* aDocument) { if (!isRootDoc) { // XXXaaronl: ideally we would traverse the presshell chain. Since there's // no easy way to do that, we cheat and use the document hierarchy. - parentDocAcc = GetDocAccessible(aDocument->GetParentDocument()); + parentDocAcc = GetDocAccessible(aDocument->GetInProcessParentDocument()); NS_ASSERTION(parentDocAcc, "Can't create an accessible for the document!"); if (!parentDocAcc) return nullptr; } diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp index 2427ffaffad5..2cb83b491359 100644 --- a/accessible/base/Logging.cpp +++ b/accessible/base/Logging.cpp @@ -121,7 +121,7 @@ static void LogDocShellTree(dom::Document* aDocumentNode) { if (aDocumentNode->IsActive()) { nsCOMPtr treeItem(aDocumentNode->GetDocShell()); nsCOMPtr parentTreeItem; - treeItem->GetParent(getter_AddRefs(parentTreeItem)); + treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem)); nsCOMPtr rootTreeItem; treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem)); printf("docshell hierarchy, parent: %p, root: %p, is tab document: %s;", @@ -182,7 +182,7 @@ static void LogDocLoadGroup(dom::Document* aDocumentNode) { } static void LogDocParent(dom::Document* aDocumentNode) { - dom::Document* parentDoc = aDocumentNode->GetParentDocument(); + dom::Document* parentDoc = aDocumentNode->GetInProcessParentDocument(); printf("parent DOM document: %p", static_cast(parentDoc)); if (parentDoc) { printf(", parent acc document: %p", diff --git a/accessible/base/nsAccUtils.cpp b/accessible/base/nsAccUtils.cpp index 3ab47ea6c956..c8991b3505f7 100644 --- a/accessible/base/nsAccUtils.cpp +++ b/accessible/base/nsAccUtils.cpp @@ -511,12 +511,13 @@ bool nsAccUtils::IsARIALive(const Accessible* aAccessible) { } nsCOMPtr sameTypeParent; - docShellTreeItem->GetSameTypeParent(getter_AddRefs(sameTypeParent)); + docShellTreeItem->GetInProcessSameTypeParent( + getter_AddRefs(sameTypeParent)); if (!sameTypeParent || sameTypeParent == docShellTreeItem) { break; } - dom::Document* parentDoc = doc->GetParentDocument(); + dom::Document* parentDoc = doc->GetInProcessParentDocument(); if (!parentDoc) { break; } diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 78c3650be534..a9f364674678 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -342,7 +342,7 @@ bool nsCoreUtils::IsRootDocument(Document* aDocument) { NS_ASSERTION(docShellTreeItem, "No document shell for document!"); nsCOMPtr parentTreeItem; - docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem)); + docShellTreeItem->GetInProcessParent(getter_AddRefs(parentTreeItem)); return !parentTreeItem; } @@ -358,7 +358,7 @@ bool nsCoreUtils::IsTabDocument(Document* aDocumentNode) { nsCOMPtr treeItem(aDocumentNode->GetDocShell()); nsCOMPtr parentTreeItem; - treeItem->GetParent(getter_AddRefs(parentTreeItem)); + treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem)); // Tab document running in own process doesn't have parent. if (XRE_IsContentProcess()) return !parentTreeItem; diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index 696e14c088a8..2e2d34a12512 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -1077,10 +1077,11 @@ already_AddRefed Accessible::NativeAttributes() { if (!docShellTreeItem) break; nsCOMPtr sameTypeParent; - docShellTreeItem->GetSameTypeParent(getter_AddRefs(sameTypeParent)); + docShellTreeItem->GetInProcessSameTypeParent( + getter_AddRefs(sameTypeParent)); if (!sameTypeParent || sameTypeParent == docShellTreeItem) break; - dom::Document* parentDoc = doc->GetParentDocument(); + dom::Document* parentDoc = doc->GetInProcessParentDocument(); if (!parentDoc) break; startContent = parentDoc->FindContentForSubDocument(doc); @@ -1788,7 +1789,7 @@ Relation Accessible::RelationByType(RelationType aType) const { // Walk up the parent chain without crossing the boundary at which item // types change, preventing us from walking up out of tab content. nsCOMPtr root; - docShell->GetSameTypeRootTreeItem(getter_AddRefs(root)); + docShell->GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); if (root) { // If the item type is typeContent, we assume we are in browser tab // content. Note, this includes content such as about:addons, diff --git a/accessible/generic/DocAccessible.cpp b/accessible/generic/DocAccessible.cpp index a834e45aa428..20ff90526513 100644 --- a/accessible/generic/DocAccessible.cpp +++ b/accessible/generic/DocAccessible.cpp @@ -193,7 +193,7 @@ role DocAccessible::NativeRole() const { nsCOMPtr docShell = nsCoreUtils::GetDocShellFor(mDocumentNode); if (docShell) { nsCOMPtr sameTypeRoot; - docShell->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); + docShell->GetInProcessSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); int32_t itemType = docShell->ItemType(); if (sameTypeRoot == docShell) { // Root of content or chrome tree @@ -498,7 +498,7 @@ nsRect DocAccessible::RelativeBounds(nsIFrame** aRelativeFrame) const { bounds = scrollPort; } - document = parentDoc = document->GetParentDocument(); + document = parentDoc = document->GetInProcessParentDocument(); } return bounds; @@ -2276,7 +2276,7 @@ bool DocAccessible::IsLoadEventTarget() const { NS_ASSERTION(treeItem, "No document shell for document!"); nsCOMPtr parentTreeItem; - treeItem->GetParent(getter_AddRefs(parentTreeItem)); + treeItem->GetInProcessParent(getter_AddRefs(parentTreeItem)); // Not a root document. if (parentTreeItem) { diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 71fe7c958b5c..649d54f379d9 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -779,7 +779,7 @@ nsDocShell::LoadURI(nsDocShellLoadState* aLoadState) { void nsDocShell::MaybeHandleSubframeHistory(nsDocShellLoadState* aLoadState) { // First, verify if this is a subframe. nsCOMPtr parentAsItem; - GetSameTypeParent(getter_AddRefs(parentAsItem)); + GetInProcessSameTypeParent(getter_AddRefs(parentAsItem)); nsCOMPtr parentDS(do_QueryInterface(parentAsItem)); if (!parentDS || parentDS == static_cast(this)) { @@ -1212,7 +1212,7 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest, nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); if (root.get() == static_cast(this)) { // This is the root docshell isRoot = true; @@ -1852,7 +1852,7 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed) { // If we have no parent then we're the root docshell; no ancestor of the // original docshell doesn't have a allowfullscreen attribute, so // report fullscreen as allowed. - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (!parent) { *aFullscreenAllowed = true; return NS_OK; @@ -2215,7 +2215,7 @@ nsresult nsDocShell::Now(DOMHighResTimeStamp* aWhen) { NS_IMETHODIMP nsDocShell::SetWindowDraggingAllowed(bool aValue) { - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (!aValue && mItemType == typeChrome && !parent) { // Window dragging is always allowed for top level // chrome docshells. @@ -2230,7 +2230,7 @@ nsDocShell::GetWindowDraggingAllowed(bool* aValue) { // window dragging regions in CSS (-moz-window-drag:drag) // can be slow. Default behavior is to only allow it for // chrome top level windows. - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (mItemType == typeChrome && !parent) { // Top level chrome window *aValue = true; @@ -2244,7 +2244,7 @@ nsIDOMStorageManager* nsDocShell::TopSessionStorageManager() { nsresult rv; nsCOMPtr topItem; - rv = GetSameTypeRootTreeItem(getter_AddRefs(topItem)); + rv = GetInProcessSameTypeRootTreeItem(getter_AddRefs(topItem)); if (NS_FAILED(rv)) { return nullptr; } @@ -2462,7 +2462,7 @@ nsDocShell::GetItemType(int32_t* aItemType) { } NS_IMETHODIMP -nsDocShell::GetParent(nsIDocShellTreeItem** aParent) { +nsDocShell::GetInProcessParent(nsIDocShellTreeItem** aParent) { if (!mParent) { *aParent = nullptr; } else { @@ -2473,7 +2473,14 @@ nsDocShell::GetParent(nsIDocShellTreeItem** aParent) { return NS_OK; } -already_AddRefed nsDocShell::GetParentDocshell() { +// With Fission, related nsDocShell objects may exist in a different process. In +// that case, this method will return `nullptr`, despite a parent nsDocShell +// object existing. +// +// Prefer using `BrowsingContext::Parent()`, which will succeed even if the +// parent entry is not in the current process, and handle the case where the +// parent nsDocShell is inaccessible. +already_AddRefed nsDocShell::GetInProcessParentDocshell() { nsCOMPtr docshell = do_QueryInterface(GetAsSupports(mParent)); return docshell.forget().downcast(); } @@ -2534,7 +2541,7 @@ void nsDocShell::MaybeCreateInitialClientSource(nsIPrincipal* aPrincipal) { mInitialClientSource->DocShellExecutionReady(this); // Next, check to see if the parent is controlled. - nsCOMPtr parent = GetParentDocshell(); + nsCOMPtr parent = GetInProcessParentDocshell(); nsPIDOMWindowOuter* parentOuter = parent ? parent->GetWindow() : nullptr; nsPIDOMWindowInner* parentInner = parentOuter ? parentOuter->GetCurrentInnerWindow() : nullptr; @@ -2577,7 +2584,7 @@ Maybe nsDocShell::GetInitialClientInfo() const { void nsDocShell::RecomputeCanExecuteScripts() { bool old = mCanExecuteScripts; - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); // If we have no tree owner, that means that we've been detached from the // docshell tree (this is distinct from having no parent docshell, which @@ -2741,7 +2748,7 @@ void nsDocShell::MaybeClearStorageAccessFlag() { } NS_IMETHODIMP -nsDocShell::GetSameTypeParent(nsIDocShellTreeItem** aParent) { +nsDocShell::GetInProcessSameTypeParent(nsIDocShellTreeItem** aParent) { NS_ENSURE_ARG_POINTER(aParent); *aParent = nullptr; @@ -2784,10 +2791,10 @@ nsDocShell::GetRootTreeItem(nsIDocShellTreeItem** aRootTreeItem) { NS_ENSURE_ARG_POINTER(aRootTreeItem); RefPtr root = this; - RefPtr parent = root->GetParentDocshell(); + RefPtr parent = root->GetInProcessParentDocshell(); while (parent) { root = parent; - parent = root->GetParentDocshell(); + parent = root->GetInProcessParentDocshell(); } root.forget(aRootTreeItem); @@ -2795,17 +2802,18 @@ nsDocShell::GetRootTreeItem(nsIDocShellTreeItem** aRootTreeItem) { } NS_IMETHODIMP -nsDocShell::GetSameTypeRootTreeItem(nsIDocShellTreeItem** aRootTreeItem) { +nsDocShell::GetInProcessSameTypeRootTreeItem( + nsIDocShellTreeItem** aRootTreeItem) { NS_ENSURE_ARG_POINTER(aRootTreeItem); *aRootTreeItem = static_cast(this); nsCOMPtr parent; - NS_ENSURE_SUCCESS(GetSameTypeParent(getter_AddRefs(parent)), + NS_ENSURE_SUCCESS(GetInProcessSameTypeParent(getter_AddRefs(parent)), NS_ERROR_FAILURE); while (parent) { *aRootTreeItem = parent; NS_ENSURE_SUCCESS( - (*aRootTreeItem)->GetSameTypeParent(getter_AddRefs(parent)), + (*aRootTreeItem)->GetInProcessSameTypeParent(getter_AddRefs(parent)), NS_ERROR_FAILURE); } NS_ADDREF(*aRootTreeItem); @@ -2884,11 +2892,12 @@ bool nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, } nsCOMPtr accessingRoot; - aAccessingItem->GetSameTypeRootTreeItem(getter_AddRefs(accessingRoot)); + aAccessingItem->GetInProcessSameTypeRootTreeItem( + getter_AddRefs(accessingRoot)); nsCOMPtr accessingRootDS = do_QueryInterface(accessingRoot); nsCOMPtr targetRoot; - aTargetItem->GetSameTypeRootTreeItem(getter_AddRefs(targetRoot)); + aTargetItem->GetInProcessSameTypeRootTreeItem(getter_AddRefs(targetRoot)); nsCOMPtr targetRootDS = do_QueryInterface(targetRoot); OriginAttributes targetOA = @@ -2950,7 +2959,7 @@ bool nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem, } nsCOMPtr parent; - target->GetSameTypeParent(getter_AddRefs(parent)); + target->GetInProcessSameTypeParent(getter_AddRefs(parent)); parent.swap(target); } while (target); @@ -3027,12 +3036,12 @@ nsDocShell::FindItemWithName(const nsAString& aName, // a blank name himself. return NS_OK; } else if (aName.LowerCaseEqualsLiteral("_parent")) { - GetSameTypeParent(getter_AddRefs(foundItem)); + GetInProcessSameTypeParent(getter_AddRefs(foundItem)); if (!foundItem) { foundItem = this; } } else if (aName.LowerCaseEqualsLiteral("_top")) { - GetSameTypeRootTreeItem(getter_AddRefs(foundItem)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(foundItem)); NS_ASSERTION(foundItem, "Must have this; worst case it's us!"); } else { // Do the search for item by an actual name. @@ -3103,8 +3112,8 @@ nsresult nsDocShell::DoFindItemWithName(const nsAString& aName, } // If we have a same-type parent, respecting browser and app boundaries. - // NOTE: Could use GetSameTypeParent if the issues described in bug 1310344 - // are fixed. + // NOTE: Could use GetInProcessSameTypeParent if the issues described in + // bug 1310344 are fixed. if (!GetIsMozBrowser() && parentAsTreeItem->ItemType() == mItemType) { return parentAsTreeItem->FindItemWithName(aName, this, aOriginalRequestor, /* aSkipTabGroup = */ false, @@ -3151,7 +3160,7 @@ bool nsDocShell::IsSandboxedFrom(nsIDocShell* aTargetDocShell) { // If aTargetDocShell has an ancestor, it is not top level. nsCOMPtr ancestorOfTarget; - aTargetDocShell->GetSameTypeParent(getter_AddRefs(ancestorOfTarget)); + aTargetDocShell->GetInProcessSameTypeParent(getter_AddRefs(ancestorOfTarget)); if (ancestorOfTarget) { do { // We are not sandboxed if we are an ancestor of target. @@ -3159,7 +3168,8 @@ bool nsDocShell::IsSandboxedFrom(nsIDocShell* aTargetDocShell) { return false; } nsCOMPtr tempTreeItem; - ancestorOfTarget->GetSameTypeParent(getter_AddRefs(tempTreeItem)); + ancestorOfTarget->GetInProcessSameTypeParent( + getter_AddRefs(tempTreeItem)); tempTreeItem.swap(ancestorOfTarget); } while (ancestorOfTarget); @@ -3180,7 +3190,7 @@ bool nsDocShell::IsSandboxedFrom(nsIDocShell* aTargetDocShell) { // from our top. if (!(sandboxFlags & SANDBOXED_TOPLEVEL_NAVIGATION)) { nsCOMPtr rootTreeItem; - GetSameTypeRootTreeItem(getter_AddRefs(rootTreeItem)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(rootTreeItem)); if (SameCOMIdentity(aTargetDocShell, rootTreeItem)) { return false; } @@ -3292,7 +3302,7 @@ nsDocShell::GetIsInUnload(bool* aIsInUnload) { } NS_IMETHODIMP -nsDocShell::GetChildCount(int32_t* aChildCount) { +nsDocShell::GetInProcessChildCount(int32_t* aChildCount) { NS_ENSURE_ARG_POINTER(aChildCount); *aChildCount = mChildList.Length(); return NS_OK; @@ -3414,7 +3424,7 @@ nsDocShell::RemoveChild(nsIDocShellTreeItem* aChild) { } NS_IMETHODIMP -nsDocShell::GetChildAt(int32_t aIndex, nsIDocShellTreeItem** aChild) { +nsDocShell::GetInProcessChildAt(int32_t aIndex, nsIDocShellTreeItem** aChild) { NS_ENSURE_ARG_POINTER(aChild); #ifdef DEBUG @@ -3664,7 +3674,7 @@ nsDocShell::GetUseGlobalHistory(bool* aUseGlobalHistory) { NS_IMETHODIMP nsDocShell::RemoveFromSessionHistory() { nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); nsCOMPtr rootAsWebnav = do_QueryInterface(root); if (!rootAsWebnav) { return NS_OK; @@ -4814,7 +4824,7 @@ nsDocShell::InitSessionHistory() { // Make sure that we are the root DocShell, and set a handle to root docshell // in the session history. nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); if (root != this) { return NS_ERROR_FAILURE; } @@ -5327,7 +5337,7 @@ nsDocShell::GetVisibility(bool* aVisibility) { // would make this test meaningless. RefPtr docShell = this; - RefPtr parentItem = docShell->GetParentDocshell(); + RefPtr parentItem = docShell->GetInProcessParentDocshell(); while (parentItem) { // Null-check for crash in bug 267804 if (!parentItem->GetPresShell()) { @@ -5358,7 +5368,7 @@ nsDocShell::GetVisibility(bool* aVisibility) { } docShell = parentItem; - parentItem = docShell->GetParentDocshell(); + parentItem = docShell->GetInProcessParentDocshell(); } nsCOMPtr treeOwnerAsWin(do_QueryInterface(mTreeOwner)); @@ -5406,7 +5416,7 @@ nsDocShell::SetIsActive(bool aIsActive) { // Update orientation when the top-level browsing context becomes active. if (aIsActive) { nsCOMPtr parent; - GetSameTypeParent(getter_AddRefs(parent)); + GetInProcessSameTypeParent(getter_AddRefs(parent)); if (!parent) { // We only care about the top-level browsing context. uint16_t orientation = OrientationLock(); @@ -5556,7 +5566,7 @@ nsDocShell::SetMixedContentChannel(nsIChannel* aMixedContentChannel) { if (aMixedContentChannel) { // Get the root docshell. nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); NS_WARNING_ASSERTION(root.get() == static_cast(this), "Setting mMixedContentChannel on a docshell that is " "not the root docshell"); @@ -5594,7 +5604,7 @@ nsDocShell::GetAllowMixedContentAndConnectionData( *aIsRootDocShell = false; nsCOMPtr sameTypeRoot; - GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); NS_ASSERTION( sameTypeRoot, "No document shell root tree item from document shell tree item!"); @@ -5681,7 +5691,7 @@ nsDocShell::SetTitle(const nsAString& aTitle) { mTitleValidForCurrentURI = true; nsCOMPtr parent; - GetSameTypeParent(getter_AddRefs(parent)); + GetInProcessSameTypeParent(getter_AddRefs(parent)); // When title is set on the top object it should then be passed to the // tree owner. @@ -6730,7 +6740,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress, // Test whether this is the top frame or a subframe bool isTopFrame = true; nsCOMPtr targetParentTreeItem; - rv = GetSameTypeParent(getter_AddRefs(targetParentTreeItem)); + rv = GetInProcessSameTypeParent(getter_AddRefs(targetParentTreeItem)); if (NS_SUCCEEDED(rv) && targetParentTreeItem) { isTopFrame = false; } @@ -6774,7 +6784,7 @@ nsresult nsDocShell::EndPageLoad(nsIWebProgress* aProgress, // Parent window nsCOMPtr parentItem; - GetSameTypeParent(getter_AddRefs(parentItem)); + GetInProcessSameTypeParent(getter_AddRefs(parentItem)); if (!parentItem) { return NS_OK; } @@ -7015,7 +7025,7 @@ nsresult nsDocShell::EnsureContentViewer() { nsIPrincipal* principal = GetInheritedPrincipal(false); nsIPrincipal* storagePrincipal = GetInheritedPrincipal(false, true); nsCOMPtr parentItem; - GetSameTypeParent(getter_AddRefs(parentItem)); + GetInProcessSameTypeParent(getter_AddRefs(parentItem)); if (parentItem) { if (nsCOMPtr domWin = GetWindow()) { nsCOMPtr parentElement = domWin->GetFrameElementInternal(); @@ -7266,7 +7276,7 @@ bool nsDocShell::CanSavePresentation(uint32_t aLoadType, // Don't cache the content viewer if we're in a subframe. nsCOMPtr root; - GetSameTypeParent(getter_AddRefs(root)); + GetInProcessSameTypeParent(getter_AddRefs(root)); if (root && root != this) { return false; // this is a subframe load } @@ -7902,7 +7912,7 @@ nsresult nsDocShell::RestoreFromHistory() { } if (document) { - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (parent) { RefPtr d = parent->GetDocument(); if (d) { @@ -8314,7 +8324,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType, RefPtr newDoc = viewer->GetDocument(); - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); nsCOMPtr parentPrincipal = parent->GetDocument()->NodePrincipal(); nsCOMPtr thisPrincipal = newDoc->NodePrincipal(); @@ -8445,7 +8455,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) { DoGetPositionAndSize(&x, &y, &cx, &cy); nsCOMPtr parentAsItem; - NS_ENSURE_SUCCESS(GetSameTypeParent(getter_AddRefs(parentAsItem)), + NS_ENSURE_SUCCESS(GetInProcessSameTypeParent(getter_AddRefs(parentAsItem)), NS_ERROR_FAILURE); nsCOMPtr parent(do_QueryInterface(parentAsItem)); @@ -8642,7 +8652,7 @@ nsresult nsDocShell::CheckLoadingPermissions() { } nsCOMPtr tmp; - item->GetSameTypeParent(getter_AddRefs(tmp)); + item->GetInProcessSameTypeParent(getter_AddRefs(tmp)); item.swap(tmp); } while (item); @@ -9440,7 +9450,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, // If this docshell is owned by a frameloader, make sure to cancel // possible frameloader initialization before loading a new page. - nsCOMPtr parent = GetParentDocshell(); + nsCOMPtr parent = GetInProcessParentDocshell(); if (parent) { RefPtr doc = parent->GetDocument(); if (doc) { @@ -9628,7 +9638,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, if (OrientationLock() != hal::eScreenOrientation_None) { #ifdef DEBUG nsCOMPtr parent; - GetSameTypeParent(getter_AddRefs(parent)); + GetInProcessSameTypeParent(getter_AddRefs(parent)); MOZ_ASSERT(!parent); #endif SetOrientationLock(hal::eScreenOrientation_None); @@ -9781,7 +9791,7 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal( if (!document) { nsCOMPtr parentItem; - GetSameTypeParent(getter_AddRefs(parentItem)); + GetInProcessSameTypeParent(getter_AddRefs(parentItem)); if (parentItem) { document = parentItem->GetDocument(); } @@ -11575,7 +11585,7 @@ nsresult nsDocShell::AddToSessionHistory( // Get a handle to the root docshell nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); /* * If this is a LOAD_FLAGS_REPLACE_HISTORY in a subframe, we use * the existing SH entry in the page and replace the url and @@ -11969,7 +11979,7 @@ void nsDocShell::SetHistoryEntry(nsCOMPtr* aPtr, nsCOMPtr oldRootEntry = nsSHistory::GetRootSHEntry(*aPtr); if (oldRootEntry) { nsCOMPtr rootAsItem; - GetSameTypeRootTreeItem(getter_AddRefs(rootAsItem)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(rootAsItem)); nsCOMPtr rootShell = do_QueryInterface(rootAsItem); if (rootShell) { // if we're the root just set it, nothing to swap nsSHistory::SwapEntriesData data = {this, newRootEntry}; @@ -11991,7 +12001,7 @@ void nsDocShell::SetHistoryEntry(nsCOMPtr* aPtr, already_AddRefed nsDocShell::GetRootSessionHistory() { nsCOMPtr root; - nsresult rv = GetSameTypeRootTreeItem(getter_AddRefs(root)); + nsresult rv = GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); if (NS_WARN_IF(NS_FAILED(rv))) { return nullptr; } @@ -12503,7 +12513,7 @@ NS_IMETHODIMP nsDocShell::GetTopWindow(mozIDOMWindowProxy** aWindow) { nsCOMPtr win = GetWindow(); if (win) { - win = win->GetTop(); + win = win->GetInProcessTop(); } win.forget(aWindow); return NS_OK; @@ -12517,7 +12527,7 @@ nsDocShell::GetTopFrameElement(Element** aElement) { return NS_OK; } - nsCOMPtr top = win->GetScriptableTop(); + nsCOMPtr top = win->GetInProcessScriptableTop(); NS_ENSURE_TRUE(top, NS_ERROR_FAILURE); // GetFrameElementInternal, /not/ GetScriptableFrameElement -- if |top| is @@ -12546,7 +12556,7 @@ nsDocShell::GetUseTrackingProtection(bool* aUseTrackingProtection) { return NS_OK; } - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (parent) { return parent->GetUseTrackingProtection(aUseTrackingProtection); } @@ -13175,7 +13185,7 @@ uint32_t nsDocShell::GetInheritedFrameType() { } nsCOMPtr parentAsItem; - GetSameTypeParent(getter_AddRefs(parentAsItem)); + GetInProcessSameTypeParent(getter_AddRefs(parentAsItem)); nsCOMPtr parent = do_QueryInterface(parentAsItem); if (!parent) { @@ -13219,7 +13229,7 @@ NS_IMETHODIMP nsDocShell::GetIsTopLevelContentDocShell( if (mItemType == typeContent) { nsCOMPtr root; - GetSameTypeRootTreeItem(getter_AddRefs(root)); + GetInProcessSameTypeRootTreeItem(getter_AddRefs(root)); *aIsTopLevelContentDocShell = root.get() == static_cast(this); } @@ -13279,7 +13289,7 @@ bool nsDocShell::ServiceWorkerAllowedToControlWindow(nsIPrincipal* aPrincipal, } nsCOMPtr parent; - GetSameTypeParent(getter_AddRefs(parent)); + GetInProcessSameTypeParent(getter_AddRefs(parent)); nsPIDOMWindowOuter* parentOuter = parent ? parent->GetWindow() : nullptr; nsPIDOMWindowInner* parentInner = parentOuter ? parentOuter->GetCurrentInnerWindow() : nullptr; @@ -13403,14 +13413,14 @@ nsDocShell::GetAsyncPanZoomEnabled(bool* aOut) { } bool nsDocShell::HasUnloadedParent() { - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); while (parent) { bool inUnload = false; parent->GetIsInUnload(&inUnload); if (inUnload) { return true; } - parent = parent->GetParentDocshell(); + parent = parent->GetInProcessParentDocshell(); } return false; } @@ -13519,7 +13529,7 @@ bool nsDocShell::InFrameSwap() { if (shell->mInFrameSwap) { return true; } - shell = shell->GetParentDocshell(); + shell = shell->GetInProcessParentDocshell(); } while (shell); return false; } @@ -13574,7 +13584,7 @@ nsDocShell::GetIsOnlyToplevelInTabGroup(bool* aResult) { // If we are not toplevel then we are not the only toplevel window in the // tab group. - if (outer->GetScriptableParentOrNull()) { + if (outer->GetInProcessScriptableParentOrNull()) { *aResult = false; return NS_OK; } diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index f8414d05e017..44ffc3937736 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -328,7 +328,7 @@ class nsDocShell final : public nsDocLoader, // background loading, it triggers the parent docshell to see if the parent // document can fire load event earlier. void TriggerParentCheckDocShellIsEmpty() { - RefPtr parent = GetParentDocshell(); + RefPtr parent = GetInProcessParentDocshell(); if (parent) { parent->DocLoaderIsEmpty(true); } @@ -934,7 +934,7 @@ class nsDocShell final : public nsDocLoader, nsIDocShellTreeItem** aResult); // Convenience method for getting our parent docshell. Can return null - already_AddRefed GetParentDocshell(); + already_AddRefed GetInProcessParentDocshell(); // Helper assertion to enforce that mInPrivateBrowsing is in sync with // OriginAttributes.mPrivateBrowsingId diff --git a/docshell/base/nsDocShellEnumerator.cpp b/docshell/base/nsDocShellEnumerator.cpp index a1404594f474..ecb747be860c 100644 --- a/docshell/base/nsDocShellEnumerator.cpp +++ b/docshell/base/nsDocShellEnumerator.cpp @@ -122,14 +122,14 @@ nsresult nsDocShellForwardsEnumerator::BuildArrayRecursive( } int32_t numChildren; - rv = aItem->GetChildCount(&numChildren); + rv = aItem->GetInProcessChildCount(&numChildren); if (NS_FAILED(rv)) { return rv; } for (int32_t i = 0; i < numChildren; ++i) { nsCOMPtr curChild; - rv = aItem->GetChildAt(i, getter_AddRefs(curChild)); + rv = aItem->GetInProcessChildAt(i, getter_AddRefs(curChild)); if (NS_FAILED(rv)) { return rv; } @@ -148,14 +148,14 @@ nsresult nsDocShellBackwardsEnumerator::BuildArrayRecursive( nsresult rv; int32_t numChildren; - rv = aItem->GetChildCount(&numChildren); + rv = aItem->GetInProcessChildCount(&numChildren); if (NS_FAILED(rv)) { return rv; } for (int32_t i = numChildren - 1; i >= 0; --i) { nsCOMPtr curChild; - rv = aItem->GetChildAt(i, getter_AddRefs(curChild)); + rv = aItem->GetInProcessChildAt(i, getter_AddRefs(curChild)); if (NS_FAILED(rv)) { return rv; } diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index 602565d84770..62f3c081f346 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -1223,7 +1223,7 @@ bool ChromeTooltipListener::WebProgressShowedTooltip( // alive here. So we use the document hierarchy instead: Document* document = lastUsed->GetDocument(); if (document) { - document = document->GetParentDocument(); + document = document->GetInProcessParentDocument(); } if (!document) { break; diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index 507980e65e42..3f44233fd7ca 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -779,12 +779,16 @@ interface nsIDocShell : nsIDocShellTreeItem /** * Like nsIDocShellTreeItem::GetSameTypeParent, except this ignores