зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1659005 part 1: Move nsPageSequenceFrame's page-range-specific members into nsSharedPrintData. r=TYLin
This patch shouldn't change behavior at all; it's just moving some member variables to a new home on a helper-struct (and the struct's lifetime is the same as the lifetime of the nsPageSequenceFrame where these member variables lived, prior to this patch). These members need to move so that PrintedSheetFrame can have access to them. PrintedSheetFrame is now where pages are generated, and it will handle our page-range-induced page skipping, as of a later patch in this series. Differential Revision: https://phabricator.services.mozilla.com/D88468
This commit is contained in:
Родитель
d3aa4d7686
Коммит
2e3917b1b1
|
@ -357,8 +357,8 @@ nsresult nsPageSequenceFrame::GetFrameName(nsAString& aResult) const {
|
|||
//====================================================================
|
||||
void nsPageSequenceFrame::GetPrintRange(int32_t* aFromPage,
|
||||
int32_t* aToPage) const {
|
||||
*aFromPage = mFromPageNum;
|
||||
*aToPage = mToPageNum;
|
||||
*aFromPage = mPageData->mFromPageNum;
|
||||
*aToPage = mPageData->mToPageNum;
|
||||
}
|
||||
|
||||
// Helper Function
|
||||
|
@ -395,18 +395,19 @@ nsresult nsPageSequenceFrame::StartPrint(nsPresContext* aPresContext,
|
|||
mPageData->mDocURL = aDocURL;
|
||||
}
|
||||
|
||||
aPrintSettings->GetStartPageRange(&mFromPageNum);
|
||||
aPrintSettings->GetEndPageRange(&mToPageNum);
|
||||
aPrintSettings->GetPageRanges(mPageRanges);
|
||||
aPrintSettings->GetStartPageRange(&mPageData->mFromPageNum);
|
||||
aPrintSettings->GetEndPageRange(&mPageData->mToPageNum);
|
||||
aPrintSettings->GetPageRanges(mPageData->mPageRanges);
|
||||
|
||||
int16_t printType;
|
||||
aPrintSettings->GetPrintRange(&printType);
|
||||
mDoingPageRange = nsIPrintSettings::kRangeSpecifiedPageRange == printType;
|
||||
mPageData->mDoingPageRange =
|
||||
nsIPrintSettings::kRangeSpecifiedPageRange == printType;
|
||||
|
||||
// If printing a range of pages make sure at least the starting page
|
||||
// number is valid
|
||||
if (mDoingPageRange) {
|
||||
if (mFromPageNum > mPageData->mRawNumPages) {
|
||||
if (mPageData->mDoingPageRange) {
|
||||
if (mPageData->mFromPageNum > mPageData->mRawNumPages) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
@ -482,15 +483,16 @@ void nsPageSequenceFrame::DetermineWhetherToPrintPage() {
|
|||
|
||||
// If printing a range of pages check whether the page number is in the
|
||||
// range of pages to print
|
||||
if (mDoingPageRange) {
|
||||
if (mPageNum < mFromPageNum) {
|
||||
if (mPageData->mDoingPageRange) {
|
||||
if (mPageNum < mPageData->mFromPageNum) {
|
||||
mPrintThisPage = false;
|
||||
} else if (mPageNum > mToPageNum) {
|
||||
} else if (mPageNum > mPageData->mToPageNum) {
|
||||
mPageNum++;
|
||||
mPrintThisPage = false;
|
||||
return;
|
||||
} else {
|
||||
int32_t length = mPageRanges.Length();
|
||||
const auto& ranges = mPageData->mPageRanges;
|
||||
int32_t length = ranges.Length();
|
||||
|
||||
// Page ranges are pairs (start, end)
|
||||
if (length && (length % 2 == 0)) {
|
||||
|
@ -498,7 +500,7 @@ void nsPageSequenceFrame::DetermineWhetherToPrintPage() {
|
|||
|
||||
int32_t i;
|
||||
for (i = 0; i < length; i += 2) {
|
||||
if (mPageRanges[i] <= mPageNum && mPageNum <= mPageRanges[i + 1]) {
|
||||
if (ranges[i] <= mPageNum && mPageNum <= ranges[i + 1]) {
|
||||
mPrintThisPage = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,11 @@ class nsSharedPageData {
|
|||
// that it's reflowed the final page):
|
||||
int32_t mRawNumPages = 0;
|
||||
|
||||
// Page range info (only relevant if mDoingPageRange is true):
|
||||
int32_t mFromPageNum = 0;
|
||||
int32_t mToPageNum = 0;
|
||||
nsTArray<int32_t> mPageRanges;
|
||||
|
||||
// Margin for headers and footers; it defaults to 4/100 of an inch on UNIX
|
||||
// and 0 elsewhere; I think it has to do with some inconsistency in page size
|
||||
// computations
|
||||
|
@ -51,6 +56,9 @@ class nsSharedPageData {
|
|||
// the minimum "ComputedWidth / OverflowWidth" ratio of all page content
|
||||
// frames that overflowed. It's 1.0 if none overflowed horizontally.
|
||||
float mShrinkToFitRatio = 1.0f;
|
||||
|
||||
// True if the current print operation uses one or more print ranges:
|
||||
bool mDoingPageRange = false;
|
||||
};
|
||||
|
||||
// Page sequence frame class. Manages a series of pages, in paginated mode.
|
||||
|
@ -89,7 +97,7 @@ class nsPageSequenceFrame final : public nsContainerFrame {
|
|||
void ResetPrintCanvasList();
|
||||
int32_t GetCurrentPageNum() const { return mPageNum; }
|
||||
int32_t GetRawNumPages() const { return mPageData->mRawNumPages; }
|
||||
bool IsDoingPrintRange() const { return mDoingPageRange; }
|
||||
bool IsDoingPrintRange() const { return mPageData->mDoingPageRange; }
|
||||
void GetPrintRange(int32_t* aFromPage, int32_t* aToPage) const;
|
||||
nsresult DoPageEnd();
|
||||
|
||||
|
@ -152,15 +160,11 @@ class nsPageSequenceFrame final : public nsContainerFrame {
|
|||
|
||||
// Async Printing
|
||||
int32_t mPageNum;
|
||||
int32_t mFromPageNum;
|
||||
int32_t mToPageNum;
|
||||
|
||||
nsTArray<int32_t> mPageRanges;
|
||||
nsTArray<RefPtr<mozilla::dom::HTMLCanvasElement> > mCurrentCanvasList;
|
||||
|
||||
// Asynch Printing
|
||||
bool mPrintThisPage;
|
||||
bool mDoingPageRange;
|
||||
|
||||
bool mCalledBeginPage;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче