Bug 1843968 - Hold some strong references. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D184803
This commit is contained in:
Peter Van der Beken
2023-08-01 12:09:36 +00:00
parent c4082a8494
commit 9ec5838ef5
20 changed files with 101 additions and 64 deletions

View File

@@ -1933,7 +1933,8 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
aLoadState->AssertProcessCouldTriggerLoadIfSystem();
if (mDocShell) {
return mDocShell->LoadURI(aLoadState, aSetNavigating);
nsCOMPtr<nsIDocShell> docShell = mDocShell;
return docShell->LoadURI(aLoadState, aSetNavigating);
}
// Note: We do this check both here and in `nsDocShell::InternalLoad`, since
@@ -2030,7 +2031,8 @@ nsresult BrowsingContext::InternalLoad(nsDocShellLoadState* aLoadState) {
aLoadState->AssertProcessCouldTriggerLoadIfSystem();
if (mDocShell) {
return nsDocShell::Cast(mDocShell)->InternalLoad(aLoadState);
RefPtr<nsDocShell> docShell = nsDocShell::Cast(mDocShell);
return docShell->InternalLoad(aLoadState);
}
// Note: We do this check both here and in `nsDocShell::InternalLoad`, since
@@ -2092,9 +2094,10 @@ void BrowsingContext::DisplayLoadError(const nsAString& aURI) {
if (mDocShell) {
bool didDisplayLoadError = false;
mDocShell->DisplayLoadError(NS_ERROR_MALFORMED_URI, nullptr,
PromiseFlatString(aURI).get(), nullptr,
&didDisplayLoadError);
nsCOMPtr<nsIDocShell> docShell = mDocShell;
docShell->DisplayLoadError(NS_ERROR_MALFORMED_URI, nullptr,
PromiseFlatString(aURI).get(), nullptr,
&didDisplayLoadError);
} else {
if (ContentParent* cp = Canonical()->GetContentParent()) {
Unused << cp->SendDisplayLoadError(this, PromiseFlatString(aURI));
@@ -3681,7 +3684,8 @@ void BrowsingContext::HistoryGo(
[](mozilla::ipc::
ResponseRejectReason) { /* FIXME Is ignoring this fine? */ });
} else {
aResolver(Canonical()->HistoryGo(
RefPtr<CanonicalBrowsingContext> self = Canonical();
aResolver(self->HistoryGo(
aOffset, aHistoryEpoch, aRequireUserInteraction, aUserActivation,
Canonical()->GetContentParent()
? Some(Canonical()->GetContentParent()->ChildID())