Commit Graph

15509 Commits

Author SHA1 Message Date
Tim van der Meij
312595eb47
Update translations to the most recent versions 2022-04-02 19:43:34 +02:00
Tim van der Meij
c04373dda2
Update dependencies to the most recent versions 2022-04-02 19:43:34 +02:00
Tim van der Meij
349fc51f2c
Update GitHub Actions workflow steps to the most recent versions 2022-04-02 16:21:43 +02:00
Tim van der Meij
7c8a92da77
Merge pull request #14742 from Snuffleupagus/debugger-loops
Replace most loops in `web/debugger.js` with `for...of` loops
2022-04-02 13:52:04 +02:00
Jonas Jenwald
bc1cde238d Replace most loops in web/debugger.js with for...of loops
This leads to *slightly* more compact code overall. Also, uses object shorthand notation to remove some now unnecessary `function`-strings.
2022-04-02 11:58:10 +02:00
Jonas Jenwald
38e9a46a85
Merge pull request #14738 from Snuffleupagus/xfa-datasets-decode
Decode non-ASCII values found in the xfa:datasets (PR 14735 follow-up)
2022-04-01 12:36:57 +02:00
Jonas Jenwald
f33ce5fc2d Decode non-ASCII values found in the xfa:datasets (PR 14735 follow-up)
*Please note:* This is possibly bad/wrong in general, but I figured that submitting it for review wouldn't hurt.

It seems that even Adobe Reader doesn't handle the non-ASCII characters that appear in some of the fields correctly, however it should be pretty easy to improve things on the PDF.js side.
2022-04-01 11:54:34 +02:00
Jonas Jenwald
b0ec83262b
Merge pull request #14734 from Snuffleupagus/setAttribute-string-conversion
Don't manually convert `setAttribute` values to strings (PR 14554 follow-up)
2022-04-01 11:38:02 +02:00
Jonas Jenwald
36a289d747
Merge pull request #14735 from calixteman/14685
[Annotations] Some annotations can have their values stored in the xfa:datasets
2022-04-01 11:30:16 +02:00
Calixte Denizet
0b597304c1 [Annotations] Some annotations can have their values stored in the xfa:datasets
- it aims to fix #14685;
- add a basic object to get values from the parsed datasets;
- these annotations don't have an appearance so we must create one when printing or saving.
2022-04-01 10:28:04 +02:00
Jonas Jenwald
f1b17773c0 Don't manually convert setAttribute values to strings (PR 14554 follow-up)
According to MDN, see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute#parameters, non-string values will be automatically converted into strings. I should probably have read that article more carefully, to avoid unnecessary churn in the code; sorry about that!
2022-03-31 17:26:28 +02:00
Jonas Jenwald
54d4d345d3
Merge pull request #14733 from Snuffleupagus/String-repeat
Use `String.prototype.repeat()` in a couple of spots
2022-03-30 16:34:10 +02:00
Jonas Jenwald
addb4cb12b Use String.prototype.repeat() in a couple of spots
Rather than using a temporary Array to manually create repeated strings, we can use `String.prototype.repeat()` instead.
The reason that we didn't use this from the start is most likely because some browsers, notably IE, didn't support this; note https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat#browser_compatibility
2022-03-30 15:42:40 +02:00
Jonas Jenwald
d6592b5e37
Merge pull request #14710 from Snuffleupagus/overlays-dialog
Convert the existing overlays to use `<dialog>` elements (issue 14698)
2022-03-30 11:47:36 +02:00
calixteman
4d4c67dd6e
Merge pull request #14720 from calixteman/12189
[Annotations] Add support for printing/saving choice list with multiple selections
2022-03-30 11:12:21 +02:00
Calixte Denizet
ad3fb71a02 [Annotations] Add support for printing/saving choice list with multiple selections
- it aims to fix issue #12189.
2022-03-29 18:59:44 +02:00
Jonas Jenwald
c9f262c480 Add a <dialog> polyfill for the generic-legacy build
Please note that this patch is purposely quite basic, e.g. it doesn't add the polyfill-CSS in order to simplify the build process, and things such as `::backdrop` thus isn't working.
However, this patch does ensure that older browsers can at least still *access* all of the previous overlays and that things like e.g. opening of password-protected documents respectively printing still works.
2022-03-28 11:36:31 +02:00
Jonas Jenwald
b3d58e1000 Try to improve a11y for the PasswordPrompt and PDFDocumentProperties dialogs
This will hopefully improve the a11y a little bit in these dialogs, however there's most definately more things that can be done here (by someone more knowledgeable about a11y).
2022-03-28 11:36:31 +02:00
Jonas Jenwald
923bd52cdb Re-factor the OverlayManager class to use a WeakMap internally
This way we're able to store the `<dialog>` elements directly, which removes the need to use manually specified name-strings thus simplifying both the `OverlayManager` itself and its calling code.
2022-03-28 11:36:31 +02:00
Jonas Jenwald
f0aa08b464 Convert the existing overlays to use <dialog> elements (issue 14698)
This replaces our *custom* overlays with standard `<dialog>` DOM elements, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog, thus simplifying the related CSS, HTML, and JavaScript code.

With these changes, some of the functionality of the `OverlayManager` class is now handled natively (e.g. `Esc` to close the dialog). However, since we still need to be able to prevent dialogs from overlaying one another, it still makes sense to keep this functionality (as far as I'm concerned).
2022-03-28 11:36:29 +02:00
Jonas Jenwald
0dd6bc9a85
Merge pull request #14703 from calixteman/14627
[text selection] Add the whitespaces present in the pdf in the text chunk
2022-03-27 15:20:19 +02:00
Calixte Denizet
18e79e3c0b [text selection] Add the whitespaces present in the pdf in the text chunk
- it aims to fix issue #14627;
- the basic idea of the recent text refactoring was to only consider the rendered visible whitespaces.
  But sometimes, the heuristics aren't correct and although some whitespaces are in the text stream
  they weren't in the text chunks because they were too small. Hence we added some exceptions, for example,
  we always add a whitespace when it is between two non-whitespace chars but only when in the same Tj.
  So basically, this patch removes the constraint to have the chars in the same Tj
  (in using a circular buffer to save the two last chars) but don't add a space when the visible space is really
  too small (hence `NOT_A_SPACE_FACTOR`).
2022-03-27 14:34:56 +02:00
Tim van der Meij
20d60d92ba
Merge pull request #14715 from Snuffleupagus/issue-13230
Avoid the `textLayer` becoming visible in high contrast mode (issue 13230)
2022-03-27 14:22:35 +02:00
Tim van der Meij
973b92060c
Merge pull request #14717 from Snuffleupagus/issue-14716
Change the type of the `container` property, in the `TextLayerRenderParameters` typedef (issue 14716)
2022-03-27 14:09:36 +02:00
Tim van der Meij
d4714b3043
Merge pull request #14693 from Snuffleupagus/CSS-dir-factor
Remove the remaining `dir`-dependent CSS rules
2022-03-27 14:07:24 +02:00
Jonas Jenwald
7f0589c74a Change the type of the container property, in the TextLayerRenderParameters typedef (issue 14716)
Given that the textLayer-code has been using a `DocumentFragment` ever since PR 3356 (back in 2013), simply updating the type of the `container` property should be fine.
This patch also tries to, ever so slightly, improve the grammar of a couple of other properties in the typedef.
2022-03-24 22:42:37 +01:00
Jonas Jenwald
fd6e2e2ab3 Avoid the textLayer becoming visible in high contrast mode (issue 13230)
Unfortunately this CSS property is not yet available in Firefox, see https://developer.mozilla.org/en-US/docs/Web/CSS/forced-color-adjust#browser_compatibility which is tracked in https://bugzilla.mozilla.org/show_bug.cgi?id=1591210, however this patch seems to work when testing in Google Chrome.

Given that we really cannot do any more on the PDF.js-side of things, until this CSS feature is actually implemented in Firefox, I figured that submitting this patch cannot hurt in order to get rid of an open issue.
2022-03-24 14:20:27 +01:00
Jonas Jenwald
f8d60da94e Remove the remaining dir-dependent CSS rules
After the recent round of patches, I figured that we'd gone as far as possible in replacing `dir`-dependent CSS rules for the viewer.
However, it occurred that me that we could actually use a bit of CSS-trickery to get rid of the remaining ones. More specifically, this was done by defining a CSS variable whose value depends on the document direction and then using that variable together with `calc()` in the affected rules.

*Please note:* I suppose that this could perhaps be seen as a bit too "magical", hence I understand if this patch is ultimately rejected, however this is probably the only simple way to get rid of the remaining `dir`-dependent CSS rules.
2022-03-23 22:05:23 +01:00
Tim van der Meij
db4f3adc5e
Merge pull request #14691 from Snuffleupagus/border-inline
Replace `dir`-dependent `border`-rules with logical properties
2022-03-23 20:43:15 +01:00
Tim van der Meij
a3e34002cb
Merge pull request #14699 from Snuffleupagus/getDocument-validation
Slightly improve validation of (some) parameters in `getDocument`
2022-03-23 20:41:05 +01:00
Tim van der Meij
30612d2f4e
Merge pull request #14704 from Snuffleupagus/OverlayManager-private
Convert the `OverlayManager` class to use private fields/methods
2022-03-23 20:38:05 +01:00
Jonas Jenwald
cd133dbcac Change OverlayManager.open to always error if the overlay is already active
The old code would allow an overlay to force close *itself*, before immediately re-opening itself, which actually isn't very helpful in practice since that won't re-run any overlay-specific initialization code.
Given how the overlays are being used this really shouldn't have caused any issues, but it's a bug that we should fix nonetheless.
2022-03-22 09:50:28 +01:00
Jonas Jenwald
bace0623e5 Convert the OverlayManager class to use private fields/methods 2022-03-21 16:01:32 +01:00
Jonas Jenwald
849de5a508 Slightly improve validation of (some) parameters in getDocument
There's a couple of `getDocument` parameters that should be numbers, but which are currently not *fully* validated to prevent issues elsewhere in the code-base.
Also, improves validation of the `ownerDocument` parameter since we currently accept more-or-less anything here.
2022-03-21 13:32:17 +01:00
Jonas Jenwald
477dc08b00 Replace dir-dependent border-rules with logical properties
*Please note:* This is the final step in a series of patches to simplify/modernize the viewer CSS, since the remaining `html[dir="rtl"]`-cases cannot be converted.

Rather than having to manually specify ltr/rtl-specific border-values in the CSS, we can use logical `border-inline-end`/`border-start-end-radius`/`border-end-end-radius` instead.
These logical properties depend on, among other things, the direction of the HTML document which we *always* specify in the viewer.

Given that most of these logical CSS properties are fairly new, and that cross-browser support is thus somewhat limited (see below), we rely on the previously added PostCSS plugins in order to support this in the GENERIC viewer.

 - https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/border-start-end-radius#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/border-end-end-radius#browser_compatibility
2022-03-20 12:45:37 +01:00
Tim van der Meij
feea2b78fa
Merge pull request #14690 from Snuffleupagus/inset-inline
Replace `dir`-dependent `left`/`right` with logical properties
2022-03-20 12:27:02 +01:00
Tim van der Meij
bb6505ee69
Merge pull request #14695 from Snuffleupagus/update-packages
Update packages and translations
2022-03-20 12:23:22 +01:00
Jonas Jenwald
579ff9459e Update l10n files 2022-03-20 10:59:15 +01:00
Jonas Jenwald
73d2ddac0d Update npm packages
Note that the Prettier update made it possible to move a couple of comments after `default:`-cases back to their original/intended positions, please see https://prettier.io/blog/2022/03/16/2.6.0.html
2022-03-20 10:59:13 +01:00
calixteman
f017f295ec
Merge pull request #14692 from calixteman/14672
[JS] - Parse a date in using the given format first and then try the default date parser
2022-03-19 17:37:10 +01:00
Calixte Denizet
f0b549c2a2 [JS] - Parse a date in using the given format first and then try the default date parser
- it aims to fix #14672.
2022-03-19 16:07:43 +01:00
Jonas Jenwald
9eed8c3576 Replace dir-dependent left/right with logical properties
*Please note:* This is another step in a series of patches to simplify/modernize the viewer CSS.

Rather than having to manually specify ltr/rtl-specific left/right-values in the CSS, we can use logical `inset-inline`/`inset-inline-start`/`inset-inline-end` instead.
These logical properties depend on, among other things, the direction of the HTML document which we *always* specify in the viewer.

Given that most of these logical CSS properties are fairly new, and that cross-browser support is thus somewhat limited (see below), we rely on the previously added PostCSS plugins in order to support this in the GENERIC viewer.

 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end#browser_compatibility
2022-03-19 14:44:01 +01:00
Tim van der Meij
6381738a65
Merge pull request #14671 from Snuffleupagus/float-inline
Replace `dir`-dependent `float` with logical properties
2022-03-19 14:12:34 +01:00
Jonas Jenwald
bc6ea6a878 Replace dir-dependent float with logical properties
*Please note:* This is another step in what will, time permitting, become a series of patches to simplify/modernize the viewer CSS.

Rather than having to manually specify ltr/rtl-specific float-values in the CSS, we can use logical `inline-start`/`inline-end` instead (and similar for some related left/right occurrences).
These logical properties depend on, among other things, the direction of the HTML document which we *always* specify in the viewer.

Given that most of these logical CSS properties are fairly new, and that cross-browser support is thus somewhat limited (see below), we rely on PostCSS plugins in order to support this in the GENERIC viewer.

 - https://developer.mozilla.org/en-US/docs/Web/CSS/float#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end#browser_compatibility
2022-03-19 14:03:20 +01:00
Jonas Jenwald
502fd7c80d Stop polyfilling the CSS calc functionality
At this point in time, all browsers that we support have native support for CSS variables; please see https://developer.mozilla.org/en-US/docs/Web/CSS/calc()#browser_compatibility and https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support

We can also remove the hack introduced back in PR 11567, which was only necessary to work-around an IE 11 specific bug.
2022-03-19 14:03:19 +01:00
Tim van der Meij
079dea2274
Merge pull request #14670 from Snuffleupagus/postcss-logical
Replace `dir`-dependent `margin`/`margin-left`/`margin-right` with logical properties
2022-03-19 13:53:39 +01:00
Tim van der Meij
6f2bae680c
Merge pull request #14689 from Snuffleupagus/PDFFindController-private
Slightly simplify the `PDFFindController._extractText` method, and convert all "private" methods into proper ones
2022-03-19 13:42:13 +01:00
Tim van der Meij
5de6af4e64
Merge pull request #14683 from Snuffleupagus/sendTest-cleanup
[src/display/api.js] Simplify the `sendTest` function, used with Worker initialization (PR 14291 follow-up)
2022-03-19 13:38:05 +01:00
Jonas Jenwald
c99d558646 Replace dir-dependent margin/margin-left/margin-right with logical properties
*Please note:* This is another step in what will, time permitting, become a series of patches to simplify/modernize the viewer CSS.

Rather than having to manually specify ltr/rtl-specific margin-values in the CSS, we can use logical margin instead (and similar for some related left/right occurrences).
These logical properties depend on, among other things, the direction of the HTML document which we *always* specify in the viewer.

Given that most of these logical CSS properties are fairly new, and that cross-browser support is thus somewhat limited (see below), we need to use a couple of PostCSS plugins (see below) in order to support this in the GENERIC viewer.

 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end#browser_compatibility

---

 - https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-logical
 - https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-dir-pseudo-class
2022-03-19 13:35:24 +01:00
Tim van der Meij
9b9ce07aa6
Merge pull request #14688 from Snuffleupagus/RefSet-RefSetCache-iterator
Add general iteration support in the `RefSet` and `RefSetCache` classes
2022-03-19 13:35:04 +01:00