Bug 1682285 - Part 2: Track LOAD_FLAGS_FROM_EXTERNAL separately from LOAD_TYPE, r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D103365
This commit is contained in:
Nika Layzell 2021-01-29 22:06:36 +00:00
Родитель 29c2d4d113
Коммит bbaf7fbc65
3 изменённых файлов: 10 добавлений и 21 удалений

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

@ -235,9 +235,6 @@ static void LogShellLoadType(nsIDocShell* aDocShell) {
case LOAD_NORMAL_REPLACE:
printf("normal replace; ");
break;
case LOAD_NORMAL_EXTERNAL:
printf("normal external; ");
break;
case LOAD_HISTORY:
printf("history; ");
break;

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

@ -1047,8 +1047,7 @@ bool nsDocShell::MaybeHandleSubframeHistory(
// This is a newly created frame. Check for exception cases first.
// By default the subframe will inherit the parent's loadType.
if (aLoadState->LoadIsFromSessionHistory() &&
(parentLoadType == LOAD_NORMAL || parentLoadType == LOAD_LINK ||
parentLoadType == LOAD_NORMAL_EXTERNAL)) {
(parentLoadType == LOAD_NORMAL || parentLoadType == LOAD_LINK)) {
// The parent was loaded normally. In this case, this *brand new*
// child really shouldn't have a SHEntry. If it does, it could be
// because the parent is replacing an existing frame with a new frame,
@ -9228,7 +9227,7 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
{
bool inherits;
if (aLoadState->LoadType() != LOAD_NORMAL_EXTERNAL &&
if (!aLoadState->HasLoadFlags(LOAD_FLAGS_FROM_EXTERNAL) &&
!aLoadState->PrincipalToInherit() &&
(aLoadState->HasInternalLoadFlags(
INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL)) &&
@ -9253,7 +9252,9 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
}
// Before going any further vet loads initiated by external programs.
if (aLoadState->LoadType() == LOAD_NORMAL_EXTERNAL) {
if (aLoadState->HasLoadFlags(LOAD_FLAGS_FROM_EXTERNAL)) {
MOZ_DIAGNOSTIC_ASSERT(aLoadState->LoadType() == LOAD_NORMAL);
// Disallow external chrome: loads targetted at content windows
if (SchemeIsChrome(aLoadState->URI())) {
NS_WARNING("blocked external chrome: url -- use '--chrome' option");
@ -9265,10 +9266,6 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
// reset loadType so we don't have to add lots of tests for
// LOAD_NORMAL_EXTERNAL after this point
aLoadState->SetLoadType(LOAD_NORMAL);
}
mAllowKeywordFixup = aLoadState->HasInternalLoadFlags(
@ -9687,8 +9684,8 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
if (aLoadState->PrincipalToInherit()) {
aLoadInfo->SetPrincipalToInherit(aLoadState->PrincipalToInherit());
}
aLoadInfo->SetLoadTriggeredFromExternal(aLoadState->LoadType() ==
LOAD_NORMAL_EXTERNAL);
aLoadInfo->SetLoadTriggeredFromExternal(
aLoadState->HasLoadFlags(LOAD_FLAGS_FROM_EXTERNAL));
aLoadInfo->SetForceAllowDataURI(aLoadState->HasInternalLoadFlags(
INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI));
aLoadInfo->SetOriginalFrameSrcLoad(
@ -10287,8 +10284,6 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
// or also the load originates from external, then we pass that information on
// to the loadinfo, which allows e.g. setting Sec-Fetch-User request headers.
if (aLoadState->HasValidUserGestureActivation() ||
// FIXME: This code was reading an external load flag value from the
// internal load flag state!
aLoadState->HasLoadFlags(LOAD_FLAGS_FROM_EXTERNAL)) {
loadInfo->SetHasValidUserGestureActivation(true);
}

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

@ -28,8 +28,9 @@
* above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would
* just shift them out anyway.
*/
# define EXTRA_LOAD_FLAGS \
(nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD | \
# define EXTRA_LOAD_FLAGS \
(nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL | \
nsIWebNavigation::LOAD_FLAGS_FIRST_LOAD | \
nsIWebNavigation::LOAD_FLAGS_ALLOW_POPUPS | 0xffff0000)
/* load types are legal combinations of load commands and flags
@ -44,8 +45,6 @@ enum LoadType : uint32_t {
LOAD_NORMAL_REPLACE =
MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
LOAD_NORMAL_EXTERNAL = MAKE_LOAD_TYPE(
nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_FROM_EXTERNAL),
LOAD_HISTORY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_HISTORY,
nsIWebNavigation::LOAD_FLAGS_NONE),
LOAD_NORMAL_BYPASS_CACHE = MAKE_LOAD_TYPE(
@ -131,7 +130,6 @@ static inline bool IsValidLoadType(uint32_t aLoadType) {
switch (aLoadType) {
case LOAD_NORMAL:
case LOAD_NORMAL_REPLACE:
case LOAD_NORMAL_EXTERNAL:
case LOAD_NORMAL_BYPASS_CACHE:
case LOAD_NORMAL_BYPASS_PROXY:
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
@ -168,7 +166,6 @@ static inline nsDOMNavigationTiming::Type ConvertLoadTypeToNavigationType(
auto result = nsDOMNavigationTiming::TYPE_RESERVED;
switch (aLoadType) {
case LOAD_NORMAL:
case LOAD_NORMAL_EXTERNAL:
case LOAD_NORMAL_BYPASS_CACHE:
case LOAD_NORMAL_BYPASS_PROXY:
case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE: