Commit Graph

10585 Commits

Author SHA1 Message Date
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
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
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
Jonas Jenwald
2eb29409bc Enable the mozilla/avoid-removeChild 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 a polyfill for `ChildNode.remove()` and that most cases have already been fixed, see PRs 8056 and 8138.
2018-02-10 23:24:50 +01:00
Tim van der Meij
9767b8a9f1
Merge pull request #9453 from Snuffleupagus/upstream-bug-1432992
Upstream the changes from: Bug 1432992 - Remove definitions of Ci, Cr, Cc, and Cu
2018-02-10 20:10:11 +01:00
Tim van der Meij
f1413a9096
Merge pull request #9466 from Snuffleupagus/refactor-PDFThumbnailViewer-scrollThumbnailIntoView
Refactor `PDFThumbnailViewer.scrollThumbnailIntoView` to avoid unnecessary DOM look-ups
2018-02-09 22:17:25 +01:00
Tim van der Meij
7bb066494f
Merge pull request #9427 from Snuffleupagus/native-JPEG-decoding-fallback
Fallback to the built-in JPEG decoder when browser decoding fails, and attempt to handle JPEG images with DNL (Define Number of Lines) markers (issue 8614)
2018-02-09 21:36:08 +01:00
Jonas Jenwald
82416d4b19 Refactor PDFThumbnailViewer.scrollThumbnailIntoView to avoid unnecessary DOM look-ups
The code responsible for highlighting/scrolling thumbnails is quite old, and parts of it hasn't really changed much over time.
In particular, the `scrollThumbnailIntoView` method is currently using `document.querySelector` in order to find both the new/current thumbnail element. This seems totally unnessary, since we can easily keep track of the current thumbnail (similar to the "regular" viewer) and thus avoid unnecessary DOM look-ups.

Furthermore, note how the `PDFThumbnailView` constructor is currently highlighting the *first* thumbnail. This is yet another leftover from older viewer code, which we can now remove and instead take care of in `PDFThumbnailViewer.setDocument`.
Given that `PDFThumbnailView` does not, nor should it, have any concept of which thumbnail is currently selected, this change also improves the general structure of this code a tiny bit.
2018-02-09 14:43:11 +01:00
Jonas Jenwald
ad06979cca Attempt to unify the disableRange/contentLength handling in the various network streams
First of all, note how in both `fetch_stream.js` and `node_stream.js` we always overwrite the `this._contentLength` property even when the response headers doesn't actually contain any (valid) length information. This could thus result in the `length` parameter, as passed to the network stream, being completely ignored despite having no better information available.
Secondly, in `node_stream.js` the `this._isRangeSupported` property wasn't always updated correctly based on the response headers.
2018-02-09 13:50:48 +01:00
Jonas Jenwald
59028bac42 Upstream the changes from: Bug 1432992 - Remove definitions of Ci, Cr, Cc, and Cu
Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1432992
 - https://hg.mozilla.org/integration/autoland/rev/b38d59f71915
2018-02-09 12:49:02 +01:00
Jonas Jenwald
25293628ff
Merge pull request #9459 from tonyjin/respect-worker-src
Respect workerSrc if set
2018-02-08 13:57:43 +01:00
Jonas Jenwald
15c932c9e4
Merge pull request #9460 from Snuffleupagus/issue-9458
Use the correct stream position when reading `maxSizeOfInstructions` from the `maxp` table (issue 9458)
2018-02-08 09:09:32 +01:00
Jonas Jenwald
a18c65ae9f Use the correct stream position when reading maxSizeOfInstructions from the maxp table (issue 9458)
Please refer to the `maxp` table specification, found at https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6maxp.html.

Fixes 9458.
2018-02-07 21:57:43 +01:00
Tony Jin
3c33f32dff Respect workerSrc if set
Respect user-defined workerSrc over internal overrides.
2018-02-07 11:31:18 -08:00
Brendan Dahl
43f1f96b10
Merge pull request #9447 from Rob--W/crx-fetch-expose-headers
Expose some headers to fetch requests from the PDF.js Chrome extension
2018-02-06 16:58:44 -08:00
Rob Wu
352389c0c6 [CRX] Expose some headers to fetch requests 2018-02-06 15:06:02 +01:00
Jonas Jenwald
bf4166e6c9 Attempt to handle DNL (Define Number of Lines) markers when parsing JPEG images (issue 8614)
Please refer to the specification, found at https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=49

Given how the JPEG decoder is currently implemented, we need to know the value of the scanLines parameter (among others) *before* parsing of the SOS (Start of Scan) data begins.
Hence the best solution I could come up with here, is to re-parse the image in the *hopefully* rare case of JPEG images that include a DNL (Define Number of Lines) marker.

Fixes 8614.
2018-02-05 21:05:32 +01:00
Jonas Jenwald
80441346a3 Fallback to the built-in JPEG decoder if 'JpegStream', in src/display/api.js, fails to load the image
This works by making `PartialEvaluator.buildPaintImageXObject` wait for the success/failure of `loadJpegStream` on the API side *before* parsing continues.

Please note that in practice, it should be quite rare for the browser to fail loading/decoding of a JPEG image. In the general case, it should thus not be completely surprising if even `src/core/jpg.js` will fail to decode the image.
2018-02-05 21:05:31 +01:00
Jonas Jenwald
76afe1018b Fallback to built-in image decoding if the NativeImageDecoder fails
In particular this means that if 'JpegDecode', in `src/display/api.js`, fails we'll fallback to the built-in JPEG decoder.
2018-02-05 17:01:35 +01:00
Jonas Jenwald
2570717e77 Inline the code in loadJpegStream at the only call-site in src/display/api.js.js`
Since `loadJpegStream` is only used at a *single* spot in the code-base, and given that it's very heavily tailored to the calling code (since it relies on the data structure of `PDFObjects`), this patch simply inlines the code in `src/display/api.js` instead.
2018-02-05 17:01:35 +01:00
Jonas Jenwald
7f73fc9ace Re-factor PartialEvaluator.buildPaintImageXObject to make it asynchronous
This is necessary for upcoming changes, which will add fallback code-paths to allow graceful handling of native image decoding failures.
2018-02-05 17:01:35 +01:00
Jonas Jenwald
ec85d5c625 Change the signature of PartialEvaluator.buildPaintImageXObject to take a parameter object
This method currently requires a fair number of parameters, which creates quite	unwieldy call-sites. When invoking `buildPaintImageXObject`, you have to remember not only which arguments to supply, but also the correct order, to prevent run-time errors.
2018-02-05 17:01:35 +01:00
Jonas Jenwald
6b7e2cbcd1
Merge pull request #9439 from Rob--W/print-event-comment
Update comment regarding beforeprint event support
2018-02-05 15:49:00 +01:00
Rob Wu
a967f31950 Update comment regarding beforeprint event support
"beforeprint" / "afterprint" are standard features these days,
and Chrome added support for it in Chrome 63:
https://www.chromestatus.com/feature/5700595042222080
2018-02-05 14:51:20 +01:00
Jonas Jenwald
77135a2bc4 [Firefox addon] Adjust the minVersion numbers in install.rdf and update.rdf
After the latest update of the minimum supported Firefox version, the development addon is no longer being signed. Hence this patch attempts to address that, by pinning the `minVersion` to a specific version number instead.

*Please note:* The version numbers were taken from https://addons.mozilla.org/en-US/firefox/pages/appversions/, so it ought to have worked.
2018-02-05 13:56:34 +01:00
Jonas Jenwald
0de49ed1e2 Update l10n files 2018-02-05 12:23:54 +01:00
Tim van der Meij
4e40a341a1
Merge pull request #9436 from timvandermeij/examples
Use `setPDFNetworkStreamFactory` in the `helloworld` and `svgviewer` examples
2018-02-04 19:38:46 +01:00
Tim van der Meij
1f9878ea71
Use setPDFNetworkStreamFactory in the helloworld and svgviewer examples
This patch fixes a regression from #9363, causing the examples not to
load anymore.
2018-02-04 19:32:47 +01:00
Tim van der Meij
24f96e0f71
Merge pull request #9435 from Rob--W/content-disposition-quoted-string-semi-space
Support spaces and semicolons in filename (Content-Disposition)
2018-02-04 19:15:31 +01:00
Rob Wu
911659cd70 Add tests for file names with spaces and semicolons 2018-02-04 17:58:10 +01:00
Tim van der Meij
db9f71fe6b
Merge pull request #9433 from Snuffleupagus/addon-minimum-nightly
[Firefox addon] Change the minimum supported version to Firefox Nightly, and remove no longer needed fallback code
2018-02-04 16:24:39 +01:00
Rob Wu
2f19d9d906 Support spaces and semicolons in filename
Imports the following changes:
5b1afa7c29
7e2e35a38b
2018-02-04 16:19:40 +01:00
Tim van der Meij
7fbeeebbff
Merge pull request #9434 from Snuffleupagus/upstream-bug-1339461
Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this
2018-02-04 16:12:03 +01:00
Jonas Jenwald
712090eff8 Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this
Yet another case where PDF.js code was modified in `mozilla-central` without the changes happening in the GitHub repo first; *sigh*.
If we don't upstream at least the changes in `extensions/firefox/`, any future update of PDF.js in `mozilla-central` will be blocked.

Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1339461
 - https://hg.mozilla.org/mozilla-central/rev/d5a5ad1dbbf2
2018-02-04 14:59:27 +01:00
Jonas Jenwald
9ac9ef8ef1 Polyfill String.prototype.includes using core-js
See https://github.com/zloirock/core-js#ecmascript-6-string.
2018-02-04 14:31:59 +01:00
Jonas Jenwald
986c8b56ca Update the eslint-plugin-mozilla package to the latest version
With the updated compatibility for the addon, we can thus remove a few no longer needed exceptions from `extensions/firefox/.eslintrc`.
2018-02-04 14:07:18 +01:00
Jonas Jenwald
4db49b6613 Upstream the changes from: Bug 1431533 - Add ChromeUtils helpers for lazy module import
Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1431533
 - https://hg.mozilla.org/mozilla-central/rev/e6a7b5e11ba8
 - https://groups.google.com/forum/#!topic/mozilla.dev.platform/xQaTdsrbd-g
2018-02-04 14:07:18 +01:00
Jonas Jenwald
08b2e25ac1 [Firefox addon] Remove no longer needed fallback code for older versions of Firefox 2018-02-04 14:07:18 +01:00
Jonas Jenwald
d1ffd61093 [Firefox addon] Change the minimum supported version to (the current) Firefox Nightly release
At this point in time, trying to keep the development addon compatible with prior Firefox versions is already quite difficult and will become even harder very soon.

Please keep in mind that since Firefox 57, only WebExtensions are allowed/possible to install. The only exceptions are Firefox Nightly, with the `xpinstall.signatures.required` preference[1] set to `false`, and the (as of this writing) current ESR release.[2]

With the current compatibility situation, we thus need to effectively support both Nightly *and* ESR in the addon, while trying to keep up with current/upcoming changes in `mozilla-central`. With old addons no longer being officially supported, the amount of old code being removed/refactored is now increasing quite quickly.

*Please note:* The changes proposed here was to a large extent prompted by bugs such as:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1431533 (already landed)
 - https://bugzilla.mozilla.org/show_bug.cgi?id=767640 (already landed)
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1432992 (still open)

Upstreaming all of those changes for the `MOZCENTRAL` version of PDF.js, while also keeping the Firefox addon running in older versions of the browser, would quickly become non-trivial.
Since we're using the ruleset from `eslint-plugin-mozilla` for the addon files, which is enforced in `mozilla-central`, we must ensure that the neccessary changes are upstreamed to the PDF.js repo such that the `mozilla-central` version of PDF.js can still be updated without failures.

Trying to feature detect, for the `FIREFOX` build target, some of the changes in the referenced bugs would probably become both quite messy and (not to mention) difficult. E.g. with the upcoming and automatically defined `Cc, Ci, Cu, Cr` variables, any sort of feature detection might be tricky since those need to be defined in the global scope of the files in question.

Finally, given the amount of effort that we'd now need to spend to even attempt to keep the Firefox addon compatible, I just don't think it's worth the effort any more. Especially since the number of people that have, thus far, been doing this work is *very* low and those resources would be better spend elsewhere.
Unfortunately, this probably means that the development addon will no longer be compatible with release versions of Seamonkey. However the README has already mentioned, for quite some time, that support isn't guaranteed.

*In closing:* For all of the reasons mentioned above, I thus propose that we reduce the maintenance burden of the Firefox addon by only supporting the current Firefox Nightly.

---

[1] While the preference exists, and can be toggled, its value is ignored in non-Nightly versions of Firefox.

[2] There's unbranded builds of e.g. the release/beta versions of Firefox, where old and non-WebExtensions addons can be installed. However those builds can probably be assumed to be officially unsupported, and thus not recommended for users.
2018-02-04 14:07:17 +01:00
Jonas Jenwald
d42541d26b
Merge pull request #9412 from timvandermeij/crypto
Implement the `AESBaseCipher` class and let the `AES128Cipher` and `AES256Cipher` classes extend it
2018-02-04 09:33:37 +01:00
Tim van der Meij
73436c0d12
Implement the AESBaseCipher class and let the AES128Cipher and AES256Cipher classes extend it 2018-02-03 20:16:33 +01:00
Tim van der Meij
9a959e4df7
Update the AES128Cipher and AES256Cipher implementations to be more similar
This commit is the first step for extracting a base class for the
`AES128Cipher` and the `AES256Cipher` classes. The objective here is to
make code changes (not altering the logic) to make the implementations
as similar as possible as found by creating a diff of both classes.

In particular, we extract the key size and cycles of repetitions
constants since they are different for AES-128 and AES-256. Moreover, we
rename functions to be similar.

In the `AES256Cipher` class, there was an additional assignment to
`this` in the decryption function. However, this was unnecessary because
the assignment would also be done when the loop was exited.
2018-02-03 20:16:29 +01:00
Tim van der Meij
695a909a93
Merge pull request #9426 from Snuffleupagus/issue-9425
Attempt to find the next valid marker when encountering invalid image data in `JpegImage.parse` (issue 9425)
2018-02-03 18:46:38 +01:00