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

Convert the page view to ES6 syntax #8455

Merged
merged 1 commit into from
May 30, 2017

Conversation

timvandermeij
Copy link
Contributor

@timvandermeij timvandermeij commented May 28, 2017

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of quick comments thus far; but setting r- for now, just so that we don't accidentally land this while rotation is broken.

},
update(scale, rotation) {
this.scale = scale || this.scale;
this.rotation = rotation || this.rotation;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't correct, since it will effectively prevent setting this.rotation to zero, if the rotation has previously been set to a non-zero value; please revert this change!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I'm not entirely sure how I missed that, but I reverted the change and added a small comment to make it more clear that this structure is intended.

this.id = id;
this.renderingId = 'page' + id;
this.pageLabel = null;
constructor(options) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more general question here: Should the signature be changed to constructor({ ... }) { instead, or would that be overly verbose considering the amount of parameters involved?

Copy link
Contributor Author

@timvandermeij timvandermeij May 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to not do that because it would indeed be too verbose. I usually keep a limit at five or six parameters: if we have more, than such an expansion does not provide much more insight in my opinion. Another example is the toolbar, which also has a huge amount of parameters.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to land with final comments addressed, thanks for the patch!

* @param {PDFPageViewOptions} options
*/
function PDFPageView(options) {
var container = options.container;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be a little bit clearer if we keep let container = options.container; here, considering that otherwise you're handling all the other parameters except this one at the top of the constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

var container = options.container;
var id = options.id;
var scale = options.scale;
var defaultViewport = options.defaultViewport;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarily, let's keep let defaultViewport = options.defaultViewport; such that we can maintain the slightly simpler this.pdfPageRotate = defaultViewport.rotation; below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.


let viewport = this.viewport;
let canvas = document.createElement('canvas');
canvas.id = 'page' + this.id;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Pre-existing issue, which I've been annoyed with for a while but haven't bothered to fix: Can we do canvas.id = this.renderingId; instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in the new commit.

@timvandermeij
Copy link
Contributor Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/868720482960d83/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/868720482960d83/output.txt

Total script time: 2.04 mins

Published

@timvandermeij
Copy link
Contributor Author

/botio lint

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/037c796a2cd8fd8/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/cb0c4de19a759f3/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/037c796a2cd8fd8/output.txt

Total script time: 0.99 mins

  • Lint: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/cb0c4de19a759f3/output.txt

Total script time: 3.54 mins

  • Lint: Passed

@timvandermeij timvandermeij merged commit 6b09889 into mozilla:master May 30, 2017
@timvandermeij timvandermeij deleted the es6-page-view branch May 30, 2017 22:55
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
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