Bug 1657550 - Preserve x-axis scroll position on printPreviewScrollToPage call in any cases. r=emilio

That's what we've done for PRINTPREVIEW_PREV_PAGE, PRINTPREVIEW_NEXT_PAGE
and PRINTPREVIEW_GOTO_PAGENUM.

Differential Revision: https://phabricator.services.mozilla.com/D87545
This commit is contained in:
Hiroyuki Ikezoe 2020-08-19 22:50:15 +00:00
Родитель 8c4b16591d
Коммит ce091f13c6
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -3329,17 +3329,21 @@ nsDocumentViewer::PrintPreviewScrollToPage(int16_t aType, int32_t aPageNum) {
mPrintJob->GetPrintPreviewPresShell()->GetRootScrollFrameAsScrollable();
if (!sf) return NS_OK;
// Figure where we are currently scrolled to
nsPoint currentScrollPosition = sf->GetScrollPosition();
// Check to see if we can short circut scrolling to the top
if (aType == nsIWebBrowserPrint::PRINTPREVIEW_HOME ||
(aType == nsIWebBrowserPrint::PRINTPREVIEW_GOTO_PAGENUM &&
aPageNum == 1)) {
sf->ScrollTo(nsPoint(0, 0), ScrollMode::Instant);
sf->ScrollTo(nsPoint(currentScrollPosition.x, 0), ScrollMode::Instant);
return NS_OK;
}
// If it is "End" then just scroll to the `scrollTopMax` position.
if (aType == nsIWebBrowserPrint::PRINTPREVIEW_END) {
sf->ScrollTo(nsPoint(0, sf->GetScrollRange().YMost()), ScrollMode::Instant);
sf->ScrollTo(nsPoint(currentScrollPosition.x, sf->GetScrollRange().YMost()),
ScrollMode::Instant);
return NS_OK;
}
@ -3349,9 +3353,6 @@ nsDocumentViewer::PrintPreviewScrollToPage(int16_t aType, int32_t aPageNum) {
return NS_ERROR_FAILURE;
}
// Figure where we are currently scrolled to
nsPoint currentScrollPosition = sf->GetScrollPosition();
int32_t pageNum = 1;
nsIFrame* fndPageFrame = nullptr;
nsIFrame* currentPage = nullptr;