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

[api-major] Move the remaining options from, and completely remove, the global PDFJS object #9493

Merged
merged 16 commits into from
Mar 3, 2018
Merged

[api-major] Move the remaining options from, and completely remove, the global PDFJS object #9493

merged 16 commits into from
Mar 3, 2018

Commits on Mar 1, 2018

  1. Move API specific compatibility options from `src/shared/compatibilit…

    …y.js` and into a separate file
    
    Unfortunately, as far as I can tell, we still need the ability to adjust certain API options depending on the browser environment in PDF.js version `2.0`. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    5894bfa View commit details
    Browse the repository at this point in the history
  2. Introduce a AppOptions abstraction in preparation for a complete re…

    …factoring of the way that viewer options are handled
    
    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.
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    09da99b View commit details
    Browse the repository at this point in the history
  3. Move various viewer components options from PDFJS/`PDFViewerApplica…

    …tion.viewerPrefs` and into `AppOptions` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    81c5509 View commit details
    Browse the repository at this point in the history
  4. Move the defaultUrl parameter from the appConfig and into `AppOpt…

    …ions` instead
    
    The `appConfig` contains (mostly) references to various DOM elements, used when initializing the viewer components.
    Hence `defaultUrl` seem like a slightly better fit for the new `AppOptions` abstraction, not to mention that it should thus be easier to set/modify it for custom deployments of the default viewer.
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    57165af View commit details
    Browse the repository at this point in the history
  5. Refactor how the default viewer handles the worker options, by making…

    … use of `AppOptions` instead of the global `PDFJS` object
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    b0956a5 View commit details
    Browse the repository at this point in the history
  6. Move the maxImageSize option from the global PDFJS object and int…

    …o `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    b674409 View commit details
    Browse the repository at this point in the history
  7. Move the cMapUrl and cMapPacked options from the global PDFJS o…

    …bject and into `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    3c2fbdf View commit details
    Browse the repository at this point in the history
  8. Move the isEvalSupported option from the global PDFJS object and …

    …into `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    f3900c4 View commit details
    Browse the repository at this point in the history
  9. Move the disableFontFace option from the global PDFJS object and …

    …into `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    c7c5835 View commit details
    Browse the repository at this point in the history
  10. Move the disableAutoFetch option from the global PDFJS object and…

    … into `getDocument` instead
    
    One additional complication with removing this option 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 in `PDFDocumentProxy`, to allow checking the *actually* used values for a particular `getDocument` invocation.
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    69d7191 View commit details
    Browse the repository at this point in the history
  11. Move the disableRange option from the global PDFJS object and int…

    …o `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    b69abf1 View commit details
    Browse the repository at this point in the history
  12. Move the disableStream option from the global PDFJS object and in…

    …to `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    05c05bd View commit details
    Browse the repository at this point in the history
  13. Move the disableCreateObjectURL option from the global PDFJS obje…

    …ct and into `getDocument` instead
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    1d03ad0 View commit details
    Browse the repository at this point in the history
  14. Move the pdfBug option from the global PDFJS object and into `get…

    …Document` instead
    
    Also removes the now unused `getDefaultSetting` helper function.
    Snuffleupagus committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    2125538 View commit details
    Browse the repository at this point in the history
  15. Ensure that we only pass in the necessary parameters when initializin…

    …g `PDFDataTransportStream`/`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 various transport/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 committed Mar 1, 2018
    Configuration menu
    Copy the full SHA
    4b4fcec View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    b8606ab View commit details
    Browse the repository at this point in the history