Bug 1050412 part 1: Use nsFrameList::Enumerator in nsSimplePageSequenceFrame to iterate over child frames. r=tn

This commit is contained in:
Daniel Holbert 2014-08-07 22:07:15 -07:00
parent e3009122fa
commit 609c60e648

View File

@ -201,7 +201,8 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
// 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);
@ -244,22 +245,17 @@ nsSimplePageSequenceFrame::Reflow(nsPresContext* aPresContext,
// 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);
}
@ -421,8 +417,8 @@ nsSimplePageSequenceFrame::StartPrint(nsPresContext* aPresContext,
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;