Bug 1472087 - Remove nsDocShellLoadInfo::LoadTypes; r=nika

We have 2 different LoadType enums with two different values, which
have to be converted between depending on whether we're going to/from
LoadInfo/nsISHEntry/etc. We should be able to just use the same enum
everywhere and not have to deal with conversion, especially since we
don't have any type safety around the enum.

MozReview-Commit-ID: 2t9vVGLpOte
This commit is contained in:
Kyle Machulis
2018-07-02 16:32:47 -07:00
parent ad45351721
commit 712963e80a
13 changed files with 81 additions and 248 deletions

View File

@@ -709,9 +709,8 @@ nsDocShell::LoadURI(nsIURI* aURI,
originalURI = aLoadInfo->OriginalURI();
aLoadInfo->GetMaybeResultPrincipalURI(resultPrincipalURI);
loadReplace = aLoadInfo->LoadReplace();
nsDocShellLoadInfo::nsDocShellInfoLoadType lt = aLoadInfo->LoadType();
// Get the appropriate loadType from nsIDocShellLoadInfo type
loadType = ConvertDocShellInfoLoadTypeToLoadType(lt);
loadType = aLoadInfo->LoadType();
triggeringPrincipal = aLoadInfo->TriggeringPrincipal();
inheritPrincipal = aLoadInfo->InheritPrincipal();
@@ -3715,21 +3714,19 @@ nsDocShell::GetChildSHEntry(int32_t aChildOffset, nsISHEntry** aResult)
/* Get the parent's Load Type so that it can be set on the child too.
* By default give a loadHistory value
*/
uint32_t loadType = nsDocShellLoadInfo::loadHistory;
uint32_t loadType = LOAD_HISTORY;
mLSHE->GetLoadType(&loadType);
// If the user did a shift-reload on this frameset page,
// we don't want to load the subframes from history.
if (loadType == nsDocShellLoadInfo::loadReloadBypassCache ||
loadType == nsDocShellLoadInfo::loadReloadBypassProxy ||
loadType == nsDocShellLoadInfo::loadReloadBypassProxyAndCache ||
loadType == nsDocShellLoadInfo::loadRefresh) {
if (IsForceReloadType(loadType) ||
loadType == LOAD_REFRESH) {
return rv;
}
/* If the user pressed reload and the parent frame has expired
* from cache, we do not want to load the child frame from history.
*/
if (parentExpired && (loadType == nsDocShellLoadInfo::loadReloadNormal)) {
if (parentExpired && (loadType == LOAD_RELOAD_NORMAL)) {
// The parent has expired. Return null.
*aResult = nullptr;
return rv;
@@ -4230,10 +4227,10 @@ nsDocShell::LoadURIWithOptions(const char16_t* aURI,
loadType = MAKE_LOAD_TYPE(LOAD_NORMAL, aLoadFlags);
}
loadInfo->SetLoadType(ConvertLoadTypeToDocShellInfoLoadType(loadType));
loadInfo->SetLoadType(loadType);
loadInfo->SetPostDataStream(postStream);
loadInfo->SetReferrer(aReferringURI);
loadInfo->SetReferrerPolicy(aReferrerPolicy);
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
loadInfo->SetHeadersStream(aHeaderStream);
loadInfo->SetBaseURI(aBaseURI);
loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
@@ -6211,7 +6208,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
* we have in mind (15000 ms as defined by REFRESH_REDIRECT_TIMER).
* Pass a REPLACE flag to LoadURI().
*/
loadInfo->SetLoadType(nsDocShellLoadInfo::loadNormalReplace);
loadInfo->SetLoadType(LOAD_NORMAL_REPLACE);
/* for redirects we mimic HTTP, which passes the
* original referrer
@@ -6222,7 +6219,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDel
loadInfo->SetReferrer(internalReferrer);
}
} else {
loadInfo->SetLoadType(nsDocShellLoadInfo::loadRefresh);
loadInfo->SetLoadType(LOAD_REFRESH);
}
/*
@@ -7074,7 +7071,7 @@ nsDocShell::EndPageLoad(nsIWebProgress* aProgress,
// onLoadHandler tries to load something different in
// itself or one of its children, we can deal with it appropriately.
if (mLSHE) {
mLSHE->SetLoadType(nsDocShellLoadInfo::loadHistory);
mLSHE->SetLoadType(LOAD_HISTORY);
// Clear the mLSHE reference to indicate document loading is done one
// way or another.
@@ -9413,7 +9410,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Set up our loadinfo so it will do the load as much like we would have
// as possible.
loadInfo->SetReferrer(aReferrer);
loadInfo->SetReferrerPolicy(aReferrerPolicy);
loadInfo->SetReferrerPolicy((mozilla::net::ReferrerPolicy)aReferrerPolicy);
loadInfo->SetSendReferrer(!(aFlags &
INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
loadInfo->SetOriginalURI(aOriginalURI);
@@ -9425,7 +9422,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Explicit principal because we do not want any guesses as to what the
// principal to inherit is: it should be aTriggeringPrincipal.
loadInfo->SetPrincipalIsExplicit(true);
loadInfo->SetLoadType(ConvertLoadTypeToDocShellInfoLoadType(LOAD_LINK));
loadInfo->SetLoadType(LOAD_LINK);
loadInfo->SetForceAllowDataURI(aFlags & INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI);
rv = win->Open(NS_ConvertUTF8toUTF16(spec),
@@ -10940,7 +10937,7 @@ nsDocShell::DoChannelLoad(nsIChannel* aChannel,
// If the user pressed shift-reload, then do not allow ServiceWorker
// interception to occur. See step 12.1 of the SW HandleFetch algorithm.
if (IsForceReloadType(mLoadType)) {
if (IsForceReloading()) {
loadFlags |= nsIChannel::LOAD_BYPASS_SERVICE_WORKER;
}
@@ -14196,3 +14193,9 @@ nsDocShell::GetColorMatrix(uint32_t* aMatrixLen, float** aMatrix)
return NS_OK;
}
bool
nsDocShell::IsForceReloading()
{
return IsForceReloadType(mLoadType);
}