Bug 1050412 part 1: Use nsFrameList::Enumerator in nsSimplePageSequenceFrame to iterate over child frames. r=tn
authorDaniel Holbert <dholbert@cs.stanford.edu>
Thu, 07 Aug 2014 22:07:15 -0700
changeset 220118 b6c8125378142eecefa94120289c5e86c49561a2
parent 220117 dbd45a6fec49b7de087a0b84431025198157a6f8
child 220119 3ac1b309271d49155d34096478ed4f39cac045e2
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1050412
milestone34.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 1050412 part 1: Use nsFrameList::Enumerator in nsSimplePageSequenceFrame to iterate over child frames. r=tn
layout/generic/nsSimplePageSequenceFrame.cpp
--- a/layout/generic/nsSimplePageSequenceFrame.cpp
+++ b/layout/generic/nsSimplePageSequenceFrame.cpp
@@ -196,17 +196,18 @@ nsSimplePageSequenceFrame::Reflow(nsPres
   // We use the CSS "margin" property on the -moz-page pseudoelement
   // to determine the space between each page in print preview.
   // Keep a running y-offset for each page.
   nscoord y = 0;
   nscoord maxXMost = 0;
 
   // Tile the pages vertically
   nsHTMLReflowMetrics kidSize(aReflowState);
-  for (nsIFrame* kidFrame = mFrames.FirstChild(); nullptr != kidFrame; ) {
+  for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
+    nsIFrame* kidFrame = e.get();
     // Set the shared data into the page frame before reflow
     nsPageFrame * pf = static_cast<nsPageFrame*>(kidFrame);
     pf->SetSharedPageData(mPageData);
 
     // Reflow the page
     nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,
                                      LogicalSize(kidFrame->GetWritingMode(),
                                                  pageSize));
@@ -239,32 +240,27 @@ nsSimplePageSequenceFrame::Reflow(nsPres
       // The page isn't complete and it doesn't have a next-in-flow, so
       // create a continuing page.
       nsIFrame* continuingPage = aPresContext->PresShell()->FrameConstructor()->
         CreateContinuingFrame(aPresContext, kidFrame, this);
 
       // Add it to our child list
       mFrames.InsertFrame(nullptr, kidFrame, continuingPage);
     }
-
-    // Get the next page
-    kidFrame = kidFrame->GetNextSibling();
   }
 
   // Get Total Page Count
-  nsIFrame* page;
-  int32_t pageTot = 0;
-  for (page = mFrames.FirstChild(); page; page = page->GetNextSibling()) {
-    pageTot++;
-  }
+  // XXXdholbert technically we could calculate this in the loop above,
+  // instead of needing a separate walk.
+  int32_t pageTot = mFrames.GetLength();
 
   // Set Page Number Info
   int32_t pageNum = 1;
-  for (page = mFrames.FirstChild(); page; page = page->GetNextSibling()) {
-    nsPageFrame * pf = static_cast<nsPageFrame*>(page);
+  for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
+    nsPageFrame * pf = static_cast<nsPageFrame*>(e.get());
     if (pf != nullptr) {
       pf->SetPageNumInfo(pageNum, pageTot);
     }
     pageNum++;
   }
 
   // Create current Date/Time String
   if (!mDateFormatter) {
@@ -416,18 +412,18 @@ nsSimplePageSequenceFrame::StartPrint(ns
   if (mDoingPageRange) {
     // XXX because of the hack for making the selection all print on one page
     // we must make sure that the page is sized correctly before printing.
     nscoord height = aPresContext->GetPageSize().height;
 
     int32_t pageNum = 1;
     nscoord y = 0;//mMargin.top;
 
-    for (nsIFrame* page = mFrames.FirstChild(); page;
-         page = page->GetNextSibling()) {
+    for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
+      nsIFrame* page = e.get();
       if (pageNum >= mFromPageNum && pageNum <= mToPageNum) {
         nsRect rect = page->GetRect();
         rect.y = y;
         rect.height = height;
         page->SetRect(rect);
         y += rect.height + mMargin.top + mMargin.bottom;
       }
       pageNum++;