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.
This commit is contained in:
Jonas Jenwald 2021-06-03 11:35:12 +02:00
parent 2a35b39c46
commit 29e6930bb6
2 changed files with 8 additions and 6 deletions

View File

@ -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() {

View File

@ -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;