Commit Graph

18250 Commits

Author SHA1 Message Date
calixteman
3ba68f68dc
Merge pull request #17171 from calixteman/issue17169
Don't take into account the INVISIBLE flag for well-known annotations
2023-10-25 14:00:12 +02:00
Jonas Jenwald
bd9b39be28
Merge pull request #17175 from Snuffleupagus/rm-lint-ignores
Remove obsolete entries in the lint-ignore files
2023-10-25 13:46:13 +02:00
Jonas Jenwald
b575de9860 Remove obsolete entries in the lint-ignore files
- The `external/webL10n/` directory was removed in PR 17115.

 - The `src/shared/{cffStandardStrings, fonts_utils}.js` files were removed in PR 17120.
2023-10-25 13:38:51 +02:00
Calixte Denizet
2967eca605 Update the path to get all locales and update locales 2023-10-25 12:47:06 +02:00
Jonas Jenwald
846bd86520 Fix error that's breaking the ConstL10n class (PR 17161 follow-up)
I forgot to include `web/l10n_utils.js` in PR 17161, which currently breaks `ConstL10n` since there's no longer a method called `setL10n`; sorry about that!
2023-10-25 12:11:57 +02:00
Calixte Denizet
133ed96f8f Don't take into account the INVISIBLE flag for well-known annotations 2023-10-25 10:16:14 +02:00
Calixte Denizet
651057c039 Slightly improve the performance of removeNullCharacters
Most of the strings shouldn't contain special chars (<= 0x1F) so we can
have a fast path which just checks if the string contains at least one such
a char.
2023-10-25 10:11:14 +02:00
Jonas Jenwald
f098121644
Merge pull request #17161 from Snuffleupagus/NullL10n-test
Add a unit-test to ensure that `NullL10n` won't diverge from the `L10n`-class
2023-10-24 20:28:34 +02:00
calixteman
3f2072eaee
Merge pull request #17159 from calixteman/bug1860602
[Annotation] Use the field V entry when there is no Parent one for a radio button (bug 1860602)
2023-10-24 16:50:18 +02:00
Jonas Jenwald
bcb01e5e2b Tweak the matchCount l10n-args handling slightly (PR 17146 follow-up)
Given that providing unused parameters in the l10n-args shouldn't be a problem, let's simplify the relevant JavaScript code a tiny bit.
2023-10-24 13:17:02 +02:00
Jonas Jenwald
e2af77fd6c Add a unit-test to ensure that NullL10n won't diverge from the L10n-class
To prevent the *standalone* viewer-components from breaking, we need to ensure that the `NullL10n`-interface won't accidentally diverge from the actual `L10n`-implementations.
2023-10-24 13:13:14 +02:00
Calixte Denizet
2f3797db34 [Annotation] Use the field V entry when there is no Parent one for a radio button (bug 1860602) 2023-10-23 22:11:30 +02:00
calixteman
377af6892b
Merge pull request #17157 from calixteman/auto_update_locale
Update locale on *.ftl change
2023-10-23 14:36:30 +02:00
Jonas Jenwald
cc18d9749a
Merge pull request #17156 from Snuffleupagus/landmark-pageLabel
Update the "aria-label" of the page when a `pageLabel` exists
2023-10-23 14:33:13 +02:00
Calixte Denizet
31cfec63c3 Update locale on *.ftl change 2023-10-23 14:03:31 +02:00
Jonas Jenwald
04696080f8 Update the "aria-label" of the page when a pageLabel exists
Looking at the `PDFThumbnailView.setPageLabel` method you'll see that we update e.g. the "aria-label" of the thumbnail-image for documents that contain (valid) pageLabels.
This isn't done in `PDFPageView`, which seems inconsistent, hence this patch.
2023-10-23 13:42:06 +02:00
Jonas Jenwald
8376b3fb05
Merge pull request #17141 from Snuffleupagus/l10n-more-setAttribute
[api-minor] Use "data-l10n-id"/"data-l10n-args", rather than manually updating DOM-elements, to trigger translation (PR 17146 follow-up)
2023-10-23 12:58:59 +02:00
Jonas Jenwald
17af706070 [api-minor] Use "data-l10n-id"/"data-l10n-args", rather than manually updating DOM-elements, to trigger translation (PR 17146 follow-up)
This patch changes almost all viewer-components[1] to use "data-l10n-id"/"data-l10n-args" for localization, which means that in many cases we no longer need to pass around the `L10n`-instance any more.

One part of the code-base where the `L10n`-instance is still being used "directly" is the AnnotationEditors, however while it might be possible to convert (most of) that code as well that's not attempted in this patch.

---
[1] The one exception is the `PDFDocumentProperties` dialog, since the way it's currently implemented makes that less straightforward to fix without a lot of code changes.
2023-10-22 14:17:47 +02:00
Tim van der Meij
898cc2e399
Merge pull request #17151 from Snuffleupagus/Fluent-PDFDocumentProperties-fixes
A couple of `PDFDocumentProperties` tweaks (PR 17115 follow-up)
2023-10-22 12:33:34 +02:00
Jonas Jenwald
da186d1b89
Merge pull request #17146 from Snuffleupagus/NullL10n-refactor
[api-minor] Re-factor `NullL10n` and remove the hard-coded l10n strings (PR 17115 follow-up)
2023-10-21 17:53:30 +02:00
Jonas Jenwald
4c4676e5a4
Merge pull request #17152 from Snuffleupagus/findbar-resizeObserver
Use a `ResizeObserver` to update the layout of `PDFFindBar`
2023-10-21 17:46:30 +02:00
Jonas Jenwald
e20ef39f59 Use a ResizeObserver to update the layout of PDFFindBar
*Please note:* In the Firefox PDF Viewer this findbar is only used for PDF documents placed in e.g. `<iframe>` elements.

By registering a `ResizeObserver` when the `PDFFindBar` is open we slightly unify and simplify how the findbar layout (row vs column) is handled.
This will be especially helpful with upcoming changes, where we'll make use of "data-l10n-id"/"data-l10n-args" to trigger translation in the viewer.
2023-10-21 16:17:49 +02:00
Jonas Jenwald
7df082fce3 A couple of PDFDocumentProperties tweaks (PR 17115 follow-up)
- The old translation engine handled language code casing slightly differently, hence we need to tweak the non-metric locale check in `PDFDocumentProperties` to account for that.

 - Use only lowercase names for the pre-defined page names, to improve overall consistency.
2023-10-21 10:27:47 +02:00
Jonas Jenwald
f07675a6a8 [api-minor] Re-factor NullL10n and remove the hard-coded l10n strings (PR 17115 follow-up)
*Please note:* These changes only affect the GENERIC build, since `NullL10n` is only a stub elsewhere (see PR 17135).

After the changes in PR 17115, which modernized and improved l10n-handling, the `NullL10n`-implementation is no longer a good fallback for the "proper" `L10n`-classes.
To improve this situation, especially for the *standalone* viewer-components, this patch makes the following changes:
 - Let the `NullL10n`-implementation extend an actual `L10n`-class, which is constant and lazily initialized, to ensure that it works *exactly* like the "proper" ones.

 - Automatically bundle the "en-US" l10n-strings in the build, via the pre-processor, such that we don't need to remember to manually update them.

 - Ensure that the *standalone* viewer-components register their DOM-elements for translation, similar to the default viewer, since this will allow future code improvements by using "data-l10n-id"/"data-l10n-args" in most (if not all) parts of the viewer.

 - Remove the `NullL10n` from the `AnnotationLayer`, to avoid affecting bundle size too much.
   For third-party users that access the `AnnotationLayer`, as exposed in the main PDF.js library, they'll now need to *manually* register it for translation. (However, the *standalone* viewer-components still works given the point above.)
2023-10-20 21:49:33 +02:00
Jonas Jenwald
a4cd2ef1db
Merge pull request #17148 from JT-External/support-rotated-imagemask
Fix size of maskCanvas to draw image masks correctly
2023-10-20 17:25:55 +02:00
JT-External
0eacd5c107 Fix size of maskCanvas to draw image masks correctly
Use existing helper to calculate the Box

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>

Ensure that there are non-zero

Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com>

Add a reference test for #17147
2023-10-20 23:46:24 +09:00
Jonas Jenwald
5f0e560949
Merge pull request #17140 from Snuffleupagus/l10n-move-init
Initialize the `L10n`-instance as soon as possible in Firefox (PR 17115 follow-up)
2023-10-19 20:13:33 +02:00
Jonas Jenwald
5c14c559dd Initialize the L10n-instance as soon as possible in Firefox (PR 17115 follow-up)
Given that there's now a bit more asynchronicity in the l10n-initialization in the Firefox PDF Viewer, after PR 17115, try to limit the impact of that by moving it to occur a tiny bit earlier in the default viewer initialization.
2023-10-19 18:40:52 +02:00
calixteman
d094e8aab0
Merge pull request #17142 from calixteman/no_connect_root
[L10n] Don't try to connect the root element when it has already been done
2023-10-19 18:29:25 +02:00
Calixte Denizet
a0b9c937ae [L10n] Don't try to connect the root element when it has already been done
In Firefox debug builds, there is an assertion to check that we don't connect
a subelement of an already connected root. Thanks to this assertion, we can see
that the root has already been added to Fluent, hence we don't need to do it
a second time.
We don't need to await anymore on the translation in order to update the
toolbar: it'll be done by Fluent, so we can safely remove the "localized"
event and avoid to wait for it.
2023-10-19 18:19:05 +02:00
Jonas Jenwald
e820688510 Remove the enableStampEditor preference 2023-10-19 15:45:07 +02:00
Jonas Jenwald
c60401a765
Merge pull request #17133 from Snuffleupagus/rm-builder-merge
Use object destructuring, rather than the `merge` helper, in the gulpfile
2023-10-19 15:41:40 +02:00
Jonas Jenwald
d6cfbd2839
Merge pull request #17130 from Snuffleupagus/AppOption-move-init
Try to make the `Preferences`/`AppOptions` initialization slightly more efficient
2023-10-19 15:12:30 +02:00
Jonas Jenwald
5ddc949159 Try to make the Preferences/AppOptions initialization slightly more efficient
*Please note:* This patch contains a couple of micro-optimizations, hence I understand if it's deemed unnecessary.

Move the `AppOptions` initialization into the `Preferences` constructor, since that allows us to remove a couple of function calls, a bit of asynchronicity and one loop that's currently happening in the early stages of the default viewer initialization.

Finally, move the `Preferences` initialization to occur a *tiny* bit earlier since that cannot hurt given that the entire viewer initialization depends on it being available.
2023-10-19 14:44:55 +02:00
Jonas Jenwald
929311fb9d
Merge pull request #17135 from Snuffleupagus/bug-1859818
Only bundle `NullL10n` in GENERIC builds (bug 1859818)
2023-10-19 14:35:01 +02:00
Jonas Jenwald
69ad0d9861 Only bundle NullL10n in GENERIC builds (bug 1859818) 2023-10-19 13:51:00 +02:00
Jonas Jenwald
f39bedd06c
Merge pull request #17138 from Snuffleupagus/issue-17137
Use a CSS-only solution to set the `dropdownToolbarButton` width (issue 17137)
2023-10-19 13:49:05 +02:00
Jonas Jenwald
482b789edf Use a CSS-only solution to set the dropdownToolbarButton width (issue 17137)
Note that CSS-features such as e.g. `flex` didn't exist, or had poor cross-browser support, back when the JavaScript-based solution was initially implemented.
2023-10-19 13:44:02 +02:00
calixteman
5d8be99782
Merge pull request #17115 from calixteman/mv_to_fluent
[api-minor] Move to Fluent for the localization (bug 1858715)
2023-10-19 13:40:50 +02:00
Jonas Jenwald
6a6f6f122c
Merge pull request #17131 from Snuffleupagus/openOrDownloadData-caching
Re-factor the blob-URL caching in `DownloadManager.openOrDownloadData`
2023-10-19 11:25:47 +02:00
Calixte Denizet
66982a2a11 [api-minor] Move to Fluent for the localization (bug 1858715)
- For the generic viewer we use @fluent/dom and @fluent/bundle
- For the builtin pdf viewer in Firefox, we set a localization url
  and then we rely on document.l10n which is a DOMLocalization object.
2023-10-19 11:20:41 +02:00
Jonas Jenwald
2a3090224f
Merge pull request #17134 from Snuffleupagus/writeStream-less-type-conversion
Reduce unnecessary type conversion in `writeStream`
2023-10-18 16:55:04 +02:00
Jonas Jenwald
25a1a9d28f Reduce unnecessary type conversion in writeStream
Currently we're unnecessarily converting data between strings and typed-arrays, when dealing with compressible data, in the `writeStream` function.
Note how we're *first* getting a string-representation of the stream, which involves converting the underlying typed-array into a string, only to immediately convert this back into a typed-array. This seems completely unnecessary, and is easy enough to avoid, and we'll now only do a *single* type-conversion in this function.
2023-10-18 15:39:01 +02:00
Jonas Jenwald
ae664ea8e0 Use object destructuring, rather than the merge helper, in the gulpfile
This helper function was originally added in PR 1953, eleven years ago, at which point object destructuring didn't exist.
2023-10-18 13:49:26 +02:00
Jonas Jenwald
674052d3fc Re-factor the blob-URL caching in DownloadManager.openOrDownloadData
Cache blob-URLs on the actual data, rather than DOM elements, to reduce potential duplicates (note the updated unit-test).
2023-10-17 10:18:34 +02:00
Tim van der Meij
22d6d95f03
Merge pull request #17125 from timvandermeij/find-intermittent
Fix intermittent problems on Windows in the XFA search integration test
2023-10-15 18:32:17 +02:00
Tim van der Meij
2bae8af96a
Fix intermittent problems on Windows in the XFA search integration test
The current test fails intermittently only on Windows for unknown
reasons: the code is correct and on Linux it always passes. However, we
have already spent quite a lot of time on this test, so rather than
spending even more time on it I figured we should look at what behavior
the test is trying to check and find an alternative way to do it that
can't trigger this intermittent issue anymore.

This commit changes the test to use a term that only exists once in the
entire document so we cannot accidentally highlight another match
anymore. This doesn't change anything about the behavior that this test
aims to check: we still test searching in the XFA layer, we still test
that the original term is matched case-insensitively and we still test
that that match is actually highlighted. Note that the only objective of
the test is confirming that the search functionality covers the XFA
layer, so the exact phrase/match is not the interesting bit.
2023-10-15 15:02:41 +02:00
Tim van der Meij
a9a1195582
Merge pull request #17123 from Snuffleupagus/eslint-globals
Update the ESLint `globals` list (PR 17055 follow-up)
2023-10-15 12:06:54 +02:00
Jonas Jenwald
93f24dd5d7 Remove the ESLint "amd" environment (PR 17055 follow-up)
Please see https://eslint.org/docs/latest/use/configure/language-options#specifying-environments
2023-10-15 11:50:57 +02:00
Jonas Jenwald
d5acbbccd3 Update the ESLint globals list (PR 17055 follow-up)
Given that we only use standard `import`/`export` statements now, after recent PRs, the "exports" global is unused.
Instead we add "__non_webpack_import__" to the `globals` to avoid having to sprinkle disable statements throughout the code.

Finally, the way that `globals` are defined has changed in ESLint and we should thus explicitly specify them as "readonly"; please find additional details at https://eslint.org/docs/latest/use/configure/language-options#specifying-globals
2023-10-15 11:38:10 +02:00