Commit Graph

13014 Commits

Author SHA1 Message Date
Calixte Denizet
ce3d3a6ff8 Get urls if any in AA::D dictionary for pushbuttons 2020-10-15 19:42:36 +02:00
Tim van der Meij
a373137304
Merge pull request #12429 from calixteman/collect_js
[api-minor] Add the possibility to collect Javascript actions
2020-10-14 23:27:47 +02:00
Calixte Denizet
71ecc3129b Add the possibility to collect Javascript actions 2020-10-14 10:44:16 +02:00
Tim van der Meij
1034769ca1
Merge pull request #12477 from Snuffleupagus/SaveDocument-WorkerTask
Handle `WorkerTask`s, and various PDF document properties, correctly in the "SaveDocument" handler in `src/core/worker.js`
2020-10-13 21:11:54 +02:00
Tim van der Meij
0700a3de36
Merge pull request #12476 from Snuffleupagus/worker-rm-handler-scope
Remove the `scope` parameter from the "GetOperatorList" handler in `src/core/worker.js` (PR 11110 follow-up)
2020-10-13 21:08:48 +02:00
Jonas Jenwald
65132ba5d8 Handle WorkerTasks, and various PDF document properties, correctly in the "SaveDocument" handler in src/core/worker.js
- Actually register/unregister the `WorkerTask`s, used when saving each page, correctly.
   To prevent issues when terminating the Worker, we purposely wait for all running `WorkerTask`s to complete first. Hence we need to actually handle `WorkerTask`s the same way in "SaveDocument" as in the rest of this file, see e.g. "GetOperatorList" and "GetTextContent".

 - Access `PDFDocument` properties in a generally safe/consistent way.
   While the current code works fine, given how the PDF document is being loaded, it still seems like a very good idea to be *consistent* in how we access these kind of properties (since in general you need to avoid `MissingDataException` everywhere in this file).

 - Change a variable name, since there's essentially no precedent in the code-base for *local* variable names to start with an underscore.
2020-10-13 19:30:43 +02:00
Jonas Jenwald
38629c345d Remove the scope parameter from the "GetOperatorList" handler in src/core/worker.js (PR 11110 follow-up)
Support for the `scope` parameter, in `MessageHandler.on`, was removed in PR 11110 however this particular case was unused/unnecessary for years prior to that change. (From a quick look through the history, I'm not even sure if it was actually needed in the first place.)
2020-10-13 15:58:38 +02:00
Tim van der Meij
49791f55b3
Merge pull request #12470 from Snuffleupagus/webpack-5
Upgrade `webpack` to version 5
2020-10-11 14:50:32 +02:00
Jonas Jenwald
e7437a0b67 Use standard import statements when loading PDFViewerApplication/AppOptions in web/viewer
Given that we're no longer using SystemJS to load the `web/` files, see PR 11919, there's nothing that prevents us from using standard `ìmport` statements in this file.
Obviously it's still necessary to load part of the code conditionally on the build type, however this still allows us to clean-up and simplify at least some of this file.
2020-10-11 14:06:47 +02:00
Jonas Jenwald
666dd73ce8 Upgrade webpack to version 5
The only noticeable changes are that the built files are now *slightly* smaller, and that Webpack now supports optional chaining and nullish coalescing without the need for Babel plugins.
2020-10-11 10:23:38 +02:00
Tim van der Meij
e59a90d8e9
Merge pull request #12458 from Snuffleupagus/LocalTilingPatternCache
Add local caching of TilingPatterns in `PartialEvaluator.getOperatorList` (issue 2765 and 8473)
2020-10-08 22:47:13 +02:00
Jonas Jenwald
30e8d5dea1 Add local caching of TilingPatterns in PartialEvaluator.getOperatorList (issue 2765 and 8473)
In practice it's not uncommon for PDF documents to re-use the same TilingPatterns more than once, and parsing them is essentially equal to parsing of a (small) page since a `getOperatorList` call is required.

By caching the internal TilingPattern representation we can thus avoid having to re-parse the same data over and over, and there's also *less* asynchronous parsing required for repeated TilingPatterns.

Initially I had intended to include (standard) benchmark results with this patch, however it's not entirely clear that this is actually necessary here given the preliminary results.
When testing this manually in the development viewer, using `pdfBug=Stats`, the following (approximate) reduction in rendering times were observed when comparing `master` against this patch:
 - http://pubs.usgs.gov/sim/3067/pdf/sim3067sheet-2.pdf (from issue 2765): `6800 ms` -> `4100 ms`.
 - https://github.com/mozilla/pdf.js/files/1046131/stepped.pdf (from issue 8473): `54000 ms` -> `13000 ms`
 - https://github.com/mozilla/pdf.js/files/1046130/proof.pdf (from issue 8473): `5900 ms` -> `2500 ms`

As always, whenever you're dealing with documents which are "slow", there's usually a certain level of subjectivity involved with regards to what's deemed acceptable performance.
Hence it's not clear to me that we want to regard any of the referenced issues as fixed, however the improvements are significant enough to warrant caching of TilingPatterns in my opinion.
2020-10-08 18:43:21 +02:00
Tim van der Meij
99a2302d88
Merge pull request #12454 from Snuffleupagus/terser-5
Upgrade `terser` to version 5
2020-10-07 22:04:31 +02:00
Jonas Jenwald
3461eac7b8 Upgrade terser to version 5
The only significant change is that the `minify` command is now asynchronous, which we can handle easily by simply making the containing functions `async`.
Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function#Browser_compatibility, using `async`/`await` in the gulpfile should no longer be an issue as far as I can tell.
2020-10-07 14:38:17 +02:00
Tim van der Meij
fd1d9cc85f
Merge pull request #12451 from Snuffleupagus/acorn-8
Upgrade `acorn` to version 8
2020-10-06 22:03:03 +02:00
Jonas Jenwald
bc036c05bd Upgrade acorn to version 8
I've run `gulp mozcentral`, `gulp generic`, and `gulp generic-es5` with `master` respectively this patch and then diffed the build output. With the (obvious) exception of increased version/build numbers, there were no actual changes from the updated Acorn version.
2020-10-06 13:53:08 +02:00
Tim van der Meij
7ae3e13f16
Merge pull request #12450 from janpe2/cff-xuid
Fix invalid `XUID` entries in CFF fonts
2020-10-05 22:54:39 +02:00
Tim van der Meij
10e7623123
Merge pull request #12448 from Snuffleupagus/eslint-no-debugger-alert
Enable the ESLint `no-debugger` and `no-alert` rules
2020-10-05 22:47:31 +02:00
Jani Pehkonen
935568c2f1 Fix invalid XUID entries in CFF fonts
In CFF fonts, entry `XUID` should be an array that has no more than
16 elements. In the issue, the length is 20, which causes the fonts to fail.
See Appendix B, "Implementation Limits" in PostScript Language Reference Manual
https://web.archive.org/web/20170218093716/https://www.adobe.com/products/postscript/pdfs/PLRM.pdf
Actually entries `XUID` and `UniqueID` are obsolete altogether.
https://blogs.adobe.com/CCJKType/2016/06/no-more-xuid-arrays.html
2020-10-05 17:38:01 +03:00
Jonas Jenwald
ba079453bf Enable the ESLint no-debugger and no-alert rules
The `debugger`-statement would only, potentially, make sense during development and we thus want to prevent it from being accidentally included when landing code.
The `alert`, `confirm`, and `prompt` functions should generally be avoided, with the few intended cases manually allowed.

Please find additional details about the ESLint rules at:
 - https://eslint.org/docs/rules/no-debugger
 - https://eslint.org/docs/rules/no-alert
2020-10-05 13:41:06 +02:00
Tim van der Meij
b3e32e2001
Merge pull request #12446 from Snuffleupagus/firefox-print-RenderingCancelledException
[Firefox] Stop logging `RenderingCancelledException`s as errors when printing
2020-10-04 23:38:31 +02:00
Tim van der Meij
a1028e2b9b
Merge pull request #12445 from timvandermeij/packages
Upgrade minor/major versions of dependencies that don't require code changes
2020-10-04 23:27:22 +02:00
Tim van der Meij
505f14e816
Upgrade minor/major versions of dependencies that don't require code changes
The changelogs of those dependencies showed no breaking changes for us.
Most of the time the major version bump was done to remove compatibility
with very outdated Node.js versions.

Only for `autoprefixer` and `gulp-postcss` a change was required, which
is including `postcss` in our `package.json` explicitly since it's now
a peer dependency of those packages.

Now only `acorn`,`systemjs`, `terser` and `yargs` are not the latest
versions because they require more work.
2020-10-04 20:26:59 +02:00
Jonas Jenwald
069ddc8686 [Firefox] Stop logging RenderingCancelledExceptions as errors when printing
In the rest of the viewer code-base, we purposely don't treat `RenderingCancelledException`s as actual errors (since they aren't) and consequently we never log them.
Hence it makes sense, as far as I'm concerned, to simply treat `RenderingCancelledException`s the same way when printing in Firefox.

While I don't print a whole lot, I cannot remember seeing these "errors" logged when printing until *very* recently[1]. Given that the browser print functionality and UI, in Firefox, is under active development it's certainly possible that there's some recent changes to the related timings which make `RenderingCancelledException`s more likely now.

---
[1] Interestingly, only some PDF documents seem to be affected as well; I'm able to reproduce this pretty consistently by opening https://www.uni-muenster.de/imperia/md/content/ziv/pdf/printpay_flyer.pdf in Firefox and then repeating the following sequence:
Clicking on the PDF.js print button, and then cancelling printing.
2020-10-04 20:25:31 +02:00
Tim van der Meij
e0c80a3556
Remove the fancy-log dependency
This dependency hasn't been updated in two years and the only place that
uses it is the `externaltest` target in the Gulpfile. We can simply
replace `fancy-log` usage there with `console.log` like we do in all
other places in the Gulpfile because we're not interested in the
timestamps here. Gulp already prints timestamps and these tests finish
within a second anyway.

Note that it remains in `package-lock.json` because other Gulp-related
packages have it as a dependency, but at least we're no longer depending
on it directly anymore now.
2020-10-04 17:30:39 +02:00
Tim van der Meij
910772cfcf
Merge pull request #12444 from Snuffleupagus/update-packages
Update packages and translations
2020-10-04 16:15:44 +02:00
Jonas Jenwald
c5a1a6fdd5 Remove now unnecessary no-unsanitized/method disabling in test/unit/jasmine-boot.js
With the latest release of the `eslint-plugin-no-unsanitized` package, we no longer need to disable this rule; see https://github.com/mozilla/eslint-plugin-no-unsanitized/pull/150
2020-10-04 15:30:24 +02:00
Jonas Jenwald
ffb0bb885c Update l10n files 2020-10-04 15:30:24 +02:00
Jonas Jenwald
082e7b5200 Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2020-10-04 15:30:24 +02:00
Jonas Jenwald
522c93b916 Update npm packages 2020-10-04 15:30:23 +02:00
Tim van der Meij
47131707bc
Merge pull request #12442 from timvandermeij/upgrade-puppeteer
Upgrade Puppeteer to version 5.3.1
2020-10-04 15:01:09 +02:00
Tim van der Meij
c10aac9a1d
Upgrade Puppeteer to version 5.3.1 2020-10-03 23:06:31 +02:00
Tim van der Meij
2823beba69
Merge pull request #12441 from Snuffleupagus/src-eslint-config
Re-factor how the ESLint `no-var` rule is enabled in the `src/` folder
2020-10-03 22:36:13 +02:00
Jonas Jenwald
9416b14e8b Re-factor how the ESLint no-var rule is enabled in the src/ folder
This simplifies/consolidates the ESLint configuration slightly in the `src/` folder, and prevents the addition of any new files where `var` is being used.[1]
Hence we no longer need to manually add `/* eslint no-var: error */` in files, which is easy to forget, and can instead disable the rule in the `src/core/` files where `var` is still in use.

---
[1] Obviously the `no-var` rule can, in the same way as every other rule, be disabled on a case-by-case basis where actually necessary.
2020-10-03 20:15:29 +02:00
Tim van der Meij
48e27a1a22
Merge pull request #12437 from Snuffleupagus/src-display-no-var
Enable the ESLint `no-var` rule in the `src/display/` folder
2020-10-03 19:59:56 +02:00
Tim van der Meij
6ff1fe4ea9
Merge pull request #12333 from calixteman/tooltip
Add tooltip if any in annotations layer
2020-10-03 19:50:39 +02:00
Tim van der Meij
76e96d4364
Merge pull request #12436 from Snuffleupagus/src-shared-no-var
Enable the ESLint `no-var` rule in the `src/shared/` folder
2020-10-03 18:47:13 +02:00
Tim van der Meij
d86546e14c
Merge pull request #12439 from Snuffleupagus/viewer-version-build
Add `version`/`build` info at the top of the *built* `web/viewer.js` file
2020-10-03 18:39:54 +02:00
Jonas Jenwald
eb0cc7f9c3 Add version/build info at the top of the *built* web/viewer.js file
This should be helpful to easily determine the *exact* version of the viewer itself, when looking at a *built* `web/viewer.js` file.
Note that we're already including this information in other built files, such as e.g. `pdf.js`, `pdf.worker.js`, `pdf_viewer.js`, and `pdf.image_decoders.js`.
2020-10-03 09:19:53 +02:00
Jonas Jenwald
2a7d1557f9 Enable the ESLint no-var rule in the src/shared/ folder
Previously this rule has been enabled in the `web/` folder, and in select files in the `src/` sub-folders.
In this case, enabling of this rule didn't actually require any further code changes.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-var
2020-10-03 08:27:45 +02:00
Jonas Jenwald
52f6016e6c Fix the remaining ESLint no-var errors in the src/display/ folder
While most of necessary changes were fixed automatically, see the previous patch, there's a number of cases that needed to be fixed manually.
2020-10-02 16:29:13 +02:00
Jonas Jenwald
e557be5a17 Re-format the src/display/ files to enforce the ESLint no-var rule
This was done automatically, using `gulp lint --fix`.
2020-10-02 16:17:28 +02:00
Jonas Jenwald
2a8983d76b Enable the ESLint no-var rule in the src/display/ folder
Previously this rule has been enabled in the `web/` folder, and in select files in the `src/` sub-folders.
Note that a number of the files in the `src/display/` folder were already enforcing the `no-var` rule, and thanks to Prettier the necessary re-writing will be (mostly) handled automatically.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-var
2020-10-02 16:16:23 +02:00
calixteman
20b12d2bda Add tooltip if any in annotations layer 2020-10-02 10:11:18 +02:00
Tim van der Meij
88f72d6b1c
Merge pull request #12426 from Snuffleupagus/app-triggerPrinting
Re-factor how printing is triggered in the default viewer
2020-09-30 22:12:42 +02:00
Tim van der Meij
8e7a6e010d
Merge pull request #12419 from Snuffleupagus/fallbackToSystemFont-cidToGidMap
Use the `cidToGidMap`, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418)
2020-09-30 21:53:16 +02:00
Jonas Jenwald
89ce326d12 Re-factor how printing is triggered in the default viewer
This adds a new `PDFViewerApplication.triggerPrinting` method, which takes care of checking that printing is actually supported before calling `window.print`, to remove the need to duplicate that code in multiple places.

Also, removes the `PDFViewerApplication.printing` getter since it's not really necessary any more.
2020-09-30 15:10:19 +02:00
Tim van der Meij
d49b2f6cc2
Merge pull request #12422 from Snuffleupagus/find-not-shiftKey
Don't trigger searching, in the `GENERIC` viewer, when <kbd>Shift</kbd> is used together with the regular keyboard shortcut (issue 12421)
2020-09-29 22:30:53 +02:00
Tim van der Meij
8fa4e48f46
Merge pull request #12423 from Snuffleupagus/escodegen-2
Update `escodegen` to version 2.0
2020-09-29 22:27:42 +02:00
Jonas Jenwald
db4cefbac3 Add basic support for the optional chaining operator ?.
For now we need to use a Babel-plugin, since part of our build system doesn't support this fully (e.g. Babel-loader, Webpack 4.x, and SystemJS).

While the `?.` operator will thus always be transpiled by Babel, even in modern builds, simply supporting it for development purposes seems like a step in the right direction.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
2020-09-29 15:56:34 +02:00