Skip to content
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

Move the page switching code into set currentPageNumber in PDFViewer instead of placing it in the pagechange event handler #6140

Merged
merged 1 commit into from
Jun 30, 2015

Conversation

Snuffleupagus
Copy link
Collaborator

The reason that this code can be moved is that the if (this.loading && page === 1) check, in the pagechange event handler in viewer.js, is never satisfied since this.loading is not defined in that scope.
This could be considered a regression from PR #5295, since prior to that this.loading was using the PDFViewerApplication scope (or PDFView as it were).
However, I don't think that we need to fix that since we've been shipping this code in no less than three Firefox releases (uplifted in https://bugzilla.mozilla.org/show_bug.cgi?id=1084158), without breaking the world.

An explanation of why the pagechange code works, despite this.loading === undefined, is that set currentPageNumber (in PDFViewer) returns early whenever this.pdfDocument isn't set. This check is, for all intents and purposes, functionally equivalent to checking PDFViewerApplication.loading.
Hence we can move the page switching code into PDFViewer, and also remove PDFViewerApplication.loading since it's not used any more.
(The this.loading property was added in PR #686, which was before the current viewer even existed.)

Note: The changes in this patch should also be beneficial to the viewer components, since requiring every implementer to provide their own pagechange event handler just to get PDFViewer.currentPageNumber to actually work seems like an unnecessary complication.

…er` instead of placing it in the `pagechange` event handler

The reason that this code can be moved is that the `if (this.loading && page === 1)` check, in the `pagechange` event handler in viewer.js, is never satisfied since `this.loading` is not defined in that scope.
This *could* be considered a regression from PR 5295, since prior to that `this.loading` was using the `PDFViewerApplication` scope (or `PDFView` as it were).
However, I don't think that we need to fix that since we've been shipping this code in no less than *three* Firefox releases (uplifted in https://bugzilla.mozilla.org/show_bug.cgi?id=1084158), without breaking the world.

An explanation of why the `pagechange` code works, despite `this.loading === undefined`, is that `set currentPageNumber` (in `PDFViewer`) returns early whenever `this.pdfDocument` isn't set. This check is, for all intents and purposes, functionally equivalent to checking `PDFViewerApplication.loading`.
Hence we can move the page switching code into `PDFViewer`, and also remove `PDFViewerApplication.loading` since it's not used any more.
(The `this.loading` property was added in PR 686, which was before the current viewer even existed.)

*Note:* The changes in this patch should also be beneficial to the viewer `components`, since requiring every implementer to provide their own `pagechange` event handler just to get `PDFViewer.currentPageNumber` to actually work seems like an unnecessary complication.
@Snuffleupagus
Copy link
Collaborator Author

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/fc908b795da6e94/output.txt

@yurydelendik
Copy link
Contributor

Nice analysis, thanks for catching this.

yurydelendik added a commit that referenced this pull request Jun 30, 2015
…iewer

Move the page switching code into `set currentPageNumber` in `PDFViewer` instead of placing it in the `pagechange` event handler
@yurydelendik yurydelendik merged commit 1da0b3a into mozilla:master Jun 30, 2015
@Snuffleupagus Snuffleupagus deleted the move-pagechange-into-PDFViewer branch June 30, 2015 19:14
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.

3 participants