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

[WIP] Move options from the global PDFJS object into the relevant viewer components or API methods #9130

Closed
wants to merge 17 commits into from

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Nov 14, 2017

Currently blocked on PRs #9037, #9095, #9125, #9126.

Edit: I'm not sure if this is necessarily the best solution, but at this point the PR now moves all (non-worker related, since those may be tricker) options from PDFJS.

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

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/a9aa25ada1a62fd/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

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

Total script time: 2.51 mins

Published

The way that various options are handled in the default viewer is currently a bit of a mess (to say the least). Some viewer options reside in the global `PDFJS` object, while others reside in `Preferences`. To make matters worse, some options even exist in both of the two.

Since the goal, with PDF.js version `2.0`, is to reduce our usage of the global `PDFJS` object, we'll instead want pass in the options when initializing the viewer components and when calling API methods (such as `getDocument`).
However given the current state of things in the default viewer, this wouldn't be exactly easy to implement. Hence this patch, which attempts to consolidate the way that viewer (and later API) options are handled by introducing a `AppOptions` singleton that provides *one* centralized way of interacting with the various options in the default viewer.

Unfortunately, as far as I can tell, we still need the ability to adjust certain options depending on the browser environment. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
…a `getDocument` option instead

One additional complication with removing this parameters from the global `PDFJS` object, is that the viewer currently needs to check `disableAutoFetch` in a couple of places. To address this I'm thus proposing adding a getter, to the `PDFDocumentProxy`, which allow checking the *actually* used values for a particular `getDocument` invocation.
…etDocument` option instead

Unfortunately, as far as I can tell, we still need the ability to adjust certain options depending on the browser environment. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
…getDocument` option instead

Unfortunately, as far as I can tell, we still need the ability to adjust certain options depending on the browser environment. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
…ct to a `getDocument` option instead

Unfortunately, as far as I can tell, we still need the ability to adjust certain options depending on the browser environment. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
…a `getDocument` option instead

*Please note:* In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now used to enabled general debugging *and* page request/rendering stats.
Considering that we, in the default viewer, were only using the stats when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
…g `PDFNetworkStream` in `src/display/api.js`

With options being moved from the global `PDFJS` object and into `getDocument`, a side-effect is that we're now passing in a fair number of useless parameters to the network streams.
Even though this doesn't *currently* cause any problems, it nonetheless seem like a good idea to explicitly provide the parameters that are actually necessary.
@Snuffleupagus Snuffleupagus deleted the viewer-options branch February 3, 2018 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants