зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1661868 part 1: Broaden PrintedSheetFrame's "layout-time" page-range handling to support complex page ranges. r=TYLin
This patch does the following: * It adds better documentation for the meanings of the page range member-vars in nsSharedPageData. * It copies some logic (with minor tweaks) from the legacy codepath that handles page-range support (nsPageSequenceFrame::DetermineWhetherToPrintPage()) into to the new codepath for page-range support (PrintedSheetFrame.cpp's helper function "TagIfSkippedByCustomRange()"). At this point in the patch stack, the legacy codepath is unchanged & still handles all print operations; and the new PrintedSheetFrame.cpp codepath only handles page-range-skipping for the print-preview visualization in the Tab-Modal print dialog. So, this patch effectively gives that print-preview visualization the platform-support that it would need for complex page ranges (though that's not available in the UI at this point, so you can't really test that). Spoiler alert: the next patch in this series will remove the legacy codepath entirely, and at *that* point, the platform-native print dialog's complex-page-range feature will be backed by the PrintedSheetFrame.cpp code that's added here. Differential Revision: https://phabricator.services.mozilla.com/D92696
This commit is contained in:
Родитель
228e721068
Коммит
59211689e7
|
@ -58,11 +58,45 @@ static bool TagIfSkippedByCustomRange(nsPageFrame* aPageFrame, int32_t aPageNum,
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!aPD->mDoingPageRange ||
|
||||
(aPD->mFromPageNum <= aPageNum && aPD->mToPageNum >= aPageNum)) {
|
||||
if (!aPD->mDoingPageRange) {
|
||||
MOZ_ASSERT(!aPageFrame->HasAnyStateBits(NS_PAGE_SKIPPED_BY_CUSTOM_RANGE),
|
||||
"page frames in print range shouldn't be tagged with the"
|
||||
"NS_PAGE_SKIPPED_BY_CUSTOM_RANGE state bit");
|
||||
"page frames shouldn't be tagged as skipped if we're not "
|
||||
"printing with a custom page range");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isPageSkipped = false;
|
||||
|
||||
// As described in nsSharedPageData documentation: we can use mFromPageNum
|
||||
// and mToPageNum as a quick way to reject entirely-out-of-range pages. For
|
||||
// page numbers inside these bounds, we need to check mRanges to find out if
|
||||
// they're included in our subranges (if there are any).
|
||||
if (aPageNum < aPD->mFromPageNum || aPageNum > aPD->mToPageNum) {
|
||||
// Page is out-of-bounds; it's skipped.
|
||||
isPageSkipped = true;
|
||||
} else {
|
||||
// Check subranges (if there are any).
|
||||
const auto& ranges = aPD->mPageRanges;
|
||||
int32_t length = ranges.Length();
|
||||
|
||||
// Page ranges are pairs (start, end) of included pages.
|
||||
if (length && (length % 2 == 0)) {
|
||||
isPageSkipped = true;
|
||||
for (int32_t i = 0; i < length; i += 2) {
|
||||
if (ranges[i] <= aPageNum && aPageNum <= ranges[i + 1]) {
|
||||
// The page is included in this piece of the custom range,
|
||||
// so it's not skipped.
|
||||
isPageSkipped = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPageSkipped) {
|
||||
MOZ_ASSERT(!aPageFrame->HasAnyStateBits(NS_PAGE_SKIPPED_BY_CUSTOM_RANGE),
|
||||
"page frames NS_PAGE_SKIPPED_BY_CUSTOM_RANGE state should "
|
||||
"only be set if we actually want to skip the page");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,9 +40,19 @@ class nsSharedPageData {
|
|||
// that it's reflowed the final page):
|
||||
int32_t mRawNumPages = 0;
|
||||
|
||||
// Page range info (only relevant if mDoingPageRange is true):
|
||||
// Smallest included page num. 1-based. Only used if mDoingPageRange is true.
|
||||
int32_t mFromPageNum = 0;
|
||||
|
||||
// Largest included page num. 1-based. Only used if mDoingPageRange is true.
|
||||
int32_t mToPageNum = 0;
|
||||
|
||||
// If there's more than one page-range, then its components are stored here
|
||||
// as pairs of (start,end). They're stored in the order provided (not
|
||||
// necessarily in ascending order). The most extreme included values will
|
||||
// still be stored in mFromPageNum and mToPageNum, so that entirely
|
||||
// out-of-bounds pages can be easily filtered out without needing to inspect
|
||||
// this array. As above, the values are 1-based, and this member is only used
|
||||
// if mDoingPageRange is true.
|
||||
nsTArray<int32_t> mPageRanges;
|
||||
|
||||
// Margin for headers and footers; it defaults to 4/100 of an inch on UNIX
|
||||
|
|
Загрузка…
Ссылка в новой задаче