Commit Graph

13969 Commits

Author SHA1 Message Date
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
Tim van der Meij
b9d87b8c0d
Merge pull request #13244 from Snuffleupagus/update-postcss-calc
Update the `postcss-calc` package to the latest version
2021-04-14 20:35:51 +02:00
Tim van der Meij
6bb0ffd374
Merge pull request #13238 from Snuffleupagus/update-es-module-shims
Update the `es-module-shims` package to the latest version
2021-04-14 20:34:57 +02:00
Jani Pehkonen
3a96977ea8 Implement visibility expressions for optional content 2021-04-14 17:39:41 +03:00
Jonas Jenwald
3e113cd38f Update the es-module-shims package to the latest version
Beside the unit/font-test suites, this is primarily used in the development viewer (i.e. `gulp server`).

https://www.npmjs.com/package/es-module-shims
2021-04-14 15:40:41 +02:00
Jonas Jenwald
da93bd18cc Update the postcss-calc package to the latest version
I've successfully run `gulp mozcentral` and `gulp generic` locally, with/without this patch and diff-ed the *built* `web/viewer.css` files. There were no changes, in the build-output, caused by this update.

https://www.npmjs.com/package/postcss-calc
2021-04-14 15:32:38 +02:00
Jonas Jenwald
f2156fc0cf Update eslint-config-prettier/eslint-plugin-unicorn packages to their latest versions
Both of these ESLint "helpers" has increased their *major* version numbers, which `npm update` doesn't handle automatically (since that could cause errors), hence this patch which updates them manually.

https://www.npmjs.com/package/eslint-config-prettier
https://www.npmjs.com/package/eslint-plugin-unicorn
2021-04-14 12:46:57 +02:00
Tim van der Meij
3ff7627120
Merge pull request #13235 from Snuffleupagus/split-core-obj
Split the classes in `src/core/obj.js` into separate files
2021-04-13 22:13:46 +02:00
Tim van der Meij
c1e9f6025f
Convert done callbacks to async/await in test/unit/custom_spec.js 2021-04-13 21:51:27 +02:00
Tim van der Meij
a1c1e1b9f8
Convert done callbacks to async/await in test/unit/fetch_stream_spec.js 2021-04-13 21:51:27 +02:00
Tim van der Meij
5607484402
Convert done callbacks to async/await in test/unit/network_spec.js 2021-04-13 21:51:26 +02:00
Tim van der Meij
fcf4d02fca
Convert done callbacks to async/await in test/unit/node_stream_spec.js 2021-04-13 21:51:26 +02:00
Tim van der Meij
99dc0d6b65
Convert done callbacks to async/await in test/unit/primitives_spec.js 2021-04-13 21:50:13 +02:00
Tim van der Meij
a56ffb92be
Convert done callbacks to async/await in test/unit/ui_utils_spec.js 2021-04-13 21:50:13 +02:00
Tim van der Meij
a2811e925d
Convert done callbacks to async/await in test/unit/util_spec.js 2021-04-13 21:47:53 +02:00
Jonas Jenwald
1d6d476cab Rename the src/core/obj.js file to src/core/catalog.js
Now that only the `Catalog` remains in this file, after the previous patches, it makes sense to rename the file to reduce confusion.
2021-04-13 21:00:30 +02:00
Jonas Jenwald
088a55f80d Enable the no-var rule in the src/core/xref.js file 2021-04-13 21:00:30 +02:00
Jonas Jenwald
bc828cd41f Convert the XRef to a "normal" class 2021-04-13 21:00:30 +02:00
Jonas Jenwald
e8750cfe95 Move the XRef from src/core/obj.js and into its own file
The size of the `src/core/obj.js` file has increased slowly over the years, and it also contains a fair amount of *distinct* functionality.
In order to improve readability and make it easier to navigate through the code, this patch moves the `XRef` into its own file.
2021-04-13 21:00:30 +02:00
Jonas Jenwald
24e5ecdf76 Move NameTree/NumberTree from src/core/obj.js and into its own file
The size of the `src/core/obj.js` file has increased slowly over the years, and it also contains a fair amount of *distinct* functionality.
In order to improve readability and make it easier to navigate through the code, this patch moves `NameTree`/`NumberTree` into its own file.
2021-04-13 21:00:30 +02:00
Jonas Jenwald
92141e0468 Enable the no-var rule in the src/core/file_spec.js file 2021-04-13 21:00:30 +02:00
Jonas Jenwald
22a066e657 Convert the FileSpec to a "normal" class 2021-04-13 21:00:30 +02:00
Jonas Jenwald
e02d17da93 Move the FileSpec from src/core/obj.js and into its own file
The size of the `src/core/obj.js` file has increased slowly over the years, and it also contains a fair amount of *distinct* functionality.
In order to improve readability and make it easier to navigate through the code, this patch moves the `FileSpec` into its own file.
2021-04-13 21:00:30 +02:00
Jonas Jenwald
6a935682fd Covert the ObjectLoader to a "normal" class 2021-04-13 21:00:30 +02:00
Jonas Jenwald
604cd6d600 Move the ObjectLoader from src/core/obj.js and into its own file
The size of the `src/core/obj.js` file has increased slowly over the years, and it also contains a fair amount of *distinct* functionality.
In order to improve readability and make it easier to navigate through the code, this patch moves the `ObjectLoader` into its own file.
2021-04-13 21:00:30 +02:00
Tim van der Meij
ebeb3f7999
Merge pull request #13234 from Snuffleupagus/hasJSActions-MissingDataException
[api-minor] Ensure that `PDFDocumentProxy.hasJSActions` won't fail if `MissingDataException`s are thrown during the associated worker-thread parsing
2021-04-13 20:44:58 +02:00
Cetin Sert
d498897ab5
Fix annotation input focus trap regression in Safari (#13232)
`setSelectionRange(0, 0)` added in 44b24fcc29 for #12359, required only by Firefox ([bug](https://bugzilla.mozilla.org/show_bug.cgi?id=860329)), causes issues mozilla#13191, mozilla#12592 in Safari.
`scrollLeft = 0` is a fix that breaks the focus trap in Safari while **keeping Firefox behavior same for #12359**.
2021-04-13 20:40:52 +02:00
Tim van der Meij
3d2d8002b0
Merge pull request #13223 from Snuffleupagus/worker-xfa-structTree-tweaks
Remove the unused "GetIsPureXfa" message handler; and avoid unnecessary parsing when no structTree is available (PR 13069 follow-up, PR 13221 follow-up)
2021-04-13 20:39:52 +02:00
Jonas Jenwald
2b2234fd5a [api-minor] Ensure that PDFDocumentProxy.hasJSActions won't fail if MissingDataExceptions are thrown during the associated worker-thread parsing
With the current implementation of `PDFDocument.hasJSActions`, in the worker-thread, we're not actually handling not-yet-loaded data correctly. This can thus fail in *two* different ways:
 - The `PDFDocument.fieldObjects` getter (and its helper method), while it may *return* a Promise, still fetches all of its data synchronously and it can thus throw a `MissingDataException` during parsing.
 - The `Catalog.jsActions` getter, which is completely synchronous, can obviously throw a `MissingDataException` during parsing.

If either of these cases occur currently, the `PDFDocumentProxy.hasJSActions` method in the API can either return a *rejected* Promise (which it never should) or possibly "hang" and never resolve.

*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.
This patch is thus based on code-inspection *and* on manually throwing a `MissingDataException` on the first access of `Catalog.jsActions` to simulate this situation.

Finally, this patch adds a couple of *API* unit-tests for this (since none existed).
2021-04-13 14:33:56 +02:00
Jonas Jenwald
4aa27cc645 Re-factor Catalog._collectJavaScript to use a Map rather than an Object
Given that this only an internal helper method, used by the `Catalog.{javaScript, jsActions}` getters, this change simplifies iteration of the returned data.
We can also (slightly) re-factor the code of the `jsActions` getter, and remove an obsolete[1] JSDoc-comment from the `openAction` getter.

---
[1] Not really relevant now that we've got proper scripting support.
2021-04-13 14:16:17 +02:00
Brendan Dahl
6cf3070008
Merge pull request #13203 from utopianknight/high_contrast
Implement high contrast mode
2021-04-12 16:24:03 -07:00
Brendan Dahl
a53cd1cc1e
Merge pull request #13141 from calixteman/xfa_text
XFA -- Display text content
2021-04-12 14:34:38 -07:00
Calixte Denizet
a4c986515f XFA -- Display text content
- display xhtml;
  - allow spaces in xhtml (xfa-spacerun:yes);
  - support column layout;
  - fix some border issues.
2021-04-12 14:13:49 +02:00
Jonas Jenwald
54ef4370a2 Ensure that the data is loaded, in the "GetPageJSActions" message handler
Similar to all other data accesses, note e.g. the "GetDocJSActions" handler just above, we need to ensure that a `MissingDataException` isn't propagated to the main-thread if this data is accessed while the PDF document is still loading.
2021-04-12 13:54:37 +02:00