Skip to content

Commit a852561

Browse files
committed
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.
1 parent 2a35b39 commit a852561

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

web/pdf_find_controller.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class PDFFindController {
223223
top: MATCH_SCROLL_OFFSET_TOP,
224224
left: MATCH_SCROLL_OFFSET_LEFT,
225225
};
226-
scrollIntoView(element, spot, /* skipOverflowHiddenElements = */ true);
226+
scrollIntoView(element, spot, /* scrollMatches = */ true);
227227
}
228228

229229
_reset() {

web/ui_utils.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ function getOutputScale(ctx) {
9797
* @param {Object} element - The element to be visible.
9898
* @param {Object} spot - An object with optional top and left properties,
9999
* specifying the offset from the top left edge.
100-
* @param {boolean} skipOverflowHiddenElements - Ignore elements that have
101-
* the CSS rule `overflow: hidden;` set. The default is false.
100+
* @param {boolean} [scrollMatches] - When scrolling search results into view,
101+
* ignore elements that either: Contains marked content identifiers,
102+
* or has the CSS-rule `overflow: hidden;` set. The default value is `false`.
102103
*/
103-
function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
104+
function scrollIntoView(element, spot, scrollMatches = false) {
104105
// Assuming offsetParent is available (it's not available when viewer is in
105106
// hidden iframe or object). We have to scroll: if the offsetParent is not set
106107
// producing the error. See also animationStarted.
@@ -114,8 +115,9 @@ function scrollIntoView(element, spot, skipOverflowHiddenElements = false) {
114115
while (
115116
(parent.clientHeight === parent.scrollHeight &&
116117
parent.clientWidth === parent.scrollWidth) ||
117-
(skipOverflowHiddenElements &&
118-
getComputedStyle(parent).overflow === "hidden")
118+
(scrollMatches &&
119+
(parent.classList.contains("markedContent") ||
120+
getComputedStyle(parent).overflow === "hidden"))
119121
) {
120122
offsetY += parent.offsetTop;
121123
offsetX += parent.offsetLeft;

0 commit comments

Comments
 (0)