mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.62k stars 10k forks source link

Refactor ui_utils.js::scrollIntoView #15746

Open calixteman opened 1 year ago

calixteman commented 1 year ago

This function is very prone to errors: some small variations in different places can lead to errors especially when highlighting search results. It has been added few years ago to fix: https://github.com/mozilla/pdf.js/issues/1738 scrollIntoView moves the parent window when it should only scroll within the iframe. So we could maybe only use element.scrollIntoView when the viewer is not in an iframe else find a better way to compute the scroll offset (based on the page offset and on the position of the element within the page, ... something like that...).

Snuffleupagus commented 1 year ago

Before attempting any further work on this method, I think that we need to add a bunch of e.g. integration-tests such that we're able to better catch any regressions since this code is absolutely vital to the correct function of the viewer.