From 335b4750cb5b84cb6a4d72c935a3b4180c5f502a Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Thu, 20 Aug 2020 06:16:04 +0000 Subject: [PATCH] Bug 1660166 part 3: Remove a redundant member-variable that represents the total number of pages. r=hiro Before this patch stack, nsPageSequenceFrame and every nsPageFrame each individually tracked the number of pages. As of the previous patch, we've coalesced the nsPageFrame variables into a single variable that lives on nsSharedPageData. This patch here replaces nsPageSequenceFrame's member-var with that nsSharedPageData variable, too. Depends on D87696 Differential Revision: https://phabricator.services.mozilla.com/D87697 --- layout/generic/nsPageSequenceFrame.cpp | 5 +---- layout/generic/nsPageSequenceFrame.h | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/layout/generic/nsPageSequenceFrame.cpp b/layout/generic/nsPageSequenceFrame.cpp index 5a9c83af5235..bdf716bc541b 100644 --- a/layout/generic/nsPageSequenceFrame.cpp +++ b/layout/generic/nsPageSequenceFrame.cpp @@ -52,7 +52,6 @@ nsPageSequenceFrame::nsPageSequenceFrame(ComputedStyle* aStyle, : nsContainerFrame(aStyle, aPresContext, kClassID), mMaxSheetSize(mWritingMode), mScrollportSize(mWritingMode), - mTotalPages(-1), mCalledBeginPage(false), mCurrentCanvasListSetup(false) { mPageData = MakeUnique(); @@ -406,10 +405,8 @@ nsresult nsPageSequenceFrame::StartPrint(nsPresContext* aPresContext, // If printing a range of pages make sure at least the starting page // number is valid - mTotalPages = mFrames.GetLength(); - if (mDoingPageRange) { - if (mFromPageNum > mTotalPages) { + if (mFromPageNum > mPageData->mTotNumPages) { return NS_ERROR_INVALID_ARG; } } diff --git a/layout/generic/nsPageSequenceFrame.h b/layout/generic/nsPageSequenceFrame.h index 302d8ea6a8e4..a3a22292a70c 100644 --- a/layout/generic/nsPageSequenceFrame.h +++ b/layout/generic/nsPageSequenceFrame.h @@ -39,7 +39,8 @@ class nsSharedPageData { nsString mDocURL; nsFont mHeadFootFont; - // Total number of pages: + // Total number of pages (populated by PrintedSheetFrame when it determines + // that it's reflowed the final page): int32_t mTotNumPages = 0; // Margin for headers and footers; it defaults to 4/100 of an inch on UNIX @@ -90,7 +91,7 @@ class nsPageSequenceFrame final : public nsContainerFrame { nsresult PrintNextPage(); void ResetPrintCanvasList(); int32_t GetCurrentPageNum() const { return mPageNum; } - int32_t GetNumPages() const { return mTotalPages; } + int32_t GetNumPages() const { return mPageData->mTotNumPages; } bool IsDoingPrintRange() const { return mDoingPageRange; } void GetPrintRange(int32_t* aFromPage, int32_t* aToPage) const; nsresult DoPageEnd(); @@ -154,7 +155,6 @@ class nsPageSequenceFrame final : public nsContainerFrame { // Async Printing int32_t mPageNum; - int32_t mTotalPages; int32_t mFromPageNum; int32_t mToPageNum;