mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1681026 - Fix PrintPreviewScrollToPage assert and simplify it. r=hiro
It was off-by-one as the pages are one-indexed. Differential Revision: https://phabricator.services.mozilla.com/D99212
This commit is contained in:
parent
56fdf285db
commit
ab1ebe2e24
@ -3280,19 +3280,9 @@ nsresult nsDocumentViewer::PrintPreviewScrollToPageForOldUI(int16_t aType,
|
||||
static const nsIFrame* GetTargetPageFrame(int32_t aTargetPageNum,
|
||||
nsPageSequenceFrame* aSequenceFrame) {
|
||||
MOZ_ASSERT(aTargetPageNum > 0 &&
|
||||
aTargetPageNum < aSequenceFrame->PrincipalChildList().GetLength());
|
||||
|
||||
int32_t pageNum = 1;
|
||||
for (const nsIFrame* sheetFrame : aSequenceFrame->PrincipalChildList()) {
|
||||
if (pageNum == aTargetPageNum) {
|
||||
return sheetFrame;
|
||||
}
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
MOZ_ASSERT_UNREACHABLE("Should have found the target frame");
|
||||
|
||||
return nullptr;
|
||||
aTargetPageNum <=
|
||||
aSequenceFrame->PrincipalChildList().GetLength());
|
||||
return aSequenceFrame->PrincipalChildList().FrameAt(aTargetPageNum - 1);
|
||||
}
|
||||
|
||||
// Calculate the scroll position where the center of |aFrame| is positioned at
|
||||
@ -3363,7 +3353,7 @@ nsDocumentViewer::PrintPreviewScrollToPage(int16_t aType, int32_t aPageNum) {
|
||||
break;
|
||||
}
|
||||
case nsIWebBrowserPrint::PRINTPREVIEW_GOTO_PAGENUM: {
|
||||
if (aPageNum < 0 || aPageNum > sheetCount) {
|
||||
if (aPageNum <= 0 || aPageNum > sheetCount) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user