Commit Graph

13902 Commits

Author SHA1 Message Date
Tim van der Meij
2e9c2ab3b8
Merge pull request #13297 from Snuffleupagus/webpack-example-minification-warning
Add a note about minification to the webpack-example README (issue 13290)
2021-04-25 17:38:32 +02:00
Jonas Jenwald
24aae858b9 Add a note about minification to the webpack-example README (issue 13290)
Since we really don't want to let a particular Webpack-mode dictate how we can/can't write code, let's add a note in the webpack-example README about minification instead.
2021-04-25 17:20:57 +02:00
Tim van der Meij
ab2428270f
Merge pull request #13291 from Snuffleupagus/rm-forEach
Replace a bunch of `Array.prototype.forEach()` cases with `for...of` loops instead
2021-04-24 20:08:51 +02:00
Jonas Jenwald
4078dd856c Clear some Arrays, rather than re-initialize them, in src/display/-code
It's generally better to re-use the same Array, by clearing out all of its elements, rather than creating a new Array.
2021-04-24 13:00:53 +02:00
Jonas Jenwald
da22146b95 Replace a bunch of Array.prototype.forEach() cases with for...of loops instead
Using `for...of` is a modern and generally much nicer pattern, since it gets rid of unnecessary callback-functions. (In a couple of spots, a "regular" `for` loop had to be used.)
2021-04-24 13:00:19 +02:00
Tim van der Meij
da0e7ea969
Merge pull request #13272 from calixteman/issue13271
Update all the text widgets having the same name with the same value
2021-04-23 21:08:54 +02:00
Tim van der Meij
a6e3ad4c72
Merge pull request #13283 from Snuffleupagus/NameOrNumberTree-getAll-map
Change `NameOrNumberTree.getAll` to return a `Map` rather than an Object
2021-04-23 20:53:52 +02:00
calixteman
762cfd2d1b
[JS] Use heap allocation when initializing quickjs sandbox (#13286)
- In case of large string the sandbox initialization failed because of an OOM
    * so allocate a new string in the heap
    * and free it after use.
  - it requires a quickjs update since we need to export some symbols (stringToNewUTF8 and free).
2021-04-23 12:04:14 +02:00
Jonas Jenwald
4ec0a4fb43 Re-factor the Catalog._collectJavaScript method slightly
This patch first of all moves all checking/validation into the `appendIfJavaScriptDict` function, to avoid duplicating it in multiple places. Secondly, also removes what's now an outdated/incorrect comment since we have implemented scripting support.
2021-04-23 09:42:32 +02:00
Jonas Jenwald
83f7009e4b Change NameOrNumberTree.getAll to return a Map rather than an Object
Given that we're (almost) always iterating through the result of the `getAll`-calls, using a `Map` seems nicer overall since it's more suited to iteration compared to a regular Object.

Also, add a couple of `Dict`-checks in existing code touched by this patch, since it really cannot hurt to prevent *potential* errors in a corrupt PDF document.
2021-04-22 13:15:50 +02:00
Jonas Jenwald
57a1ea840f
Ensure that saveDocument works if there's no /ID-entry in the PDF document (issue 13279) (#13280)
First of all, while it should be very unlikely that the /ID-entry is an *indirect* object, note how we're using `Dict.get` when parsing it e.g. in `PDFDocument.fingerprint`. Hence we definitely should be consistent here, since if the /ID-entry is an *indirect* object the existing code in `src/core/writer.js` would already fail.
Secondly, to fix the referenced issue, we also need to check that the /ID-entry actually is an Array before attempting to access its contents in `src/core/writer.js`.

*Drive-by change:* In the `xrefInfo` object passed to the `incrementalUpdate` function, re-name the `encrypt` property to `encryptRef` since its data is fetched using `Dict.getRaw` (given the names of the other properties fetched similarly).
2021-04-22 12:08:56 +02:00
Jonas Jenwald
8538cdf845
Update Puppeteer to version 9 (#13282)
* Update Puppeteer to version 9

Hopefully the updated Chromium-version might help reduce the number of intermittent test failures.

Please find additional information at https://github.com/puppeteer/puppeteer/releases/tag/v9.0.0

* Update the `eslint-plugin-sort-exports`/`eslint-plugin-unicorn"` packages to their latest versions

Both of these ESLint plugins have increased their version numbers, however `npm update` doesn't handle this automatically.

https://www.npmjs.com/package/eslint-plugin-sort-exports
https://www.npmjs.com/package/eslint-plugin-unicorn
2021-04-22 11:35:16 +02:00
Tim van der Meij
2d073b91b8
Merge pull request #13263 from Snuffleupagus/font-tests-rm-done
Replace `done` callbacks in the font-tests with async/await instead
2021-04-21 21:07:44 +02:00
Brendan Dahl
066cbcfb27
Merge pull request #13277 from Snuffleupagus/adjustToUnicode-cff
For CFF fonts without proper `ToUnicode`/`Encoding` data, utilize the "charset"/"Encoding"-data from the font file to improve text-selection (issue 13260)
2021-04-21 10:41:36 -07:00
Brendan Dahl
5231d922ec
Add presentation role to text layer spans. (#13278)
Keeps screen readers from pausing on every span so
paragraphs are read more naturally. Note: this only seems
to affect Firefox, Chrome automatically combines the spans.
2021-04-21 10:47:51 +02:00
Jonas Jenwald
7b8d2495ca Convert the font-test ttx helper function to use the Fetch API
By replacing `XMLHttpRequest` with a `fetch` call, the helper function can be modernized to use async/await instead.
Note that the headers doesn't seem necessary to set now, since:
 - The Fetch API provides a method for accessing the response as *text*, which renders the "Content-type" header unnecessary.
 - According to https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name, the "Content-length" header isn't necessary.
2021-04-20 23:44:15 +02:00
Tim van der Meij
b0d58efb6a
Merge pull request #13275 from Snuffleupagus/loadResources-Properties
Ensure that the /Properties, used with optional content, is actually loaded *before* parsing the operatorList/textContent (PR 12095 follow-up)
2021-04-20 21:45:39 +02:00
Jonas Jenwald
7fab73ed23 For CFF fonts without proper ToUnicode/Encoding data, utilize the "charset"/"Encoding"-data from the font file to improve text-selection (issue 13260)
This patch extends the approach, implemented in PR 7550, to also apply to CFF fonts.
2021-04-20 20:48:44 +02:00
Jonas Jenwald
8f6543c218 Ensure that the /Properties, used with optional content, is actually loaded *before* parsing the operatorList/textContent (PR 12095 follow-up)
By not waiting for the /Properties to load, before parsing of the operatorList/textContent starts, there's a very real risk that a `MissingDataException` will be thrown when trying to access the data in the `PartialEvaluator.parseMarkedContentProps` method.
If this ever happens it will thus lead to incomplete and/or outright broken rendering, and with e.g. `disableAutoFetch=true` set the likelihood of this occuring would increase quite a bit.

*Please note:* While I've not yet seen this error in an actual PDF document, it can happen during loading if you're unlucky enough with e.g. the structure of the PDF document and/or the download speed offered by the server.
2021-04-20 20:22:44 +02:00
Calixte Denizet
e868ab0051 Update all the text widgets having the same name with the same value 2021-04-20 20:03:19 +02:00
Jonas Jenwald
3d55b2b10e Replace done callbacks in the font-tests with async/await instead 2021-04-19 13:26:39 +02:00
Tim van der Meij
fd82adccfa
Merge pull request #13256 from timvandermeij/unit-test-async-await-pt4
Convert done callbacks to async/await in the last two unit test files
2021-04-18 14:25:40 +02:00
Tim van der Meij
d42f3d0bfe
Convert done callbacks to async/await in test/unit/evaluator_spec.js 2021-04-18 14:20:54 +02:00
Tim van der Meij
692304247c
Merge pull request #13258 from Snuffleupagus/update-packages
Update packages and translations
2021-04-18 14:19:51 +02:00
Jonas Jenwald
d3ed3761bc Update l10n files 2021-04-18 11:24:51 +02:00
Jonas Jenwald
cfa42cb0f2 Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2021-04-18 11:05:52 +02:00
Jonas Jenwald
fc007028a2 Update npm packages 2021-04-18 11:02:42 +02:00
Tim van der Meij
f4237d3a09
Convert done callbacks to async/await in test/unit/annotation_spec.js 2021-04-17 19:59:18 +02:00
Tim van der Meij
c86e70ba08
Merge pull request #13253 from timvandermeij/unit-test-async-await-pt3
Convert done callbacks to async/await in `test/unit/api_spec.js`
2021-04-17 18:11:08 +02:00
Tim van der Meij
c2f3a71eca
Convert done callbacks to async/await in test/unit/api_spec.js 2021-04-17 17:52:23 +02:00
Tim van der Meij
dd7f04ea2e
Merge pull request #13254 from Snuffleupagus/scripting-misc-fixes
A couple of small scripting/XFA-related tweaks in the worker-code
2021-04-17 12:32:32 +02:00
Jonas Jenwald
f560fe6875 A couple of small scripting/XFA-related tweaks in the worker-code
- Use `PDFManager.ensureDoc`, rather than `PDFManager.ensure`, in a couple of spots in the code. If there exists a short-hand format, we should obviously use it whenever possible.

 - Fix a unit-test helper, to account for the previous changes. (Also, converts a function to be `async` instead.)

 - Add one more exists-check in `PDFDocument.loadXfaFonts`, which I missed to suggest in PR 13146, to prevent any possible errors if the method is ever called in a situation where it shouldn't be.
   Also, print a warning if the actual font-loading fails since that could help future debugging. (Finally, reduce overall indentation in the loop.)

 - Slightly unrelated, but make a small tweak of a comment in `src/core/fonts.js` to reduce possible confusion.
2021-04-17 10:34:22 +02:00
Brendan Dahl
ac3fa1e3d7
Merge pull request #13146 from calixteman/xfa_fonts
XFA -- Load fonts permanently from the pdf
2021-04-16 12:55:12 -07:00
Tim van der Meij
6db10d159a
Merge pull request #13250 from Snuffleupagus/rm-_delayedFallback
Remove the `PDFViewerApplication._delayedFallback` functionality
2021-04-16 20:38:22 +02:00
Tim van der Meij
ad2afab585
Merge pull request #13249 from Snuffleupagus/rm-generic-signature-warn
[GENERIC viewer] Don't display the `errorWrapper`, for documents with signatures (PR 13217 follow-up)
2021-04-16 20:36:52 +02:00
Tim van der Meij
6e8ff2fed9
Merge pull request #13247 from Snuffleupagus/update-yargs
Update the `yargs` package to the latest version
2021-04-16 20:33:45 +02:00
Tim van der Meij
cba6a3f375
Merge pull request #13246 from timvandermeij/unit-test-async-await-pt2
Convert done callbacks to async/await in more unit test files
2021-04-16 20:24:53 +02:00
Jonas Jenwald
c988712bc5 Update the yargs package to the latest version
While I wasn't able to figure out *exactly* why the old format didn't work, re-factoring the `parseOptions` function to use `yargs` differently "just worked" so that's hopefully good enough here.
With these changes everything related to a *particular* option now appears in one place, rather than being spread out, which aids readability in my opinion. Also, the options are now sorted alphabetically, to make it easier to find a particular one.

https://www.npmjs.com/package/yargs
2021-04-16 12:04:35 +02:00
Jonas Jenwald
4ef187e903 Remove the PDFViewerApplication._delayedFallback functionality
According to a decision by UX and PM, please see https://bugzilla.mozilla.org/show_bug.cgi?id=1705060#c2 (and implemented in https://bugzilla.mozilla.org/show_bug.cgi?id=1705327), we no longer show the notification-bar in Firefox; hence the special `PDFViewerApplication._delayedFallback` functionality should no longer be necessary.
Furthermore, note that at this point in time *most* of the features which used the `PDFViewerApplication._delayedFallback` functionality is now enabled by default; hence that provides even less reason to keep this code around and existing calls are thus converted to "regular" `PDFViewerApplication.fallback` calls.
2021-04-16 10:16:48 +02:00
Jonas Jenwald
a6e29ab43c Remove the special handling of "errorFontLoadNative" and "errorFontMissing" in PDFViewerApplication.fallback (PR 12931 follow-up, PR 12995 follow-up)
According to a decision by UX and PM, please see https://bugzilla.mozilla.org/show_bug.cgi?id=1705060#c2 (and implemented in https://bugzilla.mozilla.org/show_bug.cgi?id=1705327), we no longer show the notification-bar in Firefox.
Hence there's (obviously) no need to ignore certain `featureId`s in `PDFViewerApplication.fallback` anymore.
2021-04-16 09:54:02 +02:00
Jonas Jenwald
7d7a8a1a3c [GENERIC viewer] Don't display the errorWrapper, for documents with signatures (PR 13217 follow-up)
According to a decision by UX and PM, please see https://bugzilla.mozilla.org/show_bug.cgi?id=1705060#c2, in Firefox we should first of all *not* display the notification-bar for signatures. Secondly, as can also be seen there, we shouldn't display the notification-bar *at all* and it's thus disabled in https://bugzilla.mozilla.org/show_bug.cgi?id=1705327.

If we purposely don't display a notification, for documents with signatures, in the *built in* Firefox PDF Viewer then it cannot be necessary in the GENERIC viewer either.
2021-04-16 09:53:59 +02:00
Calixte Denizet
7e9579045f XFA -- Load fonts permanently from the pdf
- Different fonts can be used in xfa and some of them are embedded in the pdf.
  - Load all the fonts in window.document.

Update src/core/document.js

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>

Update src/core/worker.js

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>
2021-04-15 17:57:42 +02:00
Tim van der Meij
38ed655562
Convert done callbacks to async/await in test/unit/cmap_spec.js 2021-04-14 22:24:28 +02:00
Tim van der Meij
046467ff47
Drop obsolete done callbacks in test/unit/annotation_storage_spec.js
There is no asynchronous code involved here, so we can get rid of all
done callbacks here and simply use the fact that if the function call
ends without failed assertion that the test passed.
2021-04-14 22:11:45 +02:00
Tim van der Meij
82bdba78fb
Drop obsolete done callbacks in test/unit/crypto_spec.js
There is no asynchronous code involved here, so we can get rid of all
done callbacks here and simply use the fact that if the function call
ends without failed assertion that the test passed.
2021-04-14 22:09:17 +02:00
Tim van der Meij
43eb4302ff
Convert done callbacks to async/await in test/unit/message_handler_spec.js 2021-04-14 21:59:13 +02:00
Tim van der Meij
bc8c0bbbfd
Convert done callbacks to async/await in test/unit/display_svg_spec.js 2021-04-14 21:59:13 +02:00
Tim van der Meij
ae48d07582
Merge pull request #13243 from janpe2/ocg-ve
Implement visibility expressions for optional content
2021-04-14 20:42:49 +02:00
Tim van der Meij
cd2c4e277c
Merge pull request #13222 from timvandermeij/unit-test-async
Convert done callbacks to async/await in the smaller unit test files
2021-04-14 20:37:17 +02:00
Tim van der Meij
eddb9087a1
Merge pull request #13240 from Snuffleupagus/update-eslint-helpers
Update `eslint-config-prettier`/`eslint-plugin-unicorn` packages to their latest versions
2021-04-14 20:36:45 +02:00