-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Refactoring to move page display code into separate class #5295
Conversation
9917d97
to
35b278e
Compare
Adding a class named I've done some quick testing, and the viewer still appears to (mostly) work as before :-) Given that one of the TODOs is "Refactor PresentationMode", I'm not sure how relevant this comment is, but I thought I should mention it anyway. I noticed that the zoom level isn't reset properly when exiting presentation mode. To reproduce:
Actual result: Expected result: |
|
||
'use strict'; | ||
|
||
var PDFViewer = (function pdfViewer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: function PDFViewerClosure()
instead?
I have to decisions made yet, however we started to name everything as PDFXxxx. I'm proposing to keep PDFViewer (since other names will not fit here). PDFView is a bad name here. So I decided to deprecate it, in the future it can be e.g. an alias for |
2d7273a
to
ca279b2
Compare
Fixed that. PresentationMode stuff is not was I expected, I'm going to keep that mostly as is, except removing dependency from PDFViewer on this object. |
I think I'm done. Here is minimal viewer https://gist.github.com/yurydelendik/5e7eda82bfd67a5a15df |
15b7352
to
2874a7f
Compare
Confirmed fixed, thank you! |
'use strict'; | ||
|
||
var PresentationModeState = { | ||
UKNOWN: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: UNKNOWN
.
2874a7f
to
eac6d69
Compare
013c35d
to
03ea82d
Compare
downloadedPromise.then(function () { | ||
var event = document.createEvent('CustomEvent'); | ||
event.initCustomEvent('documentload', true, true, {}); | ||
window.dispatchEvent(event); | ||
}); | ||
|
||
PDFView.loadingBar.setWidth(container); | ||
self.loadingBar.setWidth(document.getElementById('viewerContainer')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to use the DOM element viewer
instead, otherwise it won't work.
For some reason, in this scope, the variable container
doesn't refer to what you would expect; see https://github.com/mozilla/pdf.js/pull/5295/files#diff-dd42e9b2d2a652b8e312efa567698aa6L994
03ea82d
to
86af3d7
Compare
OverlayManager, PDFFindController, PDFFindBar, getVisibleElements, | ||
watchScroll, PDFViewer, PDFRenderingQueue, PresentationModeState, | ||
DEFAULT_SCALE, UNKNOWN_SCALE, | ||
IGNORE_CURRENT_POSITION_ON_ZOOM: true */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not typo -- signals lint that property can be overwritten
86af3d7
to
25b1633
Compare
* @returns {number} | ||
*/ | ||
get pagesRotation() { | ||
return this._pageRotation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this (and in the setter below) be this._pagesRotation
to match L#286?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thank you
25b1633
to
5510652
Compare
return; | ||
} | ||
dest = null; | ||
PDFView.setScale(PDFView.currentScaleValue, true, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't removing this line reintroduce the issue that PR #3829 fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, /test/pdfs/rotation.pdf a test case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
5510652
to
44779f1
Compare
Refactoring to move page display code into separate class
Fixes typo/regression of #5295 for presentation mode
* 'master' of https://github.com/mozilla/pdf.js: Move text_layer_builder and pdf_viewer styles out Adds css import preprocessing Moves scrollPageIntoView to the PDFViewer. Followup fix for entering/exiting Presentation mode Fixes typo/regression of mozilla#5295 for presentation mode Renames and refactors PDFView to PDFViewerApplication. Adds types definitions (jsdoc) for the PDFViewer code. Marks some private methods in PDFViewer and PDFThumbnailViewer Moves constants to avoid dependency on PDFView Removes any usage of PDFView in the PageView Removes PresentationMode dependency from PDFViewer Moves rendering queue logic from PDFView Moves pdfDocument.getPage/getTextContent requests out of PDFView Moves viewer code into PDFViewer and some code from PageView. Moves thumbs logic into PDFThumbnailViewer. Moves watchScroll and getVisibleElements from PDFView Fix Symbol fonts without font file but with Encoding dictionary (issue 5238)
Idea is to create reusable PDFViewer that will not have dependency on the PDFView (toolbars, find controller, etc).
NOTE: The refactoring shall not include any optimization or bug fixes