From 2a35b39c467c301ef04bfee11b0ec256f7ba0e63 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 3 Jun 2021 11:11:27 +0200 Subject: [PATCH 1/2] Remove the unused `dataset` checks from the `scrollIntoView` helper function This code was added in PR 3968, apparently in order to fix scrolling of search results in HiDPI-mode. However, after PR 4570 nothing is setting these `dataset`-properties any more and this is thus dead code which should be removed. (If that change had broken scrolling of search results in HiDPI-mode, you'd really expect that it'd been reported and fixed a long time ago.) --- web/ui_utils.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/web/ui_utils.js b/web/ui_utils.js index 3d7634bb0..47b7a9feb 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -117,12 +117,9 @@ function scrollIntoView(element, spot, skipOverflowHiddenElements = false) { (skipOverflowHiddenElements && getComputedStyle(parent).overflow === "hidden") ) { - if (parent.dataset._scaleY) { - offsetY /= parent.dataset._scaleY; - offsetX /= parent.dataset._scaleX; - } offsetY += parent.offsetTop; offsetX += parent.offsetLeft; + parent = parent.offsetParent; if (!parent) { return; // no need to scroll From 29e6930bb6717e82929742c1588520ddb36d170c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 3 Jun 2021 11:35:12 +0200 Subject: [PATCH 2/2] Fix scrolling of search results in documents with marked content (bug 1714183) This regressed in PR 13171, since the `span`s with the marked content identifiers interfere with scrolling of search results. --- web/pdf_find_controller.js | 2 +- web/ui_utils.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/web/pdf_find_controller.js b/web/pdf_find_controller.js index 7eeb01e65..db7534f42 100644 --- a/web/pdf_find_controller.js +++ b/web/pdf_find_controller.js @@ -223,7 +223,7 @@ class PDFFindController { top: MATCH_SCROLL_OFFSET_TOP, left: MATCH_SCROLL_OFFSET_LEFT, }; - scrollIntoView(element, spot, /* skipOverflowHiddenElements = */ true); + scrollIntoView(element, spot, /* scrollMatches = */ true); } _reset() { diff --git a/web/ui_utils.js b/web/ui_utils.js index 47b7a9feb..e93511211 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -97,10 +97,11 @@ function getOutputScale(ctx) { * @param {Object} element - The element to be visible. * @param {Object} spot - An object with optional top and left properties, * specifying the offset from the top left edge. - * @param {boolean} skipOverflowHiddenElements - Ignore elements that have - * the CSS rule `overflow: hidden;` set. The default is false. + * @param {boolean} [scrollMatches] - When scrolling search results into view, + * ignore elements that either: Contains marked content identifiers, + * or have the CSS-rule `overflow: hidden;` set. The default value is `false`. */ -function scrollIntoView(element, spot, skipOverflowHiddenElements = false) { +function scrollIntoView(element, spot, scrollMatches = false) { // Assuming offsetParent is available (it's not available when viewer is in // hidden iframe or object). We have to scroll: if the offsetParent is not set // producing the error. See also animationStarted. @@ -114,8 +115,9 @@ function scrollIntoView(element, spot, skipOverflowHiddenElements = false) { while ( (parent.clientHeight === parent.scrollHeight && parent.clientWidth === parent.scrollWidth) || - (skipOverflowHiddenElements && - getComputedStyle(parent).overflow === "hidden") + (scrollMatches && + (parent.classList.contains("markedContent") || + getComputedStyle(parent).overflow === "hidden")) ) { offsetY += parent.offsetTop; offsetX += parent.offsetLeft;