Commit Graph

16313 Commits

Author SHA1 Message Date
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
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
Jonas Jenwald
205ab95819 [Editing] Disable the HandTool during editing (bug 1792422)
This extends the approach used in PresentationMode to also cover the AnnotationEditor, and tries to handle the combination of both cases correctly.
In order to simplify the overall implementation we simply track the *first* seen "previous" cursorTool, and don't allow it to be reset as long as either PresentationMode or an AnnotationEditor is being used.
2022-09-29 10:44:06 +02:00
Jonas Jenwald
c87f90102c Add more non-standard ligatures in the glyphlist.js file (issue 15516)
Note that this PR only adds the "underscore"-variant of *actually existing* ligatures, however the referenced PDF document also uses a couple of non-standard ones (e.g. `ft`, `Th`, and `fh`) that we cannot easily support without larger changes (since they don't have official Unicode-entries).
Given that it's clearly the PDF document, and its fonts, that's the culprit here it's not entirely clear to me that we actually want to attempt a larger refactoring/rewriting of the `glyphlist.js` code, assuming it's even generally possible. Especially when this patch alone already improves our copy-paste behaviour when compared to both Adobe Reader and PDFium, and that this is only the *second* time this sort of bug has been reported.
2022-09-27 16:31:51 +02:00
Jonas Jenwald
4c7a03c4cb
Revert "Don't listen for window resolution changes in old browsers (PR 15319 follow-up)" 2022-09-27 12:27:27 +02:00
Jonas Jenwald
c894be92fb Replace the DOMMatrix polyfill, used with Node.js, with the one from node-canvas
Fewer dependencies shouldn't be a bad idea in general, and given that the `node-canvas` package already include a `DOMMatrix` polyfill we can simply use that one instead.
2022-09-27 12:12:50 +02:00
Jonas Jenwald
5675a6ee64
Merge pull request #15512 from Snuffleupagus/issue-15509
[JS] Override the `Doc.external`-getter to avoid `alert`-modals on load (issue 15509)
2022-09-26 21:59:58 +02:00
Jonas Jenwald
9769b3b71a [JS] Override the Doc.external-getter to avoid alert-modals on load (issue 15509)
This property is documented in https://web.archive.org/web/20201112021418if_/https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf#G5.1977075

Given that PR 14207, which is *somewhat* similar, landed without tests that's hopefully fine here as well.
2022-09-26 20:55:26 +02:00
Jonas Jenwald
9ce2427e79 [Firefox viewer] Skip some unnecessary code in the FontLoader.bind method
Given that Firefox supports *synchronous* font loading, when the Font Loading API isn't being used, there's really no point including code which if called would just throw in the MOZCENTRAL build. (This is safe, since the `FontLoader.isSyncFontLoadingSupported`-getter always return `true` there.)
2022-09-26 15:18:22 +02:00
Jonas Jenwald
2161f334a0 Remove the ability to pass in more than one font to the _prepareFontLoadEvent method (PR 10539 follow-up)
After the changes in PR 10539 (which landed over three years ago) the `FontLoader.bind` method can only be called with *a single* font at a time, hence the `_prepareFontLoadEvent` method obviously don't need to support multiple fonts any more.
2022-09-26 13:33:52 +02:00
Jonas Jenwald
ca05b650aa Remove the unused rules parameter from the _prepareFontLoadEvent method (PR 3477 follow-up)
This is yet another small piece of functionality that became unused in PR 3477 (which landed nine years ago).
2022-09-26 13:26:14 +02:00
calixteman
da1780f826
Merge pull request #15486 from nmtigor/fix_orders_of_prop
Fix property chain orders of Operators in isDotExpression
2022-09-25 04:13:25 -10:00
Tim van der Meij
dab81f5981
Merge pull request #15507 from Snuffleupagus/FontLoader-cleanup
Improve the `FontLoader` code
2022-09-25 13:31:33 +02:00
Jonas Jenwald
ad83fbe2a1 Replace the BaseFontLoader classes with one FontLoader class
By having just *one* class, and using pre-processor blocks directly in the relevant methods, we reduce the size of this code in the *built* `pdf.js` file.
Originally, when the `BaseFontLoader` abstraction was added in PR 9982, the idea was probably that additional build-targets would get their own implementations. Given that this hasn't happened in the four years since that landed, it doesn't seem meaningful to keep it around.
2022-09-25 12:31:58 +02:00
Jonas Jenwald
9a03d36af4 Remove some unused code from the _queueLoadingCallback method (PR 3477 follow-up)
The existing `loadingContext` class-property can be simplified slightly, since we've not been using the `id`-property on the requests ever since PR 3477 (which landed nine 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.
2022-09-25 10:41:06 +02:00
Tim van der Meij
5f65df774f
Merge pull request #15504 from Snuffleupagus/rm-stopImmediatePropagation-checks
Use `stopImmediatePropagation` without checking for its existence first
2022-09-24 15:15:04 +02:00
Jonas Jenwald
b420f0165a Use stopImmediatePropagation without checking for its existence first
These checks were added years ago, but given the following compatibility data we should just be able to call the method directly: https://developer.mozilla.org/en-US/docs/Web/API/Event/stopImmediatePropagation#browser_compatibility
2022-09-24 15:02:12 +02:00
Tim van der Meij
907ef467ea
Merge pull request #15503 from Snuffleupagus/consistent-outline
Use a consistent `outline` for all UI buttons (PR 15438 follow-up)
2022-09-24 14:48:21 +02:00
Tim van der Meij
27a1ab52b1
Merge pull request #15501 from Snuffleupagus/errorWrapper-font
Restore the old fonts in the `errorWrapper` (PR 15438 follow-up)
2022-09-24 14:46:54 +02:00
Tim van der Meij
4cedbca365
Merge pull request #15500 from Snuffleupagus/LoopbackPort-rm-export
[api-minor] Stop exposing the `LoopbackPort` class in the API
2022-09-24 14:45:59 +02:00
Tim van der Meij
369f23ff3d
Merge pull request #15499 from Snuffleupagus/support-docs
Reference supported browsers Wiki-page in more README files
2022-09-24 14:43:45 +02:00
Tim van der Meij
10f6a0154f
Merge pull request #15485 from Snuffleupagus/more-optional-chaining-2
Use more optional chaining in the code-base (PR 15398 follow-up)
2022-09-24 14:41:43 +02:00
Jonas Jenwald
5296fc991c Restore the old fonts in the errorWrapper (PR 15438 follow-up)
This only applies to the GENERIC viewer, hence we use the pre-processor to exclude it from the Firefox PDF Viewer.
2022-09-24 13:54:34 +02:00
Jonas Jenwald
616535b7a7 Use a consistent outline for all UI buttons (PR 15438 follow-up)
Currently the `viewBookmark`-button, which is actually a `href`-element, gets an inconsistent `outline`.
Similarly, the `dialog`-buttons also have an inconsistent `outline` after the changes in PR 15438.

Finally, simplifies a couple of `border` rules since setting a border-width when "none" is being used doesn't seem meaningful.
2022-09-24 13:42:27 +02:00
Jonas Jenwald
cf038d0368 [api-minor] Stop exposing the LoopbackPort class in the API
This was done all the way back in PR 8361, for a mozilla-central test that's since been removed. As can be seen in the following search results, there's no `LoopbackPort` invocation outside of the PDF.js code itself: https://searchfox.org/mozilla-central/search?q=LoopbackPort&path=

Given that the `LoopbackPort` is only used in connection with "fake workers", which is something that we don't officially recommend/support, this doesn't seem like functionality that we want to keep exposing in the public API.
2022-09-23 13:44:35 +02:00
Jonas Jenwald
499610779e Re-factor the LoopbackPort class to use *proper* private fields 2022-09-23 13:25:15 +02:00