Bug 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn
authorDaniel Holbert <dholbert@cs.stanford.edu>
Sat, 27 Jun 2015 03:07:30 -0700
changeset 250404 052df7a415f12f11d4faf35a45462f60f338ed2d
parent 250403 9fb9dbd7a0dd018483ca56c725f6eff55012902a
child 250405 30e8c73f674ef5c6567b580b2f0e8caa627d1117
push id61548
push userdholbert@mozilla.com
push dateSat, 27 Jun 2015 10:08:23 +0000
treeherdermozilla-inbound@052df7a415f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1177927
milestone41.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 1177927: Use nsFrameList::GetLength() instead of manual iteration to count pages in nsPrintEngine. r=tn
layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -355,26 +355,20 @@ nsPrintEngine::GetSeqFrameAndCountPagesI
 
   // Finds the SimplePageSequencer frame
   nsIPageSequenceFrame* seqFrame = aPO->mPresShell->GetPageSequenceFrame();
   aSeqFrame = do_QueryFrame(seqFrame);
   if (!aSeqFrame) {
     return NS_ERROR_FAILURE;
   }
 
-  // first count the total number of pages
-  aCount = 0;
-  nsIFrame* pageFrame = aSeqFrame->GetFirstPrincipalChild();
-  while (pageFrame != nullptr) {
-    aCount++;
-    pageFrame = pageFrame->GetNextSibling();
-  }
+  // count the total number of pages
+  aCount = aSeqFrame->PrincipalChildList()->GetLength();
 
   return NS_OK;
-
 }
 
 //-----------------------------------------------------------------
 nsresult nsPrintEngine::GetSeqFrameAndCountPages(nsIFrame*& aSeqFrame, int32_t& aCount)
 {
   NS_ASSERTION(mPrtPreview, "mPrtPreview can't be null!");
   return GetSeqFrameAndCountPagesInternal(mPrtPreview->mPrintObject, aSeqFrame, aCount);
 }