Commit Graph

10825 Commits

Author SHA1 Message Date
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
Jonas Jenwald
77efed6626 Replace the PDFJS.disableWebGL option with a enableWebGL option passed, via BaseViewer/PDFPageView, to PDFPageProxy.render
Please note that the, pre-existing, viewer preference is already named `enableWebGL`; fixes 4919.
2018-02-13 16:56:56 +01:00
Jonas Jenwald
a1cfa5f4d7 Replace the disableTextLayer and enhanceTextSelection options/preferences with a single textLayerMode option/preference
Rather than having two different (but connected) options for the textLayer, I think that it makes sense to try and unify this. For example: currently if `disableTextLayer === true`, then the value of `enhanceTextSelection` is simply ignored.

Since PDF.js version `2.0` already won't be backwards compatible in lots of ways, I don't think that we need to worry about migrating existing preferences here.
2018-02-13 16:56:54 +01:00
Jonas Jenwald
3a6f6d23d6 Move the externalLinkTarget and externalLinkRel options to PDFLinkService options
This removes the `PDFJS.externalLinkTarget`/`PDFJS.externalLinkRel` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 14:28:40 +01:00
Jonas Jenwald
c45c394364 Move the imageResourcesPath option to a BaseViewer/PDFPageView/AnnotationLayerBuilder option
This removes the `PDFJS.imageResourcesPath` dependency from the viewer components and the test-suite, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 14:28:38 +01:00
Jonas Jenwald
fdf99c6af5 Move the maxCanvasPixels option to a BaseViewer/PDFPageView option
This removes the `PDFJS.maxCanvasPixels` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 13:42:03 +01:00
Jonas Jenwald
f4280368f7 Move the useOnlyCssZoom option to a BaseViewer/PDFPageView option
This removes the `PDFJS.useOnlyCssZoom` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
2018-02-13 13:42:03 +01:00
Jonas Jenwald
9e0a31f662 Move viewer 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 viewer 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-02-13 13:41:59 +01:00
Jonas Jenwald
90ab9bafff Remove the actual enableHandToolOnLoad preference (PR 9040 follow-up)
This should have been removed as part of PR 9040, but was simply overlooked.
2018-02-13 09:36:53 +01:00
Tim van der Meij
ea3d8450d2
Merge pull request #9473 from Snuffleupagus/DownloadManager-a-click
Remove the non-`a.click()` case from the `DownloadManager`
2018-02-12 22:16:48 +01:00
Jonas Jenwald
f05e5c5460 Take the dictionary, and not just the image data, into account when caching inline images (issue 9398)
The reason for the bug is that we're only computing a checksum of the image data itself, but completely ignore the inline dictionary. The latter is important, since in practice it's not uncommon for inline images to be identical but use e.g. different ColourSpaces.

There's obviously a couple of different ways that we could compute a hash/checksum of the dictionary.
Initially I tried using `MurmurHash3_64` to compute a hash of the keys/values in the dictionary. Unfortunately this approach turned out to be *way* too slow in practice, especially for PDF files with a huge number of inline images; in particular issue 2618 would regresses quite badly with this solution.

The solution that is instead implemented in this patch, is to compute a checksum of the dictionary contents. While this is a much simpler, not to mention a lot more efficient, solution there's one drawback associated with it:
If the contents of inline image dictionaries are ordered differently, they will not be considered equal with this approach which could thus lead to failures to cache repeated inline images. In practice this doesn't seem to be a problem in any of the PDF files I've tested, and generally I'd rather err on the side of *not* caching given that too aggressive caching can easily lead to rendering bugs.

One small, but somewhat annoying, complication is that by the time `Parser.makeInlineImage` is called, we no longer know the *exact* stream position where the inline image dictionary starts. Having access to that information is crucial here, and the easiest solution I could come up with is to track this in the current `Lexer` instance.[1]

With the patch, we're thus able to fix the referenced issues without incurring large regressions in problematic cases such as issue 2618.

Fixes 9398; also improves/fixes the `issue8823` reference test.

---

[1] Obviously I'd have preferred if this patch could be limited to `Parser.makeInlineImage`, without the need for this "hack", but I'm not sure what that'd look like here.
2018-02-12 16:43:47 +01:00
Jonas Jenwald
46fb55ceed Remove the non-a.click() case from the DownloadManager
With PDF.js version `2.0`, all the browsers we intend to support implements `a.click()`; see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/click#Browser_compatibility.
2018-02-12 12:50:04 +01:00
Jonas Jenwald
be2674a0e8
Merge pull request #9472 from timvandermeij/find-controller-methods
Improve the interface for `PDFFindController`
2018-02-12 12:47:38 +01:00
Tim van der Meij
909dfa254b
Move public methods above private methods in web/pdf_find_controller.js 2018-02-11 20:31:59 +01:00
Tim van der Meij
b1203bce97
Prefix private methods with an underscore in web/pdf_find_controller.js 2018-02-11 20:28:34 +01:00
Tim van der Meij
b3557483cb
Merge pull request #9465 from Snuffleupagus/streams-unify-disableRange-contentLength
Attempt to unify the `disableRange`/`contentLength` handling in the various network streams
2018-02-11 16:21:34 +01:00
Tim van der Meij
368a91b577
Merge pull request #9468 from Snuffleupagus/eslint-mozilla-plugin
Enable the `mozilla/avoid-removeChild` and `mozilla/use-includes-instead-of-indexOf` ESLint rules globally
2018-02-11 16:08:18 +01:00
Jonas Jenwald
1cf116ab88 Enable the mozilla/use-includes-instead-of-indexOf ESLint rule globally
This rule is available from https://www.npmjs.com/package/eslint-plugin-mozilla, and is enforced in mozilla-central. Note that we have the necessary `Array`/`String` polyfills and that most cases have already been fixed, see PRs 9032 and 9434.
2018-02-10 23:24:50 +01:00