Bug 1347823 - Part 1: Reorder includes and data members. r?smaug draft
authorSamael Wang <freesamael@gmail.com>
Thu, 27 Apr 2017 18:16:46 +0800
changeset 570048 039e51cd9e59fe4e37f65beef631c6ccd9b80da3
parent 566789 8e969cc9aff49f845678cba5b35d9dd8aa340f16
child 570049 18fcf19f48a5c4f6aaf91bdf8d7f7daf394ec217
child 570084 f6aaccd17e45d649cc3898cdc335fc3c692228b0
child 571856 56a5e0d1dd0075a5d95431611f2f7601a462704d
push id56370
push userbmo:sawang@mozilla.com
push dateFri, 28 Apr 2017 09:08:18 +0000
reviewerssmaug
bugs1347823
milestone55.0a1
Bug 1347823 - Part 1: Reorder includes and data members. r?smaug Re-order includes to meet gecko's coding style, and move bool data members to the bottom for slightly better alignment (nsSHEntry down from 192->176, nsSHEntryShared down from 208->200 on a Linux64 build). MozReview-Commit-ID: CG1M6Hh39uI
docshell/shistory/nsSHEntry.cpp
docshell/shistory/nsSHEntry.h
docshell/shistory/nsSHEntryShared.cpp
docshell/shistory/nsSHEntryShared.h
docshell/shistory/nsSHTransaction.cpp
docshell/shistory/nsSHTransaction.h
docshell/shistory/nsSHistory.cpp
docshell/shistory/nsSHistory.h
--- a/docshell/shistory/nsSHEntry.cpp
+++ b/docshell/shistory/nsSHEntry.cpp
@@ -1,66 +1,70 @@
 /* -*- 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/. */
 
 #include "nsSHEntry.h"
+
+#include <algorithm>
+
+#include "nsDocShellEditorData.h"
+#include "nsIContentViewer.h"
 #include "nsIDocShellLoadInfo.h"
 #include "nsIDocShellTreeItem.h"
-#include "nsDocShellEditorData.h"
-#include "nsSHEntryShared.h"
+#include "nsIInputStream.h"
 #include "nsILayoutHistoryState.h"
-#include "nsIContentViewer.h"
 #include "nsIStructuredCloneContainer.h"
-#include "nsIInputStream.h"
 #include "nsIURI.h"
+#include "nsSHEntryShared.h"
+#include "nsSHistory.h"
+
 #include "mozilla/net/ReferrerPolicy.h"
-#include <algorithm>
 
 namespace dom = mozilla::dom;
 
 static uint32_t gEntryID = 0;
 
 nsSHEntry::nsSHEntry()
   : mShared(new nsSHEntryShared())
-  , mLoadReplace(false)
   , mReferrerPolicy(mozilla::net::RP_Unset)
   , mLoadType(0)
   , mID(gEntryID++)
   , mScrollPositionX(0)
   , mScrollPositionY(0)
   , mParent(nullptr)
+  , mLoadReplace(false)
   , mURIWasModified(false)
   , mIsSrcdocEntry(false)
   , mScrollRestorationIsManual(false)
 {
 }
 
 nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
   : mShared(aOther.mShared)
   , mURI(aOther.mURI)
   , mOriginalURI(aOther.mOriginalURI)
-  , mLoadReplace(aOther.mLoadReplace)
   , mReferrerURI(aOther.mReferrerURI)
   , mReferrerPolicy(aOther.mReferrerPolicy)
   , mTitle(aOther.mTitle)
   , mPostData(aOther.mPostData)
   , mLoadType(0)         // XXX why not copy?
   , mID(aOther.mID)
   , mScrollPositionX(0)  // XXX why not copy?
   , mScrollPositionY(0)  // XXX why not copy?
   , mParent(aOther.mParent)
+  , mStateData(aOther.mStateData)
+  , mSrcdocData(aOther.mSrcdocData)
+  , mBaseURI(aOther.mBaseURI)
+  , mLoadReplace(aOther.mLoadReplace)
   , mURIWasModified(aOther.mURIWasModified)
-  , mStateData(aOther.mStateData)
   , mIsSrcdocEntry(aOther.mIsSrcdocEntry)
   , mScrollRestorationIsManual(false)
-  , mSrcdocData(aOther.mSrcdocData)
-  , mBaseURI(aOther.mBaseURI)
 {
 }
 
 nsSHEntry::~nsSHEntry()
 {
   // Null out the mParent pointers on all our kids.
   for (nsISHEntry* entry : mChildren) {
     if (entry) {
--- a/docshell/shistory/nsSHEntry.h
+++ b/docshell/shistory/nsSHEntry.h
@@ -2,26 +2,24 @@
 /* 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/. */
 
 #ifndef nsSHEntry_h
 #define nsSHEntry_h
 
-// Helper Classes
+#include "nsCOMArray.h"
 #include "nsCOMPtr.h"
-#include "nsCOMArray.h"
+#include "nsISHContainer.h"
+#include "nsISHEntry.h"
 #include "nsString.h"
+
 #include "mozilla/Attributes.h"
 
-// Interfaces needed
-#include "nsISHEntry.h"
-#include "nsISHContainer.h"
-
 class nsSHEntryShared;
 class nsIInputStream;
 class nsIURI;
 
 class nsSHEntry final : public nsISHEntry,
                         public nsISHContainer,
                         public nsISHEntryInternal
 {
@@ -44,28 +42,28 @@ private:
 
   // We share the state in here with other SHEntries which correspond to the
   // same document.
   RefPtr<nsSHEntryShared> mShared;
 
   // See nsSHEntry.idl for comments on these members.
   nsCOMPtr<nsIURI> mURI;
   nsCOMPtr<nsIURI> mOriginalURI;
-  bool mLoadReplace;
   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;
+  nsCOMPtr<nsIStructuredCloneContainer> mStateData;
+  nsString mSrcdocData;
+  nsCOMPtr<nsIURI> mBaseURI;
+  bool mLoadReplace;
   bool mURIWasModified;
-  nsCOMPtr<nsIStructuredCloneContainer> mStateData;
   bool mIsSrcdocEntry;
   bool mScrollRestorationIsManual;
-  nsString mSrcdocData;
-  nsCOMPtr<nsIURI> mBaseURI;
 };
 
 #endif /* nsSHEntry_h */
--- a/docshell/shistory/nsSHEntryShared.cpp
+++ b/docshell/shistory/nsSHEntryShared.cpp
@@ -1,30 +1,31 @@
 /* -*- 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/. */
 
 #include "nsSHEntryShared.h"
 
-#include "nsIDOMDocument.h"
-#include "nsISHistory.h"
-#include "nsISHistoryInternal.h"
-#include "nsIDocument.h"
-#include "nsIWebNavigation.h"
+#include "nsArray.h"
+#include "nsDocShellEditorData.h"
 #include "nsIContentViewer.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
-#include "nsDocShellEditorData.h"
+#include "nsIDocument.h"
+#include "nsIDOMDocument.h"
+#include "nsILayoutHistoryState.h"
+#include "nsISHistory.h"
+#include "nsISHistoryInternal.h"
+#include "nsIWebNavigation.h"
 #include "nsThreadUtils.h"
-#include "nsILayoutHistoryState.h"
+
 #include "mozilla/Attributes.h"
 #include "mozilla/Preferences.h"
-#include "nsArray.h"
 
 namespace dom = mozilla::dom;
 
 namespace {
 
 uint64_t gSHEntrySharedID = 0;
 
 } // namespace
@@ -68,24 +69,24 @@ void
 nsSHEntryShared::Shutdown()
 {
   delete gHistoryTracker;
   gHistoryTracker = nullptr;
 }
 
 nsSHEntryShared::nsSHEntryShared()
   : mDocShellID({0})
+  , mLastTouched(0)
+  , mID(gSHEntrySharedID++)
+  , mViewerBounds(0, 0, 0, 0)
   , mIsFrameNavigation(false)
   , mSaveLayoutState(true)
   , mSticky(true)
   , mDynamicallyCreated(false)
-  , mLastTouched(0)
-  , mID(gSHEntrySharedID++)
   , mExpired(false)
-  , mViewerBounds(0, 0, 0, 0)
 {
 }
 
 nsSHEntryShared::~nsSHEntryShared()
 {
   RemoveFromExpirationTracker();
 
 #ifdef DEBUG
--- a/docshell/shistory/nsSHEntryShared.h
+++ b/docshell/shistory/nsSHEntryShared.h
@@ -2,24 +2,25 @@
 /* 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/. */
 
 #ifndef nsSHEntryShared_h__
 #define nsSHEntryShared_h__
 
-#include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
+#include "nsCOMPtr.h"
+#include "nsExpirationTracker.h"
 #include "nsIBFCacheEntry.h"
 #include "nsIMutationObserver.h"
-#include "nsExpirationTracker.h"
 #include "nsRect.h"
 #include "nsString.h"
+
 #include "mozilla/Attributes.h"
 
 class nsSHEntry;
 class nsISHEntry;
 class nsIDocument;
 class nsIContentViewer;
 class nsIDocShellTreeItem;
 class nsILayoutHistoryState;
@@ -68,30 +69,32 @@ private:
 
   // These members are copied by nsSHEntryShared::Duplicate().  If you add a
   // member here, be sure to update the Duplicate() implementation.
   nsID mDocShellID;
   nsCOMArray<nsIDocShellTreeItem> mChildShells;
   nsCOMPtr<nsIPrincipal> mTriggeringPrincipal;
   nsCOMPtr<nsIPrincipal> mPrincipalToInherit;
   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<nsIMutableArray> mRefreshURIList;
   nsExpirationState mExpirationState;
   nsAutoPtr<nsDocShellEditorData> mEditorData;
+
+  bool mIsFrameNavigation;
+  bool mSaveLayoutState;
+  bool mSticky;
+  bool mDynamicallyCreated;
+  bool mExpired;
 };
 
 #endif
--- a/docshell/shistory/nsSHTransaction.cpp
+++ b/docshell/shistory/nsSHTransaction.cpp
@@ -3,18 +3,18 @@
 /* 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/. */
 
 #include "nsSHTransaction.h"
 #include "nsISHEntry.h"
 
 nsSHTransaction::nsSHTransaction()
-  : mPersist(true)
-  , mPrev(nullptr)
+  : mPrev(nullptr)
+  , mPersist(true)
 {
 }
 
 nsSHTransaction::~nsSHTransaction()
 {
 }
 
 NS_IMPL_ADDREF(nsSHTransaction)
--- a/docshell/shistory/nsSHTransaction.h
+++ b/docshell/shistory/nsSHTransaction.h
@@ -2,36 +2,32 @@
 /* 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/. */
 
 #ifndef nsSHTransaction_h
 #define nsSHTransaction_h
 
-// Helper Classes
 #include "nsCOMPtr.h"
-
-// Needed interfaces
 #include "nsISHTransaction.h"
 
 class nsISHEntry;
 
 class nsSHTransaction : public nsISHTransaction
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSISHTRANSACTION
 
   nsSHTransaction();
 
 protected:
   virtual ~nsSHTransaction();
 
 protected:
-  bool mPersist;
-
   nsISHTransaction* mPrev;  // Weak Reference
   nsCOMPtr<nsISHTransaction> mNext;
   nsCOMPtr<nsISHEntry> mSHEntry;
+  bool mPersist;
 };
 
 #endif /* nsSHTransaction_h */
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -1,45 +1,42 @@
 /* -*- 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/. */
 
 #include "nsSHistory.h"
+
 #include <algorithm>
 
-// Helper Classes
-#include "mozilla/Preferences.h"
-#include "mozilla/StaticPtr.h"
-
-// Interfaces Needed
-#include "nsILayoutHistoryState.h"
+#include "nsCOMArray.h"
+#include "nsComponentManagerUtils.h"
+#include "nsDocShell.h"
+#include "nsIContentViewer.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellLoadInfo.h"
-#include "nsISHContainer.h"
 #include "nsIDocShellTreeItem.h"
-#include "nsIURI.h"
-#include "nsIContentViewer.h"
+#include "nsILayoutHistoryState.h"
 #include "nsIObserverService.h"
-#include "mozilla/Services.h"
+#include "nsISHContainer.h"
+#include "nsISHEntry.h"
+#include "nsISHistoryListener.h"
+#include "nsISHTransaction.h"
+#include "nsIURI.h"
+#include "nsNetUtil.h"
 #include "nsTArray.h"
-#include "nsCOMArray.h"
-#include "nsDocShell.h"
+#include "prsystem.h"
+
 #include "mozilla/Attributes.h"
 #include "mozilla/LinkedList.h"
-#include "nsISHEntry.h"
-#include "nsISHTransaction.h"
-#include "nsISHistoryListener.h"
-#include "nsComponentManagerUtils.h"
-#include "nsNetUtil.h"
-
-// For calculating max history entries and max cachable contentviewers
-#include "prsystem.h"
 #include "mozilla/MathAlgorithms.h"
+#include "mozilla/Preferences.h"
+#include "mozilla/Services.h"
+#include "mozilla/StaticPtr.h"
 
 using namespace mozilla;
 
 #define PREF_SHISTORY_SIZE "browser.sessionhistory.max_entries"
 #define PREF_SHISTORY_MAX_TOTAL_VIEWERS "browser.sessionhistory.max_total_viewers"
 
 static const char* kObservedPrefs[] = {
   PREF_SHISTORY_SIZE,
@@ -228,20 +225,20 @@ nsSHistory::EvictContentViewerForTransac
     RemoveDynEntries(index, container);
   }
 }
 
 nsSHistory::nsSHistory()
   : mIndex(-1)
   , mLength(0)
   , mRequestedIndex(-1)
-  , mIsPartial(false)
   , mGlobalIndexOffset(0)
   , mEntriesInFollowingPartialHistories(0)
   , mRootDocShell(nullptr)
+  , mIsPartial(false)
 {
   // Add this new SHistory object to the list
   gSHistoryList.insertBack(this);
 }
 
 nsSHistory::~nsSHistory()
 {
 }
--- a/docshell/shistory/nsSHistory.h
+++ b/docshell/shistory/nsSHistory.h
@@ -3,23 +3,25 @@
 /* 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
 
 #include "nsCOMPtr.h"
+#include "nsExpirationTracker.h"
+#include "nsIPartialSHistoryListener.h"
 #include "nsISHistory.h"
 #include "nsISHistoryInternal.h"
+#include "nsISimpleEnumerator.h"
 #include "nsIWebNavigation.h"
-#include "nsISimpleEnumerator.h"
+#include "nsSHEntryShared.h"
 #include "nsTObserverArray.h"
 #include "nsWeakPtr.h"
-#include "nsIPartialSHistoryListener.h"
 
 #include "mozilla/LinkedList.h"
 
 class nsIDocShell;
 class nsSHEnumerator;
 class nsSHistoryObserver;
 class nsISHEntry;
 class nsISHTransaction;
@@ -85,34 +87,34 @@ private:
   // 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;
 
-  // Set to true if attached to a grouped session history.
-  bool mIsPartial;
-
   // The number of entries before this session history object.
   int32_t mGlobalIndexOffset;
 
   // The number of entries after this session history object.
   int32_t mEntriesInFollowingPartialHistories;
 
   // Session History listeners
   nsAutoTObserverArray<nsWeakPtr, 2> mListeners;
 
   // Partial session history listener
   nsWeakPtr mPartialHistoryListener;
 
   // Weak reference. Do not refcount this.
   nsIDocShell* mRootDocShell;
 
+  // Set to true if attached to a grouped session history.
+  bool mIsPartial;
+
   // Max viewers allowed total, across all SHistory objects
   static int32_t sHistoryMaxTotalViewers;
 };
 
 class nsSHEnumerator : public nsISimpleEnumerator
 {
 public:
   NS_DECL_ISUPPORTS