Commit Graph

10792 Commits

Author SHA1 Message Date
Jonas Jenwald
b8606abbc1 [api-major] Completely remove the global PDFJS object 2018-03-01 18:13:27 +01:00
Jonas Jenwald
4b4fcecf70 Ensure that we only pass in the necessary parameters when initializing 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.
2018-03-01 18:11:17 +01:00
Jonas Jenwald
212553840f Move the pdfBug option from the global PDFJS object and into getDocument instead
Also removes the now unused `getDefaultSetting` helper function.
2018-03-01 18:11:17 +01:00
Jonas Jenwald
1d03ad0060 Move the disableCreateObjectURL option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:17 +01:00
Jonas Jenwald
05c05bdef5 Move the disableStream option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
b69abf1111 Move the disableRange option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
69d7191034 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.
2018-03-01 18:11:16 +01:00
Jonas Jenwald
c7c583583b Move the disableFontFace option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
f3900c4e57 Move the isEvalSupported option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
3c2fbdffe6 Move the cMapUrl and cMapPacked options from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
b674409397 Move the maxImageSize option from the global PDFJS object and into getDocument instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
b0956a5d91 Refactor how the default viewer handles the worker options, by making use of AppOptions instead of the global PDFJS object 2018-03-01 18:11:16 +01:00
Jonas Jenwald
57165afb08 Move the defaultUrl parameter from the appConfig and into AppOptions 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.
2018-03-01 18:11:16 +01:00
Jonas Jenwald
81c550903f Move various viewer components options from PDFJS/PDFViewerApplication.viewerPrefs and into AppOptions instead 2018-03-01 18:11:16 +01:00
Jonas Jenwald
09da99b8a0 Introduce a AppOptions abstraction in preparation for a complete refactoring 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.
2018-03-01 18:11:16 +01:00
Jonas Jenwald
5894bfa449 Move API specific compatibility options from src/shared/compatibility.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.
2018-03-01 18:11:16 +01:00
Rob Wu
401f3a9d97
Merge pull request #9520 from Snuffleupagus/fix-includes-polyfills
Attempt to fix the `Array.prototype.includes` and `String.prototype.includes` polyfills (issue 9514, 9516)
2018-03-01 18:05:14 +01:00
Jonas Jenwald
cd12a177a9 Attempt to fix the Array.prototype.includes and String.prototype.includes polyfills (issue 9514, 9516)
I don't understand why the previous way importing the polyfills didn't work, and I don't have time to try and figure it out, however this patch seems to fix things.

Fixes 9514.
Fixes 9516.
2018-03-01 17:38:14 +01:00
Rob Wu
f893bcd41b
Merge pull request #9494 from pardeepshokeen/windows-drive-letter
Windows drive letter
2018-03-01 16:39:44 +01:00
Tim van der Meij
80bf6150d6
Merge pull request #9519 from Snuffleupagus/bug-888600
Upstream the changes from: Bug 888600 - Move ContentFrameMessageManager to WebIDL. Part 6: Mark some IDL interfaces as non-scriptable. r=bz.
2018-02-28 22:31:02 +01:00
Jonas Jenwald
ae7821484c Update l10n files 2018-02-28 12:30:13 +01:00
Jonas Jenwald
8b2c46dce7 Upstream the changes from: Bug 888600 - Move ContentFrameMessageManager to WebIDL. Part 6: Mark some IDL interfaces as non-scriptable. r=bz.
Please see:
https://bugzilla.mozilla.org/show_bug.cgi?id=888600
https://hg.mozilla.org/mozilla-central/rev/83c87140dc3d
2018-02-28 11:00:55 +01:00
Brendan Dahl
97faedba0c
Merge pull request #9511 from Snuffleupagus/more-upstreaming
Upstream changes from bug 792808 and 1440284
2018-02-26 13:09:15 -08:00
Jonas Jenwald
5497bdc46d Update the ESLint packages 2018-02-26 17:46:49 +01:00
Jonas Jenwald
a30c184f1f Upstream the changes from: Bug 1440284 - change this.EXPORTED_SYMBOLS back to var EXPORTED_SYMBOLS in JS modules, r=mccr8.
Please see:
https://bugzilla.mozilla.org/show_bug.cgi?id=1440284
https://hg.mozilla.org/mozilla-central/rev/b599a95ce057

For consistency, the patch also updates the `PdfJsTelemetry-stub.jsm` file.
2018-02-26 17:44:48 +01:00
Jonas Jenwald
68077f61f1 Upstream the changes from: Bug 792808 - Change PdfStreamConverter.jsm to import and instantiate XHRs from global properties rather than using Cc.createInstance(Ci.nsIXMLHttpRequest); r=mossop
Please see:
https://bugzilla.mozilla.org/show_bug.cgi?id=792808
https://hg.mozilla.org/mozilla-central/rev/56f9de9da69a

Fixes 9499.
2018-02-26 17:34:04 +01:00
pardeepshokeen
7ebbdd2579 helper function to parse url 2018-02-25 01:25:32 +05:30
Tim van der Meij
5f98f9b8f1
Merge pull request #9505 from Rob--W/hosted-viewer-blob-url
Don't block origin-less blob:-URLs in hosted viewer
2018-02-23 22:35:58 +01:00
Rob Wu
a6aca3cabe Don't block origin-less blob:-URLs in hosted viewer 2018-02-23 12:48:52 +01:00
Rob Wu
a8a7d815e7
Merge pull request #9490 from Rob--W/crx-migrate-pref-to-textLayerMode
Fix regressions in preferences in Chrome
2018-02-22 14:41:37 +01:00
Rob Wu
9d55a1edc7 Ignore managed prefs documented as "Deprecated."
Deprecated keys are removed from web/default_preferences.json,
but still maintained in managed_preferences.json.
2018-02-22 14:40:30 +01:00
Rob Wu
94a49fa048 [CRX] Make textLayerMode pref visible and add migration logic
In a1cfa5f4d7, the textLayerMode
preference was introduced, to replace the disableTextLayer and
enhanceTextSelection preferences.

As a result, the text selection preference was no longer visible
in Chrome (because preferences are only rendered by default for
boolean preferences, not for enumerations).

This commit adds the necessary bits to
extensions/chromium/options/options.{html,js}
so that the textLayerMode preference can be changed again.

Also, migration logic has been added to move over preferences
from the old to the new names:
- In web/chromecom.js, the logic is added to translate
  preferences that were set by an administrator (it is read-only,
  so this layer is unavoidable).
- In extensions/chromium/options/migration.js, similar logic is
  added, except in this case the preference storage is writable,
  so this migration logic happens only once.

The "enhanced text selection" mode is still experimental, so it
has been marked as experimental to signal that there may be bugs.
The list of tasks that block promotion to stable is at #7584.
2018-02-22 14:39:58 +01:00
Tim van der Meij
99060e2485
Merge pull request #9480 from Snuffleupagus/refactor-worker-options
[api-major] Move the worker related options from the global `PDFJS` object
2018-02-18 15:56:44 +01:00
Rob Wu
fc83ce1aae [CRX] Restore migration logic for managed enableHandToolOnLoad pref
This partially reverts df0836b9b8.
The entry in preferences_schema.json is restored because that is
required to make managed preferences visible to the extension code.

The default key is still removed from default_preferences.json,
because this change only concerns the Chrome extension, not the
other parts of PDF.js. To account for the missing key, the
deprecated key was added back in chromecom.js

The key needs to be restored in preferences_schema.json too,
because that's the only way to make managed preferences visible.

I'm using `Object.assign`, which was introduced in Chrome 45,
so the preference module will break in Chrome 45 and earlier.
This is fine, because we do not support Chrome before 49.
2018-02-18 11:56:27 +01:00
Jonas Jenwald
a97901efb6 Move the verbosity option from the global PDFJS object and into getDocument/PDFWorker instead
Given the purpose of this option, it doesn't seem necessary to make it available through `GlobalWorkerOptions`.
2018-02-16 13:22:35 +01:00
Jonas Jenwald
fdd2376170 Move the postMessageTransfers option from the global PDFJS object and into getDocument/PDFWorker instead
Given the purpose of this option, it doesn't seem necessary to make it available through `GlobalWorkerOptions`.
2018-02-16 13:22:35 +01:00
Jonas Jenwald
83d52518da [api-major] Refactor PDFWorker to be initialized with a parameter object, rather than a bunch of regular parameters 2018-02-16 13:22:35 +01:00
Jonas Jenwald
c3c1fc511d Move the workerSrc option from the global PDFJS object and into GlobalWorkerOptions instead 2018-02-16 13:22:35 +01:00
Jonas Jenwald
45adf33187 Move the workerPort from the global PDFJS object and into GlobalWorkerOptions instead 2018-02-16 13:22:35 +01:00
Jonas Jenwald
003bd4044b Introduce a GlobalWorkerOptions object for (basic) Worker configuration
Compared to most other options currently/previously residing on the global `PDFJS` object, some of the Worker specific ones (e.g. `workerPort`/`workerSrc`) probably cannot be moved into options provided directly when initializing e.g. `PDFWorker`.
The reason is that in some cases, e.g. the Webpack examples, we try to provide Worker auto-configuration and I cannot see a good solution for that use-case if we completely remove the globally available Worker configuration.

However inline with previous patches for PDF.js version `2.0`, it does seem like a worthwhile goal to move away from storing options directly on the global `PDFJS` object, since that is a pattern we should avoid going forward. Especially since one of the (eventual) goals is to attempt to *completely* remove the global `PDFJS` object, and rely solely on exporting/importing the needed functionality.

By introducing the `GlobalWorkerOptions` we thus have larger flexibility in the future, if/when the global `PDFJS` object will be removed.
2018-02-16 13:22:35 +01:00
Rob Wu
a89071bdef
Merge pull request #9470 from Snuffleupagus/issue-4888
Ensure that `JpegImage.getData` returns the correct data length when `forceRGBoutput == true` (issue 4888)
2018-02-16 13:14:21 +01:00
Brendan Dahl
4f5fb78237
Merge pull request #9401 from brendandahl/svg-fail
Make the test framework more resilient to errors.
2018-02-14 17:05:40 -08:00
Brendan Dahl
53d19b619d Make the test framework more resilient to errors. 2018-02-14 17:02:19 -08:00
Tim van der Meij
538dda1096
Merge pull request #9479 from Snuffleupagus/refactor-viewer-options
[api-major] Refactor viewer components initialization to reduce their dependency on the global `PDFJS` object
2018-02-14 22:47:33 +01:00
Tim van der Meij
2e780d4e2b
Merge pull request #9420 from Snuffleupagus/makeInlineImage-dict
Take the dictionary, and not just the image data, into account when caching inline images (issue 9398)
2018-02-14 00:05:36 +01:00
Tim van der Meij
df0836b9b8
Merge pull request #9475 from Snuffleupagus/rm-handToolPref
Remove the actual `enableHandToolOnLoad` preference (PR 9040 follow-up)
2018-02-14 00:00:15 +01:00
Jonas Jenwald
11ab3b5c00 Ensure that JpegImage.getData returns the correct data length when forceRGBoutput == true (issue 4888)
With PDF.js version `2.0` we'll only support browsers with built-in `TypedArray` functionality, hence there doesn't seem to be any good reason not to implement this now.

Fixes 4888.
2018-02-13 20:44:21 +01:00
Jonas Jenwald
e95c11a7f0 Remove the undocumented PDFJS.enableStats option
In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now instead used to enabled general debugging *and* page request/rendering stats.
Considering that in the default viewer the `stats` was only used when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
2018-02-13 16:56:57 +01:00
Jonas Jenwald
6bc3e1fb93 Remove version/build from the global PDFJS object
There's no need to expose these properties multiple times, since they're already exported by `src/display/api.js`.
2018-02-13 16:56:57 +01:00
Jonas Jenwald
74ffd1d865 Pass in the PDFJS.locale option to ExternalServices.createL10n
This allows us to remove an otherwise unnecessary `PDFJS` dependency from the `web/genericcom.js` file.
2018-02-13 16:56:56 +01:00