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 initialization of "page labels"/"metadata"/"auto print" out of PDFViewerApplication.load #11780

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Apr 5, 2020

Please refer to the individual commit messages for additional details.

For awhile now I've been thinking that the PDFViewerApplication.load method has become way to large and unwieldy, hence this series of patches that move some of its non-critical code out into helper methods instead.

Edit: Currently blocked by PR #11781.

@Snuffleupagus Snuffleupagus force-pushed the refactor-PDFViewerApplication-load branch from 43f0d14 to 3a83399 Compare April 5, 2020 10:00
@Snuffleupagus Snuffleupagus changed the title Refactor pdf viewer application load Move the initialization of "page labels"/"metadata"/"auto print" out of PDFViewerApplication.load Apr 5, 2020
@pdfjsbot
Copy link

pdfjsbot commented Apr 5, 2020

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/0f0f646f5fc87fa/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Apr 5, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/0f0f646f5fc87fa/output.txt

Total script time: 2.39 mins

Published

….load`

Over time, with more and more API-functionality added, the `PDFViewerApplication.load` method has become quite large and complex. In an attempt to improve the current situation somewhat, this patch moves the fetching and initialization of "page labels" out into its own (private) helper method instead.
Over time, with more and more API-functionality added, the `PDFViewerApplication.load` method has become quite large and complex. In an attempt to improve the current situation somewhat, this patch moves the fetching and initialization of "metadata" out into its own (private) helper method instead.
…load`

Over time, with more and more API-functionality added, the `PDFViewerApplication.load` method has become quite large and complex. In an attempt to improve the current situation somewhat, this patch moves the fetching and initialization of "auto print" out into its own (private) helper method instead.
…izeMetadata, _initializePdfHistory}` methods

 - Use template strings when printing document/viewer information in `_initializeMetadata`, since the old format feels overly verbose.
   Also, get the WebGL state from the `BaseViewer` instance[1] rather than the `AppOptions`. Since the `AppOptions` value could theoretically have been changed (by the user) after the viewer components were initialized, it seems much more useful to print the *actual* value that'll be used during rendering.

 - Change `_initializePdfHistory` to actually do the "is embedded"-check first, in accordance with the comment and given that the "disableHistory" option usually shouldn't be set.

---
[1] Admittedly reaching into the `BaseViewer` instance and just grabbing the value perhaps isn't a great approach overall, but given that the WebGL-backend isn't even on by default this probably doesn't matter too much.
@Snuffleupagus Snuffleupagus force-pushed the refactor-PDFViewerApplication-load branch from 3a83399 to 9ef5834 Compare April 5, 2020 13:41
@pdfjsbot
Copy link

pdfjsbot commented Apr 5, 2020

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/fb4fe836f6a503a/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Apr 5, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/fb4fe836f6a503a/output.txt

Total script time: 2.47 mins

Published

@timvandermeij timvandermeij merged commit 09cccd8 into mozilla:master Apr 5, 2020
@timvandermeij
Copy link
Contributor

The method is reduced from 400 lines of code to 200 lines; much better!

@Snuffleupagus Snuffleupagus deleted the refactor-PDFViewerApplication-load branch April 5, 2020 13:55
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