Bug 1699003 - Simplify initial about:blank detection in SetCurrentURI, r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D109110
This commit is contained in:
Nika Layzell 2021-03-22 18:06:49 +00:00
Родитель 6805775cc9
Коммит 79390b28ce
2 изменённых файлов: 23 добавлений и 12 удалений

Просмотреть файл

@ -1234,7 +1234,9 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
nsCOMPtr<nsIChannel> channel = doc->GetChannel();
if (channel) {
SetCurrentURI(doc->GetDocumentURI(), channel, true, 0);
SetCurrentURI(doc->GetDocumentURI(), channel,
/* aFireOnLocationChange */ true,
/* aIsInitialAboutBlank */ false, /* aLocationFlags */ 0);
mEODForCurrentDocument = false;
mIsRestoringDocument = true;
mLoadGroup->AddRequest(channel, nullptr);
@ -1477,12 +1479,14 @@ NS_IMETHODIMP
nsDocShell::SetCurrentURI(nsIURI* aURI) {
// Note that securityUI will set STATE_IS_INSECURE, even if
// the scheme of |aURI| is "https".
SetCurrentURI(aURI, nullptr, true, 0);
SetCurrentURI(aURI, nullptr, /* aFireOnLocationChange */ true,
/* aIsInitialAboutBlank */ false, /* aLocationFlags */ 0);
return NS_OK;
}
bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
bool aFireOnLocationChange,
bool aIsInitialAboutBlank,
uint32_t aLocationFlags) {
MOZ_ASSERT(!mIsBeingDestroyed);
@ -1512,11 +1516,11 @@ bool nsDocShell::SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
mHasLoadedNonBlankURI = true;
}
// Don't bother firing onLocationChange when creating a subframe's initial
// about:blank document, as this can happen when it's not safe for us to run
// script.
if (!(mLoadingEntry || mLSHE) && !mHasLoadedNonBlankURI && !aRequest &&
aLocationFlags == 0 && !mBrowsingContext->IsTop()) {
// Don't fire onLocationChange when creating a subframe's initial about:blank
// document, as this can happen when it's not safe for us to run script.
if (aIsInitialAboutBlank && !mHasLoadedNonBlankURI &&
!mBrowsingContext->IsTop()) {
MOZ_ASSERT(!aRequest && aLocationFlags == 0);
return false;
}
@ -6885,7 +6889,9 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
rv = Embed(viewer, aActor, true, false);
NS_ENSURE_SUCCESS(rv, rv);
SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
SetCurrentURI(blankDoc->GetDocumentURI(), nullptr,
/* aFireLocationChange */ true,
/* aIsInitialAboutBlank */ true, /* aLocationFlags */ 0);
rv = mIsBeingDestroyed ? NS_ERROR_NOT_AVAILABLE : NS_OK;
}
}
@ -7678,7 +7684,8 @@ nsresult nsDocShell::RestoreFromHistory() {
// origLSHE we don't have to worry about whether the entry in question
// is still mLSHE or whether it's now mOSHE.
nsCOMPtr<nsIURI> uri = origLSHE->GetURI();
SetCurrentURI(uri, document->GetChannel(), true, 0);
SetCurrentURI(uri, document->GetChannel(), /* aFireLocationChange */ true,
/* aIsInitialAboutBlank */ false, /* aLocationFlags */ 0);
}
// This is the end of our CreateContentViewer() replacement.
@ -11121,7 +11128,8 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
aCloneSHChildren ? uint32_t(LOCATION_CHANGE_SAME_DOCUMENT) : 0;
bool onLocationChangeNeeded =
SetCurrentURI(aURI, aChannel, aFireOnLocationChange, locationFlags);
SetCurrentURI(aURI, aChannel, aFireOnLocationChange,
/* aIsInitialAboutBlank */ false, locationFlags);
// Make sure to store the referrer from the channel, if any
SetupReferrerInfoFromChannel(aChannel);
return onLocationChangeNeeded;
@ -11527,7 +11535,9 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
// can't load into a docshell that is being destroyed.
if (!aEqualURIs && !mIsBeingDestroyed) {
aDocument->SetDocumentURI(aNewURI);
SetCurrentURI(aNewURI, nullptr, true, LOCATION_CHANGE_SAME_DOCUMENT);
SetCurrentURI(aNewURI, nullptr, /* aFireLocationChange */ true,
/* aIsInitialAboutBlank */ false,
LOCATION_CHANGE_SAME_DOCUMENT);
AddURIVisit(aNewURI, aCurrentURI, 0);

Просмотреть файл

@ -819,7 +819,8 @@ class nsDocShell final : public nsDocLoader,
// FireOnLocationChange is called.
// In all other cases false is returned.
bool SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
bool aFireOnLocationChange, uint32_t aLocationFlags);
bool aFireOnLocationChange, bool aIsInitialAboutBlank,
uint32_t aLocationFlags);
// The following methods deal with saving and restoring content viewers
// in session history.