Move the page switching code into set currentPageNumber
in PDFViewer
instead of placing it in the pagechange
event handler
#6140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The reason that this code can be moved is that the
if (this.loading && page === 1)
check, in thepagechange
event handler in viewer.js, is never satisfied sincethis.loading
is not defined in that scope.This could be considered a regression from PR #5295, since prior to that
this.loading
was using thePDFViewerApplication
scope (orPDFView
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, despitethis.loading === undefined
, is thatset currentPageNumber
(inPDFViewer
) returns early wheneverthis.pdfDocument
isn't set. This check is, for all intents and purposes, functionally equivalent to checkingPDFViewerApplication.loading
.Hence we can move the page switching code into
PDFViewer
, and also removePDFViewerApplication.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 ownpagechange
event handler just to getPDFViewer.currentPageNumber
to actually work seems like an unnecessary complication.