Commit Graph

16847 Commits

Author SHA1 Message Date
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
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
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
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
Jonas Jenwald
9faf2fa8a0
Merge pull request #16019 from Snuffleupagus/viewer-rm-require
Remove most build-time `require` statements from the viewer (PR 16009 follow-up)
2023-02-08 15:02:40 +01:00
Calixte Denizet
bb89daa2a8 Avoid a useless animation when the spinner is invisible
In looking at a profile, I noticed in Marker chart that there's an animation
for loading-icon.gif even if this icon isn't visible.
This patch doesn't completely remove it but just slightly postpones it.
2023-02-08 11:57:53 +01:00
calixteman
c8d9ad894b
Merge pull request #16023 from calixteman/issue16021
[Annotation] Take into account the stroke alpha for a FreeText without appearance
2023-02-07 23:17:16 +01:00
Jonas Jenwald
90ffbc1d39 Remove most build-time require statements from the viewer (PR 16009 follow-up)
This further extends the web-specific import maps introduced in PR 16009, to allow removing *most* of the build-time `require` statements from the viewer. The few remaining ones are fallbacks used for the COMPONENTS respectively the `legacy` GENERIC builds.
2023-02-07 22:45:19 +01:00
Calixte Denizet
a25895bf72 [Annotation] Take into account the stroke alpha for a FreeText without appearance 2023-02-07 22:15:27 +01:00
Jonas Jenwald
8f37301d1f Remove the "div-css" gulp task (PR 15968 follow-up)
After the compatibility updates in PR 15968 it's no longer strictly necessary to build the `viewer.css` file in order for the *development viewer* to work in Chromium-based browsers.

*Please note:* Given that Chromium-based browsers still don't support the *unprefixed* `mask-image` property the icons won't look right, however the development viewer itself works.
Given that Firefox is the *primary* development target, and that running `gulp generic` locally will generate polyfilled CSS, it seems reasonable to make this simplification here.
2023-02-07 21:37:41 +01:00
Jonas Jenwald
72abcedf48
Merge pull request #16018 from Snuffleupagus/GeckoView-skip-pageLabels
[GeckoView] Skip fetching/parsing of pageLabels
2023-02-07 21:36:30 +01:00
calixteman
ecd86ccffc
Merge pull request #16020 from calixteman/bug1815476
[Annotation] Avoid to encrypt the appearance stream two times (bug 1815476)
2023-02-07 20:57:49 +01:00
Calixte Denizet
ea7b4b4d6c [Annotation] Avoid to encrypt the appearance stream two times (bug 1815476) 2023-02-07 19:26:46 +01:00
Jonas Jenwald
00560ed830
Merge pull request #16009 from Snuffleupagus/GeckoView-viewer-bundle-size
[GeckoView] Reduce the size of the *built* viewer
2023-02-07 18:28:44 +01:00
Jonas Jenwald
a348162c5b [GeckoView] Skip fetching/parsing of pageLabels
Currently there's no toolbar in the GV-viewer, hence invoking the pageLabels functionality isn't meaningful and just leads to unnecessary parsing on both the main- and worker-threads. (And if a toolbar is added at some point, it's not clear to me if we'd want to support pageLabels in the GV-viewer anyway.)
2023-02-07 16:20:27 +01:00
Jonas Jenwald
8c4843f69a [GeckoView] Introduce a development mode constant to tell the viewers apart
Currently we have a couple of pre-processor checks, specifically for the GV-viewer, spread throughout the code. This works fine when *building* the viewer, however they're obviously ignored in development mode (i.e. `gulp server`).
This leads to a situation where the GV development viewer, i.e. http://localhost:8888/web/viewer-geckoview.html, behaves subtly different from its built version. This could easily lead to bugs, hence this patch introduces a development mode constant to hopefully improve things here.

Finally, in a follow-up to PR 15842, also ignores the `pageMode`-state since there's no sidebar available.
2023-02-07 16:07:12 +01:00
Calixte Denizet
5bd352f69b Hide the struct tree layer during zooming 2023-02-07 15:33:01 +01:00
Jonas Jenwald
c971f4a0a9
Merge pull request #16016 from Snuffleupagus/GeckoView-skip-sidebar-fetching
[GeckoView] Avoid unused outline, attachments, and layers fetching
2023-02-07 13:25:02 +01:00
Jonas Jenwald
0cf4fbd471 [GeckoView] Avoid unused outline, attachments, and layers fetching
Currently there's no UI for this functionality in the GV-viewer, however we still call the API methods. This potentially leads to a bunch of worker-thread parsing, for PDF documents with these features, despite the result being completely unused.
Given that mobile devices are usually more resource constrained than desktop/laptop computers, not to mentioned battery life, we can avoid doing work that'll just be ignored anyway.
2023-02-07 12:30:05 +01:00
Jonas Jenwald
a98e80c4ff [GeckoView] Reduce the size of the *built* viewer
Given that the GV-viewer isn't using most of the UI-related components of the default-viewer, we can avoid including them in the *built* viewer to save space.[1]
The least "invasive" way of implementing this, at least that I could come up with, is to leverage import maps with suitable stubs for the GV-viewer.

The one slightly annoying thing is that we now have larger import maps across multiple html-files, and you'll need to remember to update all of them when making future changes.

---
[1] With this patch, the built `viewer.js` size is 391 kB and `viewer-geckoview.js` is 285 kB.
2023-02-05 14:12:32 +01:00
Tim van der Meij
05d821e680
Merge pull request #16007 from Snuffleupagus/getDocument-params-init
Re-factor the parameter parsing/validation in `getDocument`
2023-02-05 13:16:59 +01:00
Tim van der Meij
ab6b4ca1f2
Merge pull request #16006 from Snuffleupagus/viewer-rm-pdfDocument-checks
Miscellaneous small viewer improvements
2023-02-05 12:53:17 +01:00
Jonas Jenwald
0a0f3fc733 Move the main-thread CMap/StandardFontData factory initialization to getDocument
By default we're using worker-thread fetching (in browsers) of this data nowadays, however in Node.js environments or if the user provides custom factories we still fallback to main-thread fetching.
Hence it makes sense, as far as I'm concerned, to move this initialization into the `getDocument` function to ensure that the factories can actually be initialized *before* attempting to load the document.

Also, this further reduces the amount of `getDocument` parameters that we need to pass into into the `WorkerTransport` class.
2023-02-05 11:52:35 +01:00
Jonas Jenwald
ce8ac6d96a Only pass the necessary parameters to _fetchDocument and WorkerTransport
Currently we're passing all available parameters to this function respectively class, despite that not actually being necessary.
By splitting the parameters we not only improve the structure, and basically "document" the code a little bit, but we can also simplify the `_fetchDocument` function considerably.
2023-02-05 11:52:33 +01:00
Jonas Jenwald
512aa50fdd Re-factor the parameter parsing/validation in getDocument
This is very old code, where we loop through the user-provided options and build an internal parameter object. To prevent errors we also need to ensure that the parameters are correct/valid, which is especially important for the ones that are sent to the worker-thread such that structured cloning won't fail.[1]

Over the years this has led to more and more code being added in `getDocument` to validate the user-provided options, and at this point *most* of them have at least basic validation. However the way that this is implemented feels slightly backwards, since we first build the internal parameter object and only *afterwards* validate those parameters.[2]

Hence this patch changes the `getDocument` function to instead check/validate the supported options upfront, and then *explicitly* build the internal parameter object with only the needed properties.

---
[1] Note the supported types at https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types

[2] The internal parameter object may also, because of the loop, end up with lots of unnecessary properties since anything that the user provides is being copied.
2023-02-05 11:52:25 +01:00
Jonas Jenwald
d9181236b2 [GENERIC viewer] Simplify the keyboard find-again state building
By using modern JavaScript features, we can ever so slightly reduce the amount of code needed here.
2023-02-04 23:16:04 +01:00
Jonas Jenwald
d6178a13d7 Reduce a tiny bit of duplication in the webViewerInitialized function 2023-02-04 23:16:04 +01:00
Jonas Jenwald
d930f267f6 Remove a couple of unnecessary PresentationMode-checks in webViewerKeyDown
Given that the `PDFViewerApplication.{zoomIn, zoomOut}` methods already contain PresentationMode-checks, this is just unnecessary duplication.
2023-02-04 23:15:56 +01:00
Jonas Jenwald
ea1ec7ffab Remove a couple of unnecessary pdfDocument checks in web/app.js
These functions invoke the `PDFViewer.currentPageNumber` setter, which already checks that a `pdfDocument` is currently active. Also, given that they're event handlers for the First/Last-page buttons (in the SecondaryToolbar) they can't be invoked before the viewer has been fully initalized.
2023-02-04 22:17:53 +01:00
Tim van der Meij
e698664927
Merge pull request #16004 from Snuffleupagus/WorkerTransport-cacheSimpleMethod
Improve how we cache Promises in `WorkerTransport`
2023-02-04 15:13:12 +01:00
Tim van der Meij
b75dafba87
Merge pull request #15987 from Snuffleupagus/onOpenWithTransport-params
Remove unused parameters from the `onOpenWithTransport` method in `PDFViewerApplication.initPassiveLoading`
2023-02-04 15:07:42 +01:00
Tim van der Meij
bdb6d978a9
Merge pull request #15968 from Snuffleupagus/rm-postCSS-logical
[api-minor] Update the minimum supported browsers, and remove the PostCSS `logical` plugin
2023-02-04 15:04:29 +01:00
Tim van der Meij
e848a0e61c
Merge pull request #15981 from Snuffleupagus/cMapPacked-true
[api-minor] Let the `cMapPacked` parameter, in `getDocument`, default to `true`
2023-02-04 15:00:26 +01:00
Jonas Jenwald
df71f82037
Merge pull request #16003 from Snuffleupagus/scaleSelect-width-CSS-var
Move the `--scale-select-width` CSS variable to the relevant DOM element
2023-02-04 14:23:43 +01:00
Jonas Jenwald
eb341cadd7
Merge pull request #16005 from Snuffleupagus/rm-isEmptyObj
Remove the `isEmptyObj` unit-test helper function
2023-02-04 14:19:51 +01:00