Bug 841261: Use init list instead of assignment in nsFrameIterator constructor. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 18 Feb 2013 08:59:55 -0800
changeset 122245 4e92ba60695d675be9c797a5cb1dabd109bf2820
parent 122244 5dec45f30b77f60ac6415b26c6aaa57b0e14f547
child 122246 ae60b8d343e5e23888d1ee4b35ad18f18f132416
push id24327
push usergszorc@mozilla.com
push dateTue, 19 Feb 2013 05:22:32 +0000
treeherdermozilla-central@e8f8a3f6f1f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs841261
milestone21.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 841261: Use init list instead of assignment in nsFrameIterator constructor. r=mats
layout/base/nsFrameTraversal.cpp
--- a/layout/base/nsFrameTraversal.cpp
+++ b/layout/base/nsFrameTraversal.cpp
@@ -28,23 +28,21 @@ public:
   virtual void Prev();
 
   nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
                   nsIteratorType aType, bool aLockScroll, bool aFollowOOFs);
 
 protected:
   void      setCurrent(nsIFrame *aFrame){mCurrent = aFrame;}
   nsIFrame *getCurrent(){return mCurrent;}
-  void      setStart(nsIFrame *aFrame){mStart = aFrame;}
   nsIFrame *getStart(){return mStart;}
   nsIFrame *getLast(){return mLast;}
   void      setLast(nsIFrame *aFrame){mLast = aFrame;}
   int8_t    getOffEdge(){return mOffEdge;}
   void      setOffEdge(int8_t aOffEdge){mOffEdge = aOffEdge;}
-  void      SetLockInScrollView(bool aLockScroll){mLockScroll = aLockScroll;}
 
   /*
    Our own versions of the standard frame tree navigation
    methods, which, if the iterator is following out-of-flows,
    apply the following rules for placeholder frames:
    
    - If a frame HAS a placeholder frame, getting its parent
    gets the placeholder's parent.
@@ -80,25 +78,25 @@ protected:
   virtual nsIFrame* GetLastChildInner(nsIFrame* aFrame);  
 
   virtual nsIFrame* GetNextSiblingInner(nsIFrame* aFrame);
   virtual nsIFrame* GetPrevSiblingInner(nsIFrame* aFrame);
 
   nsIFrame* GetPlaceholderFrame(nsIFrame* aFrame);
   bool      IsPopupFrame(nsIFrame* aFrame);
 
-  nsPresContext* mPresContext;
-  bool mLockScroll;
-  bool mFollowOOFs;
-  nsIteratorType mType;
+  nsPresContext* const mPresContext;
+  const bool mLockScroll;
+  const bool mFollowOOFs;
+  const nsIteratorType mType;
 
 private:
-  nsIFrame *mStart;
-  nsIFrame *mCurrent;
-  nsIFrame *mLast; //the last one that was in current;
+  nsIFrame* const mStart;
+  nsIFrame* mCurrent;
+  nsIFrame* mLast; //the last one that was in current;
   int8_t    mOffEdge; //0= no -1 to far prev, 1 to far next;
 };
 
 
 
 // Bidi visual iterator
 class nsVisualIterator: public nsFrameIterator
 {
@@ -136,16 +134,21 @@ NS_NewFrameTraversal(nsIFrameEnumerator 
                      nsIFrame *aStart,
                      nsIteratorType aType,
                      bool aVisual,
                      bool aLockInScrollView,
                      bool aFollowOOFs)
 {
   if (!aEnumerator || !aStart)
     return NS_ERROR_NULL_POINTER;
+
+  if (aFollowOOFs) {
+    aStart = nsPlaceholderFrame::GetRealFrameFor(aStart);
+  }
+
   nsCOMPtr<nsIFrameEnumerator> trav;
   if (aVisual) {
     trav = new nsVisualIterator(aPresContext, aStart, aType,
                                 aLockInScrollView, aFollowOOFs);
   } else {
     trav = new nsFrameIterator(aPresContext, aStart, aType,
                                aLockInScrollView, aFollowOOFs);
   }
@@ -180,27 +183,27 @@ NS_IMETHODIMP
 
 // nsFrameIterator implementation
 
 NS_IMPL_ISUPPORTS1(nsFrameIterator, nsIFrameEnumerator)
 
 nsFrameIterator::nsFrameIterator(nsPresContext* aPresContext, nsIFrame *aStart,
                                  nsIteratorType aType, bool aLockInScrollView,
                                  bool aFollowOOFs)
+: mPresContext(aPresContext),
+  mLockScroll(aLockInScrollView),
+  mFollowOOFs(aFollowOOFs),
+  mType(aType),
+  mStart(aStart),
+  mCurrent(aStart),
+  mLast(aStart),
+  mOffEdge(0)
 {
-  mOffEdge = 0;
-  mPresContext = aPresContext;
-  if (aFollowOOFs && aStart)
-    aStart = nsPlaceholderFrame::GetRealFrameFor(aStart);
-  setStart(aStart);
-  setCurrent(aStart);
-  setLast(aStart);
-  mType = aType;
-  SetLockInScrollView(aLockInScrollView);
-  mFollowOOFs = aFollowOOFs;
+  MOZ_ASSERT(!aFollowOOFs || aStart->GetType() != nsGkAtoms::placeholderFrame,
+             "Caller should have resolved placeholder frame");
 }
 
 
 
 nsIFrame*
 nsFrameIterator::CurrentItem()
 {
   if (mOffEdge)