Commit Graph

16487 Commits

Author SHA1 Message Date
Jonas Jenwald
081e897588 Ensure that Page.getOperatorList handles Annotation parsing errors correctly (issue 15557)
*Fixes a regression from PR 15246, sorry about that!*

The return value of all `Annotation.getOperatorList` methods was changed in PR 15246, however I missed updating the error code-path in `Page.getOperatorList` which thus breaks all operatorList-parsing for pages with corrupt Annotations.
2022-10-10 09:48:01 +02:00
Tim van der Meij
dff444d441
Merge pull request #15555 from Snuffleupagus/improve-GetDocRequest
Clean-up the data that we're sending with "GetDocRequest"
2022-10-09 14:10:44 +02:00
Tim van der Meij
bf6e287572
Merge pull request #15552 from Snuffleupagus/simplify-dropdownToolbarButton
Simplify the `dropdownToolbarButton`-select width computation
2022-10-09 13:37:15 +02:00
Tim van der Meij
229d21b50d
Merge pull request #15553 from Snuffleupagus/rm-CMapCompressionType-STREAM
Remove the unused `CMapCompressionType.STREAM` value
2022-10-09 13:33:54 +02:00
Jonas Jenwald
8a4f6aca97 Stop using the source-object when sending "GetDocRequest"
Looking at the code on the worker-thread, there doesn't appear to be any particular reason for placing *some* of the properties in a `source`-object when sending them with "GetDocRequest".
As is often the case the explanation for this structure is rather "for historical reasons", since originally we simply sent the `source`-object as-is. Doing that was obviously a bad idea, for a couple of reasons:
 - It makes it less clear what is/isn't actually needed on the worker-thread.
 - Sending unused properties will unnecessarily increase memory usage.
 - The `source`-object may contain unclonable data, which would break the library.
2022-10-09 12:45:24 +02:00
Jonas Jenwald
c84b717773 Group the evaluatorOptions on the main-thread, when sending "GetDocRequest"
Rather than sending all of these parameters individually and then grouping them together on the worker-thread, we can simply handle that in the API instead.
2022-10-09 12:31:03 +02:00
Jonas Jenwald
447915af9d Stop sending the unused source.url property in "GetDocRequest"
It seems that this property became *effectively* unused already in PR 8617, however we missed removing it as part of the clean-up in PR 10376.
2022-10-09 12:30:46 +02:00
Jonas Jenwald
30f968fd7f
Merge pull request #15554 from Snuffleupagus/rm-deprecated-constants
[api-major] Remove some deprecated constants
2022-10-09 09:16:11 +02:00
Jonas Jenwald
484e81ef6e [api-major] Remove some deprecated constants
All of the these constants have been deprecated for a while, and with the upcoming *major* version this seems like a good time to remove them.
For the string-constants we can simply remove them, but the number-constants are left commented out since we don't want to re-number the list to prevent third-party breakage.
2022-10-08 18:13:53 +02:00
Jonas Jenwald
4cc98de6d7 Remove the unused CMapCompressionType.STREAM value
This was added in PR 8064, over five years ago, for a possible future CMap file-format that was never implemented.
2022-10-08 17:10:05 +02:00
Jonas Jenwald
4f5f362d60 Remove unnecessary size attribute from the pageNumber-input
This attribute is overridden by the explicit `width` that's specified in the CSS rules, hence we can remove one more small piece of very old code; see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#size
2022-10-08 12:34:13 +02:00
Jonas Jenwald
450be1ad3e Simplify the dropdownToolbarButton-select width computation
The way that we set the width of the `dropdownToolbarButton`-select is very old, and despite some improvements over the years this is still somewhat hacky.
In particular, note how we're assigning the select-element a larger width than its containing `dropdownToolbarButton`-element. This was done to prevent displaying *two* separate icons, i.e. the native and the PDF.js one, since it's the only way to handle this in older browsers (particularly Internet Explorer).

Given the currently supported browsers, there's however a better solution available: use `appearance: none;` to disable native styling of the select-element. [According to MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/appearance#browser_compatibility), this is supported in all reasonably modern browsers.
This way we're able to simplify both the CSS rules and the JS-code that's used to adjust the `dropdownToolbarButton` width in a localization aware way.
2022-10-07 18:19:10 +02:00
calixteman
3dc9b427b9
Merge pull request #15549 from calixteman/padding_inline
[XFA] Add some padding inline in selects
2022-10-07 03:49:14 -10:00
calixteman
b27753aa3d
Merge pull request #15548 from calixteman/simplify_remainder
Simplify the way to compute the remainder modulo 3 in PDF20Hash function
2022-10-07 03:48:41 -10:00
Calixte Denizet
24757e32d1 [XFA] Add some padding inline in selects
Because of https://bugzilla.mozilla.org/show_bug.cgi?id=1582545, the padding-inline is by default 0.
0 is not really enough because of the outline, so just set it to 2px (it was 4px before the patch)
in order to have something visually correct.
2022-10-07 15:11:58 +02:00
Jonas Jenwald
9931295bea
Merge pull request #15547 from Snuffleupagus/rm-Util-apply3dTransform
Remove the unused `Util.apply3dTransform` method
2022-10-07 15:03:19 +02:00
Calixte Denizet
c0e165bf97 Simplify the way to compute the remainder modulo 3 in PDF20Hash function
I noticed the 256 % 3 (which is equal to 1) so I slighty simplify the code.
The sum of the 16 Uint8 doesn't exceed 2^12, hence we can just take the
sum modulo 3.
2022-10-07 14:43:31 +02:00
Jonas Jenwald
4b39b1c76b Remove the unused Util.apply3dTransform method
This method was originally added in PR 1157 (back in 2012), however its only call-site was then removed in PR 2423 (also in 2012).
Hence this method has been completely unused for nearly a decade, and it should thus be safe to remove it.
2022-10-07 13:55:36 +02:00
Jonas Jenwald
8629a55215
Merge pull request #15538 from Snuffleupagus/viewer-error-logging
Stop localizing error *details* in the viewer (PR 15533 follow-up)
2022-10-07 11:16:22 +02:00
Jonas Jenwald
3cb119cb32
Merge pull request #15539 from Snuffleupagus/DecryptStream-set
Replace loop with `TypedArray.prototype.set` in the `DecryptStream.readBlock` method
2022-10-07 11:14:28 +02:00
Jonas Jenwald
a5a6b9f641
Merge pull request #15542 from Snuffleupagus/issue-14952
[api-minor] Make `isOffscreenCanvasSupported` configurable via the API (issue 14952)
2022-10-07 10:05:03 +02:00
Jonas Jenwald
1ea4c4b519 [api-minor] Make isOffscreenCanvasSupported configurable via the API (issue 14952)
This patch first of all makes `isOffscreenCanvasSupported` configurable, defaulting to `true` in browsers and `false` in Node.js environments, with a new `getDocument` parameter. While you normally want to use this, in order to improve performance, it should still be possible for users to control it (similar to e.g. `isEvalSupported`).

The specific problem, as reported in issue 14952, is that the SVG back-end doesn't support the new ImageMask data-format that's introduced in PR 14754. In particular:
 - When the SVG back-end is used in Node.js environments, this patch will "just work" without the user needing to make any code changes.
 - If the SVG back-end is used in browsers, this patch will require that `isOffscreenCanvasSupported: false` is added to the `getDocument`-call.
2022-10-07 00:10:46 +02:00
Jonas Jenwald
6877d8b9e2 Replace loop with TypedArray.prototype.set in the DecryptStream.readBlock method
There's no reason to use a manual loop, when a native method exists.
2022-10-06 14:43:24 +02:00
Jonas Jenwald
2f238a11c1 Stop localizing error *details* in the viewer (PR 15533 follow-up)
While it can't hurt to localize the main error-messages, also localizing the error *details* has always seemed somewhat unnecessary since those are only intended for debugging/development purposes. However, I can understand why that's done since the GENERIC viewer used to expose this information in the UI; via the `errorWrapper` UI that's removed in PR 15533.

At this point, when any errors are simply logged in the console, it no longer seems necessary to keep localizing the error *details* in the default viewer.
2022-10-06 13:09:39 +02:00
Jonas Jenwald
6bd5ef29ae Log the build number, in addition to the version, in the viewer
Given that the `build` number allows you to *directly* find the relevant commit, it cannot hurt to log that one as well.
2022-10-06 12:03:22 +02:00
Jonas Jenwald
7d5f7a517c
Merge pull request #15537 from Snuffleupagus/issue-8844
[api-minor] Add partial support for the "GoToE" action (issue 8844)
2022-10-06 11:34:52 +02:00
Jonas Jenwald
ce66fefbff [api-minor] Add partial support for the "GoToE" action (issue 8844)
*Please note:* The referenced issue is the only mention that I can find, in either GitHub or Bugzilla, of "GoToE" actions.
Hence why I've purposely settled for a very simple, and partial, "GoToE" implementation to avoid complicating things initially.[1] In particular, this patch only supports "GoToE" actions that references the /EmbeddedFiles-dict in the PDF document.

See https://web.archive.org/web/20220309040754if_/https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2048909

---
[1] Usually I always prefer having *real-world* test-cases to work with, whenever I'm implementing new features.
2022-10-06 10:33:07 +02:00
Jonas Jenwald
8c59cc72a3
Merge pull request #15536 from Snuffleupagus/more-for-of-2
Use more `for...of` loops in the code-base
2022-10-05 11:32:19 +02:00
Jonas Jenwald
60f6272ed9 Use more for...of loops in the code-base
Most, if not all, of this code is old enough to predate the general availability of `for...of` iteration.
2022-10-03 13:08:38 +02:00
Tim van der Meij
4e58dabb32
Merge pull request #15534 from Snuffleupagus/FontLoader-cleanup-3
[api-minor] Stop setting an `id` on the styleElement used with CSS font-loading
2022-10-02 14:22:51 +02:00
Jonas Jenwald
fe5d9b4b6a Remove duplicated destroy-calls in the "custom ownerDocument" unit-tests
Given that `PDFDocumentProxy.destroy` is nothing but an alias for `PDFDocumentLoadingTask.destroy` calling both methods is obviously not useful.
2022-10-02 12:01:41 +02:00
Jonas Jenwald
8e4ef6d89d [api-minor] Stop setting an id on the styleElement used with CSS font-loading
This is yet another small piece of clean-up of the `FontLoader`-code, since we've not used this `id`-property for anything ever since PR 6571 (which landed almost seven years ago). Furthermore, by default we're also not even using that code-path now since the Font Loading API will always be used when available.

*Please note:* This is tagged `[api-minor]` since it's technically observable from the outside, however no user ought to be directly interacting with these CSS font rules.
2022-10-02 12:01:33 +02:00
Tim van der Meij
beff913813
Merge pull request #15533 from Snuffleupagus/rm-errorWrapper
[GENERIC viewer] Remove the `errorWrapper` UI
2022-10-01 19:07:28 +02:00
Tim van der Meij
284634f30d
Merge pull request #15508 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2022-10-01 19:03:51 +02:00
Tim van der Meij
606fb8c394
Fix intermittent errors in the "check that first text field has focus" scripting test
This commit fixes the "Expected null to equal '401R'" errors that
surfaced after the Puppeteer 18 upgrade. Note that even before that
this would have been an improvement because it takes some time between
scripting being reported ready (i.e., triggering the execution of any
OpenActions) and those OpenActions actually completing execution, so
it's only safe to check which element is focused if we know an element
actually became focused.
2022-10-01 18:08:15 +02:00
Tim van der Meij
9525bfaa66
Update translations to the most recent versions 2022-10-01 18:07:44 +02:00
Tim van der Meij
b0725e75c6
Update dependencies to the most recent versions 2022-10-01 18:04:29 +02:00
Jonas Jenwald
62c1a4e8c8 [Firefox viewer] Skip unused printing-string in DEFAULT_L10N_STRINGS
Given that the Firefox PDF Viewer uses the *browser* print UI, this fallback l10n-string isn't necessary in the MOZCENTRAL build.
2022-10-01 17:35:43 +02:00
Jonas Jenwald
75e06fddf1 [GENERIC viewer] Remove the errorWrapper UI
In the Firefox PDF Viewer this has never been used, with the error message simply printed in the web-console, and (somewhat) recently we've also updated the viewer code to avoid bundling the relevant code there. Furthermore, in the Firefox PDF Viewer we're not even display the *browser* fallback bar any more; see https://bugzilla.mozilla.org/show_bug.cgi?id=1705327.

Hence it seems slightly strange to keep this UI around in the GENERIC viewer, and this patch proposes that we simply remove it to simplify/unify the relevant code in the viewer. In particular this also allows us to remove a couple of l10n-strings, which have always been unused in the Firefox PDF Viewer.
2022-10-01 17:35:35 +02:00
Jonas Jenwald
a93c01ae6a
Merge pull request #15510 from Snuffleupagus/compatibility-loading
Change how `src/shared/compatibility.js` is imported
2022-10-01 13:47:44 +02:00
Jonas Jenwald
3e625994bd Change how src/shared/compatibility.js is imported
Currently the compatibility-file is loaded using a standard `import`-statement and while its code is enclosed in a pre-processor block, and thus is excluded in e.g. the MOZCENTRAL build-target, it still results in the *built* `pdf.js`/`pdf.worker.js` files having an effectively empty closure as a result.
By moving the checks from `src/shared/compatibility.js` and into `src/shared/util.js` instead, we can load the file using a build-time `require`-statement and thus avoid that closure.

Note that with these changes the compatibility-file will no longer be loaded in development mode, i.e. when `gulp server` is used. However, this shouldn't be a big issue given that none of its included polyfills could be loaded then anyway (since `require`-statements are being used) and that it's really only intended for the `legacy`-builds of the library.
2022-10-01 13:29:54 +02:00
Tim van der Meij
2c38a14a14
Merge pull request #15530 from Snuffleupagus/sidebar-toggleButton-l10n
Re-factor the `toggleButton` l10n in the `PDFSidebar` class
2022-10-01 13:10:32 +02:00
Tim van der Meij
0cca2d4f6e
Merge pull request #15511 from Snuffleupagus/FontLoader-cleanup-2
More `FontLoader` clean-up
2022-10-01 13:04:29 +02:00
Tim van der Meij
29a784c240
Merge pull request #15514 from Snuffleupagus/DOMMatrix-polyfill
Replace the `DOMMatrix` polyfill, used with Node.js, with the one from `node-canvas`
2022-10-01 12:56:57 +02:00
Jonas Jenwald
7b24931f67
Merge pull request #15517 from Snuffleupagus/issue-15516
Add more non-standard ligatures in the `glyphlist.js` file (issue 15516)
2022-09-30 23:30:50 +02:00
Jonas Jenwald
1ee096d229
Merge pull request #15515 from mozilla/revert-15418-pr-15319-followup
Revert "Don't listen for window resolution changes in old browsers (PR 15319 follow-up)"
2022-09-30 10:15:05 +02:00
Jonas Jenwald
bad00f825a Re-factor the toggleButton l10n in the PDFSidebar class
Rather than "manually" looking up the l10n-string and then updating the button, we can (and probably even should) just update the l10n-id and then trigger proper translation for the button DOM-element.
2022-09-30 09:59:58 +02:00
Jonas Jenwald
0011a747f7
Merge pull request #15527 from calixteman/15523
[JS] Add the function AFExactMatch
2022-09-30 09:32:16 +02:00
Calixte Denizet
330048ad6b [JS] Add the function AFExactMatch 2022-09-29 14:23:56 -10:00
Jonas Jenwald
294db228bc
Merge pull request #15522 from Snuffleupagus/editor-disable-cursor-tools
[Editing] Disable the HandTool during editing (bug 1792422)
2022-09-29 11:09:44 +02:00