Bug 1472087 - deCOMtaminate nsIDocShellLoadInfo; r=nika
authorKyle Machulis <kyle@nonpolynomial.com>
Fri, 29 Jun 2018 16:29:50 -0700
changeset 481442 e9df2dcfe09f9905c0777412eb302546ac210766
parent 481441 7bba6867db6efc3da44365e92cb01efd0ad7e35d
child 481443 ffbed43e8c35622dcdee4c6dc193c18bbc26d16a
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1472087
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1472087 - deCOMtaminate nsIDocShellLoadInfo; r=nika Change all references from nsIDocShellLoadInfo to nsDocShellLoadInfo MozReview-Commit-ID: AyKlZUtSEDD
docshell/base/moz.build
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsDocShellLoadInfo.cpp
docshell/base/nsDocShellLoadInfo.h
docshell/base/nsDocShellLoadTypes.h
docshell/base/nsIDocShell.idl
docshell/shistory/nsSHEntry.cpp
docshell/shistory/nsSHistory.cpp
dom/base/Location.cpp
dom/base/Location.h
dom/base/nsFrameLoader.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsGlobalWindowOuter.h
dom/base/nsObjectLoadingContent.cpp
dom/base/nsPIDOMWindow.h
dom/clients/manager/ClientNavigateOpChild.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/TabChild.cpp
toolkit/components/viewsource/content/viewSource-content.js
toolkit/components/windowcreator/nsIWindowProvider.idl
toolkit/components/windowwatcher/nsPIWindowWatcher.idl
toolkit/components/windowwatcher/nsWindowWatcher.cpp
toolkit/components/windowwatcher/nsWindowWatcher.h
toolkit/modules/sessionstore/SessionHistory.jsm
xpfe/appshell/nsContentTreeOwner.cpp
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -59,16 +59,17 @@ XPIDL_SOURCES += [
     'nsIWebNavigationInfo.idl',
     'nsIWebPageDescriptor.idl',
 ]
 
 XPIDL_MODULE = 'docshell'
 
 EXPORTS += [
     'nsCTooltipTextProvider.h',
+    'nsDocShellLoadInfo.h',
     'nsDocShellLoadTypes.h',
     'nsDocShellTreeOwner.h',
     'nsILinkHandler.h',
     'nsIScrollObserver.h',
     'nsIWebShellServices.h',
     'SerializedLoadContext.h',
 ]
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -651,17 +651,17 @@ nsDocShell::GetInterface(const nsIID& aI
   }
 
   NS_IF_ADDREF(((nsISupports*)*aSink));
   return *aSink ? NS_OK : NS_NOINTERFACE;
 }
 
 NS_IMETHODIMP
 nsDocShell::LoadURI(nsIURI* aURI,
-                    nsIDocShellLoadInfo* aLoadInfo,
+                    nsDocShellLoadInfo* aLoadInfo,
                     uint32_t aLoadFlags,
                     bool aFirstParty)
 {
   MOZ_ASSERT(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
              "Unexpected flags");
   MOZ_ASSERT((aLoadFlags & 0xf) == 0, "Should not have these flags set");
 
   // Note: we allow loads to get through here even if mFiredUnloadEvent is
@@ -704,17 +704,17 @@ nsDocShell::LoadURI(nsIURI* aURI,
   }
 
   // Extract the info from the DocShellLoadInfo struct...
   if (aLoadInfo) {
     aLoadInfo->GetReferrer(getter_AddRefs(referrer));
     aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI));
     GetMaybeResultPrincipalURI(aLoadInfo, resultPrincipalURI);
     aLoadInfo->GetLoadReplace(&loadReplace);
-    nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
+    nsDocShellLoadInfo::nsDocShellInfoLoadType lt = nsDocShellLoadInfo::loadNormal;
     aLoadInfo->GetLoadType(&lt);
     // Get the appropriate loadType from nsIDocShellLoadInfo type
     loadType = ConvertDocShellInfoLoadTypeToLoadType(lt);
 
     aLoadInfo->GetTriggeringPrincipal(getter_AddRefs(triggeringPrincipal));
     aLoadInfo->GetInheritPrincipal(&inheritPrincipal);
     aLoadInfo->GetPrincipalIsExplicit(&principalIsExplicit);
     aLoadInfo->GetSHEntry(getter_AddRefs(shEntry));
@@ -1020,20 +1020,20 @@ nsDocShell::LoadURI(nsIURI* aURI,
                       srcdoc,
                       sourceDocShell,
                       baseURI,
                       nullptr,  // No nsIDocShell
                       nullptr); // No nsIRequest
 }
 
 NS_IMETHODIMP
-nsDocShell::CreateLoadInfo(nsIDocShellLoadInfo** aLoadInfo)
+nsDocShell::CreateLoadInfo(nsDocShellLoadInfo** aLoadInfo)
 {
   nsDocShellLoadInfo* loadInfo = new nsDocShellLoadInfo();
-  nsCOMPtr<nsIDocShellLoadInfo> localRef(loadInfo);
+  RefPtr<nsDocShellLoadInfo> localRef(loadInfo);
 
   localRef.forget(aLoadInfo);
   return NS_OK;
 }
 
 /*
  * Reset state to a new content model within the current document and the
  * document viewer. Called by the document before initiating an out of band
@@ -3721,31 +3721,31 @@ 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 = nsIDocShellLoadInfo::loadHistory;
+    uint32_t loadType = nsDocShellLoadInfo::loadHistory;
     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 == nsIDocShellLoadInfo::loadReloadBypassCache ||
-        loadType == nsIDocShellLoadInfo::loadReloadBypassProxy ||
-        loadType == nsIDocShellLoadInfo::loadReloadBypassProxyAndCache ||
-        loadType == nsIDocShellLoadInfo::loadRefresh) {
+    if (loadType == nsDocShellLoadInfo::loadReloadBypassCache ||
+        loadType == nsDocShellLoadInfo::loadReloadBypassProxy ||
+        loadType == nsDocShellLoadInfo::loadReloadBypassProxyAndCache ||
+        loadType == nsDocShellLoadInfo::loadRefresh) {
       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 == nsIDocShellLoadInfo::loadReloadNormal)) {
+    if (parentExpired && (loadType == nsDocShellLoadInfo::loadReloadNormal)) {
       // 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.
@@ -4223,21 +4223,17 @@ nsDocShell::LoadURIWithOptions(const cha
     aLoadFlags & LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
 
   // Don't pass certain flags that aren't needed and end up confusing
   // ConvertLoadTypeToDocShellInfoLoadType.  We do need to ensure that they are
   // passed to LoadURI though, since it uses them.
   uint32_t extraFlags = (aLoadFlags & EXTRA_LOAD_FLAGS);
   aLoadFlags &= ~EXTRA_LOAD_FLAGS;
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-  rv = CreateLoadInfo(getter_AddRefs(loadInfo));
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   /*
    * If the user "Disables Protection on This Page", we have to make sure to
    * remember the users decision when opening links in child tabs [Bug 906190]
    */
   uint32_t loadType;
   if (aLoadFlags & LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
     loadType = MAKE_LOAD_TYPE(LOAD_NORMAL_ALLOW_MIXED_CONTENT, aLoadFlags);
@@ -6185,19 +6181,17 @@ nsDocShell::ForceRefreshURIFromTimer(nsI
   return ForceRefreshURI(aURI, aPrincipal, aDelay, aMetaRefresh);
 }
 
 NS_IMETHODIMP
 nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDelay, bool aMetaRefresh)
 {
   NS_ENSURE_ARG(aURI);
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-  CreateLoadInfo(getter_AddRefs(loadInfo));
-  NS_ENSURE_TRUE(loadInfo, NS_ERROR_OUT_OF_MEMORY);
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   /* We do need to pass in a referrer, but we don't want it to
    * be sent to the server.
    */
   loadInfo->SetSendReferrer(false);
 
   /* for most refreshes the current URI is an appropriate
    * internal referrer
@@ -6223,28 +6217,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(nsIDocShellLoadInfo::loadNormalReplace);
+    loadInfo->SetLoadType(nsDocShellLoadInfo::loadNormalReplace);
 
     /* 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(nsIDocShellLoadInfo::loadRefresh);
+    loadInfo->SetLoadType(nsDocShellLoadInfo::loadRefresh);
   }
 
   /*
    * 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);
 
@@ -7086,17 +7080,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(nsIDocShellLoadInfo::loadHistory);
+    mLSHE->SetLoadType(nsDocShellLoadInfo::loadHistory);
 
     // 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)
@@ -9420,21 +9414,17 @@ nsDocShell::InternalLoad(nsIURI* aURI,
         // If OnLinkClickSync was invoked inside the onload handler, the load
         // type would be set to LOAD_NORMAL_REPLACE; otherwise it should be
         // LOAD_LINK.
         MOZ_ASSERT(aLoadType == LOAD_LINK ||
                    aLoadType == LOAD_NORMAL_REPLACE);
         MOZ_ASSERT(!aSHEntry);
         MOZ_ASSERT(aFirstParty); // Windowwatcher will assume this.
 
-        nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-        rv = CreateLoadInfo(getter_AddRefs(loadInfo));
-        if (NS_FAILED(rv)) {
-          return rv;
-        }
+        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->SetSendReferrer(!(aFlags &
                                     INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER));
         loadInfo->SetOriginalURI(aOriginalURI);
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -19,17 +19,16 @@
 #include "mozilla/gfx/Matrix.h"
 #include "mozilla/dom/ChildSHistory.h"
 
 #include "nsIAuthPromptProvider.h"
 #include "nsIBaseWindow.h"
 #include "nsIClipboardCommands.h"
 #include "nsIDeprecationWarner.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMStorageManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsILinkHandler.h"
 #include "nsILoadContext.h"
 #include "nsILoadURIDelegate.h"
 #include "nsINetworkInterceptController.h"
 #include "nsIRefreshURI.h"
--- a/docshell/base/nsDocShellLoadInfo.cpp
+++ b/docshell/base/nsDocShellLoadInfo.cpp
@@ -6,21 +6,22 @@
 
 #include "nsDocShellLoadInfo.h"
 #include "nsISHEntry.h"
 #include "nsIInputStream.h"
 #include "nsIURI.h"
 #include "nsIDocShell.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include "mozilla/Unused.h"
+#include "mozilla/Maybe.h"
 
 namespace mozilla {
 
 void
-GetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>>& aRPURI)
+GetMaybeResultPrincipalURI(nsDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>>& aRPURI)
 {
   if (!aLoadInfo) {
     return;
   }
 
   nsresult rv;
 
   bool isSome;
@@ -40,17 +41,17 @@ GetMaybeResultPrincipalURI(nsIDocShellLo
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   aRPURI.emplace(std::move(uri));
 }
 
 void
-SetMaybeResultPrincipalURI(nsIDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
+SetMaybeResultPrincipalURI(nsDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>> const& aRPURI)
 {
   if (!aLoadInfo) {
     return;
   }
 
   nsresult rv;
 
   rv = aLoadInfo->SetResultPrincipalURI(aRPURI.refOr(nullptr));
@@ -66,33 +67,25 @@ nsDocShellLoadInfo::nsDocShellLoadInfo()
   : mResultPrincipalURIIsSome(false)
   , mLoadReplace(false)
   , mInheritPrincipal(false)
   , mPrincipalIsExplicit(false)
   , mForceAllowDataURI(false)
   , mOriginalFrameSrc(false)
   , mSendReferrer(true)
   , mReferrerPolicy(mozilla::net::RP_Unset)
-  , mLoadType(nsIDocShellLoadInfo::loadNormal)
+  , mLoadType(nsDocShellLoadInfo::loadNormal)
   , mIsSrcdocLoad(false)
 {
 }
 
 nsDocShellLoadInfo::~nsDocShellLoadInfo()
 {
 }
 
-NS_IMPL_ADDREF(nsDocShellLoadInfo)
-NS_IMPL_RELEASE(nsDocShellLoadInfo)
-
-NS_INTERFACE_MAP_BEGIN(nsDocShellLoadInfo)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDocShellLoadInfo)
-  NS_INTERFACE_MAP_ENTRY(nsIDocShellLoadInfo)
-NS_INTERFACE_MAP_END
-
 NS_IMETHODIMP
 nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
 {
   NS_ENSURE_ARG_POINTER(aReferrer);
 
   *aReferrer = mReferrer;
   NS_IF_ADDREF(*aReferrer);
   return NS_OK;
--- a/docshell/base/nsDocShellLoadInfo.h
+++ b/docshell/base/nsDocShellLoadInfo.h
@@ -6,31 +6,150 @@
 
 #ifndef nsDocShellLoadInfo_h__
 #define nsDocShellLoadInfo_h__
 
 // Helper Classes
 #include "nsCOMPtr.h"
 #include "nsString.h"
 
-// Interfaces Needed
-#include "nsIDocShellLoadInfo.h"
-
 class nsIInputStream;
 class nsISHEntry;
 class nsIURI;
 class nsIDocShell;
 
-class nsDocShellLoadInfo : public nsIDocShellLoadInfo
+class nsDocShellLoadInfo
 {
 public:
+  typedef uint32_t nsDocShellInfoLoadType;
+  typedef uint32_t nsDocShellInfoReferrerPolicy;
+  /* these are load type enums... */
+  const static uint32_t loadNormal = 0;                     // Normal Load
+  const static uint32_t loadNormalReplace = 1;              // Normal Load but replaces current history slot
+  const static uint32_t loadHistory = 2;                    // Load from history
+  const static uint32_t loadReloadNormal = 3;               // Reload
+  const static uint32_t loadReloadBypassCache = 4;
+  const static uint32_t loadReloadBypassProxy = 5;
+  const static uint32_t loadReloadBypassProxyAndCache = 6;
+  const static uint32_t loadLink = 7;
+  const static uint32_t loadRefresh = 8;
+  const static uint32_t loadReloadCharsetChange = 9;
+  const static uint32_t loadBypassHistory = 10;
+  const static uint32_t loadStopContent = 11;
+  const static uint32_t loadStopContentAndReplace = 12;
+  const static uint32_t loadNormalExternal = 13;
+  const static uint32_t loadNormalBypassCache = 14;
+  const static uint32_t loadNormalBypassProxy = 15;
+  const static uint32_t loadNormalBypassProxyAndCache = 16;
+  const static uint32_t loadPushState = 17;                 // history.pushState or replaceState
+  const static uint32_t loadReplaceBypassCache = 18;
+  const static uint32_t loadReloadMixedContent = 19;
+  const static uint32_t loadNormalAllowMixedContent = 20;
+  const static uint32_t loadReloadCharsetChangeBypassCache = 21;
+  const static uint32_t loadReloadCharsetChangeBypassProxyAndCache = 22;
+
+
+  NS_INLINE_DECL_REFCOUNTING(nsDocShellLoadInfo);
+
   nsDocShellLoadInfo();
 
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOCSHELLLOADINFO
+  NS_IMETHOD GetReferrer(nsIURI** aReferrer);
+
+  NS_IMETHOD SetReferrer(nsIURI* aReferrer);
+
+  NS_IMETHOD GetOriginalURI(nsIURI** aOriginalURI);
+
+  NS_IMETHOD SetOriginalURI(nsIURI* aOriginalURI);
+
+  NS_IMETHOD GetResultPrincipalURI(nsIURI** aResultPrincipalURI);
+
+  NS_IMETHOD
+  SetResultPrincipalURI(nsIURI* aResultPrincipalURI);
+
+  NS_IMETHOD
+  GetResultPrincipalURIIsSome(bool* aIsSome);
+
+  NS_IMETHOD
+  SetResultPrincipalURIIsSome(bool aIsSome);
+
+  NS_IMETHOD
+  GetLoadReplace(bool* aLoadReplace);
+
+  NS_IMETHOD
+  SetLoadReplace(bool aLoadReplace);
+
+  NS_IMETHOD
+  GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal);
+
+  NS_IMETHOD
+  SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal);
+
+  NS_IMETHOD
+  GetInheritPrincipal(bool* aInheritPrincipal);
+
+  NS_IMETHOD
+  SetInheritPrincipal(bool aInheritPrincipal);
+
+  NS_IMETHOD
+  GetPrincipalIsExplicit(bool* aPrincipalIsExplicit);
+
+  NS_IMETHOD
+  SetPrincipalIsExplicit(bool aPrincipalIsExplicit);
+
+  NS_IMETHOD
+  GetForceAllowDataURI(bool* aForceAllowDataURI);
+
+  NS_IMETHOD
+  SetForceAllowDataURI(bool aForceAllowDataURI);
+
+  NS_IMETHOD GetOriginalFrameSrc(bool* aOriginalFrameSrc);
+
+  NS_IMETHOD SetOriginalFrameSrc(bool aOriginalFrameSrc);
+
+  NS_IMETHOD GetLoadType(nsDocShellInfoLoadType* aLoadType);
+
+  NS_IMETHOD SetLoadType(nsDocShellInfoLoadType aLoadType);
+
+  NS_IMETHOD GetSHEntry(nsISHEntry** aSHEntry);
+
+  NS_IMETHOD SetSHEntry(nsISHEntry* aSHEntry);
+
+  NS_IMETHOD GetTarget(char16_t** aTarget);
+
+  NS_IMETHOD SetTarget(const char16_t* aTarget);
+
+  NS_IMETHOD GetPostDataStream(nsIInputStream** aResult);
+
+  NS_IMETHOD SetPostDataStream(nsIInputStream* aStream);
+
+  NS_IMETHOD GetHeadersStream(nsIInputStream** aHeadersStream);
+
+  NS_IMETHOD SetHeadersStream(nsIInputStream* aHeadersStream);
+
+  NS_IMETHOD GetSendReferrer(bool* aSendReferrer);
+
+  NS_IMETHOD SetSendReferrer(bool aSendReferrer);
+
+  NS_IMETHOD GetReferrerPolicy(nsDocShellInfoReferrerPolicy* aReferrerPolicy);
+
+  NS_IMETHOD SetReferrerPolicy(nsDocShellInfoReferrerPolicy aReferrerPolicy);
+
+  NS_IMETHOD GetIsSrcdocLoad(bool* aIsSrcdocLoad);
+
+  NS_IMETHOD GetSrcdocData(nsAString& aSrcdocData);
+
+  NS_IMETHOD SetSrcdocData(const nsAString& aSrcdocData);
+
+  NS_IMETHOD GetSourceDocShell(nsIDocShell** aSourceDocShell);
+
+  NS_IMETHOD SetSourceDocShell(nsIDocShell* aSourceDocShell);
+
+  NS_IMETHOD GetBaseURI(nsIURI** aBaseURI);
+
+  NS_IMETHOD SetBaseURI(nsIURI* aBaseURI);
 
 protected:
   virtual ~nsDocShellLoadInfo();
 
 protected:
   nsCOMPtr<nsIURI> mReferrer;
   nsCOMPtr<nsIURI> mOriginalURI;
   nsCOMPtr<nsIURI> mResultPrincipalURI;
@@ -49,9 +168,16 @@ protected:
   nsCOMPtr<nsIInputStream> mPostDataStream;
   nsCOMPtr<nsIInputStream> mHeadersStream;
   bool mIsSrcdocLoad;
   nsString mSrcdocData;
   nsCOMPtr<nsIDocShell> mSourceDocShell;
   nsCOMPtr<nsIURI> mBaseURI;
 };
 
+namespace mozilla {
+void
+GetMaybeResultPrincipalURI(nsDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>>& aRPURI);
+void
+SetMaybeResultPrincipalURI(nsDocShellLoadInfo* aLoadInfo, Maybe<nsCOMPtr<nsIURI>> const& aRPURI);
+}
+
 #endif /* nsDocShellLoadInfo_h__ */
--- a/docshell/base/nsDocShellLoadTypes.h
+++ b/docshell/base/nsDocShellLoadTypes.h
@@ -6,17 +6,17 @@
 
 #ifndef nsDocShellLoadTypes_h_
 #define nsDocShellLoadTypes_h_
 
 #ifdef MOZILLA_INTERNAL_API
 
 #include "nsDOMNavigationTiming.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 
 /**
  * Load flag for error pages. This uses one of the reserved flag
  * values from nsIWebNavigation.
  */
 #define LOAD_FLAGS_ERROR_PAGE 0x0001U
 
@@ -115,175 +115,175 @@ IsForceReloadType(uint32_t aLoadType) {
     case LOAD_RELOAD_BYPASS_PROXY:
     case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
     case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
       return true;
   }
   return false;
 }
 
-static inline nsDocShellInfoLoadType
+static inline nsDocShellLoadInfo::nsDocShellInfoLoadType
 ConvertLoadTypeToDocShellInfoLoadType(uint32_t aLoadType)
 {
-  nsDocShellInfoLoadType docShellLoadType = nsIDocShellLoadInfo::loadNormal;
+  nsDocShellLoadInfo::nsDocShellInfoLoadType docShellLoadType = nsDocShellLoadInfo::loadNormal;
   switch (aLoadType) {
     case LOAD_NORMAL:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormal;
+      docShellLoadType = nsDocShellLoadInfo::loadNormal;
       break;
     case LOAD_NORMAL_REPLACE:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalReplace;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalReplace;
       break;
     case LOAD_NORMAL_EXTERNAL:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalExternal;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalExternal;
       break;
     case LOAD_NORMAL_BYPASS_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassCache;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassCache;
       break;
     case LOAD_NORMAL_BYPASS_PROXY:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassProxy;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassProxy;
       break;
     case LOAD_NORMAL_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalBypassProxyAndCache;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalBypassProxyAndCache;
       break;
     case LOAD_NORMAL_ALLOW_MIXED_CONTENT:
-      docShellLoadType = nsIDocShellLoadInfo::loadNormalAllowMixedContent;
+      docShellLoadType = nsDocShellLoadInfo::loadNormalAllowMixedContent;
       break;
     case LOAD_HISTORY:
-      docShellLoadType = nsIDocShellLoadInfo::loadHistory;
+      docShellLoadType = nsDocShellLoadInfo::loadHistory;
       break;
     case LOAD_RELOAD_NORMAL:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadNormal;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadNormal;
       break;
     case LOAD_RELOAD_CHARSET_CHANGE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChange;
       break;
     case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChangeBypassCache;
       break;
     case LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache;
       break;
     case LOAD_RELOAD_BYPASS_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassCache;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassCache;
       break;
     case LOAD_RELOAD_BYPASS_PROXY:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassProxy;
       break;
     case LOAD_RELOAD_BYPASS_PROXY_AND_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadBypassProxyAndCache;
       break;
     case LOAD_LINK:
-      docShellLoadType = nsIDocShellLoadInfo::loadLink;
+      docShellLoadType = nsDocShellLoadInfo::loadLink;
       break;
     case LOAD_REFRESH:
-      docShellLoadType = nsIDocShellLoadInfo::loadRefresh;
+      docShellLoadType = nsDocShellLoadInfo::loadRefresh;
       break;
     case LOAD_BYPASS_HISTORY:
     case LOAD_ERROR_PAGE:
-      docShellLoadType = nsIDocShellLoadInfo::loadBypassHistory;
+      docShellLoadType = nsDocShellLoadInfo::loadBypassHistory;
       break;
     case LOAD_STOP_CONTENT:
-      docShellLoadType = nsIDocShellLoadInfo::loadStopContent;
+      docShellLoadType = nsDocShellLoadInfo::loadStopContent;
       break;
     case LOAD_STOP_CONTENT_AND_REPLACE:
-      docShellLoadType = nsIDocShellLoadInfo::loadStopContentAndReplace;
+      docShellLoadType = nsDocShellLoadInfo::loadStopContentAndReplace;
       break;
     case LOAD_PUSHSTATE:
-      docShellLoadType = nsIDocShellLoadInfo::loadPushState;
+      docShellLoadType = nsDocShellLoadInfo::loadPushState;
       break;
     case LOAD_REPLACE_BYPASS_CACHE:
-      docShellLoadType = nsIDocShellLoadInfo::loadReplaceBypassCache;
+      docShellLoadType = nsDocShellLoadInfo::loadReplaceBypassCache;
       break;
     case LOAD_RELOAD_ALLOW_MIXED_CONTENT:
-      docShellLoadType = nsIDocShellLoadInfo::loadReloadMixedContent;
+      docShellLoadType = nsDocShellLoadInfo::loadReloadMixedContent;
       break;
     default:
       MOZ_ASSERT_UNREACHABLE("Unexpected load type value");
   }
 
   return docShellLoadType;
 }
 
 static inline uint32_t
-ConvertDocShellInfoLoadTypeToLoadType(nsDocShellInfoLoadType aDocShellLoadType)
+ConvertDocShellInfoLoadTypeToLoadType(nsDocShellLoadInfo::nsDocShellInfoLoadType aDocShellLoadType)
 {
   uint32_t loadType = LOAD_NORMAL;
 
   switch (aDocShellLoadType) {
-    case nsIDocShellLoadInfo::loadNormal:
+    case nsDocShellLoadInfo::loadNormal:
       loadType = LOAD_NORMAL;
       break;
-    case nsIDocShellLoadInfo::loadNormalReplace:
+    case nsDocShellLoadInfo::loadNormalReplace:
       loadType = LOAD_NORMAL_REPLACE;
       break;
-    case nsIDocShellLoadInfo::loadNormalExternal:
+    case nsDocShellLoadInfo::loadNormalExternal:
       loadType = LOAD_NORMAL_EXTERNAL;
       break;
-    case nsIDocShellLoadInfo::loadHistory:
+    case nsDocShellLoadInfo::loadHistory:
       loadType = LOAD_HISTORY;
       break;
-    case nsIDocShellLoadInfo::loadNormalBypassCache:
+    case nsDocShellLoadInfo::loadNormalBypassCache:
       loadType = LOAD_NORMAL_BYPASS_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadNormalBypassProxy:
+    case nsDocShellLoadInfo::loadNormalBypassProxy:
       loadType = LOAD_NORMAL_BYPASS_PROXY;
       break;
-    case nsIDocShellLoadInfo::loadNormalBypassProxyAndCache:
+    case nsDocShellLoadInfo::loadNormalBypassProxyAndCache:
       loadType = LOAD_NORMAL_BYPASS_PROXY_AND_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadNormalAllowMixedContent:
+    case nsDocShellLoadInfo::loadNormalAllowMixedContent:
       loadType = LOAD_NORMAL_ALLOW_MIXED_CONTENT;
       break;
-    case nsIDocShellLoadInfo::loadReloadNormal:
+    case nsDocShellLoadInfo::loadReloadNormal:
       loadType = LOAD_RELOAD_NORMAL;
       break;
-    case nsIDocShellLoadInfo::loadReloadCharsetChange:
+    case nsDocShellLoadInfo::loadReloadCharsetChange:
       loadType = LOAD_RELOAD_CHARSET_CHANGE;
       break;
-    case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassCache:
+    case nsDocShellLoadInfo::loadReloadCharsetChangeBypassCache:
       loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache:
+    case nsDocShellLoadInfo::loadReloadCharsetChangeBypassProxyAndCache:
       loadType = LOAD_RELOAD_CHARSET_CHANGE_BYPASS_PROXY_AND_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadReloadBypassCache:
+    case nsDocShellLoadInfo::loadReloadBypassCache:
       loadType = LOAD_RELOAD_BYPASS_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadReloadBypassProxy:
+    case nsDocShellLoadInfo::loadReloadBypassProxy:
       loadType = LOAD_RELOAD_BYPASS_PROXY;
       break;
-    case nsIDocShellLoadInfo::loadReloadBypassProxyAndCache:
+    case nsDocShellLoadInfo::loadReloadBypassProxyAndCache:
       loadType = LOAD_RELOAD_BYPASS_PROXY_AND_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadLink:
+    case nsDocShellLoadInfo::loadLink:
       loadType = LOAD_LINK;
       break;
-    case nsIDocShellLoadInfo::loadRefresh:
+    case nsDocShellLoadInfo::loadRefresh:
       loadType = LOAD_REFRESH;
       break;
-    case nsIDocShellLoadInfo::loadBypassHistory:
+    case nsDocShellLoadInfo::loadBypassHistory:
       loadType = LOAD_BYPASS_HISTORY;
       break;
-    case nsIDocShellLoadInfo::loadStopContent:
+    case nsDocShellLoadInfo::loadStopContent:
       loadType = LOAD_STOP_CONTENT;
       break;
-    case nsIDocShellLoadInfo::loadStopContentAndReplace:
+    case nsDocShellLoadInfo::loadStopContentAndReplace:
       loadType = LOAD_STOP_CONTENT_AND_REPLACE;
       break;
-    case nsIDocShellLoadInfo::loadPushState:
+    case nsDocShellLoadInfo::loadPushState:
       loadType = LOAD_PUSHSTATE;
       break;
-    case nsIDocShellLoadInfo::loadReplaceBypassCache:
+    case nsDocShellLoadInfo::loadReplaceBypassCache:
       loadType = LOAD_REPLACE_BYPASS_CACHE;
       break;
-    case nsIDocShellLoadInfo::loadReloadMixedContent:
+    case nsDocShellLoadInfo::loadReloadMixedContent:
       loadType = LOAD_RELOAD_ALLOW_MIXED_CONTENT;
       break;
     default:
-      MOZ_ASSERT_UNREACHABLE("Unexpected nsDocShellInfoLoadType value");
+      MOZ_ASSERT_UNREACHABLE("Unexpected nsDocShellLoadInfo::nsDocShellInfoLoadType value");
   }
 
   return loadType;
 }
 
 static inline nsDOMNavigationTiming::Type
 ConvertLoadTypeToNavigationType(uint32_t aLoadType)
 {
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -12,16 +12,17 @@
 #include "js/TypeDecls.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/NotNull.h"
 #include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsIURI.h"
 class nsPresContext;
 class nsIPresShell;
+class nsDocShellLoadInfo;
 namespace mozilla {
 class Encoding;
 class HTMLEditor;
 namespace dom {
 class ClientSource;
 } // namespace dom
 }
 %}
@@ -56,16 +57,17 @@ interface nsIPrivacyTransitionObserver;
 interface nsIReflowObserver;
 interface nsIScrollObserver;
 interface nsITabParent;
 interface nsITabChild;
 interface nsICommandManager;
 interface nsICommandParams;
 interface nsILoadURIDelegate;
 native TabChildRef(already_AddRefed<nsITabChild>);
+native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
 
 webidl EventTarget;
 
 [scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)]
 interface nsIDocShell : nsIDocShellTreeItem
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
@@ -82,17 +84,17 @@ interface nsIDocShell : nsIDocShellTreeI
    *                     then pass it to loadURI.
    * @param aLoadFlags - Flags to modify load behaviour. Flags are defined in
    *                     nsIWebNavigation.  Note that using flags outside
    *                     LOAD_FLAGS_MASK is only allowed if passing in a
    *                     non-null loadInfo.  And even some of those might not
    *                     be allowed.  Use at your own risk.
    */
   [noscript]void loadURI(in nsIURI uri,
-                         in nsIDocShellLoadInfo loadInfo,
+                         in nsDocShellLoadInfoPtr loadInfo,
                          in unsigned long aLoadFlags,
                          in boolean firstParty);
 
   const long INTERNAL_LOAD_FLAGS_NONE                    = 0x0;
   const long INTERNAL_LOAD_FLAGS_INHERIT_PRINCIPAL       = 0x1;
   const long INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER      = 0x2;
   const long INTERNAL_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 0x4;
 
@@ -205,17 +207,17 @@ interface nsIDocShell : nsIDocShellTreeI
   [implicit_jscontext]
   void addState(in jsval aData, in DOMString aTitle,
                 in DOMString aURL, in boolean aReplace);
 
   /**
    * Creates a DocShellLoadInfo object that you can manipulate and then pass
    * to loadURI.
    */
-  void createLoadInfo(out nsIDocShellLoadInfo loadInfo);
+  void createLoadInfo(out nsDocShellLoadInfoPtr loadInfo);
 
   /**
    * Reset state to a new content model within the current document and the document
    * viewer.  Called by the document before initiating an out of band document.write().
    */
   void prepareForNewContentModel();
 
   /**
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsSHEntry.h"
 
 #include <algorithm>
 
 #include "nsDocShellEditorData.h"
 #include "nsIContentViewer.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIInputStream.h"
 #include "nsILayoutHistoryState.h"
 #include "nsIStructuredCloneContainer.h"
 #include "nsIURI.h"
 #include "nsSHEntryShared.h"
 #include "nsSHistory.h"
 
@@ -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)nsIDocShellLoadInfo::loadHistory;
+  mLoadType = (uint32_t)nsDocShellLoadInfo::loadHistory;
 
   mShared->mCacheKey = aCacheKey;
   mShared->mContentType = aContentType;
   mShared->mTriggeringPrincipal = aTriggeringPrincipal;
   mShared->mPrincipalToInherit = aPrincipalToInherit;
   mShared->mDocShellID = aDocShellID;
   mShared->mDynamicallyCreated = aDynamicCreation;
 
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -8,17 +8,17 @@
 
 #include <algorithm>
 
 #include "nsCOMArray.h"
 #include "nsComponentManagerUtils.h"
 #include "nsDocShell.h"
 #include "nsIContentViewer.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsILayoutHistoryState.h"
 #include "nsIObserverService.h"
 #include "nsISHContainer.h"
 #include "nsISHEntry.h"
 #include "nsISHistoryListener.h"
 #include "nsISHTransaction.h"
 #include "nsIURI.h"
@@ -1109,49 +1109,49 @@ NS_IMETHODIMP
 nsSHistory::GoBack()
 {
   bool canGoBack = false;
 
   GetCanGoBack(&canGoBack);
   if (!canGoBack) {
     return NS_ERROR_UNEXPECTED;
   }
-  return LoadEntry(mIndex - 1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
+  return LoadEntry(mIndex - 1, nsDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
 }
 
 NS_IMETHODIMP
 nsSHistory::GoForward()
 {
   bool canGoForward = false;
 
   GetCanGoForward(&canGoForward);
   if (!canGoForward) {
     return NS_ERROR_UNEXPECTED;
   }
-  return LoadEntry(mIndex + 1, nsIDocShellLoadInfo::loadHistory,
+  return LoadEntry(mIndex + 1, nsDocShellLoadInfo::loadHistory,
                    HIST_CMD_FORWARD);
 }
 
 NS_IMETHODIMP
 nsSHistory::Reload(uint32_t aReloadFlags)
 {
-  nsDocShellInfoLoadType loadType;
+  nsDocShellLoadInfo::nsDocShellInfoLoadType loadType;
   if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
       aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
-    loadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
+    loadType = nsDocShellLoadInfo::loadReloadBypassProxyAndCache;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) {
-    loadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
+    loadType = nsDocShellLoadInfo::loadReloadBypassProxy;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
-    loadType = nsIDocShellLoadInfo::loadReloadBypassCache;
+    loadType = nsDocShellLoadInfo::loadReloadBypassCache;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE) {
-    loadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
+    loadType = nsDocShellLoadInfo::loadReloadCharsetChange;
   } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
-    loadType = nsIDocShellLoadInfo::loadReloadMixedContent;
+    loadType = nsDocShellLoadInfo::loadReloadMixedContent;
   } else {
-    loadType = nsIDocShellLoadInfo::loadReloadNormal;
+    loadType = nsDocShellLoadInfo::loadReloadNormal;
   }
 
   // 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, nsIDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
+  return LoadEntry(mIndex, nsDocShellLoadInfo::loadHistory, 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, nsIDocShellLoadInfo::loadHistory);
+  return InitiateLoad(nextEntry, mRootDocShell, nsDocShellLoadInfo::loadHistory);
 }
 
 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
@@ -1835,17 +1835,17 @@ nsSHistory::LoadURI(const char16_t* aURI
                     nsIPrincipal* aTriggeringPrincipal)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GotoIndex(int32_t aIndex)
 {
-  return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
+  return LoadEntry(aIndex, nsDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
 }
 
 nsresult
 nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
                                   uint32_t aHistCmd)
 {
   mRequestedIndex = -1;
   if (aNewIndex < mIndex) {
@@ -2034,24 +2034,23 @@ nsSHistory::LoadDifferingEntries(nsISHEn
 }
 
 nsresult
 nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
                          long aLoadType)
 {
   NS_ENSURE_STATE(aFrameDS && aFrameEntry);
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   /* Set the loadType in the SHEntry too to  what was passed on.
    * This will be passed on to child subframes later in nsDocShell,
    * so that proper loadType is maintained through out a frameset
    */
   aFrameEntry->SetLoadType(aLoadType);
-  aFrameDS->CreateLoadInfo(getter_AddRefs(loadInfo));
 
   loadInfo->SetLoadType(aLoadType);
   loadInfo->SetSHEntry(aFrameEntry);
 
   nsCOMPtr<nsIURI> originalURI;
   aFrameEntry->GetOriginalURI(getter_AddRefs(originalURI));
   loadInfo->SetOriginalURI(originalURI);
 
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "Location.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 #include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
 #include "nsIURL.h"
 #include "nsIURIMutator.h"
 #include "nsIJARURI.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
@@ -57,17 +57,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Location, mInnerWindow)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Location)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Location)
 
 nsresult
-Location::CheckURL(nsIURI* aURI, nsIDocShellLoadInfo** aLoadInfo)
+Location::CheckURL(nsIURI* aURI, nsDocShellLoadInfo** aLoadInfo)
 {
   *aLoadInfo = nullptr;
 
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   NS_ENSURE_TRUE(docShell, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   nsCOMPtr<nsIURI> sourceURI;
@@ -145,19 +145,17 @@ Location::CheckURL(nsIURI* aURI, nsIDocS
       // subjectPrincipal, wich is the principal of the current JS
       // compartment, or a null principal in case there is no
       // compartment yet.
       triggeringPrincipal = nsContentUtils::SubjectPrincipal();
     }
   }
 
   // Create load info
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-  docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
-  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   loadInfo->SetTriggeringPrincipal(triggeringPrincipal);
 
   if (sourceURI) {
     loadInfo->SetReferrer(sourceURI);
     loadInfo->SetReferrerPolicy(referrerPolicy);
   }
 
@@ -228,25 +226,25 @@ Location::GetWritableURI(nsIURI** aURI, 
   return uri->CloneWithNewRef(*aNewRef, aURI);
 }
 
 nsresult
 Location::SetURI(nsIURI* aURI, bool aReplace)
 {
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   if (docShell) {
-    nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
+    RefPtr<nsDocShellLoadInfo> loadInfo;
 
     if(NS_FAILED(CheckURL(aURI, getter_AddRefs(loadInfo))))
       return NS_ERROR_FAILURE;
 
     if (aReplace) {
-      loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContentAndReplace);
+      loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContentAndReplace);
     } else {
-      loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContent);
+      loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContent);
     }
 
     // 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/Location.h
+++ b/dom/base/Location.h
@@ -11,17 +11,16 @@
 #include "mozilla/ErrorResult.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsPIDOMWindow.h"
 #include "nsString.h"
 #include "nsWrapperCache.h"
 
 class nsIDocShell;
-class nsIDocShellLoadInfo;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 
 //*****************************************************************************
 // Location: Script "location" object
 //*****************************************************************************
@@ -174,17 +173,17 @@ protected:
                           const nsACString* aNewRef = nullptr);
   nsresult SetURI(nsIURI* aURL, bool aReplace = false);
   nsresult SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
                            bool aReplace);
   nsresult SetHrefWithContext(JSContext* cx, const nsAString& aHref,
                               bool aReplace);
 
   nsresult GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL);
-  nsresult CheckURL(nsIURI *url, nsIDocShellLoadInfo** aLoadInfo);
+  nsresult CheckURL(nsIURI *url, nsDocShellLoadInfo** aLoadInfo);
   bool CallerSubsumes(nsIPrincipal* aSubjectPrincipal);
 
   nsString mCachedHash;
   nsCOMPtr<nsPIDOMWindowInner> mInnerWindow;
   nsWeakPtr mDocShell;
 };
 
 } // dom namespace
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -20,17 +20,17 @@
 #include "nsIContentInlines.h"
 #include "nsIContentViewer.h"
 #include "nsIDocument.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebProgress.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeOwner.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIBaseWindow.h"
 #include "nsIBrowser.h"
 #include "nsContentUtils.h"
 #include "nsIXPConnect.h"
 #include "nsUnicharUtils.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScrollable.h"
@@ -467,19 +467,17 @@ nsFrameLoader::ReallyStartLoadingInterna
   }
   NS_ASSERTION(mDocShell,
                "MaybeCreateDocShell succeeded with a null mDocShell");
 
   // Just to be safe, recheck uri.
   rv = CheckURILoad(mURIToLoad, mTriggeringPrincipal);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-  mDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
-  NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   loadInfo->SetOriginalFrameSrc(mLoadingOriginalSrc);
   mLoadingOriginalSrc = false;
 
   // If this frame is sandboxed with respect to origin we will set it up with
   // a null principal later in nsDocShell::DoURILoad.
   // We do it there to correctly sandbox content that was loaded into
   // the frame via other methods than the src attribute.
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -54,16 +54,17 @@
 #include "nsWindowSizes.h"
 #include "WindowNamedPropertiesHandler.h"
 #include "nsFrameSelection.h"
 #include "nsNetUtil.h"
 #include "nsVariant.h"
 #include "nsPrintfCString.h"
 #include "mozilla/intl/LocaleService.h"
 #include "WindowDestroyedEvent.h"
+#include "nsDocShellLoadInfo.h"
 
 // Helper Classes
 #include "nsJSUtils.h"
 #include "jsapi.h"              // for JSAutoRequest
 #include "js/Wrapper.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsReadableUtils.h"
 #include "nsJSEnvironment.h"
@@ -5462,17 +5463,17 @@ nsGlobalWindowOuter::OpenOuter(const nsA
 {
   nsCOMPtr<nsPIDOMWindowOuter> window;
   aError = OpenJS(aUrl, aName, aOptions, getter_AddRefs(window));
   return window.forget();
 }
 
 nsresult
 nsGlobalWindowOuter::Open(const nsAString& aUrl, const nsAString& aName,
-                          const nsAString& aOptions, nsIDocShellLoadInfo* aLoadInfo,
+                          const nsAString& aOptions, nsDocShellLoadInfo* aLoadInfo,
                           bool aForceNoOpener, nsPIDOMWindowOuter **_retval)
 {
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
                       false,          // aContentModal
                       true,           // aCalledNoScript
                       false,          // aDoJSFixups
                       true,           // aNavigate
@@ -6847,17 +6848,17 @@ public:
 
 nsresult
 nsGlobalWindowOuter::OpenInternal(const nsAString& aUrl, const nsAString& aName,
                                   const nsAString& aOptions, bool aDialog,
                                   bool aContentModal, bool aCalledNoScript,
                                   bool aDoJSFixups, bool aNavigate,
                                   nsIArray *argv,
                                   nsISupports *aExtraArgument,
-                                  nsIDocShellLoadInfo* aLoadInfo,
+                                  nsDocShellLoadInfo* aLoadInfo,
                                   bool aForceNoOpener,
                                   nsPIDOMWindowOuter **aReturn)
 {
 #ifdef DEBUG
   uint32_t argc = 0;
   if (argv)
       argv->GetLength(&argc);
 #endif
--- a/dom/base/nsGlobalWindowOuter.h
+++ b/dom/base/nsGlobalWindowOuter.h
@@ -67,16 +67,17 @@ class nsIControllers;
 class nsIJSID;
 class nsIScriptContext;
 class nsIScriptTimeoutHandler;
 class nsITabChild;
 class nsITimeoutHandler;
 class nsIWebBrowserChrome;
 class mozIDOMWindowProxy;
 
+class nsDocShellLoadInfo;
 class nsDOMWindowList;
 class nsScreen;
 class nsHistory;
 class nsGlobalWindowObserver;
 class nsGlobalWindowInner;
 class nsDOMWindowUtils;
 class nsIIdleService;
 struct nsRect;
@@ -606,17 +607,17 @@ public:
   mozilla::dom::Element* GetFrameElement() override;
   already_AddRefed<nsPIDOMWindowOuter>
   OpenOuter(const nsAString& aUrl,
             const nsAString& aName,
             const nsAString& aOptions,
             mozilla::ErrorResult& aError);
   nsresult Open(const nsAString& aUrl, const nsAString& aName,
                 const nsAString& aOptions,
-                nsIDocShellLoadInfo* aLoadInfo,
+                nsDocShellLoadInfo* aLoadInfo,
                 bool aForceNoOpener,
                 nsPIDOMWindowOuter **_retval) override;
   mozilla::dom::Navigator* GetNavigator() override;
 
 #if defined(MOZ_WIDGET_ANDROID)
   int16_t Orientation(mozilla::dom::CallerType aCallerType) const;
 #endif
 
@@ -892,17 +893,17 @@ private:
                         const nsAString& aOptions,
                         bool aDialog,
                         bool aContentModal,
                         bool aCalledNoScript,
                         bool aDoJSFixups,
                         bool aNavigate,
                         nsIArray *argv,
                         nsISupports *aExtraArgument,
-                        nsIDocShellLoadInfo* aLoadInfo,
+                        nsDocShellLoadInfo* aLoadInfo,
                         bool aForceNoOpener,
                         nsPIDOMWindowOuter **aReturn);
 
 public:
   // Helper Functions
   already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
   already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
   already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -11,17 +11,16 @@
 
 // Interface headers
 #include "imgLoader.h"
 #include "nsIClassOfService.h"
 #include "nsIConsoleService.h"
 #include "nsIContent.h"
 #include "nsIContentInlines.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
 #include "nsIDocument.h"
 #include "nsIExternalProtocolHandler.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIObjectFrame.h"
 #include "nsIOService.h"
 #include "nsIPermissionManager.h"
 #include "nsPluginHost.h"
 #include "nsPluginInstanceOwner.h"
--- a/dom/base/nsPIDOMWindow.h
+++ b/dom/base/nsPIDOMWindow.h
@@ -24,17 +24,17 @@
 
 class nsDOMWindowList;
 class nsGlobalWindowInner;
 class nsGlobalWindowOuter;
 class nsIArray;
 class nsIContent;
 class nsICSSDeclaration;
 class nsIDocShell;
-class nsIDocShellLoadInfo;
+class nsDocShellLoadInfo;
 class nsIDocument;
 class nsIIdleObserver;
 class nsIPrincipal;
 class nsIScriptTimeoutHandler;
 class nsISerialEventTarget;
 class nsIURI;
 class nsPIDOMWindowInner;
 class nsPIDOMWindowOuter;
@@ -1120,17 +1120,17 @@ public:
 
   virtual nsDOMWindowList* GetFrames() = 0;
 
   // aLoadInfo will be passed on through to the windowwatcher.
   // aForceNoOpener will act just like a "noopener" feature in aOptions except
   //                will not affect any other window features.
   virtual nsresult Open(const nsAString& aUrl, const nsAString& aName,
                         const nsAString& aOptions,
-                        nsIDocShellLoadInfo* aLoadInfo,
+                        nsDocShellLoadInfo* aLoadInfo,
                         bool aForceNoOpener,
                         nsPIDOMWindowOuter **_retval) = 0;
   virtual nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
                               const nsAString& aOptions,
                               nsISupports* aExtraArgument,
                               nsPIDOMWindowOuter** _retval) = 0;
 
   virtual nsresult GetInnerWidth(int32_t* aWidth) = 0;
--- a/dom/clients/manager/ClientNavigateOpChild.cpp
+++ b/dom/clients/manager/ClientNavigateOpChild.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ClientNavigateOpChild.h"
 
 #include "ClientState.h"
 #include "mozilla/Unused.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebProgress.h"
 #include "nsIWebProgressListener.h"
 #include "nsNetUtil.h"
 #include "nsPIDOMWindow.h"
 
 namespace mozilla {
 namespace dom {
@@ -211,26 +211,21 @@ ClientNavigateOpChild::DoNavigate(const 
 
   nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
   nsCOMPtr<nsIWebProgress> webProgress = do_GetInterface(docShell);
   if (!docShell || !webProgress) {
     ref = ClientOpPromise::CreateAndReject(NS_ERROR_DOM_INVALID_STATE_ERR, __func__);
     return ref.forget();
   }
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
-  rv = docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
-  if (NS_FAILED(rv)) {
-    ref = ClientOpPromise::CreateAndReject(rv, __func__);
-    return ref.forget();
-  }
+  RefPtr<nsDocShellLoadInfo> loadInfo = new nsDocShellLoadInfo();
 
   loadInfo->SetTriggeringPrincipal(principal);
   loadInfo->SetReferrerPolicy(doc->GetReferrerPolicy());
-  loadInfo->SetLoadType(nsIDocShellLoadInfo::loadStopContent);
+  loadInfo->SetLoadType(nsDocShellLoadInfo::loadStopContent);
   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/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -110,17 +110,17 @@
 #include "mozilla/Sandbox.h"
 #endif
 #endif
 
 #include "mozilla/Unused.h"
 
 #include "mozInlineSpellChecker.h"
 #include "nsDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIConsoleListener.h"
 #include "nsIContentViewer.h"
 #include "nsICycleCollectorListener.h"
 #include "nsIIdlePeriod.h"
 #include "nsIDragService.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMemoryReporter.h"
 #include "nsIMemoryInfoDumper.h"
@@ -763,29 +763,29 @@ ContentChild::ProvideWindow(mozIDOMWindo
                             uint32_t aChromeFlags,
                             bool aCalledFromJS,
                             bool aPositionSpecified,
                             bool aSizeSpecified,
                             nsIURI* aURI,
                             const nsAString& aName,
                             const nsACString& aFeatures,
                             bool aForceNoOpener,
-                            nsIDocShellLoadInfo* aLoadInfo,
+                            nsDocShellLoadInfo* aLoadInfo,
                             bool* aWindowIsNew,
                             mozIDOMWindowProxy** aReturn)
 {
   return ProvideWindowCommon(nullptr, aParent, false, aChromeFlags,
                              aCalledFromJS, aPositionSpecified,
                              aSizeSpecified, aURI, aName, aFeatures,
                              aForceNoOpener, aLoadInfo, aWindowIsNew, aReturn);
 }
 
 static nsresult
 GetCreateWindowParams(mozIDOMWindowProxy* aParent,
-                      nsIDocShellLoadInfo* aLoadInfo,
+                      nsDocShellLoadInfo* aLoadInfo,
                       nsACString& aBaseURIString, float* aFullZoom,
                       uint32_t* aReferrerPolicy,
                       nsIPrincipal** aTriggeringPrincipal)
 {
   *aFullZoom = 1.0f;
   if (!aTriggeringPrincipal) {
     NS_ERROR("aTriggeringPrincipal is null");
     return NS_ERROR_FAILURE;
@@ -840,17 +840,17 @@ ContentChild::ProvideWindowCommon(TabChi
                                   uint32_t aChromeFlags,
                                   bool aCalledFromJS,
                                   bool aPositionSpecified,
                                   bool aSizeSpecified,
                                   nsIURI* aURI,
                                   const nsAString& aName,
                                   const nsACString& aFeatures,
                                   bool aForceNoOpener,
-                                  nsIDocShellLoadInfo* aLoadInfo,
+                                  nsDocShellLoadInfo* aLoadInfo,
                                   bool* aWindowIsNew,
                                   mozIDOMWindowProxy** aReturn)
 {
   *aReturn = nullptr;
 
   nsAutoPtr<IPCTabContext> ipcContext;
   TabId openerTabId = TabId(0);
   nsAutoCString features(aFeatures);
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -29,17 +29,17 @@
 
 struct ChromePackage;
 class nsIObserver;
 struct SubstitutionMapping;
 struct OverrideMapping;
 class nsIDomainPolicy;
 class nsIURIClassifierCallback;
 struct LookAndFeelInt;
-class nsIDocShellLoadInfo;
+class nsDocShellLoadInfo;
 
 namespace mozilla {
 class RemoteSpellcheckEngineChild;
 class ChildProfilerController;
 
 using mozilla::loader::PScriptCacheChild;
 
 #if !defined(XP_WIN)
@@ -114,17 +114,17 @@ public:
                       uint32_t aChromeFlags,
                       bool aCalledFromJS,
                       bool aPositionSpecified,
                       bool aSizeSpecified,
                       nsIURI* aURI,
                       const nsAString& aName,
                       const nsACString& aFeatures,
                       bool aForceNoOpener,
-                      nsIDocShellLoadInfo* aLoadInfo,
+                      nsDocShellLoadInfo* aLoadInfo,
                       bool* aWindowIsNew,
                       mozIDOMWindowProxy** aReturn);
 
   bool Init(MessageLoop* aIOLoop,
             base::ProcessId aParentPid,
             const char* aParentBuildID,
             IPC::Channel* aChannel,
             uint64_t aChildID,
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -118,17 +118,17 @@
 #include "nsICommandParams.h"
 #include "nsISHistory.h"
 #include "nsQueryObject.h"
 #include "nsIHttpChannel.h"
 #include "mozilla/dom/DocGroup.h"
 #include "nsString.h"
 #include "nsISupportsPrimitives.h"
 #include "mozilla/Telemetry.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 
 #ifdef XP_WIN
 #include "mozilla/plugins/PluginWidgetChild.h"
 #endif
 
 #ifdef NS_PRINTING
 #include "nsIPrintSession.h"
 #include "nsIPrintSettings.h"
@@ -995,17 +995,17 @@ TabChild::GetInterface(const nsIID & aII
 
 NS_IMETHODIMP
 TabChild::ProvideWindow(mozIDOMWindowProxy* aParent,
                         uint32_t aChromeFlags,
                         bool aCalledFromJS,
                         bool aPositionSpecified, bool aSizeSpecified,
                         nsIURI* aURI, const nsAString& aName,
                         const nsACString& aFeatures, bool aForceNoOpener,
-                        nsIDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
+                        nsDocShellLoadInfo* aLoadInfo, bool* aWindowIsNew,
                         mozIDOMWindowProxy** aReturn)
 {
     *aReturn = nullptr;
 
     // If aParent is inside an <iframe mozbrowser> and this isn't a request to
     // open a modal-type window, we're going to create a new <iframe mozbrowser>
     // and return its window here.
     nsCOMPtr<nsIDocShell> docshell = do_GetInterface(aParent);
--- 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 = Ci.nsIDocShellLoadInfo.loadHistory;
+    shEntry.loadType = 2; /* nsDocShellLoadInfo::loadHistory */
     shEntry.cacheKey = shEntrySource.cacheKey;
     docShell.QueryInterface(Ci.nsIWebNavigation)
             .sessionHistory
             .legacySHistory
             .QueryInterface(Ci.nsISHistoryInternal)
             .addEntry(shEntry, true);
   },
 
--- a/toolkit/components/windowcreator/nsIWindowProvider.idl
+++ b/toolkit/components/windowcreator/nsIWindowProvider.idl
@@ -8,19 +8,23 @@
  * open a new window.  This interface can be implemented by Gecko consumers who
  * wish to provide a custom "new window" of their own (for example by returning
  * a new tab, an existing window, etc) instead of just having a real new
  * toplevel window open.
  */
 
 #include "nsISupports.idl"
 
+%{ C++
+class nsDocShellLoadInfo;
+%}
+
 interface mozIDOMWindowProxy;
 interface nsIURI;
-interface nsIDocShellLoadInfo;
+native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
 
 /**
  * The nsIWindowProvider interface exists so that the window watcher's default
  * behavior of opening a new window can be easly modified.  When the window
  * watcher needs to open a new window, it will first check with the
  * nsIWindowProvider it gets from the parent window.  If there is no provider
  * or the provider does not provide a window, the window watcher will proceed
  * to actually open a new window.
@@ -97,11 +101,11 @@ interface nsIWindowProvider : nsISupport
                                    in unsigned long aChromeFlags,
                                    in boolean aCalledFromJS,
                                    in boolean aPositionSpecified,
                                    in boolean aSizeSpecified,
                                    in nsIURI aURI,
                                    in AString aName,
                                    in AUTF8String aFeatures,
                                    in boolean aForceNoOpener,
-                                   in nsIDocShellLoadInfo aLoadInfo,
+                                   in nsDocShellLoadInfoPtr aLoadInfo,
                                    out boolean aWindowIsNew);
 };
--- a/toolkit/components/windowwatcher/nsPIWindowWatcher.idl
+++ b/toolkit/components/windowwatcher/nsPIWindowWatcher.idl
@@ -5,24 +5,28 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* Private "control" methods on the Window Watcher. These are annoying
    bookkeeping methods, not part of the public (embedding) interface.
 */
 
 #include "nsISupports.idl"
 
+%{ C++
+class nsDocShellLoadInfo;
+%}
+
 interface mozIDOMWindowProxy;
 interface nsIDOMWindow;
 interface nsISimpleEnumerator;
 interface nsIWebBrowserChrome;
 interface nsIDocShellTreeItem;
 interface nsIArray;
 interface nsITabParent;
-interface nsIDocShellLoadInfo;
+native nsDocShellLoadInfoPtr(nsDocShellLoadInfo*);
 
 [uuid(d162f9c4-19d5-4723-931f-f1e51bfa9f68)]
 
 interface nsPIWindowWatcher : nsISupports
 {
   /** A window has been created. Add it to our list.
       @param aWindow the window to add
       @param aChrome the corresponding chrome window. The DOM window
@@ -81,17 +85,17 @@ interface nsPIWindowWatcher : nsISupport
   mozIDOMWindowProxy openWindow2(in mozIDOMWindowProxy aParent, in string aUrl,
                                  in string aName, in string aFeatures,
                                  in boolean aCalledFromScript,
                                  in boolean aDialog,
                                  in boolean aNavigate,
                                  in nsISupports aArgs,
                                  in boolean aIsPopupSpam,
                                  in boolean aForceNoOpener,
-                                 in nsIDocShellLoadInfo aLoadInfo);
+                                 in nsDocShellLoadInfoPtr aLoadInfo);
 
   /**
    * Opens a new window so that the window that aOpeningTab belongs to
    * is set as the parent window. The newly opened window will also
    * inherit load context information from aOpeningTab.
    *
    * @param aOpeningTab
    *        The nsITabParent that is requesting the new window be opened.
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -17,17 +17,17 @@
 #include "plstr.h"
 
 #include "nsDocShell.h"
 #include "nsGlobalWindow.h"
 #include "nsHashPropertyBag.h"
 #include "nsIBaseWindow.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIDocShell.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocumentLoader.h"
 #include "nsIDocument.h"
 #include "nsIDOMWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIPrompt.h"
 #include "nsIScriptObjectPrincipal.h"
@@ -390,17 +390,17 @@ nsWindowWatcher::OpenWindow2(mozIDOMWind
                              const char* aName,
                              const char* aFeatures,
                              bool aCalledFromScript,
                              bool aDialog,
                              bool aNavigate,
                              nsISupports* aArguments,
                              bool aIsPopupSpam,
                              bool aForceNoOpener,
-                             nsIDocShellLoadInfo* aLoadInfo,
+                             nsDocShellLoadInfo* aLoadInfo,
                              mozIDOMWindowProxy** aResult)
 {
   nsCOMPtr<nsIArray> argv = ConvertArgsToArray(aArguments);
 
   uint32_t argc = 0;
   if (argv) {
     argv->GetLength(&argc);
   }
@@ -636,17 +636,17 @@ nsWindowWatcher::OpenWindowInternal(mozI
                                     const char* aName,
                                     const char* aFeatures,
                                     bool aCalledFromJS,
                                     bool aDialog,
                                     bool aNavigate,
                                     nsIArray* aArgv,
                                     bool aIsPopupSpam,
                                     bool aForceNoOpener,
-                                    nsIDocShellLoadInfo* aLoadInfo,
+                                    nsDocShellLoadInfo* aLoadInfo,
                                     mozIDOMWindowProxy** aResult)
 {
   nsresult rv = NS_OK;
   bool isNewToplevelWindow = false;
   bool windowIsNew = false;
   bool windowNeedsName = false;
   bool windowIsModal = false;
   bool uriToLoadIsChrome = false;
@@ -1117,20 +1117,19 @@ nsWindowWatcher::OpenWindowInternal(mozI
   } else if (windowIsNew) {
     nsCOMPtr<nsILoadContext> childContext = do_QueryInterface(newDocShellItem);
     if (childContext) {
       childContext->SetPrivateBrowsing(isPrivateBrowsingWindow);
       childContext->SetRemoteTabs(isRemoteWindow);
     }
   }
 
-  nsCOMPtr<nsIDocShellLoadInfo> loadInfo = aLoadInfo;
+  RefPtr<nsDocShellLoadInfo> loadInfo = aLoadInfo;
   if (uriToLoad && aNavigate && !loadInfo) {
-    newDocShell->CreateLoadInfo(getter_AddRefs(loadInfo));
-    NS_ENSURE_TRUE(loadInfo, NS_ERROR_FAILURE);
+    loadInfo = new nsDocShellLoadInfo();
 
     if (subjectPrincipal) {
       loadInfo->SetTriggeringPrincipal(subjectPrincipal);
     }
 
     /* use the URL from the *extant* document, if any. The usual accessor
        GetDocument will synchronously create an about:blank document if
        it has no better answer, and we only care about a real document.
--- a/toolkit/components/windowwatcher/nsWindowWatcher.h
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.h
@@ -83,17 +83,17 @@ protected:
                               const char* aName,
                               const char* aFeatures,
                               bool aCalledFromJS,
                               bool aDialog,
                               bool aNavigate,
                               nsIArray* aArgv,
                               bool aIsPopupSpam,
                               bool aForceNoOpener,
-                              nsIDocShellLoadInfo* aLoadInfo,
+                              nsDocShellLoadInfo* aLoadInfo,
                               mozIDOMWindowProxy** aResult);
 
   static nsresult URIfromURL(const char* aURL,
                              mozIDOMWindowProxy* aParent,
                              nsIURI** aURI);
 
   static uint32_t CalculateChromeFlagsForChild(const nsACString& aFeaturesStr);
 
--- 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 = Ci.nsIDocShellLoadInfo.loadHistory;
+    shEntry.loadType = 2; /* nsDocShellLoadInfo::loadHistory */
     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);
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -28,17 +28,17 @@
 #include "nsIWebNavigation.h"
 #include "nsDocShellCID.h"
 #include "nsIExternalURLHandlerService.h"
 #include "nsIMIMEInfo.h"
 #include "nsIWidget.h"
 #include "nsWindowWatcher.h"
 #include "NullPrincipal.h"
 #include "mozilla/BrowserElementParent.h"
-#include "nsIDocShellLoadInfo.h"
+#include "nsDocShellLoadInfo.h"
 
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
 #include "nsIDocument.h"
 #if defined(XP_MACOSX)
 #include "nsThreadUtils.h"
 #endif
 
@@ -794,17 +794,17 @@ nsContentTreeOwner::ProvideWindow(mozIDO
                                   uint32_t aChromeFlags,
                                   bool aCalledFromJS,
                                   bool aPositionSpecified,
                                   bool aSizeSpecified,
                                   nsIURI* aURI,
                                   const nsAString& aName,
                                   const nsACString& aFeatures,
                                   bool aForceNoOpener,
-                                  nsIDocShellLoadInfo* aLoadInfo,
+                                  nsDocShellLoadInfo* aLoadInfo,
                                   bool* aWindowIsNew,
                                   mozIDOMWindowProxy** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aParent);
 
   auto* parent = nsPIDOMWindowOuter::From(aParent);
 
   *aReturn = nullptr;