Commit Graph

17029 Commits

Author SHA1 Message Date
Jonas Jenwald
1b076b7a35
Move the ImageBitmap clean-up into the PDFObjects class
With upcoming changes we'll potentially start to cache `ImageBitmap` data at the document-level, in addition to just at the page-level.
Hence we need to ensure that such data is actually released on clean-up, and rather than duplicating the existing *manual* handling this code is instead moved into the `PDFObjects.clear` method. (In my opinion, this is an overall improvement even without globally cached `ImageBitmap` data.)

*Please note:* This patch is written using the GitHub UI, since I'm currently without a dev machine, so hopefully it's correct and makes sense.
2023-02-21 12:00:45 +01:00
calixteman
534b22aec5
Merge pull request #16071 from calixteman/issue16067
[JS] Send a Validate action on change on Choice widget
2023-02-20 11:15:20 +01:00
Calixte Denizet
dca54c8f8a [JS] Send a Validate action on change on Choice widget 2023-02-19 16:33:05 +01:00
Tim van der Meij
255e982542
Merge pull request #16056 from Snuffleupagus/xfaLayer-on-top
Don't try to place the `xfaLayer` "on top" in regular PDF documents
2023-02-19 12:22:10 +01:00
Tim van der Meij
f2baa48608
Merge pull request #16055 from Snuffleupagus/deprecated-Node-Buffer
[api-minor] Deprecate providing binary data as `Buffer` in Node.js environments
2023-02-19 12:20:09 +01:00
Tim van der Meij
9fac676796
Merge pull request #16054 from Snuffleupagus/Driver-getDocument-cleanup
A little clean-up of the `getDocument` call in `test/driver.js`
2023-02-19 12:12:07 +01:00
calixteman
13af3f3442
Merge pull request #16065 from calixteman/issue16063
Don't replace an eol by a whitespace when the last char is a Katakana-Hiragana diacritic
2023-02-17 13:40:54 +01:00
Calixte Denizet
fc7d74385f Don't replace an eol by a whitespace when the last char is a Katakana-Hiragana diacritic 2023-02-16 11:31:58 +01:00
Jonas Jenwald
3c66b031e3 Don't try to place the xfaLayer "on top" in regular PDF documents
Given that we only create an `xfaLayer` in "pure" XFA-documents, this code can be moved into the appropriate branch instead.
2023-02-14 12:54:44 +01:00
Jonas Jenwald
b6ba8cc84a [api-minor] Deprecate providing binary data as Buffer in Node.js environments
The `Buffer`-object is Node.js specific functionality[1], thus (obviously) not found in browsers. Please note that the PDF.js library has never officially supported/documented that binary data can be passed as a `Buffer`, and that *internally* in the `src/core`-code we only work with standard `Uint8Array`s.
This means that if, in Node.js environments, a `Buffer` is passed to the API we need to wrap it into a `Uint8Array`, which essentially means creating a copy of the data and thus increasing memory usage.

---
[1] Refer to https://nodejs.org/api/buffer.html#buffer
2023-02-14 11:30:40 +01:00
Jonas Jenwald
df3b359280 Remove "else after return" from the getUrlProp/getDataProp helper functions
This helps readability of this code a little bit, in my opinion, and it's actually ever so slightly less code in the *built* `pdf.js` file.
2023-02-14 10:50:22 +01:00
Jonas Jenwald
0e840f1c39 A little clean-up of the getDocument call in test/driver.js
- Pass the `URL`-object directly to `getDocument`, since that's been supported since PR 13166.
 - Remove support for the `disableRange`-option in the test-manifest, since it's completely unused. Please note that it's originally added in PR 2719, however there's never actually been any reference tests using it (not even from the start).
   Given that the option is `false` by default everywhere (e.g. in the Firefox PDF Viewer) and that we have unit-tests for `disableRange = true`, it doesn't seem necessary to add new reference tests for it now.
2023-02-13 14:49:33 +01:00
Jonas Jenwald
546902df63
Merge pull request #16053 from Snuffleupagus/test-set-annotationStorage
Reduce duplication for reference tests with an `annotationStorage` entry
2023-02-13 11:56:12 +01:00
Jonas Jenwald
8026ed6b0a Reduce duplication for reference tests with an annotationStorage entry
Currently we duplicate the same code more than once in the `test/driver.js` file, which we can avoid by adding a new `AnnotationStorage` helper method instead.
2023-02-13 11:09:16 +01:00
Tim van der Meij
f66cbb0b5e
Merge pull request #16051 from Snuffleupagus/rm-PDFThumbnailViewer-eventBus
Remove the unused `eventBus` option in `PDFThumbnailViewer` (PR 15215 follow-up)
2023-02-12 19:29:52 +01:00
Jonas Jenwald
6985286300 Remove the unused eventBus option in PDFThumbnailViewer (PR 15215 follow-up)
This became unused with PR 15215, but I unfortunately forgot to remove it.
2023-02-12 18:38:31 +01:00
Tim van der Meij
22618213c7
Merge pull request #16040 from Snuffleupagus/arrayBuffersToBytes
Re-factor the `arraysToBytes` helper function (PR 16032 follow-up)
2023-02-12 11:47:57 +01:00
Jonas Jenwald
6d4d402a78 Move the arrayBuffersToBytes helper function into the worker-thread
Given that this helper function is only used on the worker-thread, there's no reason to duplicate it in both of the *built* `pdf.js` and `pdf.worker.js` files.
2023-02-11 21:34:37 +01:00
Tim van der Meij
25a6bc4e01
Merge pull request #16013 from Snuffleupagus/COMPONENTS-rm-inline-attachment-open
Remove inline opening of PDF attachments in the COMPONENTS build
2023-02-11 19:03:51 +01:00
Tim van der Meij
ddf05b0795
Merge pull request #16028 from Snuffleupagus/move-CHROME-rewriteUrlClosure
Move `rewriteUrlClosure` into the `web/chromecom.js` file
2023-02-11 19:02:32 +01:00
Tim van der Meij
3daf4274e8
Merge pull request #16045 from Snuffleupagus/viewer-initializeOptions
Slightly re-factor preferences/options initialization in the viewer
2023-02-11 19:01:31 +01:00
Tim van der Meij
ec4c84176f
Merge pull request #16047 from Snuffleupagus/BasePdfManager-args
Improve the consistency between the `LocalPdfManager`/`NetworkPdfManager` constructor
2023-02-11 18:58:29 +01:00
Tim van der Meij
5c3017b6ae
Merge pull request #16048 from Snuffleupagus/update-Stylelint
Update Stylelint to version 15
2023-02-11 18:49:52 +01:00
Jonas Jenwald
5023a41fb7 Update Stylelint to version 15
Notably this obsoletes the `stylelint-config-prettier` package; please see https://github.com/stylelint/stylelint/blob/main/docs/migration-guide/to-15.md for additional details.
2023-02-11 14:41:32 +01:00
Tim van der Meij
fd1c9e34ac
Merge pull request #16046 from Snuffleupagus/update-packages
Update packages and translations
2023-02-11 14:10:09 +01:00
Jonas Jenwald
18042163ce Improve the consistency between the LocalPdfManager/NetworkPdfManager constructor
Currently these classes take a bunch of parameters (somewhat randomly ordered), probably because this is very old code that's been extended over the years.
Hence this patch changes the constructors to use parameter-objects instead, which improves consistency and (slightly) reduces the amount of code as well.

*Please note:* Also removes the `msgHandler`-property on these classes, since I cannot find a single call-site that accesses it.
2023-02-11 13:39:52 +01:00
Jonas Jenwald
34ec3caaa7 Update l10n files 2023-02-11 10:35:21 +01:00
Jonas Jenwald
650fd79f92 Update npm packages 2023-02-11 10:30:43 +01:00
Jonas Jenwald
0e070c805e Slightly re-factor preferences/options initialization in the viewer
Given that the debugging hash-parameters will only be used when the `pdfBugEnabled` option is manually set[1], we can skip a *tiny* bit of asynchronicity for "regular" users.

---
[1] Note that it's enabled by default in the development viewer, i.e. in `gulp server` mode.
2023-02-10 15:45:39 +01:00
Jonas Jenwald
6c158da5a8 Limit AppOptions._hasUserOptions to only GENERIC builds
It's completely unused elsewhere, e.g. in the Firefox PDF Viewer.
2023-02-10 15:37:51 +01:00
Jonas Jenwald
903adc8708
Merge pull request #16042 from Snuffleupagus/GetAnnotations-rethrow
Ensure that "GetAnnotations" errors are propagated to the main-thread (PR 15267 follow-up)
2023-02-10 12:55:19 +01:00
Jonas Jenwald
14b0e8c0b6 Ensure that "GetAnnotations" errors are propagated to the main-thread (PR 15267 follow-up)
With the changes in PR 15267 we're now accidentally swallowing "GetAnnotations" errors, rather than propagating them to the main-thread as intended.
2023-02-10 12:18:35 +01:00
Jonas Jenwald
c56f25409d Re-factor the arraysToBytes helper function (PR 16032 follow-up)
Currently this helper function only has two call-sites, and both of them only pass in `ArrayBuffer` data. Given how it's implemented there's a couple of code-paths that are completely unused (e.g. the "string" one), and in particular the intended fast-paths don't actually work.
This patch re-factors and simplifies the helper function, and it'll no longer accept anything except `ArrayBuffer` data (hence why it's also re-named).

Note that at the time when `arraysToBytes` was added we still supported browsers without TypedArray functionality, and we'd then simulate them using regular Arrays.
2023-02-10 10:26:35 +01:00
Jonas Jenwald
5ba596786c Change WorkerTasks, in WorkerMessageHandler.createDocumentHandler, to a use a Set
This is a tiny bit more compact, thanks to the `Set.prototype.delete` method.
2023-02-09 22:01:16 +01:00
calixteman
0fca6e187c
Merge pull request #16035 from calixteman/fix_combo_value
[Annotation] A combo can have a value other than one in the options
2023-02-09 19:56:16 +01:00
Jonas Jenwald
1fc8350795
Merge pull request #16032 from Snuffleupagus/less-arrayByteLength
Reduce usage of the `arrayByteLength` helper function
2023-02-09 18:56:20 +01:00
Calixte Denizet
cb1638530d [Annotation] A combo can have a value other than one in the options
When printing the pdf in #12233 in Acrobat, we can see that the combo for country
is empty: it's because the V entry doesn't have to be one of the options.
2023-02-09 18:50:57 +01:00
calixteman
972744a68f
Merge pull request #16033 from calixteman/bug1640217
Ignore position of combining diacritics when getting text (bug 1640217)
2023-02-09 18:23:59 +01:00
calixteman
533a461db0
Merge pull request #16031 from calixteman/bug1770750
[Annotation] For choice widget, use the I entry instead of the V one (bug 1770750)
2023-02-09 18:01:28 +01:00
Calixte Denizet
58e4d92884 [Annotation] For choice widget, use the I entry instead of the V one (bug 1770750)
It isn't really conform to the specifications but Acrobat is working like that...
2023-02-09 17:26:13 +01:00
Calixte Denizet
4e9f26afa3 Ignore position of combining diacritics when getting text (bug 1640217) 2023-02-09 17:13:57 +01:00
Jonas Jenwald
96d338e437 Reduce usage of the arrayByteLength helper function
We're using this helper function when reading data from the [`PDFWorkerStreamReader.read`](a49d1d1615/src/core/worker_stream.js (L90-L98)) and [`PDFWorkerStreamRangeReader.read`](a49d1d1615/src/core/worker_stream.js (L122-L128)) methods, and as can be seen they always return `ArrayBuffer` data. Hence we can simply get the `byteLength` directly, and don't need to use the helper function.

Note that at the time when `arrayByteLength` was added we still supported browsers without TypedArray functionality, and we'd then simulate them using regular Arrays.
2023-02-09 15:50:38 +01:00
Jonas Jenwald
323d3d246a Re-factor the readChunk function in ChunkedStreamManager.sendRequest
Move the `done` branch to the top of the function, similar to how we usually format things when `ReadableStream`s are used.
2023-02-09 15:33:06 +01:00
Jonas Jenwald
a49d1d1615
Merge pull request #16030 from Snuffleupagus/LoopbackPort-Set
Change the `LoopbackPort` class to use a Set internally
2023-02-09 12:58:14 +01:00
Jonas Jenwald
9d29abdfa0 Change the LoopbackPort class to use a Set internally
This is a tiny bit more compact, thanks to the `Set.prototype.delete` method.
2023-02-09 12:34:41 +01:00
calixteman
ff3b9ccf6e
Merge pull request #16017 from calixteman/hide_struct_tree
Hide the struct tree layer during zooming
2023-02-09 11:32:28 +01:00
calixteman
8df06f62bc
Merge pull request #16025 from calixteman/no_display_for_spinner
Avoid a useless animation when the spinner is invisible
2023-02-09 11:31:27 +01:00
Jonas Jenwald
40a3de8c37 Move rewriteUrlClosure into the web/chromecom.js file
Given that this is only used for the Chrome-addon, we can move this code into the relevant file instead.
2023-02-09 11:18:08 +01:00
calixteman
9cea76483a
Merge pull request #16026 from calixteman/ptz_mac
Fix pinch-to-zoom on mac for the Firefox builtin viewer
2023-02-08 15:16:59 +01:00
Calixte Denizet
c92ba393c2 Fix pinch-to-zoom on mac for the Firefox builtin viewer
In the mac case we don't want to care about the scaleFactor threshold
because else if too big another move could start and then subsequent
events aren't considered as wheel events.
It isn't really ideal and at some point we'll need to find a way at
least for the Firefox case to get the real events instead of the fake
wheel ones.
2023-02-08 15:04:41 +01:00