Skip to content

Prevent destinations with bad left/top values from scrolling the wrong page into view (bug 874482) #7440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 28, 2016

Conversation

Snuffleupagus
Copy link
Collaborator

There are PDF generators which create destinations with e.g. too large top values, which cause the wrong page to be scrolled into view because the offset becomes negative.
By ignoring negative offsets, we can prevent this issue, and get a similar behaviour as in Adobe Reader.

However, since we're also using PDFViewer_scrollPageIntoView in more cases than just when links (in the document/outline) are clicked, the patch adds a way to allow the caller to opt-out of this behaviour.
In e.g. the following situations, I think that we still want to be able to allow negative offsets: when restoring a position from the ViewHistory, when the viewBookmark button is used to obtain a link to the current position, or when maintaining the current position on zooming.

Rather than adding another parameter to PDFViewer_scrollPageIntoView, I've changed the signature to take an parameter object instead. To maintain backwards compatibility, I've added fallback code enclosed in a GENERIC preprocessor tag.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=874482.

Note: This PR includes the patch from PR #6903 which is enough to fixes the bug, but with the addition of the second patch we also avoid the issues described in that PR.

/cc @timvandermeij

xlc and others added 2 commits August 7, 2016 16:20
…g page into view (bug 874482)

There are PDF generators which create destinations with e.g. too large top values, which cause the wrong page to be scrolled into view because the offset becomes negative.
By ignoring negative offsets, we can prevent this issue, and get a similar behaviour as in Adobe Reader.

However, since we're also using `PDFViewer_scrollPageIntoView` in more cases than just when links (in the document/outline) are clicked, the patch adds a way to allow the caller to opt-out of this behaviour.
In e.g. the following situations, I think that we still want to be able to allow negative offsets: when restoring a position from the `ViewHistory`, when the `viewBookmark` button is used to obtain a link to the current position, or when maintaining the current position on zooming.

Rather than adding another parameter to `PDFViewer_scrollPageIntoView`, I've changed the signature to take an parameter object instead. To maintain backwards compatibility, I've added fallback code enclosed in a `GENERIC` preprocessor tag.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=874482.
@timvandermeij timvandermeij self-assigned this Aug 28, 2016
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/79957b4e77888c3/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/79957b4e77888c3/output.txt

Total script time: 1.07 mins

Published

@timvandermeij timvandermeij merged commit b0a0bef into mozilla:master Aug 28, 2016
@timvandermeij
Copy link
Contributor

Thank you for fixing this, @Snuffleupagus and @xlc!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants