Bug 1129795 - Convert rest of docshell/ to Gecko style. r=mccr8
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 06 May 2015 10:57:23 -0700
changeset 261585 db70fd907041471df8102f6bd4a3250078cda8c7
parent 261584 ef516c84ef5496c3a8576e85c3e6ecb7b0776104
child 261586 cd73fb605ca3666419d8d62ca8f480a1ac957fa2
push id8007
push userraliiev@mozilla.com
push dateMon, 11 May 2015 19:23:16 +0000
treeherdermozilla-aurora@e2ce1aac996e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1129795
milestone40.0a1
Bug 1129795 - Convert rest of docshell/ to Gecko style. r=mccr8
docshell/base/LoadContext.cpp
docshell/base/LoadContext.h
docshell/base/SerializedLoadContext.cpp
docshell/base/SerializedLoadContext.h
docshell/base/nsDSURIContentListener.cpp
docshell/base/nsDefaultURIFixup.cpp
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsDocShellEditorData.h
docshell/base/nsDocShellEnumerator.h
docshell/base/nsDocShellLoadInfo.cpp
docshell/base/nsDocShellLoadTypes.h
docshell/base/nsDocShellTransferableHooks.cpp
docshell/base/nsDownloadHistory.cpp
docshell/base/nsILinkHandler.h
docshell/base/nsIWebShellServices.h
docshell/base/nsWebNavigationInfo.h
docshell/build/nsDocShellCID.h
docshell/build/nsDocShellModule.cpp
docshell/shistory/src/nsSHEntry.cpp
docshell/shistory/src/nsSHEntry.h
docshell/shistory/src/nsSHEntryShared.cpp
docshell/shistory/src/nsSHEntryShared.h
docshell/shistory/src/nsSHTransaction.cpp
docshell/shistory/src/nsSHTransaction.h
docshell/shistory/src/nsSHistory.cpp
docshell/shistory/src/nsSHistory.h
--- a/docshell/base/LoadContext.cpp
+++ b/docshell/base/LoadContext.cpp
@@ -6,38 +6,40 @@
 
 #include "mozilla/Assertions.h"
 #include "mozilla/LoadContext.h"
 
 namespace mozilla {
 
 NS_IMPL_ISUPPORTS(LoadContext, nsILoadContext, nsIInterfaceRequestor)
 
-LoadContext::LoadContext(nsIPrincipal* aPrincipal, nsILoadContext* aOptionalBase)
+LoadContext::LoadContext(nsIPrincipal* aPrincipal,
+                         nsILoadContext* aOptionalBase)
   : mTopFrameElement(nullptr)
   , mNestedFrameId(0)
   , mIsContent(true)
   , mUsePrivateBrowsing(false)
   , mUseRemoteTabs(false)
 #ifdef DEBUG
   , mIsNotNull(true)
 #endif
 {
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aPrincipal->GetAppId(&mAppId)));
-  MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement)));
+  MOZ_ALWAYS_TRUE(
+    NS_SUCCEEDED(aPrincipal->GetIsInBrowserElement(&mIsInBrowserElement)));
 
   if (!aOptionalBase) {
     return;
   }
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aOptionalBase->GetIsContent(&mIsContent)));
-  MOZ_ALWAYS_TRUE(NS_SUCCEEDED(
-    aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing)));
-  MOZ_ALWAYS_TRUE(NS_SUCCEEDED(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs)));
+  MOZ_ALWAYS_TRUE(
+    NS_SUCCEEDED(aOptionalBase->GetUsePrivateBrowsing(&mUsePrivateBrowsing)));
+  MOZ_ALWAYS_TRUE(
+    NS_SUCCEEDED(aOptionalBase->GetUseRemoteTabs(&mUseRemoteTabs)));
 }
 
 //-----------------------------------------------------------------------------
 // LoadContext::nsILoadContext
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
 LoadContext::GetAssociatedWindow(nsIDOMWindow**)
--- a/docshell/base/LoadContext.h
+++ b/docshell/base/LoadContext.h
@@ -48,34 +48,36 @@ public:
     , mAppId(aAppId)
     , mIsContent(aToCopy.mIsContent)
     , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mIsInBrowserElement(aInBrowser)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
-  {}
+  {
+  }
 
   // AppId/inBrowser arguments override those in SerializedLoadContext provided
   // by child process.
   LoadContext(const IPC::SerializedLoadContext& aToCopy,
               uint64_t aNestedFrameId,
               uint32_t aAppId, bool aInBrowser)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(aNestedFrameId)
     , mAppId(aAppId)
     , mIsContent(aToCopy.mIsContent)
     , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing)
     , mUseRemoteTabs(aToCopy.mUseRemoteTabs)
     , mIsInBrowserElement(aInBrowser)
 #ifdef DEBUG
     , mIsNotNull(aToCopy.mIsNotNull)
 #endif
-  {}
+  {
+  }
 
   LoadContext(dom::Element* aTopFrameElement,
               uint32_t aAppId,
               bool aIsContent,
               bool aUsePrivateBrowsing,
               bool aUseRemoteTabs,
               bool aIsInBrowserElement)
     : mTopFrameElement(do_GetWeakReference(aTopFrameElement))
@@ -83,31 +85,33 @@ public:
     , mAppId(aAppId)
     , mIsContent(aIsContent)
     , mUsePrivateBrowsing(aUsePrivateBrowsing)
     , mUseRemoteTabs(aUseRemoteTabs)
     , mIsInBrowserElement(aIsInBrowserElement)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
-  {}
+  {
+  }
 
   // Constructor taking reserved appId for the safebrowsing cookie.
   explicit LoadContext(uint32_t aAppId)
     : mTopFrameElement(nullptr)
     , mNestedFrameId(0)
     , mAppId(aAppId)
     , mIsContent(false)
     , mUsePrivateBrowsing(false)
     , mUseRemoteTabs(false)
     , mIsInBrowserElement(false)
 #ifdef DEBUG
     , mIsNotNull(true)
 #endif
-  {}
+  {
+  }
 
   // Constructor for creating a LoadContext with a given principal's appId and
   // browser flag.
   explicit LoadContext(nsIPrincipal* aPrincipal,
                        nsILoadContext* aOptionalBase = nullptr);
 
 private:
   ~LoadContext() {}
@@ -122,9 +126,8 @@ private:
 #ifdef DEBUG
   bool mIsNotNull;
 #endif
 };
 
 } // namespace mozilla
 
 #endif // LoadContext_h
-
--- a/docshell/base/SerializedLoadContext.cpp
+++ b/docshell/base/SerializedLoadContext.cpp
@@ -72,9 +72,8 @@ SerializedLoadContext::Init(nsILoadConte
     mUsePrivateBrowsing = false;
     mUseRemoteTabs = false;
     mAppId = 0;
     mIsInBrowserElement = false;
   }
 }
 
 } // namespace IPC
-
--- a/docshell/base/SerializedLoadContext.h
+++ b/docshell/base/SerializedLoadContext.h
@@ -67,25 +67,24 @@ struct ParamTraits<SerializedLoadContext
     WriteParam(aMsg, aParam.mUseRemoteTabs);
     WriteParam(aMsg, aParam.mAppId);
     WriteParam(aMsg, aParam.mIsInBrowserElement);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     if (!ReadParam(aMsg, aIter, &aResult->mIsNotNull) ||
-        !ReadParam(aMsg, aIter, &aResult->mIsContent)  ||
-        !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid)  ||
-        !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing)  ||
-        !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs)  ||
-        !ReadParam(aMsg, aIter, &aResult->mAppId)  ||
+        !ReadParam(aMsg, aIter, &aResult->mIsContent) ||
+        !ReadParam(aMsg, aIter, &aResult->mIsPrivateBitValid) ||
+        !ReadParam(aMsg, aIter, &aResult->mUsePrivateBrowsing) ||
+        !ReadParam(aMsg, aIter, &aResult->mUseRemoteTabs) ||
+        !ReadParam(aMsg, aIter, &aResult->mAppId) ||
         !ReadParam(aMsg, aIter, &aResult->mIsInBrowserElement)) {
       return false;
     }
 
     return true;
   }
 };
 
 } // namespace IPC
 
 #endif // SerializedLoadContext_h
-
--- a/docshell/base/nsDSURIContentListener.cpp
+++ b/docshell/base/nsDSURIContentListener.cpp
@@ -21,20 +21,16 @@
 #include "nsCharSeparatedTokenizer.h"
 #include "nsIConsoleService.h"
 #include "nsIScriptError.h"
 #include "nsDocShellLoadTypes.h"
 #include "nsIMultiPartChannel.h"
 
 using namespace mozilla;
 
-//*****************************************************************************
-//***    nsDSURIContentListener: Object Management
-//*****************************************************************************
-
 nsDSURIContentListener::nsDSURIContentListener(nsDocShell* aDocShell)
   : mDocShell(aDocShell)
   , mExistingJPEGRequest(nullptr)
   , mParentContentListener(nullptr)
 {
 }
 
 nsDSURIContentListener::~nsDSURIContentListener()
@@ -45,39 +41,30 @@ nsresult
 nsDSURIContentListener::Init()
 {
   nsresult rv;
   mNavInfo = do_GetService(NS_WEBNAVIGATION_INFO_CONTRACTID, &rv);
   NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to get webnav info");
   return rv;
 }
 
-//*****************************************************************************
-// nsDSURIContentListener::nsISupports
-//*****************************************************************************
-
 NS_IMPL_ADDREF(nsDSURIContentListener)
 NS_IMPL_RELEASE(nsDSURIContentListener)
 
 NS_INTERFACE_MAP_BEGIN(nsDSURIContentListener)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
   NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
-//*****************************************************************************
-// nsDSURIContentListener::nsIURIContentListener
-//*****************************************************************************
-
 NS_IMETHODIMP
 nsDSURIContentListener::OnStartURIOpen(nsIURI* aURI, bool* aAbortOpen)
 {
-  // If mDocShell is null here, that means someone's starting a load
-  // in our docshell after it's already been destroyed.  Don't let
-  // that happen.
+  // If mDocShell is null here, that means someone's starting a load in our
+  // docshell after it's already been destroyed.  Don't let that happen.
   if (!mDocShell) {
     *aAbortOpen = true;
     return NS_OK;
   }
 
   nsCOMPtr<nsIURIContentListener> parentListener;
   GetParentContentListener(getter_AddRefs(parentListener));
   if (parentListener) {
@@ -183,27 +170,26 @@ nsDSURIContentListener::IsPreferred(cons
 
   nsCOMPtr<nsIURIContentListener> parentListener;
   GetParentContentListener(getter_AddRefs(parentListener));
   if (parentListener) {
     return parentListener->IsPreferred(aContentType,
                                        aDesiredContentType,
                                        aCanHandle);
   }
-  // we used to return false here if we didn't have a parent properly
-  // registered at the top of the docshell hierarchy to dictate what
-  // content types this docshell should be a preferred handler for.  But
-  // this really makes it hard for developers using iframe or browser tags
-  // because then they need to make sure they implement
-  // nsIURIContentListener otherwise all link clicks would get sent to
-  // another window because we said we weren't the preferred handler type.
-  // I'm going to change the default now...if we can handle the content,
-  // and someone didn't EXPLICITLY set a nsIURIContentListener at the top
-  // of our docshell chain, then we'll now always attempt to process the
-  // content ourselves...
+  // we used to return false here if we didn't have a parent properly registered
+  // at the top of the docshell hierarchy to dictate what content types this
+  // docshell should be a preferred handler for. But this really makes it hard
+  // for developers using iframe or browser tags because then they need to make
+  // sure they implement nsIURIContentListener otherwise all link clicks would
+  // get sent to another window because we said we weren't the preferred handler
+  // type. I'm going to change the default now... if we can handle the content,
+  // and someone didn't EXPLICITLY set a nsIURIContentListener at the top of our
+  // docshell chain, then we'll now always attempt to process the content
+  // ourselves...
   return CanHandleContent(aContentType, true, aDesiredContentType, aCanHandle);
 }
 
 NS_IMETHODIMP
 nsDSURIContentListener::CanHandleContent(const char* aContentType,
                                          bool aIsContentPreferred,
                                          char** aDesiredContentType,
                                          bool* aCanHandleContent)
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -965,17 +965,18 @@ nsDefaultURIFixup::KeywordURIFixup(const
              (*iter >= 'A' && *iter <= 'F') ||
              nsCRT::IsAsciiDigit(*iter)))) {
         looksLikeIpv6 = false;
       }
     }
 
     // If we're at the end of the string or this is the first slash,
     // check if the thing before the slash looks like ipv4:
-    if ((iter.size_forward() == 1 || (lastSlashLoc == uint32_t(kNotFound) && *iter == '/')) &&
+    if ((iter.size_forward() == 1 ||
+         (lastSlashLoc == uint32_t(kNotFound) && *iter == '/')) &&
         // Need 2 or 3 dots + only digits
         (foundDots == 2 || foundDots == 3) &&
         // and they should be all that came before now:
         (foundDots + foundDigits == pos ||
          // or maybe there was also exactly 1 colon that came after the last dot,
          // and the digits, dots and colon were all that came before now:
          (foundColons == 1 && firstColonLoc > lastDotLoc &&
           foundDots + foundDigits + foundColons == pos))) {
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -707,17 +707,18 @@ SendPing(void* aClosure, nsIContent* aCo
   chan->SetLoadGroup(loadGroup);
 
   // Construct a listener that merely discards any response.  If successful at
   // opening the channel, then it is not necessary to hold a reference to the
   // channel.  The networking subsystem will take care of that for us.
   nsPingListener* pingListener =
     new nsPingListener(info->requireSameHost, aContent, loadGroup);
 
-  nsCOMPtr<nsINetworkInterceptController> interceptController = do_QueryInterface(info->docShell);
+  nsCOMPtr<nsINetworkInterceptController> interceptController =
+    do_QueryInterface(info->docShell);
   pingListener->SetInterceptController(interceptController);
   nsCOMPtr<nsIStreamListener> listener(pingListener);
 
   // Observe redirects as well:
   nsCOMPtr<nsIInterfaceRequestor> callbacks = do_QueryInterface(listener);
   NS_ASSERTION(callbacks, "oops");
   loadGroup->SetNotificationCallbacks(callbacks);
 
@@ -840,20 +841,16 @@ DecreasePrivateDocShellCount()
 
     nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService();
     if (obsvc) {
       obsvc->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
     }
   }
 }
 
-//*****************************************************************************
-//***    nsDocShell: Object Management
-//*****************************************************************************
-
 static uint64_t gDocshellIDCounter = 0;
 
 nsDocShell::nsDocShell()
   : nsDocLoader()
   , mDefaultScrollbarPref(Scrollbar_Auto, Scrollbar_Auto)
   , mTreeOwner(nullptr)
   , mChromeEventHandler(nullptr)
   , mCharsetReloadState(eCharsetReloadInit)
@@ -1027,20 +1024,16 @@ nsDocShell::DestroyChildren()
     if (shell) {
       shell->SetTreeOwner(nullptr);
     }
   }
 
   nsDocLoader::DestroyChildren();
 }
 
-//*****************************************************************************
-// nsDocShell::nsISupports
-//*****************************************************************************
-
 NS_IMPL_ADDREF_INHERITED(nsDocShell, nsDocLoader)
 NS_IMPL_RELEASE_INHERITED(nsDocShell, nsDocLoader)
 
 NS_INTERFACE_MAP_BEGIN(nsDocShell)
   NS_INTERFACE_MAP_ENTRY(nsIDocShell)
   NS_INTERFACE_MAP_ENTRY(nsIDocShellTreeItem)
   NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
   NS_INTERFACE_MAP_ENTRY(nsIBaseWindow)
@@ -1056,19 +1049,16 @@ NS_INTERFACE_MAP_BEGIN(nsDocShell)
   NS_INTERFACE_MAP_ENTRY(nsILoadContext)
   NS_INTERFACE_MAP_ENTRY(nsIWebShellServices)
   NS_INTERFACE_MAP_ENTRY(nsILinkHandler)
   NS_INTERFACE_MAP_ENTRY(nsIClipboardCommands)
   NS_INTERFACE_MAP_ENTRY(nsIDOMStorageManager)
   NS_INTERFACE_MAP_ENTRY(nsINetworkInterceptController)
 NS_INTERFACE_MAP_END_INHERITING(nsDocLoader)
 
-///*****************************************************************************
-// nsDocShell::nsIInterfaceRequestor
-//*****************************************************************************
 NS_IMETHODIMP
 nsDocShell::GetInterface(const nsIID& aIID, void** aSink)
 {
   NS_PRECONDITION(aSink, "null out param");
 
   *aSink = nullptr;
 
   if (aIID.Equals(NS_GET_IID(nsICommandManager))) {
@@ -1356,19 +1346,16 @@ nsDocShell::ConvertLoadTypeToDocShellLoa
       break;
     default:
       NS_NOTREACHED("Unexpected load type value");
   }
 
   return docShellLoadType;
 }
 
-//*****************************************************************************
-// nsDocShell::nsIDocShell
-//*****************************************************************************
 NS_IMETHODIMP
 nsDocShell::LoadURI(nsIURI* aURI,
                     nsIDocShellLoadInfo* aLoadInfo,
                     uint32_t aLoadFlags,
                     bool aFirstParty)
 {
   NS_PRECONDITION(aLoadInfo || (aLoadFlags & EXTRA_LOAD_FLAGS) == 0,
                   "Unexpected flags");
@@ -2605,24 +2592,26 @@ NS_IMETHODIMP
 nsDocShell::SetAllowContentRetargeting(bool aAllowContentRetargeting)
 {
   mAllowContentRetargetingOnChildren = aAllowContentRetargeting;
   mAllowContentRetargeting = aAllowContentRetargeting;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::GetAllowContentRetargetingOnChildren(bool* aAllowContentRetargetingOnChildren)
+nsDocShell::GetAllowContentRetargetingOnChildren(
+    bool* aAllowContentRetargetingOnChildren)
 {
   *aAllowContentRetargetingOnChildren = mAllowContentRetargetingOnChildren;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDocShell::SetAllowContentRetargetingOnChildren(bool aAllowContentRetargetingOnChildren)
+nsDocShell::SetAllowContentRetargetingOnChildren(
+    bool aAllowContentRetargetingOnChildren)
 {
   mAllowContentRetargetingOnChildren = aAllowContentRetargetingOnChildren;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
 {
@@ -3484,17 +3473,18 @@ nsDocShell::SetDocLoaderParent(nsDocLoad
     }
     if (NS_SUCCEEDED(parentAsDocShell->GetAllowImages(&value))) {
       SetAllowImages(value);
     }
     SetAllowMedia(parentAsDocShell->GetAllowMedia());
     if (NS_SUCCEEDED(parentAsDocShell->GetAllowWindowControl(&value))) {
       SetAllowWindowControl(value);
     }
-    SetAllowContentRetargeting(parentAsDocShell->GetAllowContentRetargetingOnChildren());
+    SetAllowContentRetargeting(
+      parentAsDocShell->GetAllowContentRetargetingOnChildren());
     if (NS_SUCCEEDED(parentAsDocShell->GetIsActive(&value))) {
       SetIsActive(value);
     }
     if (parentAsDocShell->GetIsPrerendered()) {
       SetIsPrerendered(true);
     }
     if (NS_FAILED(parentAsDocShell->GetAllowDNSPrefetch(&value))) {
       value = false;
@@ -5606,16 +5596,17 @@ nsDocShell::GetSessionHistory(nsISHistor
   *aSessionHistory = mSessionHistory;
   NS_IF_ADDREF(*aSessionHistory);
   return NS_OK;
 }
 
 //*****************************************************************************
 // nsDocShell::nsIWebPageDescriptor
 //*****************************************************************************
+
 NS_IMETHODIMP
 nsDocShell::LoadPage(nsISupports* aPageDescriptor, uint32_t aDisplayType)
 {
   nsCOMPtr<nsISHEntry> shEntryIn(do_QueryInterface(aPageDescriptor));
 
   // Currently, the opaque 'page descriptor' is an nsISHEntry...
   if (!shEntryIn) {
     return NS_ERROR_INVALID_POINTER;
@@ -7169,17 +7160,17 @@ nsDocShell::RefreshURIFromQueue()
         // Replace the nsRefreshTimer element in the queue with
         // its corresponding timer object, so that in case another
         // load comes through before the timer can go off, the timer will
         // get cancelled in CancelRefreshURITimer()
         mRefreshURIList->ReplaceElementAt(timer, n);
         timer->InitWithCallback(refreshInfo, delay, nsITimer::TYPE_ONE_SHOT);
       }
     }
-  }  // while
+  }
 
   return NS_OK;
 }
 
 //*****************************************************************************
 // nsDocShell::nsIContentViewerContainer
 //*****************************************************************************
 
@@ -7816,43 +7807,41 @@ nsDocShell::EndPageLoad(nsIWebProgress* 
 
     // Errors to be shown only on top-level frames
     if ((aStatus == NS_ERROR_UNKNOWN_HOST ||
          aStatus == NS_ERROR_CONNECTION_REFUSED ||
          aStatus == NS_ERROR_UNKNOWN_PROXY_HOST ||
          aStatus == NS_ERROR_PROXY_CONNECTION_REFUSED) &&
         (isTopFrame || UseErrorPages())) {
       DisplayLoadError(aStatus, url, nullptr, aChannel);
-    }
-    else if (aStatus == NS_ERROR_NET_TIMEOUT ||
-             aStatus == NS_ERROR_REDIRECT_LOOP ||
-             aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE ||
-             aStatus == NS_ERROR_NET_INTERRUPT ||
-             aStatus == NS_ERROR_NET_RESET ||
-             aStatus == NS_ERROR_OFFLINE ||
-             aStatus == NS_ERROR_MALWARE_URI ||
-             aStatus == NS_ERROR_PHISHING_URI ||
-             aStatus == NS_ERROR_UNWANTED_URI ||
-             aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
-             aStatus == NS_ERROR_REMOTE_XUL ||
-             aStatus == NS_ERROR_OFFLINE ||
-             NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
+    } else if (aStatus == NS_ERROR_NET_TIMEOUT ||
+               aStatus == NS_ERROR_REDIRECT_LOOP ||
+               aStatus == NS_ERROR_UNKNOWN_SOCKET_TYPE ||
+               aStatus == NS_ERROR_NET_INTERRUPT ||
+               aStatus == NS_ERROR_NET_RESET ||
+               aStatus == NS_ERROR_OFFLINE ||
+               aStatus == NS_ERROR_MALWARE_URI ||
+               aStatus == NS_ERROR_PHISHING_URI ||
+               aStatus == NS_ERROR_UNWANTED_URI ||
+               aStatus == NS_ERROR_UNSAFE_CONTENT_TYPE ||
+               aStatus == NS_ERROR_REMOTE_XUL ||
+               aStatus == NS_ERROR_OFFLINE ||
+               NS_ERROR_GET_MODULE(aStatus) == NS_ERROR_MODULE_SECURITY) {
       // Errors to be shown for any frame
       DisplayLoadError(aStatus, url, nullptr, aChannel);
     } else if (aStatus == NS_ERROR_DOCUMENT_NOT_CACHED) {
       // Non-caching channels will simply return NS_ERROR_OFFLINE.
       // Caching channels would have to look at their flags to work
       // out which error to return. Or we can fix up the error here.
       if (!(mLoadType & LOAD_CMD_HISTORY)) {
         aStatus = NS_ERROR_OFFLINE;
       }
       DisplayLoadError(aStatus, url, nullptr, aChannel);
     }
-  }
-  else if (url && NS_SUCCEEDED(aStatus)) {
+  } else if (url && NS_SUCCEEDED(aStatus)) {
     // If we have a host
     mozilla::net::PredictorLearnRedirect(url, aChannel, this);
   }
 
   return NS_OK;
 }
 
 //*****************************************************************************
@@ -7996,19 +7985,19 @@ nsDocShell::CreateAboutBlankContentViewe
 
       blankDoc->SetContainer(this);
 
       // Copy our sandbox flags to the document. These are immutable
       // after being set here.
       blankDoc->SetSandboxFlags(mSandboxFlags);
 
       // create a content viewer for us and the new document
-      docFactory->CreateInstanceForDocument(NS_ISUPPORTS_CAST(nsIDocShell*, this),
-                                            blankDoc, "view",
-                                            getter_AddRefs(viewer));
+      docFactory->CreateInstanceForDocument(
+        NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view",
+        getter_AddRefs(viewer));
 
       // hook 'em up
       if (viewer) {
         viewer->SetContainer(this);
         rv = Embed(viewer, "", 0);
         NS_ENSURE_SUCCESS(rv, rv);
 
         SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
@@ -8400,18 +8389,18 @@ nsDocShell::RestorePresentation(nsISHEnt
   return rv;
 }
 
 namespace {
 class MOZ_STACK_CLASS PresentationEventForgetter
 {
 public:
   explicit PresentationEventForgetter(
-      nsRevocableEventPtr<nsDocShell::RestorePresentationEvent>&
-        aRestorePresentationEvent)
+        nsRevocableEventPtr<nsDocShell::RestorePresentationEvent>&
+          aRestorePresentationEvent)
     : mRestorePresentationEvent(aRestorePresentationEvent)
     , mEvent(aRestorePresentationEvent.get())
   {
   }
 
   ~PresentationEventForgetter()
   {
     Forget();
@@ -8780,17 +8769,18 @@ nsDocShell::RestoreFromHistory()
     childShell->GetAllowImages(&allowImages);
 
     bool allowMedia = childShell->GetAllowMedia();
 
     bool allowDNSPrefetch;
     childShell->GetAllowDNSPrefetch(&allowDNSPrefetch);
 
     bool allowContentRetargeting = childShell->GetAllowContentRetargeting();
-    bool allowContentRetargetingOnChildren = childShell->GetAllowContentRetargetingOnChildren();
+    bool allowContentRetargetingOnChildren =
+      childShell->GetAllowContentRetargetingOnChildren();
 
     uint32_t defaultLoadFlags;
     childShell->GetDefaultLoadFlags(&defaultLoadFlags);
 
     // this.AddChild(child) calls child.SetDocLoaderParent(this), meaning that
     // the child inherits our state. Among other things, this means that the
     // child inherits our mIsActive, mIsPrerendered and mInPrivateBrowsing,
     // which is what we want.
@@ -8799,17 +8789,18 @@ nsDocShell::RestoreFromHistory()
     childShell->SetAllowPlugins(allowPlugins);
     childShell->SetAllowJavascript(allowJavascript);
     childShell->SetAllowMetaRedirects(allowRedirects);
     childShell->SetAllowSubframes(allowSubframes);
     childShell->SetAllowImages(allowImages);
     childShell->SetAllowMedia(allowMedia);
     childShell->SetAllowDNSPrefetch(allowDNSPrefetch);
     childShell->SetAllowContentRetargeting(allowContentRetargeting);
-    childShell->SetAllowContentRetargetingOnChildren(allowContentRetargetingOnChildren);
+    childShell->SetAllowContentRetargetingOnChildren(
+      allowContentRetargetingOnChildren);
     childShell->SetDefaultLoadFlags(defaultLoadFlags);
 
     rv = childShell->BeginRestore(nullptr, false);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   nsCOMPtr<nsIPresShell> shell = GetPresShell();
 
@@ -9080,18 +9071,19 @@ nsDocShell::CreateContentViewer(const ns
 
     // Mark the channel as being a document URI...
     aOpenedChannel->GetLoadFlags(&loadFlags);
     loadFlags |= nsIChannel::LOAD_DOCUMENT_URI;
 
     aOpenedChannel->SetLoadFlags(loadFlags);
 
     mLoadGroup->AddRequest(aRequest, nullptr);
-    if (currentLoadGroup)
+    if (currentLoadGroup) {
       currentLoadGroup->RemoveRequest(aRequest, nullptr, NS_BINDING_RETARGETED);
+    }
 
     // Update the notification callbacks, so that progress and
     // status information are sent to the right docshell...
     aOpenedChannel->SetNotificationCallbacks(this);
   }
 
   NS_ENSURE_SUCCESS(Embed(viewer, "", nullptr), NS_ERROR_FAILURE);
 
@@ -9400,16 +9392,17 @@ nsDocShell::CheckLoadingPermissions()
   } while (item);
 
   return NS_ERROR_DOM_PROP_ACCESS_DENIED;
 }
 
 //*****************************************************************************
 // nsDocShell: Site Loading
 //*****************************************************************************
+
 namespace {
 
 #ifdef MOZ_PLACES
 // Callback used by CopyFavicon to inform the favicon service that one URI
 // (mNewURI) has the same favicon URI (OnComplete's aFaviconURI) as another.
 class nsCopyFaviconCallback final : public nsIFaviconDataCallback
 {
 public:
@@ -9510,17 +9503,18 @@ public:
     , mBaseURI(aBaseURI)
   {
     // Make sure to keep null things null as needed
     if (aTypeHint) {
       mTypeHint = aTypeHint;
     }
   }
 
-  NS_IMETHOD Run()
+  NS_IMETHOD
+  Run()
   {
     return mDocShell->InternalLoad(mURI, mReferrer,
                                    mReferrerPolicy,
                                    mOwner, mFlags,
                                    nullptr, mTypeHint.get(),
                                    NullString(), mPostData, mHeadersData,
                                    mLoadType, mSHEntry, mFirstParty,
                                    mSrcdoc, mSourceDocShell, mBaseURI,
@@ -11217,17 +11211,17 @@ nsDocShell::OnNewURI(nsIURI* aURI, nsICh
   nsCOMPtr<nsISHistory> rootSH = mSessionHistory;
   if (!rootSH) {
     // Get the handle to SH from the root docshell
     GetRootSessionHistory(getter_AddRefs(rootSH));
     if (!rootSH) {
       updateSHistory = false;
       updateGHistory = false; // XXX Why global history too?
     }
-  }  // rootSH
+  }
 
   // Check if the url to be loaded is the same as the one already loaded.
   if (mCurrentURI) {
     aURI->Equals(mCurrentURI, &equalUri);
   }
 
 #ifdef DEBUG
   bool shAvailable = (rootSH != nullptr);
@@ -11818,19 +11812,19 @@ nsDocShell::AddToSessionHistory(nsIURI* 
     if (shContainer) {
       int32_t childCount = 0;
       shContainer->GetChildCount(&childCount);
       // Remove all children of this entry
       for (int32_t i = childCount - 1; i >= 0; i--) {
         nsCOMPtr<nsISHEntry> child;
         shContainer->GetChildAt(i, getter_AddRefs(child));
         shContainer->RemoveChild(child);
-      }  // for
+      }
       entry->AbandonBFCacheEntry();
-    }  // shContainer
+    }
   }
 
   // Create a new entry if necessary.
   if (!entry) {
     entry = do_CreateInstance(NS_SHENTRY_CONTRACTID);
 
     if (!entry) {
       return NS_ERROR_OUT_OF_MEMORY;
@@ -12161,17 +12155,18 @@ nsDocShell::WalkHistoryEntries(nsISHEntr
       aCallback(nullptr, nullptr, i, aData);
       continue;
     }
 
     nsDocShell* childShell = nullptr;
     if (aRootShell) {
       // Walk the children of aRootShell and see if one of them
       // has srcChild as a SHEntry.
-      nsTObserverArray<nsDocLoader*>::ForwardIterator iter(aRootShell->mChildList);
+      nsTObserverArray<nsDocLoader*>::ForwardIterator iter(
+        aRootShell->mChildList);
       while (iter.HasMore()) {
         nsDocShell* child = static_cast<nsDocShell*>(iter.GetNext());
 
         if (child->HasHistoryEntry(childEntry)) {
           childShell = child;
           break;
         }
       }
@@ -12934,61 +12929,47 @@ NS_IMETHODIMP
 nsDocShell::SetLayoutHistoryState(nsILayoutHistoryState* aLayoutHistoryState)
 {
   if (mOSHE) {
     mOSHE->SetLayoutHistoryState(aLayoutHistoryState);
   }
   return NS_OK;
 }
 
-//*****************************************************************************
-//***    nsRefreshTimer: Object Management
-//*****************************************************************************
-
 nsRefreshTimer::nsRefreshTimer()
   : mDelay(0), mRepeat(false), mMetaRefresh(false)
 {
 }
 
 nsRefreshTimer::~nsRefreshTimer()
 {
 }
 
-//*****************************************************************************
-// nsRefreshTimer::nsISupports
-//*****************************************************************************
-
 NS_IMPL_ADDREF(nsRefreshTimer)
 NS_IMPL_RELEASE(nsRefreshTimer)
 
 NS_INTERFACE_MAP_BEGIN(nsRefreshTimer)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITimerCallback)
   NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
 NS_INTERFACE_MAP_END_THREADSAFE
 
-///*****************************************************************************
-// nsRefreshTimer::nsITimerCallback
-//******************************************************************************
 NS_IMETHODIMP
 nsRefreshTimer::Notify(nsITimer* aTimer)
 {
   NS_ASSERTION(mDocShell, "DocShell is somehow null");
 
   if (mDocShell && aTimer) {
     // Get the delay count to determine load type
     uint32_t delay = 0;
     aTimer->GetDelay(&delay);
     mDocShell->ForceRefreshURIFromTimer(mURI, delay, mMetaRefresh, aTimer);
   }
   return NS_OK;
 }
 
-//*****************************************************************************
-// nsDocShell::InterfaceRequestorProxy
-//*****************************************************************************
 nsDocShell::InterfaceRequestorProxy::InterfaceRequestorProxy(
     nsIInterfaceRequestor* aRequestor)
 {
   if (aRequestor) {
     mWeakPtr = do_GetWeakReference(aRequestor);
   }
 }
 
@@ -13017,18 +12998,19 @@ nsDocShell::SetBaseUrlForWyciwyg(nsICont
 {
   if (!aContentViewer) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIURI> baseURI;
   nsresult rv = NS_ERROR_NOT_AVAILABLE;
 
-  if (sURIFixup)
+  if (sURIFixup) {
     rv = sURIFixup->CreateExposableURI(mCurrentURI, getter_AddRefs(baseURI));
+  }
 
   // Get the current document and set the base uri
   if (baseURI) {
     nsIDocument* document = aContentViewer->GetDocument();
     if (document) {
       rv = document->SetBaseURI(baseURI);
     }
   }
@@ -13064,16 +13046,17 @@ nsDocShell::GetAuthPrompt(uint32_t aProm
 
   return wwatch->GetPrompt(mScriptGlobal, aIID,
                            reinterpret_cast<void**>(aResult));
 }
 
 //*****************************************************************************
 // nsDocShell::nsILoadContext
 //*****************************************************************************
+
 NS_IMETHODIMP
 nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
 {
   CallGetInterface(this, aWindow);
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -13316,18 +13299,16 @@ nsDocShell::SelectAll(void)
 // of previous selection.
 //
 NS_IMETHODIMP
 nsDocShell::SelectNone(void)
 {
   return DoCommand("cmd_selectNone");
 }
 
-//----------------------------------------------------------------------
-
 // link handling
 
 class OnLinkClickEvent : public nsRunnable
 {
 public:
   OnLinkClickEvent(nsDocShell* aHandler, nsIContent* aContent,
                    nsIURI* aURI,
                    const char16_t* aTargetSpec,
@@ -13377,18 +13358,16 @@ OnLinkClickEvent::OnLinkClickEvent(nsDoc
   , mPostDataStream(aPostDataStream)
   , mHeadersDataStream(aHeadersDataStream)
   , mContent(aContent)
   , mPopupState(mHandler->mScriptGlobal->GetPopupControlState())
   , mIsTrusted(aIsTrusted)
 {
 }
 
-//----------------------------------------
-
 NS_IMETHODIMP
 nsDocShell::OnLinkClick(nsIContent* aContent,
                         nsIURI* aURI,
                         const char16_t* aTargetSpec,
                         const nsAString& aFileName,
                         nsIInputStream* aPostDataStream,
                         nsIInputStream* aHeadersDataStream,
                         bool aIsTrusted)
@@ -13929,32 +13908,31 @@ URLSearchParams*
 nsDocShell::GetURLSearchParams()
 {
   return mURLSearchParams;
 }
 
 class JavascriptTimelineMarker : public TimelineMarker
 {
 public:
-
   JavascriptTimelineMarker(nsDocShell* aDocShell, const char* aName,
                            const char* aReason)
     : TimelineMarker(aDocShell, aName, TRACING_INTERVAL_START,
                      NS_ConvertUTF8toUTF16(aReason))
   {
   }
 
   void AddDetails(mozilla::dom::ProfileTimelineMarker& aMarker) override
   {
     aMarker.mCauseName.Construct(GetCause());
   }
 };
 
 void
-nsDocShell::NotifyJSRunToCompletionStart(const char *aReason)
+nsDocShell::NotifyJSRunToCompletionStart(const char* aReason)
 {
   bool timelineOn = nsIDocShell::GetRecordProfileTimelineMarkers();
 
   // If first start, mark interval start.
   if (timelineOn && mJSRunToCompletionDepth == 0) {
     mozilla::UniquePtr<TimelineMarker> marker =
       MakeUnique<JavascriptTimelineMarker>(this, "Javascript", aReason);
     AddProfileTimelineMarker(Move(marker));
@@ -14004,25 +13982,26 @@ nsDocShell::MaybeNotifyKeywordSearchLoad
         obsSvc->NotifyObservers(searchEngine, "keyword-search", aKeyword.get());
       }
     }
   }
 #endif
 }
 
 NS_IMETHODIMP
-nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate, bool* aShouldIntercept)
+nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, bool aIsNavigate,
+                                      bool* aShouldIntercept)
 {
   *aShouldIntercept = false;
   if (mSandboxFlags) {
     // If we're sandboxed, don't intercept.
     return NS_OK;
   }
 
-  nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager();
+  nsCOMPtr<nsIServiceWorkerManager> swm = services::GetServiceWorkerManager();
   if (!swm) {
     return NS_OK;
   }
 
   if (aIsNavigate) {
     return swm->IsAvailableForURI(aURI, aShouldIntercept);
   }
 
@@ -14032,17 +14011,17 @@ nsDocShell::ShouldPrepareForIntercept(ns
   }
 
   return swm->IsControlled(doc, aShouldIntercept);
 }
 
 NS_IMETHODIMP
 nsDocShell::ChannelIntercepted(nsIInterceptedChannel* aChannel)
 {
-  nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager();
+  nsCOMPtr<nsIServiceWorkerManager> swm = services::GetServiceWorkerManager();
   if (!swm) {
     aChannel->Cancel();
     return NS_OK;
   }
 
   bool isNavigation = false;
   nsresult rv = aChannel->GetIsNavigation(&isNavigation);
   NS_ENSURE_SUCCESS(rv, rv);
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -84,30 +84,23 @@ class nsISHistory;
 class nsISecureBrowserUI;
 class nsIStringBundle;
 class nsISupportsArray;
 class nsIURIFixup;
 class nsIURILoader;
 class nsIWebBrowserFind;
 class nsIWidget;
 
-/* load commands were moved to nsIDocShell.h */
-/* load types were moved to nsDocShellLoadTypes.h */
-
 /* internally used ViewMode types */
 enum ViewMode
 {
   viewNormal = 0x0,
   viewSource = 0x1
 };
 
-//*****************************************************************************
-//***    nsRefreshTimer
-//*****************************************************************************
-
 class nsRefreshTimer : public nsITimerCallback
 {
 public:
   nsRefreshTimer();
 
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSITIMERCALLBACK
 
@@ -125,20 +118,16 @@ protected:
 
 enum eCharsetReloadState
 {
   eCharsetReloadInit,
   eCharsetReloadRequested,
   eCharsetReloadStopOrigional
 };
 
-//*****************************************************************************
-//***    nsDocShell
-//*****************************************************************************
-
 class nsDocShell final
   : public nsDocLoader
   , public nsIDocShell
   , public nsIWebNavigation
   , public nsIBaseWindow
   , public nsIScrollable
   , public nsITextScroll
   , public nsIDocCharset
@@ -154,17 +143,17 @@ class nsDocShell final
   , public nsIDOMStorageManager
   , public nsINetworkInterceptController
   , public mozilla::SupportsWeakPtr<nsDocShell>
 {
   friend class nsDSURIContentListener;
 
 public:
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(nsDocShell)
-  // Object Management
+
   nsDocShell();
 
   NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
 
   virtual nsresult Init() override;
 
   NS_DECL_ISUPPORTS_INHERITED
 
@@ -181,17 +170,18 @@ public:
   NS_DECL_NSICONTENTVIEWERCONTAINER
   NS_DECL_NSIWEBPAGEDESCRIPTOR
   NS_DECL_NSIAUTHPROMPTPROVIDER
   NS_DECL_NSICLIPBOARDCOMMANDS
   NS_DECL_NSIWEBSHELLSERVICES
   NS_DECL_NSINETWORKINTERCEPTCONTROLLER
   NS_FORWARD_SAFE_NSIDOMSTORAGEMANAGER(TopSessionStorageManager())
 
-  NS_IMETHOD Stop() override {
+  NS_IMETHOD Stop() override
+  {
     // Need this here because otherwise nsIWebNavigation::Stop
     // overrides the docloader's Stop()
     return nsDocLoader::Stop();
   }
 
   // Need to implement (and forward) nsISecurityEventSink, because
   // nsIWebProgressListener has methods with identical names...
   NS_FORWARD_NSISECURITYEVENTSINK(nsDocLoader::)
@@ -214,17 +204,17 @@ public:
                              nsIRequest** aRequest = 0) override;
   NS_IMETHOD OnOverLink(nsIContent* aContent,
                         nsIURI* aURI,
                         const char16_t* aTargetSpec) override;
   NS_IMETHOD OnLeaveLink() override;
 
   nsDocShellInfoLoadType ConvertLoadTypeToDocShellLoadInfo(uint32_t aLoadType);
   uint32_t ConvertDocShellLoadInfoToLoadType(
-      nsDocShellInfoLoadType aDocShellLoadType);
+    nsDocShellInfoLoadType aDocShellLoadType);
 
   // Don't use NS_DECL_NSILOADCONTEXT because some of nsILoadContext's methods
   // are shared with nsIDocShell (appID, etc.) and can't be declared twice.
   NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**) override;
   NS_IMETHOD GetTopWindow(nsIDOMWindow**) override;
   NS_IMETHOD GetTopFrameElement(nsIDOMElement**) override;
   NS_IMETHOD GetNestedFrameId(uint64_t*) override;
   NS_IMETHOD IsAppOfType(uint32_t, bool*) override;
@@ -232,20 +222,20 @@ public:
   NS_IMETHOD GetUsePrivateBrowsing(bool*) override;
   NS_IMETHOD SetUsePrivateBrowsing(bool) override;
   NS_IMETHOD SetPrivateBrowsing(bool) override;
   NS_IMETHOD GetUseRemoteTabs(bool*) override;
   NS_IMETHOD SetRemoteTabs(bool) override;
 
   // Restores a cached presentation from history (mLSHE).
   // This method swaps out the content viewer and simulates loads for
-  // subframes.  It then simulates the completion of the toplevel load.
+  // subframes. It then simulates the completion of the toplevel load.
   nsresult RestoreFromHistory();
 
-  // Perform a URI load from a refresh timer.  This is just like the
+  // Perform a URI load from a refresh timer. This is just like the
   // ForceRefreshURI method on nsIRefreshURI, but makes sure to take
   // the timer involved out of mRefreshURIList if it's there.
   // aTimer must not be null.
   nsresult ForceRefreshURIFromTimer(nsIURI* aURI, int32_t aDelay,
                                     bool aMetaRefresh, nsITimer* aTimer);
 
   friend class OnLinkClickEvent;
 
@@ -264,37 +254,35 @@ public:
   void NotifyAsyncPanZoomStarted();
   // Notify Scroll observers when an async panning/zooming transform
   // is no longer applied
   void NotifyAsyncPanZoomStopped();
 
   // Add new profile timeline markers to this docShell. This will only add
   // markers if the docShell is currently recording profile timeline markers.
   // See nsIDocShell::recordProfileTimelineMarkers
-  void AddProfileTimelineMarker(const char* aName,
-                                TracingMetadata aMetaData);
+  void AddProfileTimelineMarker(const char* aName, TracingMetadata aMetaData);
   void AddProfileTimelineMarker(mozilla::UniquePtr<TimelineMarker>&& aMarker);
 
   // Global counter for how many docShells are currently recording profile
   // timeline markers
   static unsigned long gProfileTimelineRecordingsCount;
 
   // Tell the favicon service that aNewURI has the same favicon as aOldURI.
   static void CopyFavicon(nsIURI* aOldURI,
                           nsIURI* aNewURI,
                           bool aInPrivateBrowsing);
 
 protected:
-  // Object Management
   virtual ~nsDocShell();
   virtual void DestroyChildren() override;
 
   // Content Viewer Management
   nsresult EnsureContentViewer();
-  // aPrincipal can be passed in if the caller wants.  If null is
+  // aPrincipal can be passed in if the caller wants. If null is
   // passed in, the about:blank principal will end up being used.
   nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
                                          nsIURI* aBaseURI,
                                          bool aTryToSaveOldPresentation = true);
   nsresult CreateContentViewer(const nsACString& aContentType,
                                nsIRequest* aRequest,
                                nsIStreamListener** aContentHandler);
   nsresult NewContentViewerObj(const nsACString& aContentType,
@@ -302,26 +290,26 @@ protected:
                                nsIStreamListener** aContentHandler,
                                nsIContentViewer** aViewer);
   nsresult SetupNewViewer(nsIContentViewer* aNewViewer);
 
   void SetupReferrerFromChannel(nsIChannel* aChannel);
 
   nsresult GetEldestPresContext(nsPresContext** aPresContext);
 
-  // Get the principal that we'll set on the channel if we're inheriting.  If
+  // Get the principal that we'll set on the channel if we're inheriting. If
   // aConsiderCurrentDocument is true, we try to use the current document if
-  // at all possible.  If that fails, we fall back on the parent document.
+  // at all possible. If that fails, we fall back on the parent document.
   // If that fails too, we force creation of a content viewer and use the
-  // resulting principal.  If aConsiderCurrentDocument is false, we just look
+  // resulting principal. If aConsiderCurrentDocument is false, we just look
   // at the parent.
   nsIPrincipal* GetInheritedPrincipal(bool aConsiderCurrentDocument);
 
-  // Actually open a channel and perform a URI load.  Note: whatever owner is
-  // passed to this function will be set on the channel.  Callers who wish to
+  // Actually open a channel and perform a URI load. Note: whatever owner is
+  // passed to this function will be set on the channel. Callers who wish to
   // not have an owner on the channel should just pass null.
   // If aSrcdoc is not void, the load will be considered as a srcdoc load,
   // and the contents of aSrcdoc will be loaded instead of aURI.
   nsresult DoURILoad(nsIURI* aURI,
                      nsIURI* aReferrer,
                      bool aSendReferrer,
                      uint32_t aReferrerPolicy,
                      nsISupports* aOwner,
@@ -356,35 +344,35 @@ protected:
                      bool aFireOnLocationChange,
                      bool aAddToGlobalHistory = true);
 
   // Returns true if would have called FireOnLocationChange,
   // but did not because aFireOnLocationChange was false on entry.
   // In this case it is the caller's responsibility to ensure
   // FireOnLocationChange is called.
   // In all other cases false is returned.
-  // Either aChannel or aOwner must be null.  If aChannel is
+  // Either aChannel or aOwner must be null. If aChannel is
   // present, the owner should be gotten from it.
   // If OnNewURI calls AddToSessionHistory, it will pass its
   // aCloneSHChildren argument as aCloneChildren.
   bool OnNewURI(nsIURI* aURI, nsIChannel* aChannel, nsISupports* aOwner,
                 uint32_t aLoadType,
                 bool aFireOnLocationChange,
                 bool aAddToGlobalHistory,
                 bool aCloneSHChildren);
 
   void SetReferrerURI(nsIURI* aURI);
   void SetReferrerPolicy(uint32_t aReferrerPolicy);
 
   // Session History
   bool ShouldAddToSessionHistory(nsIURI* aURI);
-  // Either aChannel or aOwner must be null.  If aChannel is
+  // Either aChannel or aOwner must be null. If aChannel is
   // present, the owner should be gotten from it.
   // If aCloneChildren is true, then our current session history's
-  // children will be cloned onto the new entry.  This should be
+  // children will be cloned onto the new entry. This should be
   // used when we aren't actually changing the document while adding
   // the new session history entry.
   nsresult AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
                                nsISupports* aOwner,
                                bool aCloneChildren,
                                nsISHEntry** aNewEntry);
   nsresult AddChildSHEntryToParent(nsISHEntry* aNewEntry, int32_t aChildOffset,
                                    bool aCloneChildren);
@@ -394,17 +382,17 @@ protected:
                                    bool aCloneChildren);
 
   nsresult LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType);
   nsresult PersistLayoutHistoryState();
 
   // Clone a session history tree for subframe navigation.
   // The tree rooted at |aSrcEntry| will be cloned into |aDestEntry|, except
   // for the entry with id |aCloneID|, which will be replaced with
-  // |aReplaceEntry|.  |aSrcShell| is a (possibly null) docshell which
+  // |aReplaceEntry|. |aSrcShell| is a (possibly null) docshell which
   // corresponds to |aSrcEntry| via its mLSHE or mOHE pointers, and will
   // have that pointer updated to point to the cloned history entry.
   // If aCloneChildren is true then the children of the entry with id
   // |aCloneID| will be cloned into |aReplaceEntry|.
   static nsresult CloneAndReplace(nsISHEntry* aSrcEntry,
                                   nsDocShell* aSrcShell,
                                   uint32_t aCloneID,
                                   nsISHEntry* aReplaceEntry,
@@ -425,17 +413,17 @@ protected:
   {
     return aEntry && (aEntry == mOSHE || aEntry == mLSHE);
   }
 
   // Update any pointers (mOSHE or mLSHE) to aOldEntry to point to aNewEntry
   void SwapHistoryEntries(nsISHEntry* aOldEntry, nsISHEntry* aNewEntry);
 
   // Call this method to swap in a new history entry to m[OL]SHE, rather than
-  // setting it directly.  This completes the navigation in all docshells
+  // setting it directly. This completes the navigation in all docshells
   // in the case of a subframe navigation.
   void SetHistoryEntry(nsCOMPtr<nsISHEntry>* aPtr, nsISHEntry* aEntry);
 
   // Child-walking callback for SetHistoryEntry
   static nsresult SetChildHistoryEntry(nsISHEntry* aEntry, nsDocShell* aShell,
                                        int32_t aEntryIndex, void* aData);
 
   // Callback prototype for WalkHistoryEntries.
@@ -443,17 +431,17 @@ protected:
   // aChildIndex is the child's index in its parent entry, and aData is
   // the opaque pointer passed to WalkHistoryEntries.
   typedef nsresult(*WalkHistoryEntriesFunc)(nsISHEntry* aEntry,
                                             nsDocShell* aShell,
                                             int32_t aChildIndex,
                                             void* aData);
 
   // For each child of aRootEntry, find the corresponding docshell which is
-  // a child of aRootShell, and call aCallback.  The opaque pointer aData
+  // a child of aRootShell, and call aCallback. The opaque pointer aData
   // is passed to the callback.
   static nsresult WalkHistoryEntries(nsISHEntry* aRootEntry,
                                      nsDocShell* aRootShell,
                                      WalkHistoryEntriesFunc aCallback,
                                      void* aData);
 
   // overridden from nsDocLoader, this provides more information than the
   // normal OnStateChange with flags STATE_REDIRECTING
@@ -472,17 +460,17 @@ protected:
    */
   bool ChannelIsPost(nsIChannel* aChannel);
 
   /**
    * Helper function that finds the last URI and its transition flags for a
    * channel.
    *
    * This method first checks the channel's property bag to see if previous
-   * info has been saved.  If not, it gives back the referrer of the channel.
+   * info has been saved. If not, it gives back the referrer of the channel.
    *
    * @param aChannel
    *        The channel we are transitioning to
    * @param aURI
    *        Output parameter with the previous URI, not addref'd
    * @param aChannelRedirectFlags
    *        If a redirect, output parameter with the previous redirect flags
    *        from nsIChannelEventSink
@@ -501,25 +489,25 @@ protected:
    * @param aChannelRedirectFlags
    *        The nsIChannelEventSink redirect flags to save for later
    */
   void SaveLastVisit(nsIChannel* aChannel,
                      nsIURI* aURI,
                      uint32_t aChannelRedirectFlags);
 
   /**
-   * Helper function for adding a URI visit using IHistory.  If IHistory is
+   * Helper function for adding a URI visit using IHistory. If IHistory is
    * not available, the method tries nsIGlobalHistory2.
    *
    * The IHistory API maintains chains of visits, tracking both HTTP referrers
    * and redirects for a user session. VisitURI requires the current URI and
    * the previous URI in the chain.
    *
    * Visits can be saved either during a redirect or when the request has
-   * reached its final destination.  The previous URI in the visit may be
+   * reached its final destination. The previous URI in the visit may be
    * from another redirect or it may be the referrer.
    *
    * @pre aURI is not null.
    *
    * @param aURI
    *        The URI that was just visited
    * @param aReferrerURI
    *        The referrer URI of this request
@@ -578,23 +566,23 @@ protected:
   // Helper method that is called when a new document (including any
   // sub-documents - ie. frames) has been completely loaded.
   //
   virtual nsresult EndPageLoad(nsIWebProgress* aProgress,
                                nsIChannel* aChannel,
                                nsresult aResult);
 
   // Sets the current document's current state object to the given SHEntry's
-  // state object.  The current state object is eventually given to the page
+  // state object. The current state object is eventually given to the page
   // in the PopState event.
   nsresult SetDocCurrentStateObj(nsISHEntry* aShEntry);
 
   nsresult CheckLoadingPermissions();
 
-  // Security checks to prevent frameset spoofing.  See comments at
+  // Security checks to prevent frameset spoofing. See comments at
   // implementation sites.
   static bool CanAccessItem(nsIDocShellTreeItem* aTargetItem,
                             nsIDocShellTreeItem* aAccessingItem,
                             bool aConsiderOpener = true);
   static bool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
                              nsIDocShellTreeItem* aTargetTreeItem);
 
   // Returns true if would have called FireOnLocationChange,
@@ -605,43 +593,43 @@ protected:
   bool SetCurrentURI(nsIURI* aURI, nsIRequest* aRequest,
                      bool aFireOnLocationChange,
                      uint32_t aLocationFlags);
 
   // The following methods deal with saving and restoring content viewers
   // in session history.
 
   // mContentViewer points to the current content viewer associated with
-  // this docshell.  When loading a new document, the content viewer is
-  // either destroyed or stored into a session history entry.  To make sure
+  // this docshell. When loading a new document, the content viewer is
+  // either destroyed or stored into a session history entry. To make sure
   // that destruction happens in a controlled fashion, a given content viewer
   // is always owned in exactly one of these ways:
   //   1) The content viewer is active and owned by a docshell's
   //      mContentViewer.
   //   2) The content viewer is still being displayed while we begin loading
-  //      a new document.  The content viewer is owned by the _new_
+  //      a new document. The content viewer is owned by the _new_
   //      content viewer's mPreviousViewer, and has a pointer to the
-  //      nsISHEntry where it will eventually be stored.  The content viewer
+  //      nsISHEntry where it will eventually be stored. The content viewer
   //      has been close()d by the docshell, which detaches the document from
   //      the window object.
-  //   3) The content viewer is cached in session history.  The nsISHEntry
-  //      has the only owning reference to the content viewer.  The viewer
+  //   3) The content viewer is cached in session history. The nsISHEntry
+  //      has the only owning reference to the content viewer. The viewer
   //      has released its nsISHEntry pointer to prevent circular ownership.
   //
   // When restoring a content viewer from session history, open() is called
-  // to reattach the document to the window object.  The content viewer is
+  // to reattach the document to the window object. The content viewer is
   // then placed into mContentViewer and removed from the history entry.
   // (mContentViewer is put into session history as described above, if
   // applicable).
 
   // Determines whether we can safely cache the current mContentViewer in
-  // session history.  This checks a number of factors such as cache policy,
+  // session history. This checks a number of factors such as cache policy,
   // pending requests, and unload handlers.
   // |aLoadType| should be the load type that will replace the current
-  // presentation.  |aNewRequest| should be the request for the document to
+  // presentation. |aNewRequest| should be the request for the document to
   // be loaded in place of the current document, or null if such a request
   // has not been created yet. |aNewDocument| should be the document that will
   // replace the current document.
   bool CanSavePresentation(uint32_t aLoadType,
                            nsIRequest* aNewRequest,
                            nsIDocument* aNewDocument);
 
   // Captures the state of the supporting elements of the presentation
@@ -657,17 +645,17 @@ protected:
   // Call BeginRestore(nullptr, false) for each child of this shell.
   nsresult BeginRestoreChildren();
 
   // Method to get our current position and size without flushing
   void DoGetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aWidth,
                             int32_t* aHeight);
 
   // Call this when a URI load is handed to us (via OnLinkClick or
-  // InternalLoad).  This makes sure that we're not inside unload, or that if
+  // InternalLoad). This makes sure that we're not inside unload, or that if
   // we are it's still OK to load this URI.
   bool IsOKToLoadURI(nsIURI* aURI);
 
   void ReattachEditorToWindow(nsISHEntry* aSHEntry);
 
   nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
   nsIDOMStorageManager* TopSessionStorageManager();
 
@@ -675,17 +663,17 @@ protected:
   nsresult GetControllerForCommand(const char* aCommand,
                                    nsIController** aResult);
   nsresult EnsureCommandHandler();
 
   nsIChannel* GetCurrentDocChannel();
 
   bool ShouldBlockLoadingForBackButton();
 
-  // Convenience method for getting our parent docshell.  Can return null
+  // Convenience method for getting our parent docshell. Can return null
   already_AddRefed<nsDocShell> GetParentDocshell();
 
   // Check if we have an app redirect registered for the URI and redirect if
   // needed. Returns true if a redirect happened, false otherwise.
   bool DoAppRedirectIfNeeded(nsIURI* aURI,
                              nsIDocShellLoadInfo* aLoadInfo,
                              bool aFirstParty);
 
@@ -783,32 +771,32 @@ protected:
   // Somebody give me better name.
   // If mLSHE is non-null, non-pushState subframe loads don't create separate
   // root history entries. That is, frames loaded during the parent page
   // load don't generate history entries the way frame navigation after the
   // parent has loaded does. (This isn't the only purpose of mLSHE.)
   nsCOMPtr<nsISHEntry> mLSHE;
 
   // Holds a weak pointer to a RestorePresentationEvent object if any that
-  // holds a weak pointer back to us.  We use this pointer to possibly revoke
+  // holds a weak pointer back to us. We use this pointer to possibly revoke
   // the event whenever necessary.
   nsRevocableEventPtr<RestorePresentationEvent> mRestorePresentationEvent;
 
   // Editor data, if this document is designMode or contentEditable.
   nsAutoPtr<nsDocShellEditorData> mEditorData;
 
   // Transferable hooks/callbacks
   nsCOMPtr<nsIClipboardDragDropHookList> mTransferableHookData;
 
   // Secure browser UI object
   nsCOMPtr<nsISecureBrowserUI> mSecurityUI;
 
-  // The URI we're currently loading.  This is only relevant during the
-  // firing of a pagehide/unload.  The caller of FirePageHideNotification()
-  // is responsible for setting it and unsetting it.  It may be null if the
+  // The URI we're currently loading. This is only relevant during the
+  // firing of a pagehide/unload. The caller of FirePageHideNotification()
+  // is responsible for setting it and unsetting it. It may be null if the
   // pagehide/unload is happening for some reason other than just loading a
   // new URI.
   nsCOMPtr<nsIURI> mLoadingURI;
 
   // Set in LoadErrorPage from the method argument and used later
   // in CreateContentViewer. We have to delay an shistory entry creation
   // for which these objects are needed.
   nsCOMPtr<nsIURI> mFailedURI;
@@ -819,35 +807,35 @@ protected:
   nsRefPtr<mozilla::dom::URLSearchParams> mURLSearchParams;
 
   // Set in DoURILoad when either the LOAD_RELOAD_ALLOW_MIXED_CONTENT flag or
   // the LOAD_NORMAL_ALLOW_MIXED_CONTENT flag is set.
   // Checked in nsMixedContentBlocker, to see if the channels match.
   nsCOMPtr<nsIChannel> mMixedContentChannel;
 
   // WEAK REFERENCES BELOW HERE.
-  // Note these are intentionally not addrefd.  Doing so will create a cycle.
+  // Note these are intentionally not addrefd. Doing so will create a cycle.
   // For that reasons don't use nsCOMPtr.
 
   nsIDocShellTreeOwner* mTreeOwner; // Weak Reference
-  mozilla::dom::EventTarget* mChromeEventHandler; //Weak Reference
+  mozilla::dom::EventTarget* mChromeEventHandler; // Weak Reference
 
   eCharsetReloadState mCharsetReloadState;
 
   // Offset in the parent's child list.
   // -1 if the docshell is added dynamically to the parent shell.
   uint32_t mChildOffset;
   uint32_t mBusyFlags;
   uint32_t mAppType;
   uint32_t mLoadType;
 
   int32_t mMarginWidth;
   int32_t mMarginHeight;
 
-  // This can either be a content docshell or a chrome docshell.  After
+  // This can either be a content docshell or a chrome docshell. After
   // Create() is called, the type is not expected to change.
   int32_t mItemType;
 
   // Index into the SHTransaction list, indicating the previous and current
   // transaction at the time that this DocShell begins to load
   int32_t mPreviousTransIndex;
   int32_t mLoadedTransIndex;
 
@@ -905,17 +893,17 @@ protected:
 
   // Because scriptability depends on the mAllowJavascript values of our
   // ancestors, we cache the effective scriptability and recompute it when
   // it might have changed;
   bool mCanExecuteScripts;
   void RecomputeCanExecuteScripts();
 
   // This boolean is set to true right before we fire pagehide and generally
-  // unset when we embed a new content viewer.  While it's true no navigation
+  // unset when we embed a new content viewer. While it's true no navigation
   // is allowed in this docshell.
   bool mFiredUnloadEvent;
 
   // this flag is for bug #21358. a docshell may load many urls
   // which don't result in new documents being created (i.e. a new
   // content viewer) we want to make sure we don't call a on load
   // event more than once for a given content viewer.
   bool mEODForCurrentDocument;
@@ -952,17 +940,17 @@ protected:
   // We will check the innerWin's timing before creating a new one
   // in MaybeInitTiming()
   bool mBlankTiming;
 
   // Are we a regular frame, a browser frame, or an app frame?
   FrameType mFrameType;
 
   // We only expect mOwnOrContainingAppId to be something other than
-  // UNKNOWN_APP_ID if mFrameType != eFrameTypeRegular.  For vanilla iframes
+  // UNKNOWN_APP_ID if mFrameType != eFrameTypeRegular. For vanilla iframes
   // inside an app, we'll retrieve the containing app-id by walking up the
   // docshell hierarchy.
   //
   // (This needs to be the docshell's own /or containing/ app id because the
   // containing app frame might be in another process, in which case we won't
   // find it by walking up the docshell hierarchy.)
   uint32_t mOwnOrContainingAppId;
 
--- a/docshell/base/nsDocShellEditorData.h
+++ b/docshell/base/nsDocShellEditorData.h
@@ -53,12 +53,11 @@ protected:
   bool mIsDetached;
 
   // Backup for mMakeEditable while the editor is detached.
   bool mDetachedMakeEditable;
 
   // Backup for the corresponding nsIHTMLDocument's  editing state while
   // the editor is detached.
   nsIHTMLDocument::EditingState mDetachedEditingState;
-
 };
 
 #endif // nsDocShellEditorData_h__
--- a/docshell/base/nsDocShellEnumerator.h
+++ b/docshell/base/nsDocShellEnumerator.h
@@ -84,17 +84,16 @@ public:
   nsDocShellForwardsEnumerator()
     : nsDocShellEnumerator(enumerateForwards)
   {
   }
 
 protected:
   virtual nsresult BuildArrayRecursive(nsIDocShellTreeItem* aItem,
                                        nsTArray<nsWeakPtr>& aItemArray);
-
 };
 
 class nsDocShellBackwardsEnumerator : public nsDocShellEnumerator
 {
 public:
   nsDocShellBackwardsEnumerator()
     : nsDocShellEnumerator(enumerateBackwards)
   {
--- a/docshell/base/nsDocShellLoadInfo.cpp
+++ b/docshell/base/nsDocShellLoadInfo.cpp
@@ -1,56 +1,43 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-// Local Includes
 #include "nsDocShellLoadInfo.h"
 #include "nsISHEntry.h"
 #include "nsIInputStream.h"
 #include "nsIURI.h"
 #include "nsIDocShell.h"
 #include "mozilla/net/ReferrerPolicy.h"
 
-//*****************************************************************************
-//***    nsDocShellLoadInfo: Object Management
-//*****************************************************************************
-
 nsDocShellLoadInfo::nsDocShellLoadInfo()
   : mInheritOwner(false)
   , mOwnerIsExplicit(false)
   , mSendReferrer(true)
   , mReferrerPolicy(mozilla::net::RP_Default)
   , mLoadType(nsIDocShellLoadInfo::loadNormal)
   , mIsSrcdocLoad(false)
 {
 }
 
 nsDocShellLoadInfo::~nsDocShellLoadInfo()
 {
 }
 
-//*****************************************************************************
-// nsDocShellLoadInfo::nsISupports
-//*****************************************************************************
-
 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
 
-//*****************************************************************************
-// nsDocShellLoadInfo::nsIDocShellLoadInfo
-//*****************************************************************************
-
 NS_IMETHODIMP
 nsDocShellLoadInfo::GetReferrer(nsIURI** aReferrer)
 {
   NS_ENSURE_ARG_POINTER(aReferrer);
 
   *aReferrer = mReferrer;
   NS_IF_ADDREF(*aReferrer);
   return NS_OK;
--- a/docshell/base/nsDocShellLoadTypes.h
+++ b/docshell/base/nsDocShellLoadTypes.h
@@ -22,18 +22,18 @@
 #define LOAD_TYPE_HAS_FLAGS(type, flags) ((type) & ((flags) << 16))
 
 /**
  * These are flags that confuse ConvertLoadTypeToDocShellLoadInfo and should
  * not be passed to MAKE_LOAD_TYPE.  In particular this includes all flags
  * above 0xffff (e.g. LOAD_FLAGS_BYPASS_CLASSIFIER), since MAKE_LOAD_TYPE would
  * just shift them out anyway.
  */
-#define EXTRA_LOAD_FLAGS (LOAD_FLAGS_FIRST_LOAD              | \
-                          LOAD_FLAGS_ALLOW_POPUPS            | \
+#define EXTRA_LOAD_FLAGS (LOAD_FLAGS_FIRST_LOAD | \
+                          LOAD_FLAGS_ALLOW_POPUPS | \
                           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.
  */
@@ -60,17 +60,18 @@ enum LoadType
   LOAD_STOP_CONTENT_AND_REPLACE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_STOP_CONTENT | nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY),
   LOAD_PUSHSTATE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_PUSHSTATE, nsIWebNavigation::LOAD_FLAGS_NONE),
   LOAD_REPLACE_BYPASS_CACHE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY | nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE),
   /**
    * Load type for an error page. These loads are never triggered by users of
    * Docshell. Instead, Docshell triggers the load itself when a
    * consumer-triggered load failed.
    */
-  LOAD_ERROR_PAGE = MAKE_LOAD_TYPE(nsIDocShell::LOAD_CMD_NORMAL, LOAD_FLAGS_ERROR_PAGE)
+  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
 IsValidLoadType(uint32_t aLoadType)
 {
   switch (aLoadType) {
     case LOAD_NORMAL:
--- a/docshell/base/nsDocShellTransferableHooks.cpp
+++ b/docshell/base/nsDocShellTransferableHooks.cpp
@@ -12,20 +12,16 @@
 nsTransferableHookData::nsTransferableHookData()
 {
 }
 
 nsTransferableHookData::~nsTransferableHookData()
 {
 }
 
-//*****************************************************************************
-// nsIClipboardDragDropHookList
-//*****************************************************************************
-
 NS_IMPL_ISUPPORTS(nsTransferableHookData, nsIClipboardDragDropHookList)
 
 NS_IMETHODIMP
 nsTransferableHookData::AddClipboardDragDropHooks(
     nsIClipboardDragDropHooks* aOverrides)
 {
   NS_ENSURE_ARG(aOverrides);
 
--- a/docshell/base/nsDownloadHistory.cpp
+++ b/docshell/base/nsDownloadHistory.cpp
@@ -7,24 +7,18 @@
 #include "nsDownloadHistory.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIGlobalHistory2.h"
 #include "nsIObserverService.h"
 #include "nsIURI.h"
 #include "mozilla/Services.h"
 
-////////////////////////////////////////////////////////////////////////////////
-//// nsDownloadHistory
-
 NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
 
-////////////////////////////////////////////////////////////////////////////////
-//// nsIDownloadHistory
-
 NS_IMETHODIMP
 nsDownloadHistory::AddDownload(nsIURI* aSource,
                                nsIURI* aReferrer,
                                PRTime aStartTime,
                                nsIURI* aDestination)
 {
   NS_ENSURE_ARG_POINTER(aSource);
 
@@ -37,18 +31,17 @@ nsDownloadHistory::AddDownload(nsIURI* a
   bool visited;
   nsresult rv = history->IsVisited(aSource, &visited);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = history->AddURI(aSource, false, true, aReferrer);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!visited) {
-    nsCOMPtr<nsIObserverService> os =
-      mozilla::services::GetObserverService();
+    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
     if (os) {
       os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
     }
   }
 
   return NS_OK;
 }
 
--- a/docshell/base/nsILinkHandler.h
+++ b/docshell/base/nsILinkHandler.h
@@ -9,17 +9,16 @@
 #include "nsISupports.h"
 #include "mozilla/EventForwards.h"
 
 class nsIContent;
 class nsIDocShell;
 class nsIInputStream;
 class nsIRequest;
 
-// Interface ID for nsILinkHandler
 #define NS_ILINKHANDLER_IID \
   { 0xceb9aade, 0x43da, 0x4f1a, \
     { 0xac, 0x8a, 0xc7, 0x09, 0xfb, 0x22, 0x46, 0x64 } }
 
 /**
  * Interface used for handling clicks on links
  */
 class nsILinkHandler : public nsISupports
--- a/docshell/base/nsIWebShellServices.h
+++ b/docshell/base/nsIWebShellServices.h
@@ -4,30 +4,26 @@
  * 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/. */
 #ifndef nsIWebShellServices_h___
 #define nsIWebShellServices_h___
 
 #include "nsISupports.h"
 #include "nsCharsetSource.h"
 
-// Interface ID for nsIWebShellServices
-
 /* 0c628af0-5638-4703-8f99-ed6134c9de18 */
 #define NS_IWEB_SHELL_SERVICES_IID \
 { 0x0c628af0, 0x5638, 0x4703, {0x8f, 0x99, 0xed, 0x61, 0x34, 0xc9, 0xde, 0x18} }
 
-//----------------------------------------------------------------------
-
 class nsIWebShellServices : public nsISupports
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWEB_SHELL_SERVICES_IID)
 
-  NS_IMETHOD ReloadDocument(const char* aCharset = nullptr ,
+  NS_IMETHOD ReloadDocument(const char* aCharset = nullptr,
                             int32_t aSource = kCharsetUninitialized) = 0;
   NS_IMETHOD StopDocumentLoad(void) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIWebShellServices, NS_IWEB_SHELL_SERVICES_IID)
 
 /* Use this macro when declaring classes that implement this interface. */
 #define NS_DECL_NSIWEBSHELLSERVICES \
--- a/docshell/base/nsWebNavigationInfo.h
+++ b/docshell/base/nsWebNavigationInfo.h
@@ -9,17 +9,16 @@
 
 #include "nsIWebNavigationInfo.h"
 #include "nsCOMPtr.h"
 #include "nsICategoryManager.h"
 #include "mozilla/Attributes.h"
 
 class nsCString;
 
-// Class ID for webnavigationinfo
 #define NS_WEBNAVIGATION_INFO_CID \
  { 0xf30bc0a2, 0x958b, 0x4287,{0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e}}
 
 class nsWebNavigationInfo final : public nsIWebNavigationInfo
 {
 public:
   nsWebNavigationInfo() {}
 
--- a/docshell/build/nsDocShellCID.h
+++ b/docshell/build/nsDocShellCID.h
@@ -2,61 +2,59 @@
  * vim: sw=4 ts=4 sts=4
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef nsDocShellCID_h__
 #define nsDocShellCID_h__
 
-#define NS_GLOBALHISTORY2_CONTRACTID \
-    "@mozilla.org/browser/global-history;2"
+#define NS_GLOBALHISTORY2_CONTRACTID "@mozilla.org/browser/global-history;2"
 
 /**
  * A contract for a service that will track download history.  This can be
  * overridden by embedders if they would like to track additional information
  * about downloads.
  *
  * @implements nsIDownloadHistory
  */
-#define NS_DOWNLOADHISTORY_CONTRACTID \
-    "@mozilla.org/browser/download-history;1"
+#define NS_DOWNLOADHISTORY_CONTRACTID "@mozilla.org/browser/download-history;1"
 
 /**
  * A contract that can be used to get a service that provides
  * meta-information about nsIWebNavigation objects' capabilities.
  * @implements nsIWebNavigationInfo
  */
-#define NS_WEBNAVIGATION_INFO_CONTRACTID \
-    "@mozilla.org/webnavigation-info;1"
+#define NS_WEBNAVIGATION_INFO_CONTRACTID "@mozilla.org/webnavigation-info;1"
 
 /**
  * Class and contract ID for the docshell.  This is the container for a web
  * navigation context.  It implements too many interfaces to count, and the
  * exact ones keep changing; if they stabilize somewhat that will get
  * documented.
  */
-#define NS_DOCSHELL_CID                                             \
-    { 0xf1eac762, 0x87e9, 0x11d3,                                   \
-      { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } }
+#define NS_DOCSHELL_CID                                                        \
+  { 0xf1eac762, 0x87e9, 0x11d3,                                                \
+    { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } }
 #define NS_DOCSHELL_CONTRACTID "@mozilla.org/docshell/html;1"
 
 /**
  * Contract ID to obtain the IHistory interface.  This is a non-scriptable
  * interface used to interact with history in an asynchronous manner.
  */
 #define NS_IHISTORY_CONTRACTID "@mozilla.org/browser/history;1"
 
 /**
  * A contract for a service that is used for finding
  * platform-specific applications for handling particular URLs.
  *
  * @implements nsIExternalURLHandlerService
  */
-#define NS_EXTERNALURLHANDLERSERVICE_CONTRACTID "@mozilla.org/uriloader/external-url-handler-service;1"
+#define NS_EXTERNALURLHANDLERSERVICE_CONTRACTID \
+  "@mozilla.org/uriloader/external-url-handler-service;1"
 
 /**
  * An observer service topic that can be listened to to catch creation
  * of content browsing areas (both toplevel ones and subframes).  The
  * subject of the notification will be the nsIWebNavigation being
  * created.  At this time the additional data wstring is not defined
  * to be anything in particular.
  */
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -18,17 +18,17 @@
 #include "nsDocLoader.h"
 #include "nsOSHelperAppService.h"
 #include "nsExternalProtocolHandler.h"
 #include "nsPrefetchService.h"
 #include "nsOfflineCacheUpdate.h"
 #include "nsLocalHandlerApp.h"
 #ifdef MOZ_ENABLE_DBUS
 #include "nsDBusHandlerApp.h"
-#endif 
+#endif
 #if defined(MOZ_WIDGET_ANDROID)
 #include "nsExternalSharingAppService.h"
 #include "nsExternalURLHandlerService.h"
 #endif
 
 // session history
 #include "nsSHEntry.h"
 #include "nsSHEntryShared.h"
@@ -76,17 +76,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOS
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheUpdateService,
                                          nsOfflineCacheUpdateService::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsOfflineCacheUpdate)
 NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
 #ifdef MOZ_ENABLE_DBUS
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
-#endif 
+#endif
 #if defined(MOZ_WIDGET_ANDROID)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalSharingAppService)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
 #endif
 
 // session history
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
@@ -115,17 +115,16 @@ NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAP
 NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
 NS_DEFINE_NAMED_CID(NS_SHTRANSACTION_CID);
 NS_DEFINE_NAMED_CID(NS_SHISTORY_CID);
 NS_DEFINE_NAMED_CID(NS_SHISTORY_INTERNAL_CID);
 NS_DEFINE_NAMED_CID(NS_DOWNLOADHISTORY_CID);
 
-
 const mozilla::Module::CIDEntry kDocShellCIDs[] = {
   { &kNS_DOCSHELL_CID, false, nullptr, nsDocShellConstructor },
   { &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor },
   { &kNS_WEBNAVIGATION_INFO_CID, false, nullptr, nsWebNavigationInfoConstructor },
   { &kNS_ABOUT_REDIRECTOR_MODULE_CID, false, nullptr, nsAboutRedirector::Create },
   { &kNS_URI_LOADER_CID, false, nullptr, nsURILoaderConstructor },
   { &kNS_DOCUMENTLOADER_SERVICE_CID, false, nullptr, nsDocLoaderConstructor },
   { &kNS_EXTERNALHELPERAPPSERVICE_CID, false, nullptr, nsOSHelperAppServiceConstructor },
--- a/docshell/shistory/src/nsSHEntry.cpp
+++ b/docshell/shistory/src/nsSHEntry.cpp
@@ -1,14 +1,13 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-// Local Includes
 #include "nsSHEntry.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsDocShellEditorData.h"
 #include "nsSHEntryShared.h"
 #include "nsILayoutHistoryState.h"
 #include "nsIContentViewer.h"
 #include "nsISupportsArray.h"
@@ -17,51 +16,46 @@
 #include "nsIURI.h"
 #include "mozilla/net/ReferrerPolicy.h"
 #include <algorithm>
 
 namespace dom = mozilla::dom;
 
 static uint32_t gEntryID = 0;
 
-//*****************************************************************************
-//***    nsSHEntry: Object Management
-//*****************************************************************************
-
-
 nsSHEntry::nsSHEntry()
-  : mReferrerPolicy(mozilla::net::RP_Default)
+  : mShared(new nsSHEntryShared())
+  , mReferrerPolicy(mozilla::net::RP_Default)
   , mLoadType(0)
   , mID(gEntryID++)
   , mScrollPositionX(0)
   , mScrollPositionY(0)
   , mParent(nullptr)
   , mURIWasModified(false)
   , mIsSrcdocEntry(false)
 {
-  mShared = new nsSHEntryShared();
 }
 
-nsSHEntry::nsSHEntry(const nsSHEntry &other)
-  : mShared(other.mShared)
-  , mURI(other.mURI)
-  , mReferrerURI(other.mReferrerURI)
-  , mReferrerPolicy(other.mReferrerPolicy)
-  , mTitle(other.mTitle)
-  , mPostData(other.mPostData)
+nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
+  : mShared(aOther.mShared)
+  , mURI(aOther.mURI)
+  , mReferrerURI(aOther.mReferrerURI)
+  , mReferrerPolicy(aOther.mReferrerPolicy)
+  , mTitle(aOther.mTitle)
+  , mPostData(aOther.mPostData)
   , mLoadType(0)         // XXX why not copy?
-  , mID(other.mID)
+  , mID(aOther.mID)
   , mScrollPositionX(0)  // XXX why not copy?
   , mScrollPositionY(0)  // XXX why not copy?
-  , mParent(other.mParent)
-  , mURIWasModified(other.mURIWasModified)
-  , mStateData(other.mStateData)
-  , mIsSrcdocEntry(other.mIsSrcdocEntry)
-  , mSrcdocData(other.mSrcdocData)
-  , mBaseURI(other.mBaseURI)
+  , mParent(aOther.mParent)
+  , mURIWasModified(aOther.mURIWasModified)
+  , mStateData(aOther.mStateData)
+  , mIsSrcdocEntry(aOther.mIsSrcdocEntry)
+  , mSrcdocData(aOther.mSrcdocData)
+  , mBaseURI(aOther.mBaseURI)
 {
 }
 
 static bool
 ClearParentPtr(nsISHEntry* aEntry, void* /* aData */)
 {
   if (aEntry) {
     aEntry->SetParent(nullptr);
@@ -70,114 +64,116 @@ ClearParentPtr(nsISHEntry* aEntry, void*
 }
 
 nsSHEntry::~nsSHEntry()
 {
   // Null out the mParent pointers on all our kids.
   mChildren.EnumerateForwards(ClearParentPtr, nullptr);
 }
 
-//*****************************************************************************
-//    nsSHEntry: nsISupports
-//*****************************************************************************
-
 NS_IMPL_ISUPPORTS(nsSHEntry, nsISHContainer, nsISHEntry, nsISHEntryInternal)
 
-//*****************************************************************************
-//    nsSHEntry: nsISHEntry
-//*****************************************************************************
-
-NS_IMETHODIMP nsSHEntry::SetScrollPosition(int32_t x, int32_t y)
+NS_IMETHODIMP
+nsSHEntry::SetScrollPosition(int32_t aX, int32_t aY)
 {
-  mScrollPositionX = x;
-  mScrollPositionY = y;
+  mScrollPositionX = aX;
+  mScrollPositionY = aY;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetScrollPosition(int32_t *x, int32_t *y)
+NS_IMETHODIMP
+nsSHEntry::GetScrollPosition(int32_t* aX, int32_t* aY)
 {
-  *x = mScrollPositionX;
-  *y = mScrollPositionY;
+  *aX = mScrollPositionX;
+  *aY = mScrollPositionY;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetURIWasModified(bool* aOut)
+NS_IMETHODIMP
+nsSHEntry::GetURIWasModified(bool* aOut)
 {
   *aOut = mURIWasModified;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetURIWasModified(bool aIn)
+NS_IMETHODIMP
+nsSHEntry::SetURIWasModified(bool aIn)
 {
   mURIWasModified = aIn;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetURI(nsIURI** aURI)
+NS_IMETHODIMP
+nsSHEntry::GetURI(nsIURI** aURI)
 {
   *aURI = mURI;
   NS_IF_ADDREF(*aURI);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetURI(nsIURI* aURI)
+NS_IMETHODIMP
+nsSHEntry::SetURI(nsIURI* aURI)
 {
   mURI = aURI;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetReferrerURI(nsIURI **aReferrerURI)
+NS_IMETHODIMP
+nsSHEntry::GetReferrerURI(nsIURI** aReferrerURI)
 {
   *aReferrerURI = mReferrerURI;
   NS_IF_ADDREF(*aReferrerURI);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetReferrerURI(nsIURI *aReferrerURI)
+NS_IMETHODIMP
+nsSHEntry::SetReferrerURI(nsIURI* aReferrerURI)
 {
   mReferrerURI = aReferrerURI;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetReferrerPolicy(uint32_t *aReferrerPolicy)
+NS_IMETHODIMP
+nsSHEntry::GetReferrerPolicy(uint32_t* aReferrerPolicy)
 {
   *aReferrerPolicy = mReferrerPolicy;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetReferrerPolicy(uint32_t aReferrerPolicy)
+NS_IMETHODIMP
+nsSHEntry::SetReferrerPolicy(uint32_t aReferrerPolicy)
 {
   mReferrerPolicy = aReferrerPolicy;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetContentViewer(nsIContentViewer *aViewer)
+nsSHEntry::SetContentViewer(nsIContentViewer* aViewer)
 {
   return mShared->SetContentViewer(aViewer);
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetContentViewer(nsIContentViewer **aResult)
+nsSHEntry::GetContentViewer(nsIContentViewer** aResult)
 {
   *aResult = mShared->mContentViewer;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetAnyContentViewer(nsISHEntry **aOwnerEntry,
-                               nsIContentViewer **aResult)
+nsSHEntry::GetAnyContentViewer(nsISHEntry** aOwnerEntry,
+                               nsIContentViewer** aResult)
 {
   // Find a content viewer in the root node or any of its children,
   // assuming that there is only one content viewer total in any one
   // nsSHEntry tree
   GetContentViewer(aResult);
   if (*aResult) {
-#ifdef DEBUG_PAGE_CACHE 
+#ifdef DEBUG_PAGE_CACHE
     printf("Found content viewer\n");
 #endif
     *aOwnerEntry = this;
     NS_ADDREF(*aOwnerEntry);
     return NS_OK;
   }
   // The root SHEntry doesn't have a ContentViewer, so check child nodes
   for (int32_t i = 0; i < mChildren.Count(); i++) {
@@ -198,310 +194,332 @@ nsSHEntry::GetAnyContentViewer(nsISHEntr
 NS_IMETHODIMP
 nsSHEntry::SetSticky(bool aSticky)
 {
   mShared->mSticky = aSticky;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetSticky(bool *aSticky)
+nsSHEntry::GetSticky(bool* aSticky)
 {
   *aSticky = mShared->mSticky;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetTitle(char16_t** aTitle)
+NS_IMETHODIMP
+nsSHEntry::GetTitle(char16_t** aTitle)
 {
   // Check for empty title...
   if (mTitle.IsEmpty() && mURI) {
     // Default title is the URL.
     nsAutoCString spec;
-    if (NS_SUCCEEDED(mURI->GetSpec(spec)))
+    if (NS_SUCCEEDED(mURI->GetSpec(spec))) {
       AppendUTF8toUTF16(spec, mTitle);
+    }
   }
 
   *aTitle = ToNewUnicode(mTitle);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetTitle(const nsAString &aTitle)
+NS_IMETHODIMP
+nsSHEntry::SetTitle(const nsAString& aTitle)
 {
   mTitle = aTitle;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetPostData(nsIInputStream** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetPostData(nsIInputStream** aResult)
 {
   *aResult = mPostData;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetPostData(nsIInputStream* aPostData)
+NS_IMETHODIMP
+nsSHEntry::SetPostData(nsIInputStream* aPostData)
 {
   mPostData = aPostData;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult)
 {
   *aResult = mShared->mLayoutHistoryState;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState)
+NS_IMETHODIMP
+nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState)
 {
   mShared->mLayoutHistoryState = aState;
   if (mShared->mLayoutHistoryState) {
-    mShared->mLayoutHistoryState->
-      SetScrollPositionOnly(!mShared->mSaveLayoutState);
+    mShared->mLayoutHistoryState->SetScrollPositionOnly(
+      !mShared->mSaveLayoutState);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetLoadType(uint32_t * aResult)
+NS_IMETHODIMP
+nsSHEntry::GetLoadType(uint32_t* aResult)
 {
   *aResult = mLoadType;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetLoadType(uint32_t  aLoadType)
+NS_IMETHODIMP
+nsSHEntry::SetLoadType(uint32_t aLoadType)
 {
   mLoadType = aLoadType;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetID(uint32_t * aResult)
+NS_IMETHODIMP
+nsSHEntry::GetID(uint32_t* aResult)
 {
   *aResult = mID;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetID(uint32_t  aID)
+NS_IMETHODIMP
+nsSHEntry::SetID(uint32_t aID)
 {
   mID = aID;
   return NS_OK;
 }
 
-nsSHEntryShared* nsSHEntry::GetSharedState()
+nsSHEntryShared*
+nsSHEntry::GetSharedState()
 {
   return mShared;
 }
 
-NS_IMETHODIMP nsSHEntry::GetIsSubFrame(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetIsSubFrame(bool* aFlag)
 {
   *aFlag = mShared->mIsFrameNavigation;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetIsSubFrame(bool    aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetIsSubFrame(bool aFlag)
 {
   mShared->mIsFrameNavigation = aFlag;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetCacheKey(nsISupports** aResult)
+NS_IMETHODIMP
+nsSHEntry::GetCacheKey(nsISupports** aResult)
 {
   *aResult = mShared->mCacheKey;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetCacheKey(nsISupports* aCacheKey)
+NS_IMETHODIMP
+nsSHEntry::SetCacheKey(nsISupports* aCacheKey)
 {
   mShared->mCacheKey = aCacheKey;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetSaveLayoutStateFlag(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetSaveLayoutStateFlag(bool* aFlag)
 {
   *aFlag = mShared->mSaveLayoutState;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetSaveLayoutStateFlag(bool    aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetSaveLayoutStateFlag(bool aFlag)
 {
   mShared->mSaveLayoutState = aFlag;
   if (mShared->mLayoutHistoryState) {
     mShared->mLayoutHistoryState->SetScrollPositionOnly(!aFlag);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetExpirationStatus(bool * aFlag)
+NS_IMETHODIMP
+nsSHEntry::GetExpirationStatus(bool* aFlag)
 {
   *aFlag = mShared->mExpired;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetExpirationStatus(bool    aFlag)
+NS_IMETHODIMP
+nsSHEntry::SetExpirationStatus(bool aFlag)
 {
   mShared->mExpired = aFlag;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::GetContentType(nsACString& aContentType)
+NS_IMETHODIMP
+nsSHEntry::GetContentType(nsACString& aContentType)
 {
   aContentType = mShared->mContentType;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsSHEntry::SetContentType(const nsACString& aContentType)
+NS_IMETHODIMP
+nsSHEntry::SetContentType(const nsACString& aContentType)
 {
   mShared->mContentType = aContentType;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::Create(nsIURI * aURI, const nsAString &aTitle,
-                  nsIInputStream * aInputStream,
-                  nsILayoutHistoryState * aLayoutHistoryState,
-                  nsISupports * aCacheKey, const nsACString& aContentType,
-                  nsISupports* aOwner,
-                  uint64_t aDocShellID, bool aDynamicCreation)
+nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
+                  nsIInputStream* aInputStream,
+                  nsILayoutHistoryState* aLayoutHistoryState,
+                  nsISupports* aCacheKey, const nsACString& aContentType,
+                  nsISupports* aOwner, uint64_t aDocShellID,
+                  bool aDynamicCreation)
 {
   mURI = aURI;
   mTitle = aTitle;
   mPostData = aInputStream;
 
   // Set the LoadType by default to loadHistory during creation
-  mLoadType = (uint32_t) nsIDocShellLoadInfo::loadHistory;
+  mLoadType = (uint32_t)nsIDocShellLoadInfo::loadHistory;
 
   mShared->mCacheKey = aCacheKey;
   mShared->mContentType = aContentType;
   mShared->mOwner = aOwner;
   mShared->mDocShellID = aDocShellID;
   mShared->mDynamicallyCreated = aDynamicCreation;
 
-  // By default all entries are set false for subframe flag. 
+  // By default all entries are set false for subframe flag.
   // nsDocShell::CloneAndReplace() which creates entries for
   // all subframe navigations, sets the flag to true.
   mShared->mIsFrameNavigation = false;
 
   // By default we save LayoutHistoryState
   mShared->mSaveLayoutState = true;
   mShared->mLayoutHistoryState = aLayoutHistoryState;
 
-  //By default the page is not expired
+  // By default the page is not expired
   mShared->mExpired = false;
 
   mIsSrcdocEntry = false;
   mSrcdocData = NullString();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::Clone(nsISHEntry ** aResult)
+nsSHEntry::Clone(nsISHEntry** aResult)
 {
   *aResult = new nsSHEntry(*this);
   NS_ADDREF(*aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetParent(nsISHEntry ** aResult)
+nsSHEntry::GetParent(nsISHEntry** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = mParent;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetParent(nsISHEntry * aParent)
+nsSHEntry::SetParent(nsISHEntry* aParent)
 {
   /* parent not Addrefed on purpose to avoid cyclic reference
    * Null parent is OK
    *
    * XXX this method should not be scriptable if this is the case!!
    */
   mParent = aParent;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetWindowState(nsISupports *aState)
+nsSHEntry::SetWindowState(nsISupports* aState)
 {
   mShared->mWindowState = aState;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetWindowState(nsISupports **aState)
+nsSHEntry::GetWindowState(nsISupports** aState)
 {
   NS_IF_ADDREF(*aState = mShared->mWindowState);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetViewerBounds(const nsIntRect &aBounds)
+nsSHEntry::SetViewerBounds(const nsIntRect& aBounds)
 {
   mShared->mViewerBounds = aBounds;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetViewerBounds(nsIntRect &aBounds)
+nsSHEntry::GetViewerBounds(nsIntRect& aBounds)
 {
   aBounds = mShared->mViewerBounds;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetOwner(nsISupports **aOwner)
+nsSHEntry::GetOwner(nsISupports** aOwner)
 {
   NS_IF_ADDREF(*aOwner = mShared->mOwner);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetOwner(nsISupports *aOwner)
+nsSHEntry::SetOwner(nsISupports* aOwner)
 {
   mShared->mOwner = aOwner;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry **aEntry)
+nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry** aEntry)
 {
   NS_ENSURE_ARG_POINTER(aEntry);
   NS_IF_ADDREF(*aEntry = mShared);
   return NS_OK;
 }
 
 bool
-nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry *aEntry)
+nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry)
 {
   return static_cast<nsIBFCacheEntry*>(mShared) == aEntry;
 }
 
 NS_IMETHODIMP
-nsSHEntry::AdoptBFCacheEntry(nsISHEntry *aEntry)
+nsSHEntry::AdoptBFCacheEntry(nsISHEntry* aEntry)
 {
   nsCOMPtr<nsISHEntryInternal> shEntry = do_QueryInterface(aEntry);
   NS_ENSURE_STATE(shEntry);
 
-  nsSHEntryShared *shared = shEntry->GetSharedState();
+  nsSHEntryShared* shared = shEntry->GetSharedState();
   NS_ENSURE_STATE(shared);
 
   mShared = shared;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SharesDocumentWith(nsISHEntry *aEntry, bool *aOut)
+nsSHEntry::SharesDocumentWith(nsISHEntry* aEntry, bool* aOut)
 {
   NS_ENSURE_ARG_POINTER(aOut);
 
-  nsCOMPtr<nsISHEntryInternal> internal = do_QueryInterface(aEntry); 
+  nsCOMPtr<nsISHEntryInternal> internal = do_QueryInterface(aEntry);
   NS_ENSURE_STATE(internal);
 
   *aOut = mShared == internal->GetSharedState();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::AbandonBFCacheEntry()
@@ -513,58 +531,54 @@ nsSHEntry::AbandonBFCacheEntry()
 NS_IMETHODIMP
 nsSHEntry::GetIsSrcdocEntry(bool* aIsSrcdocEntry)
 {
   *aIsSrcdocEntry = mIsSrcdocEntry;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetSrcdocData(nsAString &aSrcdocData)
+nsSHEntry::GetSrcdocData(nsAString& aSrcdocData)
 {
   aSrcdocData = mSrcdocData;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetSrcdocData(const nsAString &aSrcdocData)
+nsSHEntry::SetSrcdocData(const nsAString& aSrcdocData)
 {
   mSrcdocData = aSrcdocData;
   mIsSrcdocEntry = true;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetBaseURI(nsIURI **aBaseURI)
+nsSHEntry::GetBaseURI(nsIURI** aBaseURI)
 {
   *aBaseURI = mBaseURI;
   NS_IF_ADDREF(*aBaseURI);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetBaseURI(nsIURI *aBaseURI)
+nsSHEntry::SetBaseURI(nsIURI* aBaseURI)
 {
   mBaseURI = aBaseURI;
   return NS_OK;
 }
 
-//*****************************************************************************
-//    nsSHEntry: nsISHContainer
-//*****************************************************************************
-
-NS_IMETHODIMP 
-nsSHEntry::GetChildCount(int32_t * aCount)
+NS_IMETHODIMP
+nsSHEntry::GetChildCount(int32_t* aCount)
 {
   *aCount = mChildren.Count();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::AddChild(nsISHEntry * aChild, int32_t aOffset)
+nsSHEntry::AddChild(nsISHEntry* aChild, int32_t aOffset)
 {
   if (aChild) {
     NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
   }
 
   if (aOffset < 0) {
     mChildren.AppendObject(aChild);
     return NS_OK;
@@ -574,17 +588,17 @@ nsSHEntry::AddChild(nsISHEntry * aChild,
   // Bug 52670: Ensure children are added in order.
   //
   //  Later frames in the child list may load faster and get appended
   //  before earlier frames, causing session history to be scrambled.
   //  By growing the list here, they are added to the right position.
   //
   //  Assert that aOffset will not be so high as to grow us a lot.
   //
-  NS_ASSERTION(aOffset < (mChildren.Count()+1023), "Large frames array!\n");
+  NS_ASSERTION(aOffset < (mChildren.Count() + 1023), "Large frames array!\n");
 
   bool newChildIsDyn = false;
   if (aChild) {
     aChild->IsDynamicallyAdded(&newChildIsDyn);
   }
 
   // If the new child is dynamically added, try to add it to aOffset, but if
   // there are non-dynamically added children, the child must be after those.
@@ -629,25 +643,24 @@ nsSHEntry::AddChild(nsISHEntry * aChild,
           if (dyn) {
             dynEntryIndex = i;
             dynEntry = entry;
           } else {
             break;
           }
         }
       }
-  
+
       if (dynEntry) {
         nsCOMArray<nsISHEntry> tmp;
         tmp.SetCount(aOffset - dynEntryIndex + 1);
         mChildren.InsertObjectsAt(tmp, dynEntryIndex);
         NS_ASSERTION(mChildren[aOffset + 1] == dynEntry, "Whaat?");
       }
     }
-    
 
     // Make sure there isn't anything at aOffset.
     if (aOffset < mChildren.Count()) {
       nsISHEntry* oldChild = mChildren[aOffset];
       if (oldChild && oldChild != aChild) {
         NS_ERROR("Adding a child where we already have a child? This may misbehave");
         oldChild->SetParent(nullptr);
       }
@@ -659,17 +672,17 @@ nsSHEntry::AddChild(nsISHEntry * aChild,
       return NS_ERROR_FAILURE;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::RemoveChild(nsISHEntry * aChild)
+nsSHEntry::RemoveChild(nsISHEntry* aChild)
 {
   NS_ENSURE_TRUE(aChild, NS_ERROR_FAILURE);
   bool childRemoved = false;
   bool dynamic = false;
   aChild->IsDynamicallyAdded(&dynamic);
   if (dynamic) {
     childRemoved = mChildren.RemoveObject(aChild);
   } else {
@@ -687,17 +700,17 @@ nsSHEntry::RemoveChild(nsISHEntry * aChi
         break;
       }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry ** aResult)
+nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry** aResult)
 {
   if (aIndex >= 0 && aIndex < mChildren.Count()) {
     *aResult = mChildren[aIndex];
     // yes, mChildren can have holes in it.  AddChild's offset parameter makes
     // that possible.
     NS_IF_ADDREF(*aResult);
   } else {
     *aResult = nullptr;
@@ -722,46 +735,46 @@ nsSHEntry::ReplaceChild(nsISHEntry* aNew
         return aNewEntry->SetParent(this);
       }
     }
   }
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
-nsSHEntry::AddChildShell(nsIDocShellTreeItem *aShell)
+nsSHEntry::AddChildShell(nsIDocShellTreeItem* aShell)
 {
   NS_ASSERTION(aShell, "Null child shell added to history entry");
   mShared->mChildShells.AppendObject(aShell);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem **aShell)
+nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell)
 {
   NS_IF_ADDREF(*aShell = mShared->mChildShells.SafeObjectAt(aIndex));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::ClearChildShells()
 {
   mShared->mChildShells.Clear();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetRefreshURIList(nsISupportsArray **aList)
+nsSHEntry::GetRefreshURIList(nsISupportsArray** aList)
 {
   NS_IF_ADDREF(*aList = mShared->mRefreshURIList);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetRefreshURIList(nsISupportsArray *aList)
+nsSHEntry::SetRefreshURIList(nsISupportsArray* aList)
 {
   mShared->mRefreshURIList = aList;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::SyncPresentationState()
 {
@@ -799,25 +812,25 @@ nsSHEntry::SetEditorData(nsDocShellEdito
 
 bool
 nsSHEntry::HasDetachedEditor()
 {
   return mShared->mEditorData != nullptr;
 }
 
 NS_IMETHODIMP
-nsSHEntry::GetStateData(nsIStructuredCloneContainer **aContainer)
+nsSHEntry::GetStateData(nsIStructuredCloneContainer** aContainer)
 {
   NS_ENSURE_ARG_POINTER(aContainer);
   NS_IF_ADDREF(*aContainer = mStateData);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHEntry::SetStateData(nsIStructuredCloneContainer *aContainer)
+nsSHEntry::SetStateData(nsIStructuredCloneContainer* aContainer)
 {
   mStateData = aContainer;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::IsDynamicallyAdded(bool* aAdded)
 {
@@ -850,19 +863,18 @@ nsSHEntry::GetDocshellID(uint64_t* aID)
 
 NS_IMETHODIMP
 nsSHEntry::SetDocshellID(uint64_t aID)
 {
   mShared->mDocShellID = aID;
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSHEntry::GetLastTouched(uint32_t *aLastTouched)
+nsSHEntry::GetLastTouched(uint32_t* aLastTouched)
 {
   *aLastTouched = mShared->mLastTouched;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHEntry::SetLastTouched(uint32_t aLastTouched)
 {
--- a/docshell/shistory/src/nsSHEntry.h
+++ b/docshell/shistory/src/nsSHEntry.h
@@ -21,49 +21,49 @@
 class nsSHEntryShared;
 class nsIInputStream;
 class nsIURI;
 
 class nsSHEntry final : public nsISHEntry,
                         public nsISHContainer,
                         public nsISHEntryInternal
 {
-public: 
+public:
   nsSHEntry();
-  nsSHEntry(const nsSHEntry &other);
+  nsSHEntry(const nsSHEntry& aOther);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHENTRY
   NS_DECL_NSISHENTRYINTERNAL
   NS_DECL_NSISHCONTAINER
 
   void DropPresentationState();
 
   static nsresult Startup();
   static void Shutdown();
-  
+
 private:
   ~nsSHEntry();
 
   // We share the state in here with other SHEntries which correspond to the
   // same document.
   nsRefPtr<nsSHEntryShared> mShared;
 
   // See nsSHEntry.idl for comments on these members.
-  nsCOMPtr<nsIURI>         mURI;
-  nsCOMPtr<nsIURI>         mReferrerURI;
-  uint32_t                 mReferrerPolicy;
-  nsString                 mTitle;
+  nsCOMPtr<nsIURI> mURI;
+  nsCOMPtr<nsIURI> mReferrerURI;
+  uint32_t mReferrerPolicy;
+  nsString mTitle;
   nsCOMPtr<nsIInputStream> mPostData;
-  uint32_t                 mLoadType;
-  uint32_t                 mID;
-  int32_t                  mScrollPositionX;
-  int32_t                  mScrollPositionY;
-  nsISHEntry*              mParent;
-  nsCOMArray<nsISHEntry>   mChildren;
-  bool                     mURIWasModified;
+  uint32_t mLoadType;
+  uint32_t mID;
+  int32_t mScrollPositionX;
+  int32_t mScrollPositionY;
+  nsISHEntry* mParent;
+  nsCOMArray<nsISHEntry> mChildren;
+  bool mURIWasModified;
   nsCOMPtr<nsIStructuredCloneContainer> mStateData;
-  bool                     mIsSrcdocEntry;
-  nsString                 mSrcdocData;
-  nsCOMPtr<nsIURI>         mBaseURI;
+  bool mIsSrcdocEntry;
+  nsString mSrcdocData;
+  nsCOMPtr<nsIURI> mBaseURI;
 };
 
 #endif /* nsSHEntry_h */
--- a/docshell/shistory/src/nsSHEntryShared.cpp
+++ b/docshell/shistory/src/nsSHEntryShared.cpp
@@ -24,34 +24,36 @@ namespace dom = mozilla::dom;
 namespace {
 
 uint64_t gSHEntrySharedID = 0;
 
 } // anonymous namespace
 
 #define CONTENT_VIEWER_TIMEOUT_SECONDS "browser.sessionhistory.contentViewerTimeout"
 // Default this to time out unused content viewers after 30 minutes
-#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30*60)
+#define CONTENT_VIEWER_TIMEOUT_SECONDS_DEFAULT (30 * 60)
 
 typedef nsExpirationTracker<nsSHEntryShared, 3> HistoryTrackerBase;
-class HistoryTracker final : public HistoryTrackerBase {
+class HistoryTracker final : public HistoryTrackerBase
+{
 public:
   explicit HistoryTracker(uint32_t aTimeout)
     : HistoryTrackerBase(1000 * aTimeout / 2)
   {
   }
 
 protected:
-  virtual void NotifyExpired(nsSHEntryShared *aObj) {
+  virtual void NotifyExpired(nsSHEntryShared* aObj)
+  {
     RemoveObject(aObj);
     aObj->Expire();
   }
 };
 
-static HistoryTracker *gHistoryTracker = nullptr;
+static HistoryTracker* gHistoryTracker = nullptr;
 
 void
 nsSHEntryShared::EnsureHistoryTracker()
 {
   if (!gHistoryTracker) {
     // nsExpirationTracker doesn't allow one to change the timer period,
     // so just set it once when the history tracker is used for the first time.
     gHistoryTracker = new HistoryTracker(
@@ -83,35 +85,34 @@ nsSHEntryShared::nsSHEntryShared()
 nsSHEntryShared::~nsSHEntryShared()
 {
   RemoveFromExpirationTracker();
 
 #ifdef DEBUG
   if (gHistoryTracker) {
     // Check that we're not still on track to expire.  We shouldn't be, because
     // we just removed ourselves!
-    nsExpirationTracker<nsSHEntryShared, 3>::Iterator
-      iterator(gHistoryTracker);
+    nsExpirationTracker<nsSHEntryShared, 3>::Iterator iterator(gHistoryTracker);
 
-    nsSHEntryShared *elem;
+    nsSHEntryShared* elem;
     while ((elem = iterator.Next()) != nullptr) {
       NS_ASSERTION(elem != this, "Found dead entry still in the tracker!");
     }
   }
 #endif
 
   if (mContentViewer) {
     RemoveFromBFCacheSync();
   }
 }
 
 NS_IMPL_ISUPPORTS(nsSHEntryShared, nsIBFCacheEntry, nsIMutationObserver)
 
 already_AddRefed<nsSHEntryShared>
-nsSHEntryShared::Duplicate(nsSHEntryShared *aEntry)
+nsSHEntryShared::Duplicate(nsSHEntryShared* aEntry)
 {
   nsRefPtr<nsSHEntryShared> newEntry = new nsSHEntryShared();
 
   newEntry->mDocShellID = aEntry->mDocShellID;
   newEntry->mChildShells.AppendObjects(aEntry->mChildShells);
   newEntry->mOwner = aEntry->mOwner;
   newEntry->mContentType.Assign(aEntry->mContentType);
   newEntry->mIsFrameNavigation = aEntry->mIsFrameNavigation;
@@ -119,17 +120,18 @@ nsSHEntryShared::Duplicate(nsSHEntryShar
   newEntry->mSticky = aEntry->mSticky;
   newEntry->mDynamicallyCreated = aEntry->mDynamicallyCreated;
   newEntry->mCacheKey = aEntry->mCacheKey;
   newEntry->mLastTouched = aEntry->mLastTouched;
 
   return newEntry.forget();
 }
 
-void nsSHEntryShared::RemoveFromExpirationTracker()
+void
+nsSHEntryShared::RemoveFromExpirationTracker()
 {
   if (gHistoryTracker && GetExpirationState()->IsTracked()) {
     gHistoryTracker->RemoveObject(this);
   }
 }
 
 nsresult
 nsSHEntryShared::SyncPresentationState()
@@ -192,17 +194,17 @@ nsSHEntryShared::Expire()
   nsCOMPtr<nsISHistoryInternal> historyInt = do_QueryInterface(history);
   if (!historyInt) {
     return;
   }
   historyInt->EvictExpiredContentViewerForEntry(this);
 }
 
 nsresult
-nsSHEntryShared::SetContentViewer(nsIContentViewer *aViewer)
+nsSHEntryShared::SetContentViewer(nsIContentViewer* aViewer)
 {
   NS_PRECONDITION(!aViewer || !mContentViewer,
                   "SHEntryShared already contains viewer");
 
   if (mContentViewer || !aViewer) {
     DropPresentationState();
   }
 
@@ -224,18 +226,17 @@ nsSHEntryShared::SetContentViewer(nsICon
   }
 
   return NS_OK;
 }
 
 nsresult
 nsSHEntryShared::RemoveFromBFCacheSync()
 {
-  NS_ASSERTION(mContentViewer && mDocument,
-               "we're not in the bfcache!");
+  NS_ASSERTION(mContentViewer && mDocument, "we're not in the bfcache!");
 
   nsCOMPtr<nsIContentViewer> viewer = mContentViewer;
   DropPresentationState();
 
   // Warning! The call to DropPresentationState could have dropped the last
   // reference to this object, so don't access members beyond here.
 
   if (viewer) {
@@ -244,43 +245,42 @@ nsSHEntryShared::RemoveFromBFCacheSync()
 
   return NS_OK;
 }
 
 class DestroyViewerEvent : public nsRunnable
 {
 public:
   DestroyViewerEvent(nsIContentViewer* aViewer, nsIDocument* aDocument)
-    : mViewer(aViewer),
-      mDocument(aDocument)
-  {}
+    : mViewer(aViewer)
+    , mDocument(aDocument)
+  {
+  }
 
   NS_IMETHOD Run()
   {
     if (mViewer) {
       mViewer->Destroy();
     }
     return NS_OK;
   }
 
   nsCOMPtr<nsIContentViewer> mViewer;
   nsCOMPtr<nsIDocument> mDocument;
 };
 
 nsresult
 nsSHEntryShared::RemoveFromBFCacheAsync()
 {
-  NS_ASSERTION(mContentViewer && mDocument,
-               "we're not in the bfcache!");
+  NS_ASSERTION(mContentViewer && mDocument, "we're not in the bfcache!");
 
   // Release the reference to the contentviewer asynchronously so that the
   // document doesn't get nuked mid-mutation.
 
-  nsCOMPtr<nsIRunnable> evt =
-    new DestroyViewerEvent(mContentViewer, mDocument);
+  nsCOMPtr<nsIRunnable> evt = new DestroyViewerEvent(mContentViewer, mDocument);
   nsresult rv = NS_DispatchToCurrentThread(evt);
   if (NS_FAILED(rv)) {
     NS_WARNING("failed to dispatch DestroyViewerEvent");
   } else {
     // Drop presentation. Only do this if we succeeded in posting the event
     // since otherwise the document could be torn down mid-mutation, causing
     // crashes.
     DropPresentationState();
@@ -288,26 +288,22 @@ nsSHEntryShared::RemoveFromBFCacheAsync(
 
   // Careful! The call to DropPresentationState could have dropped the last
   // reference to this nsSHEntryShared, so don't access members beyond here.
 
   return NS_OK;
 }
 
 nsresult
-nsSHEntryShared::GetID(uint64_t *aID)
+nsSHEntryShared::GetID(uint64_t* aID)
 {
   *aID = mID;
   return NS_OK;
 }
 
-//*****************************************************************************
-//    nsSHEntryShared: nsIMutationObserver
-//*****************************************************************************
-
 void
 nsSHEntryShared::NodeWillBeDestroyed(const nsINode* aNode)
 {
   NS_NOTREACHED("Document destroyed while we're holding a strong ref to it");
 }
 
 void
 nsSHEntryShared::CharacterDataWillChange(nsIDocument* aDocument,
@@ -367,11 +363,11 @@ nsSHEntryShared::ContentRemoved(nsIDocum
                                 nsIContent* aChild,
                                 int32_t aIndexInContainer,
                                 nsIContent* aPreviousSibling)
 {
   RemoveFromBFCacheAsync();
 }
 
 void
-nsSHEntryShared::ParentChainChanged(nsIContent *aContent)
+nsSHEntryShared::ParentChainChanged(nsIContent* aContent)
 {
 }
--- a/docshell/shistory/src/nsSHEntryShared.h
+++ b/docshell/shistory/src/nsSHEntryShared.h
@@ -25,69 +25,70 @@ class nsDocShellEditorData;
 class nsISupportsArray;
 
 // A document may have multiple SHEntries, either due to hash navigations or
 // calls to history.pushState.  SHEntries corresponding to the same document
 // share many members; in particular, they share state related to the
 // back/forward cache.
 //
 // nsSHEntryShared is the vehicle for this sharing.
-class nsSHEntryShared final : public nsIBFCacheEntry,
-                              public nsIMutationObserver
+class nsSHEntryShared final
+  : public nsIBFCacheEntry
+  , public nsIMutationObserver
 {
-  public:
-    static void EnsureHistoryTracker();
-    static void Shutdown();
+public:
+  static void EnsureHistoryTracker();
+  static void Shutdown();
 
-    nsSHEntryShared();
+  nsSHEntryShared();
 
-    NS_DECL_ISUPPORTS
-    NS_DECL_NSIMUTATIONOBSERVER
-    NS_DECL_NSIBFCACHEENTRY
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIMUTATIONOBSERVER
+  NS_DECL_NSIBFCACHEENTRY
 
-  private:
-    ~nsSHEntryShared();
+private:
+  ~nsSHEntryShared();
 
-    friend class nsSHEntry;
+  friend class nsSHEntry;
 
-    friend class HistoryTracker;
-    friend class nsExpirationTracker<nsSHEntryShared, 3>;
-    nsExpirationState *GetExpirationState() { return &mExpirationState; }
+  friend class HistoryTracker;
+  friend class nsExpirationTracker<nsSHEntryShared, 3>;
+  nsExpirationState *GetExpirationState() { return &mExpirationState; }
 
-    static already_AddRefed<nsSHEntryShared> Duplicate(nsSHEntryShared *aEntry);
+  static already_AddRefed<nsSHEntryShared> Duplicate(nsSHEntryShared* aEntry);
 
-    void RemoveFromExpirationTracker();
-    void Expire();
-    nsresult SyncPresentationState();
-    void DropPresentationState();
+  void RemoveFromExpirationTracker();
+  void Expire();
+  nsresult SyncPresentationState();
+  void DropPresentationState();
 
-    nsresult SetContentViewer(nsIContentViewer *aViewer);
+  nsresult SetContentViewer(nsIContentViewer* aViewer);
 
-    // See nsISHEntry.idl for an explanation of these members.
+  // See nsISHEntry.idl for an explanation of these members.
 
-    // These members are copied by nsSHEntryShared::Duplicate().  If you add a
-    // member here, be sure to update the Duplicate() implementation.
-    uint64_t                        mDocShellID;
-    nsCOMArray<nsIDocShellTreeItem> mChildShells;
-    nsCOMPtr<nsISupports>           mOwner;
-    nsCString                       mContentType;
-    bool                            mIsFrameNavigation;
-    bool                            mSaveLayoutState;
-    bool                            mSticky;
-    bool                            mDynamicallyCreated;
-    nsCOMPtr<nsISupports>           mCacheKey;
-    uint32_t                        mLastTouched;
+  // These members are copied by nsSHEntryShared::Duplicate().  If you add a
+  // member here, be sure to update the Duplicate() implementation.
+  uint64_t mDocShellID;
+  nsCOMArray<nsIDocShellTreeItem> mChildShells;
+  nsCOMPtr<nsISupports> mOwner;
+  nsCString mContentType;
+  bool mIsFrameNavigation;
+  bool mSaveLayoutState;
+  bool mSticky;
+  bool mDynamicallyCreated;
+  nsCOMPtr<nsISupports> mCacheKey;
+  uint32_t mLastTouched;
 
-    // These members aren't copied by nsSHEntryShared::Duplicate() because
-    // they're specific to a particular content viewer.
-    uint64_t                        mID;
-    nsCOMPtr<nsIContentViewer>      mContentViewer;
-    nsCOMPtr<nsIDocument>           mDocument;
-    nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
-    bool                            mExpired;
-    nsCOMPtr<nsISupports>           mWindowState;
-    nsIntRect                       mViewerBounds;
-    nsCOMPtr<nsISupportsArray>      mRefreshURIList;
-    nsExpirationState               mExpirationState;
-    nsAutoPtr<nsDocShellEditorData> mEditorData;
+  // These members aren't copied by nsSHEntryShared::Duplicate() because
+  // they're specific to a particular content viewer.
+  uint64_t mID;
+  nsCOMPtr<nsIContentViewer> mContentViewer;
+  nsCOMPtr<nsIDocument> mDocument;
+  nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
+  bool mExpired;
+  nsCOMPtr<nsISupports> mWindowState;
+  nsIntRect mViewerBounds;
+  nsCOMPtr<nsISupportsArray> mRefreshURIList;
+  nsExpirationState mExpirationState;
+  nsAutoPtr<nsDocShellEditorData> mEditorData;
 };
 
 #endif
--- a/docshell/shistory/src/nsSHTransaction.cpp
+++ b/docshell/shistory/src/nsSHTransaction.cpp
@@ -1,121 +1,107 @@
 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-// Local Includes
 #include "nsSHTransaction.h"
 #include "nsISHEntry.h"
 
-//*****************************************************************************
-//***    nsSHTransaction: Object Management
-//*****************************************************************************
-
-nsSHTransaction::nsSHTransaction() : mPersist(true), mPrev(nullptr) 
+nsSHTransaction::nsSHTransaction()
+  : mPersist(true)
+  , mPrev(nullptr)
 {
 }
 
-
 nsSHTransaction::~nsSHTransaction()
 {
 }
 
-//*****************************************************************************
-//    nsSHTransaction: nsISupports
-//*****************************************************************************
-
 NS_IMPL_ADDREF(nsSHTransaction)
 NS_IMPL_RELEASE(nsSHTransaction)
 
 NS_INTERFACE_MAP_BEGIN(nsSHTransaction)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
-   NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHTransaction)
+  NS_INTERFACE_MAP_ENTRY(nsISHTransaction)
 NS_INTERFACE_MAP_END
 
-//*****************************************************************************
-//    nsSHTransaction: nsISHTransaction
-//*****************************************************************************
-
 NS_IMETHODIMP
 nsSHTransaction::Create(nsISHEntry* aSHEntry, nsISHTransaction* aPrev)
 {
-   SetSHEntry(aSHEntry);
-	if(aPrev)
-      aPrev->SetNext(this);
+  SetSHEntry(aSHEntry);
+  if (aPrev) {
+    aPrev->SetNext(this);
+  }
 
-   SetPrev(aPrev);
-	return NS_OK;
+  SetPrev(aPrev);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHTransaction::GetSHEntry(nsISHEntry ** aResult)
+nsSHTransaction::GetSHEntry(nsISHEntry** aResult)
 {
-   NS_ENSURE_ARG_POINTER(aResult);
-	*aResult = mSHEntry;
-	NS_IF_ADDREF(*aResult);
-	return NS_OK;
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = mSHEntry;
+  NS_IF_ADDREF(*aResult);
+  return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSHTransaction::SetSHEntry(nsISHEntry * aSHEntry)
+nsSHTransaction::SetSHEntry(nsISHEntry* aSHEntry)
 {
-	mSHEntry = aSHEntry;
-	return NS_OK;
+  mSHEntry = aSHEntry;
+  return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSHTransaction::GetNext(nsISHTransaction * * aResult)
+nsSHTransaction::GetNext(nsISHTransaction** aResult)
 {
-   NS_ENSURE_ARG_POINTER(aResult);
-   *aResult = mNext;
-   NS_IF_ADDREF(*aResult);
-   return NS_OK;
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = mNext;
+  NS_IF_ADDREF(*aResult);
+  return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSHTransaction::SetNext(nsISHTransaction * aNext)
+nsSHTransaction::SetNext(nsISHTransaction* aNext)
 {
   if (aNext) {
     NS_ENSURE_SUCCESS(aNext->SetPrev(this), NS_ERROR_FAILURE);
   }
 
   mNext = aNext;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHTransaction::SetPrev(nsISHTransaction * aPrev)
+nsSHTransaction::SetPrev(nsISHTransaction* aPrev)
 {
-	/* This is weak reference to parent. Do not Addref it */
-     mPrev = aPrev;
-	 return NS_OK;
+  /* This is weak reference to parent. Do not Addref it */
+  mPrev = aPrev;
+  return NS_OK;
 }
 
 nsresult
-nsSHTransaction::GetPrev(nsISHTransaction ** aResult)
+nsSHTransaction::GetPrev(nsISHTransaction** aResult)
 {
-   NS_ENSURE_ARG_POINTER(aResult);
-   *aResult  = mPrev;
-   NS_IF_ADDREF(*aResult);
-   return NS_OK;
+  NS_ENSURE_ARG_POINTER(aResult);
+  *aResult = mPrev;
+  NS_IF_ADDREF(*aResult);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHTransaction::SetPersist(bool aPersist)
 {
-   mPersist = aPersist;
-   return NS_OK;
+  mPersist = aPersist;
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHTransaction::GetPersist(bool* aPersist)
 {
-   NS_ENSURE_ARG_POINTER(aPersist);
+  NS_ENSURE_ARG_POINTER(aPersist);
 
-   *aPersist = mPersist;
-   return NS_OK;
+  *aPersist = mPersist;
+  return NS_OK;
 }
--- a/docshell/shistory/src/nsSHTransaction.h
+++ b/docshell/shistory/src/nsSHTransaction.h
@@ -10,30 +10,28 @@
 // Helper Classes
 #include "nsCOMPtr.h"
 
 // Needed interfaces
 #include "nsISHTransaction.h"
 
 class nsISHEntry;
 
-class nsSHTransaction: public nsISHTransaction
+class nsSHTransaction : public nsISHTransaction
 {
 public:
-	NS_DECL_ISUPPORTS
-	NS_DECL_NSISHTRANSACTION
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSISHTRANSACTION
 
-	nsSHTransaction();
+  nsSHTransaction();
 
 protected:
-	virtual ~nsSHTransaction();
-
+  virtual ~nsSHTransaction();
 
 protected:
-   bool           mPersist;
+  bool mPersist;
 
-	nsISHTransaction * mPrev; // Weak Reference
-	nsCOMPtr<nsISHTransaction> mNext;
-	nsCOMPtr<nsISHEntry>  mSHEntry;
+  nsISHTransaction* mPrev;  // Weak Reference
+  nsCOMPtr<nsISHTransaction> mNext;
+  nsCOMPtr<nsISHEntry> mSHEntry;
 };
 
-
-#endif   /* nsSHTransaction_h */
+#endif /* nsSHTransaction_h */
--- a/docshell/shistory/src/nsSHistory.cpp
+++ b/docshell/shistory/src/nsSHistory.cpp
@@ -1,15 +1,14 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-// Local Includes 
 #include "nsSHistory.h"
 #include <algorithm>
 
 // Helper Classes
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPtr.h"
 
 // Interfaces Needed
@@ -42,37 +41,38 @@ using namespace mozilla;
 #define PREF_SHISTORY_MAX_TOTAL_VIEWERS "browser.sessionhistory.max_total_viewers"
 
 static const char* kObservedPrefs[] = {
   PREF_SHISTORY_SIZE,
   PREF_SHISTORY_MAX_TOTAL_VIEWERS,
   nullptr
 };
 
-static int32_t  gHistoryMaxSize = 50;
+static int32_t gHistoryMaxSize = 50;
 // Max viewers allowed per SHistory objects
-static const int32_t  gHistoryMaxViewers = 3;
+static const int32_t gHistoryMaxViewers = 3;
 // List of all SHistory objects, used for content viewer cache eviction
 static PRCList gSHistoryList;
 // Max viewers allowed total, across all SHistory objects - negative default
 // means we will calculate how many viewers to cache based on total memory
 int32_t nsSHistory::sHistoryMaxTotalViewers = -1;
 
 // A counter that is used to be able to know the order in which
 // entries were touched, so that we can evict older entries first.
 static uint32_t gTouchCounter = 0;
 
 #ifdef PR_LOGGING
 
 static PRLogModuleInfo*
 GetSHistoryLog()
 {
-  static PRLogModuleInfo *sLog;
-  if (!sLog)
+  static PRLogModuleInfo* sLog;
+  if (!sLog) {
     sLog = PR_NewLogModule("nsSHistory");
+  }
   return sLog;
 }
 #define LOG(format) PR_LOG(GetSHistoryLog(), PR_LOG_DEBUG, format)
 
 // This macro makes it easier to print a log message which includes a URI's
 // spec.  Example use:
 //
 //  nsIURI *uri = [...];
@@ -150,139 +150,125 @@ GetSHistoryLog()
       }                                                    \
     );                                                     \
     if (canceled) {                                        \
       retval = false;                                      \
     }                                                      \
   }                                                        \
   PR_END_MACRO
 
-enum HistCmd{
+enum HistCmd
+{
   HIST_CMD_BACK,
   HIST_CMD_FORWARD,
   HIST_CMD_GOTOINDEX,
   HIST_CMD_RELOAD
-} ;
-
-//*****************************************************************************
-//***      nsSHistoryObserver
-//*****************************************************************************
+};
 
 class nsSHistoryObserver final : public nsIObserver
 {
-
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   nsSHistoryObserver() {}
 
 protected:
   ~nsSHistoryObserver() {}
 };
 
 StaticRefPtr<nsSHistoryObserver> gObserver;
 
 NS_IMPL_ISUPPORTS(nsSHistoryObserver, nsIObserver)
 
 NS_IMETHODIMP
-nsSHistoryObserver::Observe(nsISupports *aSubject, const char *aTopic,
-                            const char16_t *aData)
+nsSHistoryObserver::Observe(nsISupports* aSubject, const char* aTopic,
+                            const char16_t* aData)
 {
   if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
     nsSHistory::UpdatePrefs();
     nsSHistory::GloballyEvictContentViewers();
   } else if (!strcmp(aTopic, "cacheservice:empty-cache") ||
              !strcmp(aTopic, "memory-pressure")) {
     nsSHistory::GloballyEvictAllContentViewers();
   }
 
   return NS_OK;
 }
 
 namespace {
 
 already_AddRefed<nsIContentViewer>
-GetContentViewerForTransaction(nsISHTransaction *aTrans)
+GetContentViewerForTransaction(nsISHTransaction* aTrans)
 {
   nsCOMPtr<nsISHEntry> entry;
   aTrans->GetSHEntry(getter_AddRefs(entry));
   if (!entry) {
     return nullptr;
   }
 
   nsCOMPtr<nsISHEntry> ownerEntry;
   nsCOMPtr<nsIContentViewer> viewer;
   entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
                              getter_AddRefs(viewer));
   return viewer.forget();
 }
 
 void
-EvictContentViewerForTransaction(nsISHTransaction *aTrans)
+EvictContentViewerForTransaction(nsISHTransaction* aTrans)
 {
   nsCOMPtr<nsISHEntry> entry;
   aTrans->GetSHEntry(getter_AddRefs(entry));
   nsCOMPtr<nsIContentViewer> viewer;
   nsCOMPtr<nsISHEntry> ownerEntry;
   entry->GetAnyContentViewer(getter_AddRefs(ownerEntry),
                              getter_AddRefs(viewer));
   if (viewer) {
-    NS_ASSERTION(ownerEntry,
-                 "Content viewer exists but its SHEntry is null");
+    NS_ASSERTION(ownerEntry, "Content viewer exists but its SHEntry is null");
 
     LOG_SHENTRY_SPEC(("Evicting content viewer 0x%p for "
                       "owning SHEntry 0x%p at %s.",
-                      viewer.get(), ownerEntry.get(), _spec), ownerEntry);
+                      viewer.get(), ownerEntry.get(), _spec),
+                     ownerEntry);
 
     // Drop the presentation state before destroying the viewer, so that
     // document teardown is able to correctly persist the state.
     ownerEntry->SetContentViewer(nullptr);
     ownerEntry->SyncPresentationState();
     viewer->Destroy();
   }
 }
 
 } // anonymous namespace
 
-//*****************************************************************************
-//***    nsSHistory: Object Management
-//*****************************************************************************
-
-nsSHistory::nsSHistory() : mListRoot(nullptr), mIndex(-1), mLength(0), mRequestedIndex(-1)
+nsSHistory::nsSHistory()
+  : mIndex(-1)
+  , mLength(0)
+  , mRequestedIndex(-1)
 {
   // Add this new SHistory object to the list
   PR_APPEND_LINK(this, &gSHistoryList);
 }
 
-
 nsSHistory::~nsSHistory()
 {
   // Remove this SHistory object from the list
   PR_REMOVE_LINK(this);
 }
 
-//*****************************************************************************
-//    nsSHistory: nsISupports
-//*****************************************************************************
-
 NS_IMPL_ADDREF(nsSHistory)
 NS_IMPL_RELEASE(nsSHistory)
 
 NS_INTERFACE_MAP_BEGIN(nsSHistory)
-   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
-   NS_INTERFACE_MAP_ENTRY(nsISHistory)
-   NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
-   NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsISHistory)
+  NS_INTERFACE_MAP_ENTRY(nsISHistory)
+  NS_INTERFACE_MAP_ENTRY(nsIWebNavigation)
+  NS_INTERFACE_MAP_ENTRY(nsISHistoryInternal)
 NS_INTERFACE_MAP_END
 
-//*****************************************************************************
-//    nsSHistory: nsISHistory
-//*****************************************************************************
-
 // static
 uint32_t
 nsSHistory::CalcMaxTotalViewers()
 {
   // Calculate an estimate of how many ContentViewers we should cache based
   // on RAM.  This assumes that the average ContentViewer is 4MB (conservative)
   // and caps the max at 8 ContentViewers
   //
@@ -296,35 +282,37 @@ nsSHistory::CalcMaxTotalViewers()
   // 128  Mb       2
   // 256  Mb       3
   // 512  Mb       5
   // 1024 Mb       8
   // 2048 Mb       8
   // 4096 Mb       8
   uint64_t bytes = PR_GetPhysicalMemorySize();
 
-  if (bytes == 0)
+  if (bytes == 0) {
     return 0;
+  }
 
   // Conversion from unsigned int64_t to double doesn't work on all platforms.
   // We need to truncate the value at INT64_MAX to make sure we don't
   // overflow.
-  if (bytes > INT64_MAX)
+  if (bytes > INT64_MAX) {
     bytes = INT64_MAX;
+  }
 
   double kBytesD = (double)(bytes >> 10);
 
   // This is essentially the same calculation as for nsCacheService,
   // except that we divide the final memory calculation by 4, since
   // we assume each ContentViewer takes on average 4MB
   uint32_t viewers = 0;
-  double x = std::log(kBytesD)/std::log(2.0) - 14;
+  double x = std::log(kBytesD) / std::log(2.0) - 14;
   if (x > 0) {
-    viewers    = (uint32_t)(x * x - x + 2.001); // add .001 for rounding
-    viewers   /= 4;
+    viewers = (uint32_t)(x * x - x + 2.001); // add .001 for rounding
+    viewers /= 4;
   }
 
   // Cap it off at 8 max
   if (viewers > 8) {
     viewers = 8;
   }
   return viewers;
 }
@@ -351,30 +339,29 @@ nsSHistory::Startup()
 
   // The goal of this is to unbreak users who have inadvertently set their
   // session history size to less than the default value.
   int32_t defaultHistoryMaxSize =
     Preferences::GetDefaultInt(PREF_SHISTORY_SIZE, 50);
   if (gHistoryMaxSize < defaultHistoryMaxSize) {
     gHistoryMaxSize = defaultHistoryMaxSize;
   }
-  
+
   // Allow the user to override the max total number of cached viewers,
   // but keep the per SHistory cached viewer limit constant
   if (!gObserver) {
     gObserver = new nsSHistoryObserver();
     Preferences::AddStrongObservers(gObserver, kObservedPrefs);
 
     nsCOMPtr<nsIObserverService> obsSvc =
       mozilla::services::GetObserverService();
     if (obsSvc) {
       // Observe empty-cache notifications so tahat clearing the disk/memory
       // cache will also evict all content viewers.
-      obsSvc->AddObserver(gObserver,
-                          "cacheservice:empty-cache", false);
+      obsSvc->AddObserver(gObserver, "cacheservice:empty-cache", false);
 
       // Same for memory-pressure notifications
       obsSvc->AddObserver(gObserver, "memory-pressure", false);
     }
   }
 
   // Initialize the global list of all SHistory objects
   PR_INIT_CLIST(&gSHistoryList);
@@ -392,178 +379,184 @@ nsSHistory::Shutdown()
     if (obsSvc) {
       obsSvc->RemoveObserver(gObserver, "cacheservice:empty-cache");
       obsSvc->RemoveObserver(gObserver, "memory-pressure");
     }
     gObserver = nullptr;
   }
 }
 
-/* Add an entry to the History list at mIndex and 
+/* Add an entry to the History list at mIndex and
  * increment the index to point to the new entry
  */
 NS_IMETHODIMP
-nsSHistory::AddEntry(nsISHEntry * aSHEntry, bool aPersist)
+nsSHistory::AddEntry(nsISHEntry* aSHEntry, bool aPersist)
 {
   NS_ENSURE_ARG(aSHEntry);
 
   nsCOMPtr<nsISHTransaction> currentTxn;
 
-  if(mListRoot)
+  if (mListRoot) {
     GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
+  }
 
   bool currentPersist = true;
-  if(currentTxn)
+  if (currentTxn) {
     currentTxn->GetPersist(&currentPersist);
+  }
 
   int32_t currentIndex = mIndex;
 
-  if(!currentPersist)
-  {
+  if (!currentPersist) {
     NOTIFY_LISTENERS(OnHistoryReplaceEntry, (currentIndex));
-    NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry),NS_ERROR_FAILURE);
+    NS_ENSURE_SUCCESS(currentTxn->SetSHEntry(aSHEntry), NS_ERROR_FAILURE);
     currentTxn->SetPersist(aPersist);
     return NS_OK;
   }
 
-  nsCOMPtr<nsISHTransaction> txn(do_CreateInstance(NS_SHTRANSACTION_CONTRACTID));
+  nsCOMPtr<nsISHTransaction> txn(
+    do_CreateInstance(NS_SHTRANSACTION_CONTRACTID));
   NS_ENSURE_TRUE(txn, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIURI> uri;
   aSHEntry->GetURI(getter_AddRefs(uri));
   NOTIFY_LISTENERS(OnHistoryNewEntry, (uri));
 
   // If a listener has changed mIndex, we need to get currentTxn again,
   // otherwise we'll be left at an inconsistent state (see bug 320742)
   if (currentIndex != mIndex) {
     GetTransactionAtIndex(mIndex, getter_AddRefs(currentTxn));
   }
 
-  // Set the ShEntry and parent for the transaction. setting the 
+  // Set the ShEntry and parent for the transaction. setting the
   // parent will properly set the parent child relationship
   txn->SetPersist(aPersist);
   NS_ENSURE_SUCCESS(txn->Create(aSHEntry, currentTxn), NS_ERROR_FAILURE);
-   
+
   // A little tricky math here...  Basically when adding an object regardless of
   // what the length was before, it should always be set back to the current and
   // lop off the forward.
   mLength = (++mIndex + 1);
 
   // If this is the very first transaction, initialize the list
-  if(!mListRoot)
+  if (!mListRoot) {
     mListRoot = txn;
+  }
 
   // Purge History list if it is too long
-  if ((gHistoryMaxSize >= 0) && (mLength > gHistoryMaxSize))
-    PurgeHistory(mLength-gHistoryMaxSize);
-  
+  if (gHistoryMaxSize >= 0 && mLength > gHistoryMaxSize) {
+    PurgeHistory(mLength - gHistoryMaxSize);
+  }
+
   RemoveDynEntries(mIndex - 1, mIndex);
   return NS_OK;
 }
 
 /* Get size of the history list */
 NS_IMETHODIMP
-nsSHistory::GetCount(int32_t * aResult)
+nsSHistory::GetCount(int32_t* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = mLength;
   return NS_OK;
 }
 
 /* Get index of the history list */
 NS_IMETHODIMP
-nsSHistory::GetIndex(int32_t * aResult)
+nsSHistory::GetIndex(int32_t* aResult)
 {
   NS_PRECONDITION(aResult, "null out param?");
   *aResult = mIndex;
   return NS_OK;
 }
 
 /* Get the requestedIndex */
 NS_IMETHODIMP
-nsSHistory::GetRequestedIndex(int32_t * aResult)
+nsSHistory::GetRequestedIndex(int32_t* aResult)
 {
   NS_PRECONDITION(aResult, "null out param?");
   *aResult = mRequestedIndex;
   return NS_OK;
 }
 
 /* Get the entry at a given index */
 NS_IMETHODIMP
-nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex, nsISHEntry** aResult)
+nsSHistory::GetEntryAtIndex(int32_t aIndex, bool aModifyIndex,
+                            nsISHEntry** aResult)
 {
   nsresult rv;
   nsCOMPtr<nsISHTransaction> txn;
 
   /* GetTransactionAtIndex ensures aResult is valid and validates aIndex */
   rv = GetTransactionAtIndex(aIndex, getter_AddRefs(txn));
   if (NS_SUCCEEDED(rv) && txn) {
-    //Get the Entry from the transaction
+    // Get the Entry from the transaction
     rv = txn->GetSHEntry(aResult);
     if (NS_SUCCEEDED(rv) && (*aResult)) {
       // Set mIndex to the requested index, if asked to do so..
       if (aModifyIndex) {
         mIndex = aIndex;
       }
-    } //entry
-  }  //Transaction
+    }
+  }
   return rv;
 }
 
 /* Get the transaction at a given index */
 NS_IMETHODIMP
-nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult)
+nsSHistory::GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult)
 {
   nsresult rv;
   NS_ENSURE_ARG_POINTER(aResult);
 
-  if ((mLength <= 0) || (aIndex < 0) || (aIndex >= mLength))
+  if (mLength <= 0 || aIndex < 0 || aIndex >= mLength) {
     return NS_ERROR_FAILURE;
+  }
 
-  if (!mListRoot) 
+  if (!mListRoot) {
     return NS_ERROR_FAILURE;
+  }
 
-  if (aIndex == 0)
-  {
+  if (aIndex == 0) {
     *aResult = mListRoot;
     NS_ADDREF(*aResult);
     return NS_OK;
-  } 
-  int32_t   cnt=0;
-  nsCOMPtr<nsISHTransaction>  tempPtr;
+  }
 
+  int32_t cnt = 0;
+  nsCOMPtr<nsISHTransaction> tempPtr;
   rv = GetRootTransaction(getter_AddRefs(tempPtr));
-  if (NS_FAILED(rv) || !tempPtr)
+  if (NS_FAILED(rv) || !tempPtr) {
     return NS_ERROR_FAILURE;
+  }
 
-  while(1) {
+  while (true) {
     nsCOMPtr<nsISHTransaction> ptr;
     rv = tempPtr->GetNext(getter_AddRefs(ptr));
     if (NS_SUCCEEDED(rv) && ptr) {
       cnt++;
       if (cnt == aIndex) {
         ptr.forget(aResult);
         break;
-      }
-      else {
+      } else {
         tempPtr = ptr;
         continue;
       }
-    }  //NS_SUCCEEDED
-    else 
+    } else {
       return NS_ERROR_FAILURE;
-  }  // while 
-  
+    }
+  }
+
   return NS_OK;
 }
 
-
 /* Get the index of a given entry */
 NS_IMETHODIMP
-nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult) {
+nsSHistory::GetIndexOfEntry(nsISHEntry* aSHEntry, int32_t* aResult)
+{
   NS_ENSURE_ARG(aSHEntry);
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = -1;
 
   if (mLength <= 0) {
     return NS_ERROR_FAILURE;
   }
 
@@ -593,114 +586,118 @@ nsSHistory::GetIndexOfEntry(nsISHEntry* 
     }
 
     cnt++;
   }
 
   return NS_OK;
 }
 
-
 #ifdef DEBUG
 nsresult
 nsSHistory::PrintHistory()
 {
-
-  nsCOMPtr<nsISHTransaction>   txn;
+  nsCOMPtr<nsISHTransaction> txn;
   int32_t index = 0;
   nsresult rv;
 
-  if (!mListRoot) 
+  if (!mListRoot) {
     return NS_ERROR_FAILURE;
+  }
 
   txn = mListRoot;
-    
+
   while (1) {
-    if (!txn)
+    if (!txn) {
       break;
-    nsCOMPtr<nsISHEntry>  entry;
+    }
+    nsCOMPtr<nsISHEntry> entry;
     rv = txn->GetSHEntry(getter_AddRefs(entry));
-    if (NS_FAILED(rv) && !entry)
+    if (NS_FAILED(rv) && !entry) {
       return NS_ERROR_FAILURE;
+    }
 
     nsCOMPtr<nsILayoutHistoryState> layoutHistoryState;
-    nsCOMPtr<nsIURI>  uri;
+    nsCOMPtr<nsIURI> uri;
     nsXPIDLString title;
 
     entry->GetLayoutHistoryState(getter_AddRefs(layoutHistoryState));
     entry->GetURI(getter_AddRefs(uri));
     entry->GetTitle(getter_Copies(title));
 
 #if 0
     nsAutoCString url;
-    if (uri)
-     uri->GetSpec(url);
+    if (uri) {
+      uri->GetSpec(url);
+    }
 
     printf("**** SH Transaction #%d, Entry = %x\n", index, entry.get());
     printf("\t\t URL = %s\n", url.get());
 
     printf("\t\t Title = %s\n", NS_LossyConvertUTF16toASCII(title).get());
     printf("\t\t layout History Data = %x\n", layoutHistoryState.get());
 #endif
 
     nsCOMPtr<nsISHTransaction> next;
     rv = txn->GetNext(getter_AddRefs(next));
     if (NS_SUCCEEDED(rv) && next) {
       txn = next;
       index++;
       continue;
+    } else {
+      break;
     }
-    else
-      break;
   }
 
   return NS_OK;
 }
 #endif
 
-
 NS_IMETHODIMP
-nsSHistory::GetRootTransaction(nsISHTransaction ** aResult)
+nsSHistory::GetRootTransaction(nsISHTransaction** aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
-  *aResult=mListRoot;
+  *aResult = mListRoot;
   NS_IF_ADDREF(*aResult);
   return NS_OK;
 }
 
 /* Get the max size of the history list */
 NS_IMETHODIMP
-nsSHistory::GetMaxLength(int32_t * aResult)
+nsSHistory::GetMaxLength(int32_t* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = gHistoryMaxSize;
   return NS_OK;
 }
 
 /* Set the max size of the history list */
 NS_IMETHODIMP
 nsSHistory::SetMaxLength(int32_t aMaxSize)
 {
-  if (aMaxSize < 0)
+  if (aMaxSize < 0) {
     return NS_ERROR_ILLEGAL_VALUE;
+  }
 
   gHistoryMaxSize = aMaxSize;
-  if (mLength > aMaxSize)
-    PurgeHistory(mLength-aMaxSize);
+  if (mLength > aMaxSize) {
+    PurgeHistory(mLength - aMaxSize);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::PurgeHistory(int32_t aEntries)
 {
-  if (mLength <= 0 || aEntries <= 0)
+  if (mLength <= 0 || aEntries <= 0) {
     return NS_ERROR_FAILURE;
+  }
 
   aEntries = std::min(aEntries, mLength);
-  
+
   bool purgeHistory = true;
   NOTIFY_LISTENERS_CANCELABLE(OnHistoryPurge, purgeHistory,
                               (aEntries, &purgeHistory));
 
   if (!purgeHistory) {
     // Listener asked us not to purge
     return NS_SUCCESS_LOSS_OF_INSIGNIFICANT_DATA;
   }
@@ -711,78 +708,79 @@ nsSHistory::PurgeHistory(int32_t aEntrie
     if (mListRoot) {
       mListRoot->GetNext(getter_AddRefs(nextTxn));
       mListRoot->SetNext(nullptr);
     }
     mListRoot = nextTxn;
     if (mListRoot) {
       mListRoot->SetPrev(nullptr);
     }
-    cnt++;        
+    cnt++;
   }
   mLength -= cnt;
   mIndex -= cnt;
 
   // Now if we were not at the end of the history, mIndex could have
   // become far too negative.  If so, just set it to -1.
   if (mIndex < -1) {
     mIndex = -1;
   }
 
-  if (mRootDocShell)
+  if (mRootDocShell) {
     mRootDocShell->HistoryPurged(cnt);
+  }
 
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
-nsSHistory::AddSHistoryListener(nsISHistoryListener * aListener)
+nsSHistory::AddSHistoryListener(nsISHistoryListener* aListener)
 {
   NS_ENSURE_ARG_POINTER(aListener);
 
   // Check if the listener supports Weak Reference. This is a must.
-  // This listener functionality is used by embedders and we want to 
+  // This listener functionality is used by embedders and we want to
   // have the right ownership with who ever listens to SHistory
   nsWeakPtr listener = do_GetWeakReference(aListener);
-  if (!listener) return NS_ERROR_FAILURE;
+  if (!listener) {
+    return NS_ERROR_FAILURE;
+  }
 
   return mListeners.AppendElementUnlessExists(listener) ?
     NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
-
 NS_IMETHODIMP
-nsSHistory::RemoveSHistoryListener(nsISHistoryListener * aListener)
+nsSHistory::RemoveSHistoryListener(nsISHistoryListener* aListener)
 {
   // Make sure the listener that wants to be removed is the
-  // one we have in store. 
+  // one we have in store.
   nsWeakPtr listener = do_GetWeakReference(aListener);
   mListeners.RemoveElement(listener);
   return NS_OK;
 }
 
-
 /* Replace an entry in the History list at a particular index.
  * Do not update index or count.
  */
 NS_IMETHODIMP
-nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry * aReplaceEntry)
+nsSHistory::ReplaceEntry(int32_t aIndex, nsISHEntry* aReplaceEntry)
 {
   NS_ENSURE_ARG(aReplaceEntry);
   nsresult rv;
   nsCOMPtr<nsISHTransaction> currentTxn;
 
-  if (!mListRoot) // Session History is not initialised.
+  if (!mListRoot) {
+    // Session History is not initialised.
     return NS_ERROR_FAILURE;
+  }
 
   rv = GetTransactionAtIndex(aIndex, getter_AddRefs(currentTxn));
 
-  if(currentTxn)
-  {
+  if (currentTxn) {
     NOTIFY_LISTENERS(OnHistoryReplaceEntry, (aIndex));
 
     // Set the replacement entry in the transaction
     rv = currentTxn->SetSHEntry(aReplaceEntry);
     rv = currentTxn->SetPersist(true);
   }
   return rv;
 }
@@ -810,140 +808,129 @@ NS_IMETHODIMP
 nsSHistory::EvictAllContentViewers()
 {
   // XXXbz we don't actually do a good job of evicting things as we should, so
   // we might have viewers quite far from mIndex.  So just evict everything.
   nsCOMPtr<nsISHTransaction> trans = mListRoot;
   while (trans) {
     EvictContentViewerForTransaction(trans);
 
-    nsISHTransaction *temp = trans;
+    nsISHTransaction* temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 
   return NS_OK;
 }
 
-
-
-//*****************************************************************************
-//    nsSHistory: nsIWebNavigation
-//*****************************************************************************
-
 NS_IMETHODIMP
-nsSHistory::GetCanGoBack(bool * aCanGoBack)
+nsSHistory::GetCanGoBack(bool* aCanGoBack)
 {
   NS_ENSURE_ARG_POINTER(aCanGoBack);
   *aCanGoBack = false;
 
   int32_t index = -1;
   NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
-  if(index > 0)
-     *aCanGoBack = true;
+  if (index > 0) {
+    *aCanGoBack = true;
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsSHistory::GetCanGoForward(bool * aCanGoForward)
+nsSHistory::GetCanGoForward(bool* aCanGoForward)
 {
   NS_ENSURE_ARG_POINTER(aCanGoForward);
   *aCanGoForward = false;
 
   int32_t index = -1;
   int32_t count = -1;
 
   NS_ENSURE_SUCCESS(GetIndex(&index), NS_ERROR_FAILURE);
   NS_ENSURE_SUCCESS(GetCount(&count), NS_ERROR_FAILURE);
 
-  if((index >= 0) && (index < (count - 1)))
+  if (index >= 0 && index < (count - 1)) {
     *aCanGoForward = true;
+  }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GoBack()
 {
   bool canGoBack = false;
 
   GetCanGoBack(&canGoBack);
-  if (!canGoBack)  // Can't go back
+  if (!canGoBack) {
     return NS_ERROR_UNEXPECTED;
-  return LoadEntry(mIndex-1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
+  }
+  return LoadEntry(mIndex - 1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_BACK);
 }
 
-
 NS_IMETHODIMP
 nsSHistory::GoForward()
 {
   bool canGoForward = false;
 
   GetCanGoForward(&canGoForward);
-  if (!canGoForward)  // Can't go forward
+  if (!canGoForward) {
     return NS_ERROR_UNEXPECTED;
-  return LoadEntry(mIndex+1, nsIDocShellLoadInfo::loadHistory, HIST_CMD_FORWARD);
+  }
+  return LoadEntry(mIndex + 1, nsIDocShellLoadInfo::loadHistory,
+                   HIST_CMD_FORWARD);
 }
 
 NS_IMETHODIMP
 nsSHistory::Reload(uint32_t aReloadFlags)
 {
   nsDocShellInfoLoadType loadType;
-  if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY && 
-      aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
-  {
+  if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY &&
+      aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
     loadType = nsIDocShellLoadInfo::loadReloadBypassProxyAndCache;
-  }
-  else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY)
-  {
+  } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY) {
     loadType = nsIDocShellLoadInfo::loadReloadBypassProxy;
-  }
-  else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE)
-  {
+  } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE) {
     loadType = nsIDocShellLoadInfo::loadReloadBypassCache;
-  }
-  else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE)
-  {
+  } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE) {
     loadType = nsIDocShellLoadInfo::loadReloadCharsetChange;
-  }
-  else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT)
-  {
+  } else if (aReloadFlags & nsIWebNavigation::LOAD_FLAGS_ALLOW_MIXED_CONTENT) {
     loadType = nsIDocShellLoadInfo::loadReloadMixedContent;
-  }
-  else
-  {
+  } else {
     loadType = nsIDocShellLoadInfo::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;
   GetCurrentURI(getter_AddRefs(currentURI));
   NOTIFY_LISTENERS_CANCELABLE(OnHistoryReload, canNavigate,
                               (currentURI, aReloadFlags, &canNavigate));
-  if (!canNavigate)
+  if (!canNavigate) {
     return NS_OK;
+  }
 
   return LoadEntry(mIndex, loadType, HIST_CMD_RELOAD);
 }
 
 NS_IMETHODIMP
 nsSHistory::ReloadCurrentEntry()
 {
   // Notify listeners
   bool canNavigate = true;
   nsCOMPtr<nsIURI> currentURI;
   GetCurrentURI(getter_AddRefs(currentURI));
   NOTIFY_LISTENERS_CANCELABLE(OnHistoryGotoIndex, canNavigate,
                               (mIndex, currentURI, &canNavigate));
-  if (!canNavigate)
+  if (!canNavigate) {
     return NS_OK;
+  }
 
   return LoadEntry(mIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_RELOAD);
 }
 
 void
 nsSHistory::EvictOutOfRangeWindowContentViewers(int32_t aIndex)
 {
   // XXX rename method to EvictContentViewersExceptAroundIndex, or something.
@@ -987,50 +974,50 @@ nsSHistory::EvictOutOfRangeWindowContent
   NS_ENSURE_TRUE_VOID(aIndex < mLength);
 
   // Calculate the range that's safe from eviction.
   int32_t startSafeIndex = std::max(0, aIndex - gHistoryMaxViewers);
   int32_t endSafeIndex = std::min(mLength, aIndex + gHistoryMaxViewers);
 
   LOG(("EvictOutOfRangeWindowContentViewers(index=%d), "
        "mLength=%d. Safe range [%d, %d]",
-       aIndex, mLength, startSafeIndex, endSafeIndex)); 
+       aIndex, mLength, startSafeIndex, endSafeIndex));
 
   // The content viewers in range aIndex -/+ gHistoryMaxViewers will not be
   // evicted.  Collect a set of them so we don't accidentally evict one of them
   // if it appears outside this range.
   nsCOMArray<nsIContentViewer> safeViewers;
   nsCOMPtr<nsISHTransaction> trans;
   GetTransactionAtIndex(startSafeIndex, getter_AddRefs(trans));
   for (int32_t i = startSafeIndex; trans && i <= endSafeIndex; i++) {
     nsCOMPtr<nsIContentViewer> viewer = GetContentViewerForTransaction(trans);
     safeViewers.AppendObject(viewer);
-    nsISHTransaction *temp = trans;
+    nsISHTransaction* temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 
   // Walk the SHistory list and evict any content viewers that aren't safe.
   GetTransactionAtIndex(0, getter_AddRefs(trans));
   while (trans) {
     nsCOMPtr<nsIContentViewer> viewer = GetContentViewerForTransaction(trans);
     if (safeViewers.IndexOf(viewer) == -1) {
       EvictContentViewerForTransaction(trans);
     }
 
-    nsISHTransaction *temp = trans;
+    nsISHTransaction* temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
 }
 
 namespace {
 
 class TransactionAndDistance
 {
 public:
-  TransactionAndDistance(nsISHTransaction *aTrans, uint32_t aDist)
+  TransactionAndDistance(nsISHTransaction* aTrans, uint32_t aDist)
     : mTransaction(aTrans)
     , mDistance(aDist)
   {
     mViewer = GetContentViewerForTransaction(aTrans);
     NS_ASSERTION(mViewer, "Transaction should have a content viewer");
 
     nsCOMPtr<nsISHEntry> shentry;
     mTransaction->GetSHEntry(getter_AddRefs(shentry));
@@ -1039,44 +1026,44 @@ public:
     if (shentryInternal) {
       shentryInternal->GetLastTouched(&mLastTouched);
     } else {
       NS_WARNING("Can't cast to nsISHEntryInternal?");
       mLastTouched = 0;
     }
   }
 
-  bool operator<(const TransactionAndDistance &aOther) const
+  bool operator<(const TransactionAndDistance& aOther) const
   {
     // Compare distances first, and fall back to last-accessed times.
     if (aOther.mDistance != this->mDistance) {
       return this->mDistance < aOther.mDistance;
     }
 
     return this->mLastTouched < aOther.mLastTouched;
   }
 
-  bool operator==(const TransactionAndDistance &aOther) const
+  bool operator==(const TransactionAndDistance& aOther) const
   {
     // This is a little silly; we need == so the default comaprator can be
     // instantiated, but this function is never actually called when we sort
     // the list of TransactionAndDistance objects.
     return aOther.mDistance == this->mDistance &&
            aOther.mLastTouched == this->mLastTouched;
   }
 
   nsCOMPtr<nsISHTransaction> mTransaction;
   nsCOMPtr<nsIContentViewer> mViewer;
   uint32_t mLastTouched;
   int32_t mDistance;
 };
 
 } // anonymous namespace
 
-//static
+// static
 void
 nsSHistory::GloballyEvictContentViewers()
 {
   // First, collect from each SHistory object the transactions which have a
   // cached content viewer.  Associate with each transaction its distance from
   // its SHistory's current index.
 
   nsTArray<TransactionAndDistance> transactions;
@@ -1100,47 +1087,49 @@ nsSHistory::GloballyEvictContentViewers(
     //
     //   * bugs which cause us not to call nsSHistory::EvictContentViewers()
     //     often enough.  Once we do call EvictContentViewers() for the
     //     SHistory object in question, we'll do a full search of its history
     //     and evict the out-of-range content viewers, so we don't bother here.
     //
     int32_t startIndex = std::max(0, shist->mIndex - gHistoryMaxViewers);
     int32_t endIndex = std::min(shist->mLength - 1,
-                              shist->mIndex + gHistoryMaxViewers);
+                                shist->mIndex + gHistoryMaxViewers);
     nsCOMPtr<nsISHTransaction> trans;
     shist->GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
     for (int32_t i = startIndex; trans && i <= endIndex; i++) {
       nsCOMPtr<nsIContentViewer> contentViewer =
         GetContentViewerForTransaction(trans);
 
       if (contentViewer) {
         // Because one content viewer might belong to multiple SHEntries, we
         // have to search through shTransactions to see if we already know
         // about this content viewer.  If we find the viewer, update its
         // distance from the SHistory's index and continue.
         bool found = false;
         for (uint32_t j = 0; j < shTransactions.Length(); j++) {
-          TransactionAndDistance &container = shTransactions[j];
+          TransactionAndDistance& container = shTransactions[j];
           if (container.mViewer == contentViewer) {
-            container.mDistance = std::min(container.mDistance, DeprecatedAbs(i - shist->mIndex));
+            container.mDistance = std::min(container.mDistance,
+                                           DeprecatedAbs(i - shist->mIndex));
             found = true;
             break;
           }
         }
 
-        // If we didn't find a TransactionAndDistance for this content viewer, make a new
-        // one.
+        // If we didn't find a TransactionAndDistance for this content viewer,
+        // make a new one.
         if (!found) {
-          TransactionAndDistance container(trans, DeprecatedAbs(i - shist->mIndex));
+          TransactionAndDistance container(trans,
+                                           DeprecatedAbs(i - shist->mIndex));
           shTransactions.AppendElement(container);
         }
       }
 
-      nsISHTransaction *temp = trans;
+      nsISHTransaction* temp = trans;
       temp->GetNext(getter_AddRefs(trans));
     }
 
     // We've found all the transactions belonging to shist which have viewers.
     // Add those transactions to our global list and move on.
     transactions.AppendElements(shTransactions);
     listEntry = PR_NEXT_LINK(shist);
   }
@@ -1152,77 +1141,76 @@ nsSHistory::GloballyEvictContentViewers(
   }
 
   // If we need to evict, sort our list of transactions and evict the largest
   // ones.  (We could of course get better algorithmic complexity here by using
   // a heap or something more clever.  But sHistoryMaxTotalViewers isn't large,
   // so let's not worry about it.)
   transactions.Sort();
 
-  for (int32_t i = transactions.Length() - 1;
-       i >= sHistoryMaxTotalViewers; --i) {
-
+  for (int32_t i = transactions.Length() - 1; i >= sHistoryMaxTotalViewers;
+       --i) {
     EvictContentViewerForTransaction(transactions[i].mTransaction);
-
   }
 }
 
 nsresult
-nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry *aEntry)
+nsSHistory::EvictExpiredContentViewerForEntry(nsIBFCacheEntry* aEntry)
 {
   int32_t startIndex = std::max(0, mIndex - gHistoryMaxViewers);
-  int32_t endIndex = std::min(mLength - 1,
-                            mIndex + gHistoryMaxViewers);
+  int32_t endIndex = std::min(mLength - 1, mIndex + gHistoryMaxViewers);
   nsCOMPtr<nsISHTransaction> trans;
   GetTransactionAtIndex(startIndex, getter_AddRefs(trans));
 
   int32_t i;
   for (i = startIndex; trans && i <= endIndex; ++i) {
     nsCOMPtr<nsISHEntry> entry;
     trans->GetSHEntry(getter_AddRefs(entry));
 
     // Does entry have the same BFCacheEntry as the argument to this method?
     if (entry->HasBFCacheEntry(aEntry)) {
       break;
     }
 
-    nsISHTransaction *temp = trans;
+    nsISHTransaction* temp = trans;
     temp->GetNext(getter_AddRefs(trans));
   }
-  if (i > endIndex)
+  if (i > endIndex) {
     return NS_OK;
-  
+  }
+
   if (i == mIndex) {
     NS_WARNING("How did the current SHEntry expire?");
     return NS_OK;
   }
 
   EvictContentViewerForTransaction(trans);
 
   return NS_OK;
 }
 
 // Evicts all content viewers in all history objects.  This is very
 // inefficient, because it requires a linear search through all SHistory
 // objects for each viewer to be evicted.  However, this method is called
 // infrequently -- only when the disk or memory cache is cleared.
 
-//static
+// static
 void
 nsSHistory::GloballyEvictAllContentViewers()
 {
   int32_t maxViewers = sHistoryMaxTotalViewers;
   sHistoryMaxTotalViewers = 0;
   GloballyEvictContentViewers();
   sHistoryMaxTotalViewers = maxViewers;
 }
 
-void GetDynamicChildren(nsISHContainer* aContainer,
-                        nsTArray<uint64_t>& aDocshellIDs,
-                        bool aOnlyTopLevelDynamic)
+void
+GetDynamicChildren(nsISHContainer* aContainer,
+                   nsTArray<uint64_t>& aDocshellIDs,
+                   bool aOnlyTopLevelDynamic)
 {
   int32_t count = 0;
   aContainer->GetChildCount(&count);
   for (int32_t i = 0; i < count; ++i) {
     nsCOMPtr<nsISHEntry> child;
     aContainer->GetChildAt(i, getter_AddRefs(child));
     if (child) {
       bool dynAdded = false;
@@ -1272,26 +1260,28 @@ RemoveFromSessionHistoryContainer(nsISHC
           }
         }
       }
     }
   }
   return didRemove;
 }
 
-bool RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
-                          nsTArray<uint64_t>& aEntryIDs)
+bool
+RemoveChildEntries(nsISHistory* aHistory, int32_t aIndex,
+                   nsTArray<uint64_t>& aEntryIDs)
 {
   nsCOMPtr<nsISHEntry> rootHE;
   aHistory->GetEntryAtIndex(aIndex, false, getter_AddRefs(rootHE));
   nsCOMPtr<nsISHContainer> root = do_QueryInterface(rootHE);
   return root ? RemoveFromSessionHistoryContainer(root, aEntryIDs) : false;
 }
 
-bool IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
+bool
+IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2)
 {
   if (!aEntry1 && !aEntry2) {
     return true;
   }
   if ((!aEntry1 && aEntry2) || (aEntry1 && !aEntry2)) {
     return false;
   }
   uint32_t id1, id2;
@@ -1311,17 +1301,17 @@ bool IsSameTree(nsISHEntry* aEntry1, nsI
   for (int32_t i = 0; i < count; ++i) {
     nsCOMPtr<nsISHEntry> child1, child2;
     container1->GetChildAt(i, getter_AddRefs(child1));
     container2->GetChildAt(i, getter_AddRefs(child2));
     if (!IsSameTree(child1, child2)) {
       return false;
     }
   }
-  
+
   return true;
 }
 
 bool
 nsSHistory::RemoveDuplicate(int32_t aIndex, bool aKeepNext)
 {
   NS_ASSERTION(aIndex >= 0, "aIndex must be >= 0!");
   NS_ASSERTION(aIndex != 0 || aKeepNext,
@@ -1386,21 +1376,23 @@ nsSHistory::RemoveDuplicate(int32_t aInd
   }
   return false;
 }
 
 NS_IMETHODIMP_(void)
 nsSHistory::RemoveEntries(nsTArray<uint64_t>& aIDs, int32_t aStartIndex)
 {
   int32_t index = aStartIndex;
-  while(index >= 0 && RemoveChildEntries(this, --index, aIDs));
+  while (index >= 0 && RemoveChildEntries(this, --index, aIDs)) {
+  }
   int32_t minIndex = index;
   index = aStartIndex;
-  while(index >= 0 && RemoveChildEntries(this, index++, aIDs));
-  
+  while (index >= 0 && RemoveChildEntries(this, index++, aIDs)) {
+  }
+
   // We need to remove duplicate nsSHEntry trees.
   bool didRemove = false;
   while (index > minIndex) {
     if (index != mIndex) {
       didRemove = RemoveDuplicate(index, index < mIndex) || didRemove;
     }
     --index;
   }
@@ -1442,73 +1434,70 @@ nsSHistory::RemoveDynEntries(int32_t aOl
   if (toBeRemovedEntries.Length()) {
     RemoveEntries(toBeRemovedEntries, aOldIndex);
   }
 }
 
 NS_IMETHODIMP
 nsSHistory::UpdateIndex()
 {
-  // Update the actual index with the right value. 
+  // Update the actual index with the right value.
   if (mIndex != mRequestedIndex && mRequestedIndex != -1) {
     RemoveDynEntries(mIndex, mRequestedIndex);
     mIndex = mRequestedIndex;
   }
 
   mRequestedIndex = -1;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::Stop(uint32_t aStopFlags)
 {
-  //Not implemented
+  // Not implemented
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
 nsSHistory::GetDocument(nsIDOMDocument** aDocument)
 {
   // Not implemented
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
 nsSHistory::GetCurrentURI(nsIURI** aResultURI)
 {
   NS_ENSURE_ARG_POINTER(aResultURI);
   nsresult rv;
 
   nsCOMPtr<nsISHEntry> currentEntry;
   rv = GetEntryAtIndex(mIndex, false, getter_AddRefs(currentEntry));
-  if (NS_FAILED(rv) && !currentEntry) return rv;
+  if (NS_FAILED(rv) && !currentEntry) {
+    return rv;
+  }
   rv = currentEntry->GetURI(aResultURI);
   return rv;
 }
 
-
 NS_IMETHODIMP
 nsSHistory::GetReferringURI(nsIURI** aURI)
 {
   *aURI = nullptr;
   // Not implemented
   return NS_OK;
 }
 
-
 NS_IMETHODIMP
 nsSHistory::SetSessionHistory(nsISHistory* aSessionHistory)
 {
   // Not implemented
   return NS_OK;
 }
 
-	
 NS_IMETHODIMP
 nsSHistory::GetSessionHistory(nsISHistory** aSessionHistory)
 {
   // Not implemented
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -1531,21 +1520,23 @@ nsSHistory::LoadURI(const char16_t* aURI
                     nsIInputStream* aExtraHeaderStream)
 {
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GotoIndex(int32_t aIndex)
 {
-  return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory, HIST_CMD_GOTOINDEX);
+  return LoadEntry(aIndex, nsIDocShellLoadInfo::loadHistory,
+                   HIST_CMD_GOTOINDEX);
 }
 
 nsresult
-nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd)
+nsSHistory::LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
+                                  uint32_t aHistCmd)
 {
   mRequestedIndex = -1;
   if (aNewIndex < mIndex) {
     return LoadEntry(aNewIndex - 1, aLoadType, aHistCmd);
   }
   if (aNewIndex > mIndex) {
     return LoadEntry(aNewIndex + 1, aLoadType, aHistCmd);
   }
@@ -1592,52 +1583,52 @@ nsSHistory::LoadEntry(int32_t aIndex, lo
                                 (nextURI, &canNavigate));
   } else if (aHistCmd == HIST_CMD_GOTOINDEX) {
     // We are going somewhere else. This is not reload either
     NOTIFY_LISTENERS_CANCELABLE(OnHistoryGotoIndex, canNavigate,
                                 (aIndex, nextURI, &canNavigate));
   }
 
   if (!canNavigate) {
-    // If the listener asked us not to proceed with 
-    // the operation, simply return.    
+    // If the listener asked us not to proceed with
+    // the operation, simply return.
     mRequestedIndex = -1;
     return NS_OK;  // XXX Maybe I can return some other error code?
   }
 
   nsCOMPtr<nsIURI> nexturi;
-  int32_t pCount=0, nCount=0;
+  int32_t pCount = 0;
+  int32_t nCount = 0;
   nsCOMPtr<nsISHContainer> prevAsContainer(do_QueryInterface(prevEntry));
   nsCOMPtr<nsISHContainer> nextAsContainer(do_QueryInterface(nextEntry));
   if (prevAsContainer && nextAsContainer) {
     prevAsContainer->GetChildCount(&pCount);
     nextAsContainer->GetChildCount(&nCount);
   }
-  
+
   nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
   if (mRequestedIndex == mIndex) {
-    // Possibly a reload case 
+    // Possibly a reload case
     docShell = mRootDocShell;
-  }
-  else {
+  } else {
     // Going back or forward.
-    if ((pCount > 0) && (nCount > 0)) {
-      /* THis is a subframe navigation. Go find 
+    if (pCount > 0 && nCount > 0) {
+      /* THis is a subframe navigation. Go find
        * the docshell in which load should happen
        */
       bool frameFound = false;
-      nsresult rv = CompareFrames(prevEntry, nextEntry, mRootDocShell, aLoadType, &frameFound);
+      nsresult rv = CompareFrames(prevEntry, nextEntry, mRootDocShell,
+                                  aLoadType, &frameFound);
       if (!frameFound) {
         // We did not successfully find the subframe in which
         // the new url was to be loaded. Go further in the history.
         return LoadNextPossibleEntry(aIndex, aLoadType, aHistCmd);
       }
       return rv;
-    }   // (pCount >0)
-    else {
+    } else {
       // Loading top level page.
       uint32_t prevID = 0;
       uint32_t nextID = 0;
       prevEntry->GetID(&prevID);
       nextEntry->GetID(&nextID);
       if (prevID == nextID) {
         // Try harder to find something new to load.
         // This may happen for example if some page removed iframes dynamically.
@@ -1654,55 +1645,60 @@ nsSHistory::LoadEntry(int32_t aIndex, lo
     return NS_ERROR_FAILURE;
   }
 
   // Start the load on the appropriate docshell
   return InitiateLoad(nextEntry, docShell, aLoadType);
 }
 
 nsresult
-nsSHistory::CompareFrames(nsISHEntry * aPrevEntry, nsISHEntry * aNextEntry, nsIDocShell * aParent, long aLoadType, bool * aIsFrameFound)
+nsSHistory::CompareFrames(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
+                          nsIDocShell* aParent, long aLoadType,
+                          bool* aIsFrameFound)
 {
-  if (!aPrevEntry || !aNextEntry || !aParent)
+  if (!aPrevEntry || !aNextEntry || !aParent) {
     return NS_ERROR_FAILURE;
+  }
 
   // We should be comparing only entries which were created for the
   // same docshell. This is here to just prevent anything strange happening.
   // This check could be possibly an assertion.
   uint64_t prevdID, nextdID;
   aPrevEntry->GetDocshellID(&prevdID);
   aNextEntry->GetDocshellID(&nextdID);
   NS_ENSURE_STATE(prevdID == nextdID);
 
   nsresult result = NS_OK;
   uint32_t prevID, nextID;
 
   aPrevEntry->GetID(&prevID);
   aNextEntry->GetID(&nextID);
- 
+
   // Check the IDs to verify if the pages are different.
   if (prevID != nextID) {
-    if (aIsFrameFound)
+    if (aIsFrameFound) {
       *aIsFrameFound = true;
+    }
     // Set the Subframe flag of the entry to indicate that
-    // it is subframe navigation        
+    // it is subframe navigation
     aNextEntry->SetIsSubFrame(true);
     InitiateLoad(aNextEntry, aParent, aLoadType);
     return NS_OK;
   }
 
-  /* The root entries are the same, so compare any child frames */
-  int32_t pcnt=0, ncnt=0, dsCount=0;
-  nsCOMPtr<nsISHContainer>  prevContainer(do_QueryInterface(aPrevEntry));
-  nsCOMPtr<nsISHContainer>  nextContainer(do_QueryInterface(aNextEntry));
+  // The root entries are the same, so compare any child frames
+  int32_t pcnt = 0;
+  int32_t ncnt = 0;
+  int32_t dsCount = 0;
+  nsCOMPtr<nsISHContainer> prevContainer(do_QueryInterface(aPrevEntry));
+  nsCOMPtr<nsISHContainer> nextContainer(do_QueryInterface(aNextEntry));
 
-  if (!aParent)
+  if (!aParent || !prevContainer || !nextContainer) {
     return NS_ERROR_FAILURE;
-  if (!prevContainer || !nextContainer)
-    return NS_ERROR_FAILURE;
+  }
 
   prevContainer->GetChildCount(&pcnt);
   nextContainer->GetChildCount(&ncnt);
   aParent->GetChildCount(&dsCount);
 
   // Create an array for child docshells.
   nsCOMArray<nsIDocShell> docshells;
   for (int32_t i = 0; i < dsCount; ++i) {
@@ -1756,100 +1752,96 @@ nsSHistory::CompareFrames(nsISHEntry * a
         }
       }
     }
 
     // Finally recursively call this method.
     // This will either load a new page to shell or some subshell or
     // do nothing.
     CompareFrames(pChild, nChild, dsChild, aLoadType, aIsFrameFound);
-  }     
+  }
   return result;
 }
 
-
-nsresult 
-nsSHistory::InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType)
+nsresult
+nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
+                         long aLoadType)
 {
   NS_ENSURE_STATE(aFrameDS && aFrameEntry);
 
   nsCOMPtr<nsIDocShellLoadInfo> loadInfo;
 
   /* 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));
+  aFrameEntry->SetLoadType(aLoadType);
+  aFrameDS->CreateLoadInfo(getter_AddRefs(loadInfo));
 
   loadInfo->SetLoadType(aLoadType);
   loadInfo->SetSHEntry(aFrameEntry);
 
   nsCOMPtr<nsIURI> nextURI;
   aFrameEntry->GetURI(getter_AddRefs(nextURI));
   // Time   to initiate a document load
-  return aFrameDS->LoadURI(nextURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, false);
+  return aFrameDS->LoadURI(nextURI, loadInfo,
+                           nsIWebNavigation::LOAD_FLAGS_NONE, false);
 
 }
 
 NS_IMETHODIMP
-nsSHistory::SetRootDocShell(nsIDocShell * aDocShell)
+nsSHistory::SetRootDocShell(nsIDocShell* aDocShell)
 {
   mRootDocShell = aDocShell;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::GetSHistoryEnumerator(nsISimpleEnumerator** aEnumerator)
 {
   NS_ENSURE_ARG_POINTER(aEnumerator);
   nsRefPtr<nsSHEnumerator> iterator = new nsSHEnumerator(this);
   iterator.forget(aEnumerator);
   return NS_OK;
 }
 
-
-//*****************************************************************************
-//***    nsSHEnumerator: Object Management
-//*****************************************************************************
-
-nsSHEnumerator::nsSHEnumerator(nsSHistory * aSHistory):mIndex(-1)
+nsSHEnumerator::nsSHEnumerator(nsSHistory* aSHistory) : mIndex(-1)
 {
   mSHistory = aSHistory;
 }
 
 nsSHEnumerator::~nsSHEnumerator()
 {
   mSHistory = nullptr;
 }
 
 NS_IMPL_ISUPPORTS(nsSHEnumerator, nsISimpleEnumerator)
 
 NS_IMETHODIMP
-nsSHEnumerator::HasMoreElements(bool * aReturn)
+nsSHEnumerator::HasMoreElements(bool* aReturn)
 {
   int32_t cnt;
   *aReturn = false;
   mSHistory->GetCount(&cnt);
-  if (mIndex >= -1 && mIndex < (cnt-1) ) { 
+  if (mIndex >= -1 && mIndex < (cnt - 1)) {
     *aReturn = true;
   }
   return NS_OK;
 }
 
-
-NS_IMETHODIMP 
-nsSHEnumerator::GetNext(nsISupports **aItem)
+NS_IMETHODIMP
+nsSHEnumerator::GetNext(nsISupports** aItem)
 {
   NS_ENSURE_ARG_POINTER(aItem);
-  int32_t cnt= 0;
+  int32_t cnt = 0;
 
-  nsresult  result = NS_ERROR_FAILURE;
+  nsresult result = NS_ERROR_FAILURE;
   mSHistory->GetCount(&cnt);
-  if (mIndex < (cnt-1)) {
+  if (mIndex < (cnt - 1)) {
     mIndex++;
     nsCOMPtr<nsISHEntry> hEntry;
     result = mSHistory->GetEntryAtIndex(mIndex, false, getter_AddRefs(hEntry));
-    if (hEntry)
+    if (hEntry) {
       result = CallQueryInterface(hEntry, aItem);
+    }
   }
   return result;
 }
--- a/docshell/shistory/src/nsSHistory.h
+++ b/docshell/shistory/src/nsSHistory.h
@@ -2,44 +2,39 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 #ifndef nsSHistory_h
 #define nsSHistory_h
 
-// Helper Classes
 #include "nsCOMPtr.h"
-
-//Interfaces Needed
 #include "nsISHistory.h"
 #include "nsISHistoryInternal.h"
 #include "nsIWebNavigation.h"
 #include "nsISimpleEnumerator.h"
 #include "nsTObserverArray.h"
 #include "nsWeakPtr.h"
 
-// Needed to maintain global list of all SHistory objects
 #include "prclist.h"
 
 class nsIDocShell;
 class nsSHEnumerator;
 class nsSHistoryObserver;
 class nsISHEntry;
 class nsISHTransaction;
 
 class nsSHistory final : public PRCList,
                          public nsISHistory,
                          public nsISHistoryInternal,
                          public nsIWebNavigation
 {
 public:
   nsSHistory();
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHISTORY
   NS_DECL_NSISHISTORYINTERNAL
   NS_DECL_NSIWEBNAVIGATION
 
   // One time initialization method called upon docshell module construction
   static nsresult Startup();
   static void Shutdown();
@@ -51,71 +46,74 @@ public:
   // Otherwise, it comes straight from the pref.
   static uint32_t GetMaxTotalViewers() { return sHistoryMaxTotalViewers; }
 
 protected:
   virtual ~nsSHistory();
   friend class nsSHEnumerator;
   friend class nsSHistoryObserver;
 
-   // Could become part of nsIWebNavigation
-   NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction ** aResult);
-   nsresult CompareFrames(nsISHEntry * prevEntry, nsISHEntry * nextEntry, nsIDocShell * rootDocShell, long aLoadType, bool * aIsFrameFound);
-   nsresult InitiateLoad(nsISHEntry * aFrameEntry, nsIDocShell * aFrameDS, long aLoadType);
+  // Could become part of nsIWebNavigation
+  NS_IMETHOD GetTransactionAtIndex(int32_t aIndex, nsISHTransaction** aResult);
+  nsresult CompareFrames(nsISHEntry* aPrevEntry, nsISHEntry* aNextEntry,
+                         nsIDocShell* aRootDocShell, long aLoadType,
+                         bool* aIsFrameFound);
+  nsresult InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
+                        long aLoadType);
 
-   NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t histCmd);
+  NS_IMETHOD LoadEntry(int32_t aIndex, long aLoadType, uint32_t aHistCmd);
 
 #ifdef DEBUG
-   nsresult PrintHistory();
+  nsresult PrintHistory();
 #endif
 
   // Evict content viewers in this window which don't lie in the "safe" range
   // around aIndex.
   void EvictOutOfRangeWindowContentViewers(int32_t aIndex);
   static void GloballyEvictContentViewers();
   static void GloballyEvictAllContentViewers();
 
   // Calculates a max number of total
   // content viewers to cache, based on amount of total memory
   static uint32_t CalcMaxTotalViewers();
 
   void RemoveDynEntries(int32_t aOldIndex, int32_t aNewIndex);
 
-  nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType, uint32_t aHistCmd);
+  nsresult LoadNextPossibleEntry(int32_t aNewIndex, long aLoadType,
+                                 uint32_t aHistCmd);
+
 protected:
   // aIndex is the index of the transaction which may be removed.
   // If aKeepNext is true, aIndex is compared to aIndex + 1,
   // otherwise comparison is done to aIndex - 1.
   bool RemoveDuplicate(int32_t aIndex, bool aKeepNext);
 
   nsCOMPtr<nsISHTransaction> mListRoot;
   int32_t mIndex;
   int32_t mLength;
   int32_t mRequestedIndex;
   // Session History listeners
   nsAutoTObserverArray<nsWeakPtr, 2> mListeners;
   // Weak reference. Do not refcount this.
-  nsIDocShell *  mRootDocShell;
+  nsIDocShell* mRootDocShell;
 
   // Max viewers allowed total, across all SHistory objects
-  static int32_t  sHistoryMaxTotalViewers;
+  static int32_t sHistoryMaxTotalViewers;
 };
-//*****************************************************************************
-//***    nsSHEnumerator: Object Management
-//*****************************************************************************
+
 class nsSHEnumerator : public nsISimpleEnumerator
 {
 public:
-
   NS_DECL_ISUPPORTS
   NS_DECL_NSISIMPLEENUMERATOR
 
-  explicit nsSHEnumerator(nsSHistory *  aHistory);
-  
+  explicit nsSHEnumerator(nsSHistory* aHistory);
+
 protected:
   friend class nsSHistory;
   virtual ~nsSHEnumerator();
+
 private:
-  int32_t     mIndex;
-  nsSHistory *  mSHistory;  
+  int32_t mIndex;
+  nsSHistory* mSHistory;
 };
 
-#endif   /* nsSHistory */
+#endif /* nsSHistory */