Commit Graph

18328 Commits

Author SHA1 Message Date
Jonas Jenwald
c1fef7d2f2 Guard navigator-object accesses in src/-files (issue 15728)
There are environments that include *incomplete* polyfills for the `navigator`-object, which may thus cause the PDF.js library to break.
Despite that clearly not being our fault, it may still result in bug reports filed against the PDF.js project; see e.g. 15728.

Currently this even seem to affect *the latest* version of Node.js; see e.g. [here].

*Please note:* Thanks to the pre-processor none of these changes affect the Firefox PDF Viewer, however it does add "overhead" when working with and reviewing the affected code (which is why I'm not crazy about this).
2023-10-28 14:41:46 +02:00
Tim van der Meij
238f3e728f
Merge pull request #17185 from Snuffleupagus/annotationLayer-modifier
Fix `WidgetAnnotationElement._getKeyModifier` to account for Linux
2023-10-28 14:21:19 +02:00
Jonas Jenwald
d7b39fe696 Update the webpack example to account for outputting of JavaScript modules (PR 17055 follow-up)
*Please note:* While following the steps in the README still works with this patch, in the sense that the example runs and successfully renders a PDF document, I unfortunately cannot tell if it illustrates Webpack best practices.
2023-10-28 10:26:34 +02:00
Jonas Jenwald
9ec2fda09f Simplify the l10n-handling in the mobile-viewer example
- Remove the `errorWrapper`-element, since it simplifies the example and is consistent with the default viewer; see PR 15533.

 - Simplify the l10n-handling, since the `NullL10n` should be able to translate everything e.g. without fallback values; see PR 17146.
2023-10-28 10:26:34 +02:00
Jonas Jenwald
59c4041a49 Update the examples/-folder to account for outputting of JavaScript modules (PR 17055 follow-up)
This patch also changes most examples to use "top level await", since that's now supported and slightly simplifies the code.
2023-10-28 10:26:25 +02:00
Jonas Jenwald
3f0b3b15de
Merge pull request #17196 from Snuffleupagus/annotationLayer-css-nesting
Use CSS nesting in the annotationLayer
2023-10-27 19:50:10 +02:00
Jonas Jenwald
7d5b970eee Collect the forced-colors CSS rules for linkAnnotation in one spot 2023-10-27 19:29:33 +02:00
Jonas Jenwald
d30bf4482f
Merge pull request #17195 from Snuffleupagus/textLayer-css-nesting
Use CSS nesting in the textLayer
2023-10-27 19:24:15 +02:00
Jonas Jenwald
b779e418a5 Use CSS nesting in the annotationLayer 2023-10-27 18:46:47 +02:00
Jonas Jenwald
525be9afea Use CSS nesting in the textLayer 2023-10-27 17:38:01 +02:00
Jonas Jenwald
d293048c5d Pause translation when appending the textLayer and structTreeLayer to the page
Note that we must append the textLayer to the DOM *before* enabling the `highlighter` and `accessibilityManager`, to avoid breaking e.g. a pending searching operation.
The least invasive solution, that I was able to come up with, is to introduce a new `TextLayerBuilder` callback-function for this purpose.
2023-10-27 16:55:46 +02:00
calixteman
6115a328ea
Merge pull request #17189 from calixteman/mac_integration_test
Fix integration tests on Mac
2023-10-27 16:45:46 +02:00
Calixte Denizet
d72fd9ce4f Fix intermittents failure on mac 2023-10-27 16:10:06 +02:00
Calixte Denizet
517a262fb1 Fix keyboard shortcuts on mac and for some tests make sure that all
the page is displayed in using page-fit in order to make all tested
elements visible.
2023-10-27 16:09:35 +02:00
Jonas Jenwald
34781121cd
Merge pull request #17186 from flodolo/fluent_linter
Add workflow to lint Fluent en-US files
2023-10-26 17:47:08 +02:00
Francesco Lodolo
487816bd68
Add workflow to lint Fluent en-US files 2023-10-26 17:27:42 +02:00
Jonas Jenwald
069096e78f Fix WidgetAnnotationElement._getKeyModifier to account for Linux
Currently the `WidgetAnnotationElement._getKeyModifier` method will always be falsy on Linux, which seems like a simple oversight. Looking at all the other `FeatureTest.platform` accesses we only handle the `isMac`-case specially, and it seems reasonable to do the same thing here.
The reason that this hasn't led to any bug reports is most likely that the `modifier`-property seems completely unused in the scripting-implementation.

Finally, with these changes we can (slightly) simplify the `FeatureTest.platform` implementation.
2023-10-26 13:36:42 +02:00
Jonas Jenwald
097f214222 Handle appending consistently in the xfaLayer regardless of rendering intent (PR 17177 follow-up)
After PR 17177 the interface of `XfaLayerBuilder` is now inconsistent, since whether or not we directly append the xfaLayer to the DOM now depends on the rendering intent.
2023-10-26 12:05:33 +02:00
calixteman
fbfacf8828
Merge pull request #17177 from Snuffleupagus/xfaLayer-pause-l10n
Pause translation when appending the xfaLayer to the page
2023-10-25 21:46:49 +02:00
Jonas Jenwald
399f444c84 Pause translation when appending the xfaLayer to the page 2023-10-25 20:33:39 +02:00
calixteman
b31e77df17
Merge pull request #17166 from calixteman/improve_oc_parsing
Improve performance of optional content parsing
2023-10-25 18:28:38 +02:00
Jonas Jenwald
806ac67ea4
Merge pull request #17176 from Snuffleupagus/BaseTreeViewer-pause-l10n
Pause translation when appending the outline/attachment/layer trees to the sidebar
2023-10-25 17:51:39 +02:00
Calixte Denizet
0c38c6e103 Improve performance of optional content parsing 2023-10-25 17:50:53 +02:00
Jonas Jenwald
6b265b3a15 Pause translation when appending the outline/attachment/layer trees to the sidebar
Also, pause translation when collapsing/expanding subtrees.
2023-10-25 17:38:02 +02:00
Jonas Jenwald
0fc899338c
Merge pull request #17006 from Snuffleupagus/rm-enableStampEditor-pref
Remove the `enableStampEditor` preference
2023-10-25 16:24:49 +02:00
calixteman
f27f2bb403
Merge pull request #17165 from calixteman/improve_removenullchars
Slightly improve the performance of removeNullCharacters
2023-10-25 15:01:32 +02:00
Jonas Jenwald
5d3823a81a
Merge pull request #17173 from Snuffleupagus/ConstL10n-setL10n
Fix error that's breaking the `ConstL10n` class (PR 17161 follow-up)
2023-10-25 14:51:33 +02:00
calixteman
31243230af
Merge pull request #17174 from calixteman/update_import_l10n
Update the path to get all locales and update locales
2023-10-25 14:40:22 +02:00
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