Bug 1472087 - Remove nsDocShellLoadInfo::LoadTypes; r=nika draft
authorKyle Machulis <kyle@nonpolynomial.com>
Mon, 02 Jul 2018 16:32:47 -0700
changeset 817137 cddfcd24b6249830831bb4795db60a5c9794ecbe
parent 817136 a60cfe83f03ff1c176180bff788a1892ba9c8acc
child 817138 de81424e7c37e39161529ee85bf4c88b2f3e4697
push id115963
push userbmo:kyle@nonpolynomial.com
push dateThu, 12 Jul 2018 03:10:30 +0000
reviewersnika
bugs1472087
milestone63.0a1
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
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsDocShellLoadInfo.cpp
docshell/base/nsDocShellLoadInfo.h
docshell/base/nsDocShellLoadTypes.h
docshell/shistory/nsISHEntry.idl
docshell/shistory/nsSHEntry.cpp
docshell/shistory/nsSHistory.cpp
dom/base/Location.cpp
dom/base/nsDocument.cpp
dom/clients/manager/ClientNavigateOpChild.cpp
toolkit/components/viewsource/content/viewSource-content.js
toolkit/modules/sessionstore/SessionHistory.jsm
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -704,19 +704,18 @@ nsDocShell::LoadURI(nsIURI* aURI,
   }
 
   // Extract the info from the DocShellLoadInfo struct...
   if (aLoadInfo) {
     referrer = aLoadInfo->Referrer();
     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();
     principalIsExplicit = aLoadInfo->PrincipalIsExplicit();
     shEntry = aLoadInfo->SHEntry();
     aLoadInfo->GetTarget(target);
     postStream = aLoadInfo->PostDataStream();
     headersStream = aLoadInfo->HeadersStream();
@@ -3710,31 +3709,29 @@ nsDocShell::GetChildSHEntry(int32_t aChi
      * loaded from history in certain situations.
      */
     bool parentExpired = false;
     mLSHE->GetExpirationStatus(&parentExpired);
 
     /* 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;
     }
 
     nsCOMPtr<nsISHContainer> container(do_QueryInterface(mLSHE));
     if (container) {
       // Get the child subframe from session history.
@@ -4225,20 +4222,20 @@ nsDocShell::LoadURIWithOptions(const cha
    */
   uint32_t loadType;
   if (aLoadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
     loadType = MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags);
   } else {
     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);
   loadInfo->SetForceAllowDataURI(forceAllowDataURI);
 
   if (fixupInfo) {
     nsAutoString searchProvider, keyword;
     fixupInfo->GetKeywordProviderName(searchProvider);
@@ -6206,28 +6203,28 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI
   bool equalUri = false;
   nsresult rv = aURI->Equals(mCurrentURI, &equalUri);
   if (NS_SUCCEEDED(rv) && (!equalUri) && aMetaRefresh &&
       aDelay <= REFRESH_REDIRECT_TIMER) {
     /* It is a META refresh based redirection within the threshold time
      * 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
      */
     nsCOMPtr<nsIURI> internalReferrer;
     GetReferringURI(getter_AddRefs(internalReferrer));
     if (internalReferrer) {
       loadInfo->SetReferrer(internalReferrer);
     }
   } else {
-    loadInfo->SetLoadType(nsDocShellLoadInfo::loadRefresh);
+    loadInfo->SetLoadType(LOAD_REFRESH);
   }
 
   /*
    * LoadURI(...) will cancel all refresh timers... This causes the
    * Timer and its refreshData instance to be released...
    */
   LoadURI(aURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL, true);
 
@@ -7069,17 +7066,17 @@ nsDocShell::EndPageLoad(nsIWebProgress* 
       mLSHE->SetSaveLayoutStateFlag(false);
     }
   }
 
   // Clear mLSHE after calling the onLoadHandlers. This way, if the
   // 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.
     SetHistoryEntry(&mLSHE, nullptr);
   }
   // if there's a refresh header in the channel, this method
   // will set it up for us.
   if (mIsActive || !mDisableMetaRefreshWhenInactive)
@@ -9410,29 +9407,29 @@ nsDocShell::InternalLoad(nsIURI* aURI,
         MOZ_ASSERT(!aSHEntry);
         MOZ_ASSERT(aFirstParty); // Windowwatcher will assume this.
 
         RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
         // 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);
         loadInfo->SetMaybeResultPrincipalURI(aResultPrincipalURI);
         loadInfo->SetLoadReplace(aLoadReplace);
         loadInfo->SetTriggeringPrincipal(aTriggeringPrincipal);
         loadInfo->SetInheritPrincipal(
           aFlags & INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL);
         // 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),
                        aWindowTarget, // window name
                        EmptyString(), // Features
                        loadInfo,
                        true, // aForceNoOpener
                        getter_AddRefs(newWin));
@@ -10929,17 +10926,17 @@ nsDocShell::DoChannelLoad(nsIChannel* aC
   }
 
   if (!aBypassClassifier) {
     loadFlags |= nsIChannel::LOAD_CLASSIFY_URI;
   }
 
   // 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;
   }
 
   (void)aChannel->SetLoadFlags(loadFlags);
 
   uint32_t openFlags = 0;
   if (mLoadType == LOAD_LINK) {
     openFlags |= nsIURILoader::IS_CONTENT_PREFERRED;
@@ -14194,8 +14191,14 @@ nsDocShell::GetColorMatrix(uint32_t* aMa
 
     MOZ_ASSERT(20 * sizeof(float) == sizeof(mColorMatrix->components));
     *aMatrixLen = 20;
     memcpy(*aMatrix, mColorMatrix->components, 20 * sizeof(float));
   }
 
   return NS_OK;
 }
+
+bool
+nsDocShell::IsForceReloading()
+{
+  return IsForceReloadType(mLoadType);
+}
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -370,16 +370,20 @@ public:
                           nsIPrincipal* aLoadingPrincipal,
                           bool aInPrivateBrowsing);
 
   static nsDocShell* Cast(nsIDocShell* aDocShell)
   {
     return static_cast<nsDocShell*>(aDocShell);
   }
 
+  // Returns true if the current load is a force reload (started by holding
+  // shift while triggering reload)
+  bool IsForceReloading();
+
 private: // member functions
   friend class nsDSURIContentListener;
   friend class FramingChecker;
   friend class OnLinkClickEvent;
 
   // It is necessary to allow adding a timeline marker wherever a docshell
   // instance is available. This operation happens frequently and needs to
   // be very fast, so instead of using a Map or having to search for some
--- a/docshell/base/nsDocShellLoadInfo.cpp
+++ b/docshell/base/nsDocShellLoadInfo.cpp
@@ -22,17 +22,17 @@ nsDocShellLoadInfo::nsDocShellLoadInfo()
   : mResultPrincipalURIIsSome(false)
   , mLoadReplace(false)
   , mInheritPrincipal(false)
   , mPrincipalIsExplicit(false)
   , mForceAllowDataURI(false)
   , mOriginalFrameSrc(false)
   , mSendReferrer(true)
   , mReferrerPolicy(mozilla::net::RP_Unset)
-  , mLoadType(nsDocShellLoadInfo::loadNormal)
+  , mLoadType(LOAD_NORMAL)
   , mIsSrcdocLoad(false)
 {
 }
 
 nsDocShellLoadInfo::~nsDocShellLoadInfo()
 {
 }
 
@@ -151,24 +151,24 @@ nsDocShellLoadInfo::OriginalFrameSrc() c
 }
 
 void
 nsDocShellLoadInfo::SetOriginalFrameSrc(bool aOriginalFrameSrc)
 {
   mOriginalFrameSrc = aOriginalFrameSrc;
 }
 
-nsDocShellLoadInfo::nsDocShellInfoLoadType
+uint32_t
 nsDocShellLoadInfo::LoadType() const
 {
   return mLoadType;
 }
 
 void
-nsDocShellLoadInfo::SetLoadType(nsDocShellLoadInfo::nsDocShellInfoLoadType aLoadType)
+nsDocShellLoadInfo::SetLoadType(uint32_t aLoadType)
 {
   mLoadType = aLoadType;
 }
 
 nsISHEntry*
 nsDocShellLoadInfo::SHEntry() const
 {
   return mSHEntry;
--- a/docshell/base/nsDocShellLoadInfo.h
+++ b/docshell/base/nsDocShellLoadInfo.h
@@ -5,53 +5,26 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDocShellLoadInfo_h__
 #define nsDocShellLoadInfo_h__
 
 // Helper Classes
 #include "nsCOMPtr.h"
 #include "nsString.h"
+#include "nsDocShellLoadTypes.h"
 
 class nsIInputStream;
 class nsISHEntry;
 class nsIURI;
 class nsIDocShell;
 
 class nsDocShellLoadInfo
 {
 public:
-  typedef uint32_t nsDocShellInfoLoadType;
-
-  enum LoadType: uint32_t {
-    loadNormal = 0,                     // Normal Load
-    loadNormalReplace = 1,              // Normal Load but replaces current history slot
-    loadHistory = 2,                    // Load from history
-    loadReloadNormal = 3,               // Reload
-    loadReloadBypassCache = 4,
-    loadReloadBypassProxy = 5,
-    loadReloadBypassProxyAndCache = 6,
-    loadLink = 7,
-    loadRefresh = 8,
-    loadReloadCharsetChange = 9,
-    loadBypassHistory = 10,
-    loadStopContent = 11,
-    loadStopContentAndReplace = 12,
-    loadNormalExternal = 13,
-    loadNormalBypassCache = 14,
-    loadNormalBypassProxy = 15,
-    loadNormalBypassProxyAndCache = 16,
-    loadPushState = 17,                 // history.pushState or replaceState
-    loadReplaceBypassCache = 18,
-    loadReloadMixedContent = 19,
-    loadNormalAllowMixedContent = 20,
-    loadReloadCharsetChangeBypassCache = 21,
-    loadReloadCharsetChangeBypassProxyAndCache = 22
-  };
-
   NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadInfo);
 
   nsDocShellLoadInfo();
 
   nsIURI* Referrer() const;
 
   void SetReferrer(nsIURI* aReferrer);
 
@@ -86,19 +59,19 @@ public:
   bool ForceAllowDataURI() const;
 
   void SetForceAllowDataURI(bool aForceAllowDataURI);
 
   bool OriginalFrameSrc() const;
 
   void SetOriginalFrameSrc(bool aOriginalFrameSrc);
 
-  nsDocShellInfoLoadType LoadType() const;
+  uint32_t LoadType() const;
 
-  void SetLoadType(nsDocShellInfoLoadType aLoadType);
+  void SetLoadType(uint32_t aLoadType);
 
   nsISHEntry* SHEntry() const;
 
   void SetSHEntry(nsISHEntry* aSHEntry);
 
   void GetTarget(nsAString& aTarget) const;
 
   void SetTarget(const nsAString& aTarget);
@@ -150,17 +123,17 @@ protected:
   bool mResultPrincipalURIIsSome;
   bool mLoadReplace;
   bool mInheritPrincipal;
   bool mPrincipalIsExplicit;
   bool mForceAllowDataURI;
   bool mOriginalFrameSrc;
   bool mSendReferrer;
   mozilla::net::ReferrerPolicy mReferrerPolicy;
-  nsDocShellInfoLoadType mLoadType;
+  uint32_t mLoadType;
   nsCOMPtr<nsISHEntry> mSHEntry;
   nsString mTarget;
   nsCOMPtr<nsIInputStream> mPostDataStream;
   nsCOMPtr<nsIInputStream> mHeadersStream;
   bool mIsSrcdocLoad;
   nsString mSrcdocData;
   nsCOMPtr<nsIDocShell> mSourceDocShell;
   nsCOMPtr<nsIURI> mBaseURI;
--- a/docshell/base/nsDocShellLoadTypes.h
+++ b/docshell/base/nsDocShellLoadTypes.h
@@ -34,17 +34,17 @@
                           0xffff0000)
 
 /* load types are legal combinations of load commands and flags
  *
  * NOTE:
  *  Remember to update the IsValidLoadType function below if you change this
  *  enum to ensure bad flag combinations will be rejected.
  */
-enum LoadType
+enum LoadType : uint32_t
 {
   LOAD_NORMAL = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_NONE),
   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(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
   LOAD_NORMAL_BYPASS_PROXY = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
   LOAD_NORMAL_BYPASS_PROXY_AND_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE | nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY),
@@ -71,16 +71,28 @@ enum LoadType
    */
   LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL,
                                    LOAD_FLAGS_ERROR_PAGE)
 
   // NOTE: Adding a new value? Remember to update IsValidLoadType!
 };
 
 static inline bool
+IsForceReloadType(uint32_t aLoadType) {
+  switch (aLoadType) {
+    case LOAD_RELOAD_BYPASS_CACHE:
+    case LOAD_RELOAD_BYPASS_PROXY:
+    case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
+    case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
+      return true;
+  }
+  return false;
+}
+
+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:
@@ -103,192 +115,16 @@ IsValidLoadType(uint32_t aLoadType)
     case LOAD_PUSHSTATE:
     case LOAD_REPLACE_BYPASS_CACHE:
     case LOAD_ERROR_PAGE:
       return true;
   }
   return false;
 }
 
-static inline bool
-IsForceReloadType(uint32_t aLoadType) {
-  switch (aLoadType) {
-    case LOAD_RELOAD_BYPASS_CACHE:
-    case LOAD_RELOAD_BYPASS_PROXY:
-    case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
-    case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
-      return true;
-  }
-  return false;
-}
-
-static inline nsDocShellLoadInfo::nsDocShellInfoLoadType
-ConvertLoadTypeToDocShellInfoLoadType(uint32_t aLoadType)
-{
-  nsDocShellLoadInfo::nsDocShellInfoLoadType docShellLoadType = nsDocShellLoadInfo::loadNormal;
-  switch (aLoadType) {
-    case LOAD_NORMAL:
-      docShellLoadType = nsDocShellLoadInfo::loadNormal;
-      break;
-    case LOAD_NORMAL_REPLACE:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalReplace;
-      break;
-    case LOAD_NORMAL_EXTERNAL:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalExternal;
-      break;
-    case LOAD_NORMAL_BYPASS_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassCache;
-      break;
-    case LOAD_NORMAL_BYPASS_PROXY:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassProxy;
-      break;
-    case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassProxyAndCache;
-      break;
-    case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
-      docShellLoadType = nsDocShellLoadInfo::loadNormalAllowMixedContent;
-      break;
-    case LOAD_HISTORY:
-      docShellLoadType = nsDocShellLoadInfo::loadHistory;
-      break;
-    case LOAD_RELOAD_NORMAL:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadNormal;
-      break;
-    case LOAD_RELOAD_CHARSET_CHANGE:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChange;
-      break;
-    case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChangeBypassCache;
-      break;
-    case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache;
-      break;
-    case LOAD_RELOAD_BYPASS_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassCache;
-      break;
-    case LOAD_RELOAD_BYPASS_PROXY:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassProxy;
-      break;
-    case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassProxyAndCache;
-      break;
-    case LOAD_LINK:
-      docShellLoadType = nsDocShellLoadInfo::loadLink;
-      break;
-    case LOAD_REFRESH:
-      docShellLoadType = nsDocShellLoadInfo::loadRefresh;
-      break;
-    case LOAD_BYPASS_HISTORY:
-    case LOAD_ERROR_PAGE:
-      docShellLoadType = nsDocShellLoadInfo::loadBypassHistory;
-      break;
-    case LOAD_STOP_CONTENT:
-      docShellLoadType = nsDocShellLoadInfo::loadStopContent;
-      break;
-    case LOAD_STOP_CONTENT_AND_REPLACE:
-      docShellLoadType = nsDocShellLoadInfo::loadStopContentAndReplace;
-      break;
-    case LOAD_PUSHSTATE:
-      docShellLoadType = nsDocShellLoadInfo::loadPushState;
-      break;
-    case LOAD_REPLACE_BYPASS_CACHE:
-      docShellLoadType = nsDocShellLoadInfo::loadReplaceBypassCache;
-      break;
-    case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
-      docShellLoadType = nsDocShellLoadInfo::loadReloadMixedContent;
-      break;
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unexpected load type value");
-  }
-
-  return docShellLoadType;
-}
-
-static inline uint32_t
-ConvertDocShellInfoLoadTypeToLoadType(nsDocShellLoadInfo::nsDocShellInfoLoadType aDocShellLoadType)
-{
-  uint32_t loadType = LOAD_NORMAL;
-
-  switch (aDocShellLoadType) {
-    case nsDocShellLoadInfo::loadNormal:
-      loadType = LOAD_NORMAL;
-      break;
-    case nsDocShellLoadInfo::loadNormalReplace:
-      loadType = LOAD_NORMAL_REPLACE;
-      break;
-    case nsDocShellLoadInfo::loadNormalExternal:
-      loadType = LOAD_NORMAL_EXTERNAL;
-      break;
-    case nsDocShellLoadInfo::loadHistory:
-      loadType = LOAD_HISTORY;
-      break;
-    case nsDocShellLoadInfo::loadNormalBypassCache:
-      loadType = LOAD_NORMAL_BYPASS_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadNormalBypassProxy:
-      loadType = LOAD_NORMAL_BYPASS_PROXY;
-      break;
-    case nsDocShellLoadInfo::loadNormalBypassProxyAndCache:
-      loadType = LOAD_NORMAL_BYPASS_PROXY_AND_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadNormalAllowMixedContent:
-      loadType = LOAD_NORMAL_ALLOW_MIXED_CONTENT;
-      break;
-    case nsDocShellLoadInfo::loadReloadNormal:
-      loadType = LOAD_RELOAD_NORMAL;
-      break;
-    case nsDocShellLoadInfo::loadReloadCharsetChange:
-      loadType = LOAD_RELOAD_CHARSET_CHANGE;
-      break;
-    case nsDocShellLoadInfo::loadReloadCharsetChangeBypassCache:
-      loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache:
-      loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadReloadBypassCache:
-      loadType = LOAD_RELOAD_BYPASS_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadReloadBypassProxy:
-      loadType = LOAD_RELOAD_BYPASS_PROXY;
-      break;
-    case nsDocShellLoadInfo::loadReloadBypassProxyAndCache:
-      loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadLink:
-      loadType = LOAD_LINK;
-      break;
-    case nsDocShellLoadInfo::loadRefresh:
-      loadType = LOAD_REFRESH;
-      break;
-    case nsDocShellLoadInfo::loadBypassHistory:
-      loadType = LOAD_BYPASS_HISTORY;
-      break;
-    case nsDocShellLoadInfo::loadStopContent:
-      loadType = LOAD_STOP_CONTENT;
-      break;
-    case nsDocShellLoadInfo::loadStopContentAndReplace:
-      loadType = LOAD_STOP_CONTENT_AND_REPLACE;
-      break;
-    case nsDocShellLoadInfo::loadPushState:
-      loadType = LOAD_PUSHSTATE;
-      break;
-    case nsDocShellLoadInfo::loadReplaceBypassCache:
-      loadType = LOAD_REPLACE_BYPASS_CACHE;
-      break;
-    case nsDocShellLoadInfo::loadReloadMixedContent:
-      loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
-      break;
-    default:
-      MOZ_ASSERT_UNREACHABLE("Unexpected nsDocShellLoadInfo::nsDocShellInfoLoadType value");
-  }
-
-  return loadType;
-}
-
 static inline nsDOMNavigationTiming::Type
 ConvertLoadTypeToNavigationType(uint32_t aLoadType)
 {
   // Not initialized, assume it's normal load.
   if (aLoadType == 0) {
     aLoadType = LOAD_NORMAL;
   }
 
--- a/docshell/shistory/nsISHEntry.idl
+++ b/docshell/shistory/nsISHEntry.idl
@@ -341,16 +341,27 @@ interface nsISHEntry : nsISupports
     readonly attribute boolean loadedInThisProcess;
 
     /**
      * The session history it belongs to. It's usually only set on root entries.
      * SHEntry is strictly bound to the SHistory it belongs to; it should not be
      * changed once set to a non-null value.
      */
     [noscript] attribute nsISHistory SHistory;
+
+    /**
+     * Sets an SHEntry to reflect that it is a history type load. as
+     * nsIDocShellLoadInfo and its LoadType enum were removed, this is the
+     * equivalent to doing
+     *
+     * shEntry.loadType = 4;
+     *
+     * in js, but easier to maintain and less opaque.
+     */
+    void setAsHistoryLoad();
 };
 
 [scriptable, uuid(bb66ac35-253b-471f-a317-3ece940f04c5)]
 interface nsISHEntryInternal : nsISupports
 {
     [notxpcom] void RemoveFromBFCacheAsync();
     [notxpcom] void RemoveFromBFCacheSync();
 
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -448,17 +448,17 @@ nsSHEntry::Create(nsIURI* aURI, const ns
   MOZ_ASSERT(aTriggeringPrincipal,
              "need a valid triggeringPrincipal to create a session history entry");
 
   mURI = aURI;
   mTitle = aTitle;
   mPostData = aInputStream;
 
   // Set the LoadType by default to loadHistory during creation
-  mLoadType = (uint32_t)nsDocShellLoadInfo::loadHistory;
+  mLoadType = LOAD_HISTORY;
 
   mShared->mCacheKey = aCacheKey;
   mShared->mContentType = aContentType;
   mShared->mTriggeringPrincipal = aTriggeringPrincipal;
   mShared->mPrincipalToInherit = aPrincipalToInherit;
   mShared->mDocShellID = aDocShellID;
   mShared->mDynamicallyCreated = aDynamicCreation;
 
@@ -1006,8 +1006,16 @@ NS_IMETHODIMP
 nsSHEntry::SetSHistory(nsISHistory* aSHistory)
 {
   nsWeakPtr shistory = do_GetWeakReference(aSHistory);
   // mSHistory can not be changed once it's set
   MOZ_ASSERT(!mShared->mSHistory || (mShared->mSHistory == shistory));
   mShared->mSHistory = shistory;
   return NS_OK;
 }
+
+NS_IMETHODIMP
+nsSHEntry::SetAsHistoryLoad()
+{
+  // Set the LoadType by default to loadHistory during creation
+  mLoadType = LOAD_HISTORY;
+  return NS_OK;
+}
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1109,49 +1109,49 @@ NS_IMETHODIMP
 nsSHistory::GoBack()
 {
   bool canGoBack = false;
 
   GetCanGoBack(&canGoBack);
   if (!canGoBack) {
     return NS_ERROR_UNEXPECTED;
   }
-  return LoadEntry(mIndex - 1, nsDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
+  return LoadEntry(mIndex - 1, LOAD_HISTORY, HIST_CMD_BACK);
 }
 
 NS_IMETHODIMP
 nsSHistory::GoForward()
 {
   bool canGoForward = false;
 
   GetCanGoForward(&canGoForward);
   if (!canGoForward) {
     return NS_ERROR_UNEXPECTED;
   }
-  return LoadEntry(mIndex + 1, nsDocShellLoadInfo::loadHistory,
+  return LoadEntry(mIndex + 1, LOAD_HISTORY,
                    HIST_CMD_FORWARD);
 }
 
 NS_IMETHODIMP
 nsSHistory::Reload(uint32_t aReloadFlags)
 {
-  nsDocShellLoadInfo::nsDocShellInfoLoadType loadType;
+  uint32_t loadType;
   if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
       aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
-    loadType = nsDocShellLoadInfo::loadReloadBypassProxyAndCache;
+    loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) {
-    loadType = nsDocShellLoadInfo::loadReloadBypassProxy;
+    loadType = LOAD_RELOAD_BYPASS_PROXY;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
-    loadType = nsDocShellLoadInfo::loadReloadBypassCache;
+    loadType = LOAD_RELOAD_BYPASS_CACHE;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE) {
-    loadType = nsDocShellLoadInfo::loadReloadCharsetChange;
+    loadType = LOAD_RELOAD_CHARSET_CHANGE;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
-    loadType = nsDocShellLoadInfo::loadReloadMixedContent;
+    loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
   } else {
-    loadType = nsDocShellLoadInfo::loadReloadNormal;
+    loadType = LOAD_RELOAD_NORMAL;
   }
 
   // We are reloading. Send Reload notifications.
   // nsDocShellLoadFlagType is not public, where as nsIWebNavigation
   // is public. So send the reload notifications with the
   // nsIWebNavigation flags.
   bool canNavigate = true;
   nsCOMPtr<nsIURI> currentURI;
@@ -1173,33 +1173,33 @@ nsSHistory::ReloadCurrentEntry()
   nsCOMPtr<nsIURI> currentURI;
   GetCurrentURI(getter_AddRefs(currentURI));
   NOTIFY_LISTENERS_CANCELABLE(OnHistoryGotoIndex, canNavigate,
                               (mIndex, currentURI, &canNavigate));
   if (!canNavigate) {
     return NS_OK;
   }
 
-  return LoadEntry(mIndex, nsDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
+  return LoadEntry(mIndex, LOAD_HISTORY, HIST_CMD_RELOAD);
 }
 
 NS_IMETHODIMP
 nsSHistory::RestoreToEntryAtIndex(int32_t aIndex)
 {
   mRequestedIndex = aIndex;
 
   nsCOMPtr<nsISHEntry> nextEntry;
   GetEntryAtIndex(mRequestedIndex, false, getter_AddRefs(nextEntry));
   if (!nextEntry) {
     mRequestedIndex = -1;
     return NS_ERROR_FAILURE;
   }
 
   // XXX We may want to ensure docshell is currently holding about:blank
-  return InitiateLoad(nextEntry, mRootDocShell, nsDocShellLoadInfo::loadHistory);
+  return InitiateLoad(nextEntry, mRootDocShell, LOAD_HISTORY);
 }
 
 void
 nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
 {
   // XXX rename method to EvictContentViewersExceptAroundIndex, or something.
 
   // We need to release all content viewers that are no longer in the range
@@ -1834,17 +1834,17 @@ nsSHistory::LoadURI(const char16_t* aURI
                     nsIPrincipal* aTriggeringPrincipal)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GotoIndex(int32_t aIndex)
 {
-  return LoadEntry(aIndex, nsDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
+  return LoadEntry(aIndex, LOAD_HISTORY, HIST_CMD_GOTOINDEX);
 }
 
 nsresult
 nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
                                   uint32_t aHistCmd)
 {
   mRequestedIndex = -1;
   if (aNewIndex < mIndex) {
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -232,19 +232,19 @@ Location::SetURI(nsIURI* aURI, bool aRep
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   if (docShell) {
     RefPtr<nsDocShellLoadInfo> loadInfo;
 
     if(NS_FAILED(CheckURL(aURI, getter_AddRefs(loadInfo))))
       return NS_ERROR_FAILURE;
 
     if (aReplace) {
-      loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContentAndReplace);
+      loadInfo->SetLoadType(LOAD_STOP_CONTENT_AND_REPLACE);
     } else {
-      loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContent);
+      loadInfo->SetLoadType(LOAD_STOP_CONTENT);
     }
 
     // Get the incumbent script's browsing context to set as source.
     nsCOMPtr<nsPIDOMWindowInner> sourceWindow =
       do_QueryInterface(mozilla::dom::GetIncumbentGlobal());
     if (sourceWindow) {
       loadInfo->SetSourceDocShell(sourceWindow->GetDocShell());
     }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4708,21 +4708,19 @@ nsIDocument::SetScriptGlobalObject(nsISc
   }
 
   // The global in the template contents owner document should be the same.
   if (mTemplateContentsOwner && mTemplateContentsOwner != this) {
     mTemplateContentsOwner->SetScriptGlobalObject(aScriptGlobalObject);
   }
 
   if (!mMaybeServiceWorkerControlled && mDocumentContainer && mScriptGlobalObject && GetChannel()) {
-    uint32_t loadType;
-    mDocumentContainer->GetLoadType(&loadType);
 
     // If we are shift-reloaded, don't associate with a ServiceWorker.
-    if (IsForceReloadType(loadType)) {
+    if (mDocumentContainer->IsForceReloading()) {
       NS_WARNING("Page was shift reloaded, skipping ServiceWorker control");
       return;
     }
 
     mMaybeServiceWorkerControlled = true;
   }
 }
 
--- a/dom/clients/manager/ClientNavigateOpChild.cpp
+++ b/dom/clients/manager/ClientNavigateOpChild.cpp
@@ -215,17 +215,17 @@ ClientNavigateOpChild::DoNavigate(const 
     ref = ClientOpPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__);
     return ref.forget();
   }
 
   RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   loadInfo->SetTriggeringPrincipal(principal);
   loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
-  loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContent);
+  loadInfo->SetLoadType(LOAD_STOP_CONTENT);
   loadInfo->SetSourceDocShell(docShell);
   rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, true);
   if (NS_FAILED(rv)) {
     ref = ClientOpPromise::CreateAndReject(rv, __func__);
     return ref.forget();
   }
 
   RefPtr<ClientOpPromise::Private> promise =
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -260,17 +260,17 @@ var ViewSourceContent = {
 
     let shEntrySource = pageDescriptor.QueryInterface(Ci.nsISHEntry);
     let shEntry = Cc["@mozilla.org/browser/session-history-entry;1"]
                     .createInstance(Ci.nsISHEntry);
     shEntry.setURI(Services.io.newURI(viewSrcURL));
     shEntry.setTitle(viewSrcURL);
     let systemPrincipal = Services.scriptSecurityManager.getSystemPrincipal();
     shEntry.triggeringPrincipal = systemPrincipal;
-    shEntry.loadType = 2; /* nsDocShellLoadInfo::loadHistory */
+    shEntry.setAsHistoryLoad();
     shEntry.cacheKey = shEntrySource.cacheKey;
     docShell.QueryInterface(Ci.nsIWebNavigation)
             .sessionHistory
             .legacySHistory
             .QueryInterface(Ci.nsISHistoryInternal)
             .addEntry(shEntry, true);
   },
 
--- a/toolkit/modules/sessionstore/SessionHistory.jsm
+++ b/toolkit/modules/sessionstore/SessionHistory.jsm
@@ -338,17 +338,17 @@ var SessionHistoryInternal = {
 
     var shEntry = Cc["@mozilla.org/browser/session-history-entry;1"].
                   createInstance(Ci.nsISHEntry);
 
     shEntry.setURI(Utils.makeURI(entry.url));
     shEntry.setTitle(entry.title || entry.url);
     if (entry.subframe)
       shEntry.setIsSubFrame(entry.subframe || false);
-    shEntry.loadType = 2; /* nsDocShellLoadInfo::loadHistory */
+    shEntry.setAsHistoryLoad();
     if (entry.contentType)
       shEntry.contentType = entry.contentType;
     if (entry.referrer) {
       shEntry.referrerURI = Utils.makeURI(entry.referrer);
       shEntry.referrerPolicy = entry.referrerPolicy;
     }
     if (entry.originalURI) {
       shEntry.originalURI = Utils.makeURI(entry.originalURI);