Commit Graph

14619 Commits

Author SHA1 Message Date
Jonas Jenwald
96dbe38544 Update some deprecated ESLint rules
Please see https://eslint.org/docs/rules/#deprecated where the following rules apply to the PDF.js project:
 - [`no-buffer-constructor`](https://eslint.org/docs/rules/no-buffer-constructor), which we can replace with the `unicorn/no-new-buffer` rule; see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-new-buffer.md
 - [`no-catch-shadow`](https://eslint.org/docs/rules/no-catch-shadow), which was replaced by the `no-shadow` rule (that we're already using).
2021-08-11 17:35:56 +02:00
Jonas Jenwald
d3c9c08aca
Merge pull request #13887 from mozilla/dependabot/npm_and_yarn/path-parse-1.0.7
Bump path-parse from 1.0.5 to 1.0.7
2021-08-10 22:43:42 +02:00
dependabot[bot]
91ef2e19aa
Bump path-parse from 1.0.5 to 1.0.7
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.5 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-10 18:23:47 +00:00
Tim van der Meij
745d5cc819
Merge pull request #13884 from Snuffleupagus/update-packages
Update packages and translations
2021-08-08 11:58:56 +02:00
Tim van der Meij
43060d39ad
Merge pull request #13883 from Snuffleupagus/api-cache-annotations
Improve caching of Annotations-data, by using a `Map`, in the API
2021-08-08 11:30:31 +02:00
Jonas Jenwald
d24476e02c Update l10n files 2021-08-08 10:52:26 +02:00
Jonas Jenwald
d0c87e13ce Update the eslint-plugin-unicorn package to the latest version
Also enables the `no-useless-spread` rule, see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-spread.md, which didn't require any code changes.
2021-08-08 10:49:57 +02:00
Jonas Jenwald
014d00e4fb Update npm packages 2021-08-08 10:45:36 +02:00
Jonas Jenwald
7f2d524df5 Improve caching of Annotations-data, by using a Map, in the API
Rather than caching only the *last* `PDFPageProxy.getAnnotations` call, and having to handle the intent separately, we can instead implement the caching in exactly the same way as done in the `PDFPageProxy.{render, getOperatorList}` methods.
2021-08-08 08:14:51 +02:00
Tim van der Meij
036b81496e
Merge pull request #13882 from Snuffleupagus/PDFWorker-rm-closure
[api-minor] Remove the closure from the `PDFWorker` class, in the `src/display/api.js` file
2021-08-07 19:52:39 +02:00
Tim van der Meij
952f6366bf
Merge pull request #13867 from Snuffleupagus/RenderingIntentFlag
[api-minor] Re-factor the *internal* renderingIntent, and change the default `intent` value in the `PDFPageProxy.getAnnotations` method
2021-08-07 19:25:51 +02:00
Tim van der Meij
f3960a65d3
Merge pull request #13879 from Snuffleupagus/test-resources-fix-globals
Fix the global variable definitions in `test/resources/reftest-analyzer.js` (issue 13862)
2021-08-07 19:00:42 +02:00
Jonas Jenwald
1cf9405281 [api-minor] Remove the closure from the PDFWorker class, in the src/display/api.js file
This patch removes the only remaining closure in the `src/display/api.js` file, utilizing a similar approach as used in lots of other parts of the code-base, which results in a small decrease in the size of the *build* `pdf.js` file.

Given that `PDFWorker` is exposed through the *public* API, this complicates things somewhat since there's a couple of worker-related properties that really should stay *private*. Initially, while working on PR 13813, I believed that we'd need support for private (static) class fields in order to get rid of this closure, however I've managed to come up with what's hopefully deemed an acceptable work-around here.
Furthermore, some helper functions were simply moved into the `PDFWorker` class as static methods, thus simplifying the overall implementation (e.g. we don't need to manually cache the Promise in the `PDFWorker._setupFakeWorkerGlobal`-method).

Finally, as part of this re-factoring a number of missing JSDoc-comments were added which *together* with the removal of the closure significantly improves the `gulp jsdoc` output for the `PDFWorker` class.

*Please note:* This patch is tagged with `api-minor` since it deprecates `PDFWorker.getWorkerSrc()` in favor of the shorter `PDFWorker.workerSrc`, with the fallback limited to `GENERIC` builds.
2021-08-07 10:43:39 +02:00
Brendan Dahl
3d18c76a53
Merge pull request #13881 from calixteman/bug_1723734
XFA - Elements under an area must be bound (bug 1723734)
2021-08-06 11:56:58 -07:00
Calixte Denizet
328383ea7a XFA - Elements under an area must be bound (bug 1723734)
- aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1723734.
2021-08-06 20:20:19 +02:00
calixteman
98e893b84f
Merge pull request #13880 from eltociear/patch-5
Fix typo in cff_parser_spec.js
2021-08-06 19:31:52 +02:00
Brendan Dahl
d7e1a419c2
Merge pull request #13873 from brendandahl/xfa-heading
XFA - Support aria heading and table structure. (bug 1723421) (bug 1723425)
2021-08-06 09:54:47 -07:00
Ikko Ashimine
23236f1b0b
Fix typo in cff_parser_spec.js
shoudn't -> shouldn't
2021-08-06 19:30:36 +09:00
Jonas Jenwald
df79b831f4 Fix the global variable definitions in test/resources/reftest-analyzer.js (issue 13862)
It shouldn't be necessary to assign these variables to the global scope (as far as I can tell), either explicitly with `window` or implicitly with `var`, and this way we don't need to disable the ESLint `no-undef` rule; fixes another small part of issue 13862.

*Please note:* I wasn't going to put additional work into this code after PR 13869, however these changes looked so simple that I figured trying to get rid of the few remaining "Code scanning alerts" wouldn't hurt.
However, this file would still very much benefit from additional clean-up and re-factoring work, since it's quite old and currently contains some dead code (commented out).
2021-08-06 11:45:55 +02:00
Jonas Jenwald
107efdb178 [Regression] Re-factor the *internal* renderInteractiveForms handling, since it's currently subtly wrong
The value of the `renderInteractiveForms` parameter, as passed to the `PDFPageProxy.render` method, will (potentially) affect the size/content of the operatorList that's returned from the worker (for documents with forms).
Given that operatorLists will generally, unless they contain huge images, be cached in the API, repeated `PDFPageProxy.render` calls that *only* change the `renderInteractiveForms` parameter can thus return an incorrect operatorList.

As far as I can tell, this *subtle* bug has existed ever since `renderInteractiveForms`-support was first added in PR 7633 (which is almost five years ago).
With the previous patch, fixing this is now really simple by "encoding" the `renderInteractiveForms` parameter in the *internal* renderingIntent handling.
2021-08-06 00:40:43 +02:00
Jonas Jenwald
47f94235ab [api-minor] Re-factor the *internal* renderingIntent, and change the default intent value in the PDFPageProxy.getAnnotations method
With the changes made in PR 13746 the *internal* renderingIntent handling became somewhat "messy", since we're now having to do string-matching in various spots in order to handle the "oplist"-intent correctly.
Hence this patch, which implements the idea from PR 13746 to convert the `intent`-strings, used in various API-methods, into an *internal* renderingIntent that's implemented using a bit-field instead. *Please note:* This part of the patch, in itself, does *not* change the public API (but see below).

This patch is tagged `api-minor` for the following reasons:
 1. It changes the *default* value for the `intent` parameter, in the `PDFPageProxy.getAnnotations` method, to "display" in order to be consistent across the API.
 2. In order to get *all* annotations, with the `PDFPageProxy.getAnnotations` method, you now need to explicitly set "any" as the `intent` parameter.
 3. The `PDFPageProxy.getOperatorList` method will now also support the new "any" intent, to allow accessing the operatorList of all annotations (limited to those types that have one).
 4. Finally, for consistency across the API, the `PDFPageProxy.render` method also support the new "any" intent (although I'm not sure how useful that'll be).

Points 1 and 2 above are the significant, and thus breaking, changes in *default* behaviour here. However, unfortunately I cannot see a good way to improve the overall API while also keeping `PDFPageProxy.getAnnotations` unchanged.
2021-08-06 00:39:42 +02:00
Brendan Dahl
a38d1122d8 XFA - Support aria heading and table structure. (bug 1723421) (bug 1723425)
https://bugzilla.mozilla.org/show_bug.cgi?id=1723421
https://bugzilla.mozilla.org/show_bug.cgi?id=1723425
2021-08-05 15:25:04 -07:00
Tim van der Meij
849bab973c
Merge pull request #13874 from Snuffleupagus/components-annotation-zoom-factor
Update the Annotation `--zoom-factor` CSS variable when `PDFPageView` is used standalone (PR 13868 follow-up)
2021-08-05 22:28:51 +02:00
Tim van der Meij
8292076af9
Merge pull request #13869 from Snuffleupagus/test-resources-lint
Enable linting in the `test/resources/` folder, and fix the "Remote property injection" warning (issue 13862)
2021-08-05 22:17:26 +02:00
calixteman
834e475e1d
Merge pull request #13875 from calixteman/xfa_focus
Annotation & XFA: Add focus outlines on different fields (bug 1723615, bug 1718528)
2021-08-05 20:09:00 +02:00
Calixte Denizet
fef939d347 Annotation & XFA: Add focus outlines on different fields (bug 1723615, bug 1718528)
- set a default tabindex to be sure they'll be taken into account in the TAB cycle (https://bugzilla.mozilla.org/show_bug.cgi?id=1723615).
  - show default outline when fields are focused (it was an a11y bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1718528).
2021-08-05 13:33:46 +02:00
Jonas Jenwald
561faa7c94 Update the Annotation --zoom-factor CSS variable when PDFPageView is used standalone (PR 13868 follow-up)
Without this patch, when using `PDFPageView` directly[1] this CSS variable won't be updated and consequently things won't work as intended.
This is purposely implemented such that when a `PDFPageView`-instance is part of a viewer, we don't repeatedly set the CSS variable for every single page.

---
[1] See e.g. the "pageviewer" example in the `examples/components/` folder.
2021-08-05 11:43:43 +02:00
Jonas Jenwald
4ad65c8b9c
Merge pull request #13868 from calixteman/zoom_select
Annotation & XFA: Scale the font size in choicelist using zoom factor (bug 1715996)
2021-08-05 10:45:13 +02:00
Calixte Denizet
71a100a4d0 Annotation & XFA: Scale the font size in choicelist using zoom factor (bug 1715996)
- this is an accessibility issue which could be painful for some people with visual disabilities.
2021-08-04 20:36:04 +02:00
Jonas Jenwald
39663e730e Change the hashParameters function to return a Map rather than an Object (issue 13862)
This patch (basically) mirrors the implementation in PR 13831, to get rid of the "Remote property injection" warning.
2021-08-04 15:17:13 +02:00
Jonas Jenwald
5dfdfbc70b Fix *some* of the remaining linting issues in test/resources/reftest-analyzer.js
Given that issue 13862 tracks updating/modernizing the code, this patch purposely limits the scope of the changes. In particular, the following things are still left to address:
 - The ESLint `no-undef` errors; for now the rule is simply disabled globally in this file.
 - A couple of unused variables are commented out for now, but could perhaps just be removed.
2021-08-04 14:14:04 +02:00
Jonas Jenwald
92300965a4 Fix *most* linting/formatting issues in the test/resources/ folder
These changes were done automatically, by using the `gulp lint --fix` command.
2021-08-04 13:59:21 +02:00
Jonas Jenwald
99aa747a1d Include the test/resources/ folder when running ESLint/Stylelint
Also, update the `.stylelintignore` file to agree with the `.eslintignore` file since the configurations had (unintentionally) diverged.
2021-08-04 13:50:44 +02:00
calixteman
52ef63f1fe
Merge pull request #13856 from calixteman/xfa_layout_rounding
XFA - Avoid to put something in very small areas
2021-08-04 10:09:13 +02:00
Brendan Dahl
2cef6d8796
Merge pull request #13864 from brendandahl/xfa-alt-text
[XFA] Add alt text for images. (bug 1723418)
2021-08-03 18:42:31 -07:00
Brendan Dahl
3e003245b1 [XFA] Add alt text for images. (bug 1723418)
Not many XFA PDFs have alt text.

Some examples:
bug1723422.pdf
xfa_bug1718670_1.pdf
xfa_issue13611.pdf
xfa_issue13633.pdf
xfa_issue13634.pdf
2021-08-03 17:18:58 -07:00
Brendan Dahl
6cf1ee3251
Merge pull request #13858 from brendandahl/xfa-aria-label
Add aria-labels to XFA form elements. (bug 1723422)
2021-08-03 17:18:08 -07:00
Brendan Dahl
6ea56f35ab Add aria-labels to XFA form elements. (bug 1723422) 2021-08-03 15:58:33 -07:00
Tim van der Meij
b317e9311d
Merge pull request #13846 from Snuffleupagus/test-xfa
Add a special `gulp xfatest` command, to limit the ref-tests to only XFA-documents (issue 13744)
2021-08-03 23:47:30 +02:00
Jonas Jenwald
844319cdb0 Add a special gulp xfatest command, to limit the ref-tests to only XFA-documents (issue 13744)
The new command is a *variation* of the standard `gulp test` command and will run all unit/font/integration-tests just as normal, while *only* running ref-tests for XFA-documents to speed up development.
Given that we currently have (some) unit-tests for XFA-documents, and that we may also (in the future) want to add integration-tests, it thus makes sense to run all test-suites in my opinion.

*Please note:* Once this patch has landed, I'll submit a follow-up patch to https://github.com/mozilla/botio-files-pdfjs such that we can also run the new command on the bots.
2021-08-03 23:41:10 +02:00
Tim van der Meij
85be62c684
Merge pull request #13854 from Snuffleupagus/issue-13851
Prevent breaking errors when an optional content group is undefined (issue 13851)
2021-08-03 23:34:34 +02:00
Tim van der Meij
ad90fe90ed
Merge pull request #13848 from Snuffleupagus/rm-lgtm
Remove the LGTM configuration and inline disable comments (issue 13829)
2021-08-03 23:13:05 +02:00
Tim van der Meij
892af51269
Merge pull request #13859 from Snuffleupagus/refactor-EOF
Remove the `isEOF` helper function and slightly re-factor `EOF`
2021-08-03 23:11:10 +02:00
Jonas Jenwald
ad702d7088
Merge pull request #13860 from mozilla/dependabot/npm_and_yarn/tar-4.4.15
Bump tar from 4.4.8 to 4.4.15
2021-08-03 22:20:32 +02:00
dependabot[bot]
81a6ade590
Bump tar from 4.4.8 to 4.4.15
Bumps [tar](https://github.com/npm/node-tar) from 4.4.8 to 4.4.15.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v4.4.8...v4.4.15)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-03 19:41:11 +00:00
Jonas Jenwald
766299016f Remove the isEOF helper function and slightly re-factor EOF
Given how trivial the `isEOF` function is, we can simply inline the check at the various call-sites and remove the function (which ought to be ever so slightly more efficient as well).
Furthermore, this patch also changes the `EOF` primitive itself to a `Symbol` instead of an Object since that has the nice benefit of making it unclonable (thus preventing *accidentally* trying to send `EOF` from the worker-thread).
2021-08-03 20:19:32 +02:00
Calixte Denizet
be1ee155d1 XFA - Avoid to put something in very small areas
- it aims to fix #13855.
2021-08-03 17:05:29 +02:00
calixteman
0b95d698d8
Merge pull request #13852 from calixteman/xfa_print_1
XFA - Page can be too small when printing (bug 1723705)
2021-08-03 16:28:26 +02:00
Jonas Jenwald
d5e14d3dc3 Prevent breaking errors when an optional content group is undefined (issue 13851)
In the referenced PDF document *most* of the form `/Form` XObjects don't have an `/OC` entry, which thus causes the runtime failure during rendering.
2021-08-03 15:59:29 +02:00
Calixte Denizet
19309c1f28 XFA - Page can be too small when printing (bug 1723705) 2021-08-03 15:07:33 +02:00