Revert "Remove the overflowing text special-case from scrollIntoView (issue 15714)"

This commit is contained in:
Jonas Jenwald 2022-11-24 12:37:07 +01:00 committed by GitHub
parent 5960e20cde
commit 9f5e1f4818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,8 +109,8 @@ class OutputScale {
* @param {Object} spot - An object with optional top and left properties, * @param {Object} spot - An object with optional top and left properties,
* specifying the offset from the top left edge. * specifying the offset from the top left edge.
* @param {boolean} [scrollMatches] - When scrolling search results into view, * @param {boolean} [scrollMatches] - When scrolling search results into view,
* ignore elements that contain marked content identifiers. * ignore elements that either: Contains marked content identifiers,
* The default value is `false`. * or have the CSS-rule `overflow: hidden;` set. The default value is `false`.
*/ */
function scrollIntoView(element, spot, scrollMatches = false) { function scrollIntoView(element, spot, scrollMatches = false) {
// Assuming offsetParent is available (it's not available when viewer is in // Assuming offsetParent is available (it's not available when viewer is in
@ -126,7 +126,9 @@ function scrollIntoView(element, spot, scrollMatches = false) {
while ( while (
(parent.clientHeight === parent.scrollHeight && (parent.clientHeight === parent.scrollHeight &&
parent.clientWidth === parent.scrollWidth) || parent.clientWidth === parent.scrollWidth) ||
(scrollMatches && parent.classList.contains("markedContent")) (scrollMatches &&
(parent.classList.contains("markedContent") ||
getComputedStyle(parent).overflow === "hidden"))
) { ) {
offsetY += parent.offsetTop; offsetY += parent.offsetTop;
offsetX += parent.offsetLeft; offsetX += parent.offsetLeft;