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