Commit Graph

15930 Commits

Author SHA1 Message Date
Calixte Denizet
2ff65dd514 Popup trigger area must filled its parent (fix #15063) 2022-06-19 22:44:58 +02:00
Calixte Denizet
af47a0b7e0 Avoid having overflowing sections (#15036 follow-up) 2022-06-19 22:09:02 +02:00
Jonas Jenwald
57c10ac213 Simplify the newRefs computation in the "SaveDocument"-handler in the worker-thread
- Let the `Page.save`-method filter out "empty" entries, similar to the `Page._parsedAnnotations`-getter, since that on its own already simplifies the "SaveDocument"-handler a tiny bit.

 - The existing `reduce` and `concat` construction isn't exactly a wonder of readability :-)
   Thanks to modern JavaScript features it should be possible to replace all of this with `Array.prototype.flat()` instead, which at least to me feels a lot easier to understand.
2022-06-19 18:21:51 +02:00
Tim van der Meij
45de73bd00
Merge pull request #15059 from Snuffleupagus/rm-some-concat
Reduce unnecessary usage of `Array.prototype.concat()`
2022-06-19 14:36:14 +02:00
Jonas Jenwald
c21f4faaf8 Reduce unnecessary usage of Array.prototype.concat()
There are obviously cases where using `concat` makes perfect sense, since that method doesn't change any of the existing Arrays; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat

However, in a few cases throughout the code-base that's not an issue and using `concat` only leads to unnecessary intermediate allocations. With modern JavaScript we can thus replace those with a combination of `push` and spread-syntax, which wasn't originally possible when the code was written.
2022-06-19 13:40:52 +02:00
Tim van der Meij
f516bb2174
Merge pull request #15058 from Snuffleupagus/rm-baseviewerinit-event
[api-minor] Remove the "baseviewerinit" event since it's unused (PR 14324 follow-up)
2022-06-19 13:21:39 +02:00
calixteman
54777b42c2
Merge pull request #15036 from calixteman/remove_scale
[api-minor] Get rid of CSS transform on each annotation in the annotation layer
2022-06-19 11:36:13 +02:00
Jonas Jenwald
caaa78f7da [api-minor] Remove the "baseviewerinit" event since it's unused (PR 14324 follow-up)
Given that neither the viewer or the examples listen for this event, it seems unnecessary to keep dispatching it.
2022-06-19 09:57:05 +02:00
Calixte Denizet
e2db9bacef Get rid of CSS transform on each annotation in the annotation layer
- each annotation has its coordinates/dimensions expressed in percentage,
  hence it's correctly positioned whatever the scale factor is;
- the font sizes are expressed in percentage too and the main font size
  is scaled thanks a css var (--scale-factor);
- the rotation is now applied on the div annotationLayer;
- this patch improve the rendering of some strings where the glyph spacing
  was not correct (it's a Firefox bug);
- it helps to simplify the code and it should slightly improve the update of
  page (on zoom or rotation).
2022-06-18 17:54:59 +02:00
calixteman
6dc8d1f532
Merge pull request #15057 from Snuffleupagus/issue-15056
Replace element `id`s with custom attributes for Widget-annotations (issue 15056)
2022-06-18 17:47:17 +02:00
Jonas Jenwald
03757d82b7 Replace element ids with custom attributes for Widget-annotations (issue 15056)
We want to avoid adding regular `id`s to Annotation-elements, since that means that they become "linkable" through the URL hash in a way that's not supported/intended. This could end up clashing with "named destinations", and that could easily lead to bugs; see issue 11499 and PR 11503 for some context.

Rather than using `id`s, we'll instead use a *custom* `data-element-id` attribute such that it's still possible to access the Annotation-elements directly.
Unfortunately these changes required updating most of the integration-tests, and to reduce the amount of repeated code a couple of helper functions were added.
2022-06-18 16:43:05 +02:00
Tim van der Meij
3ca8d2c4f9
Merge pull request #15052 from Snuffleupagus/mv-defaultUrl-option
Simplify setting the `defaultUrl`-option in the CHROME viewer (PR 12470 follow-up)
2022-06-18 11:29:21 +02:00
Tim van der Meij
80af3a0d07
Merge pull request #15048 from Snuffleupagus/mv-renderer-option
Only define the `renderer`-option in the GENERIC viewer
2022-06-18 11:26:43 +02:00
Jonas Jenwald
77aa86e275 Stop defining the defaultUrl-option in the MOZCENTRAL viewer
This option is not used, nor has it ever been used, in the *built-in* Firefox PDF Viewer. Hence we can define it only for the environments where it makes sense instead.
2022-06-18 09:43:35 +02:00
Jonas Jenwald
abcc32ade0 Simplify setting the defaultUrl-option in the CHROME viewer (PR 12470 follow-up)
This should really have been done as part of PR 12470, since it's now possible to directly set the `defaultUrl`-option without having to fallback to `var`-usage.
2022-06-18 09:43:23 +02:00
Jonas Jenwald
be2dfe45f9
Merge pull request #15035 from Snuffleupagus/prefer-modern-dom-apis-2
Use modern DOM methods a bit more (PR 15031 follow-up)
2022-06-17 19:37:43 +02:00
calixteman
31e3427559
Merge pull request #15054 from calixteman/15053
[JS] Hide field borders and buttons (#15053)
2022-06-17 17:58:52 +02:00
Calixte Denizet
7e3941da9d [JS] Hide field borders and buttons (#15053)
- Since the border belongs to the section containing the HTML
  counterpart of an annotation, this section must be hidden when
  a JS action requires it;
- it wasn't possible to hide a button in using JS.
2022-06-17 17:36:38 +02:00
Marco Castelluccio
b9f5a70ded
Merge pull request #15051 from Maxim-Mazurok/patch-1
Fix "Good Beginner Bugs" link
2022-06-17 09:45:12 +02:00
Maxim Mazurok
bd5e1a9540
Fix "Good Beginner Bugs" link
Seems like the label was changed and the link needs to be updated
2022-06-17 11:33:07 +10:00
calixteman
b8688128e3
Merge pull request #15050 from calixteman/make_ink_better
[Editor] - Add the ability to directly draw after selecting ink tool
2022-06-16 20:34:56 +02:00
Calixte Denizet
e7dc1ef4f3 [Editor] - Add the ability to directly draw after selecting ink tool
- Right now, we must select the tool, then click to select a page and
  click to start drawing and it's a bit painful;
- so just create a new ink editor when we're hovering a page without one.
2022-06-16 19:53:07 +02:00
Jonas Jenwald
a19feac217 Reduce some duplication for AppOptions that use compatibilityParams
We can check for a relevant `compatibilityParams`-entry directly in `AppOptions.{get, getAll}` instead, which removes some unnecessary duplication.
2022-06-16 16:51:33 +02:00
Jonas Jenwald
df79b18a31 Only define the renderer-option in the GENERIC viewer
Given that the SVG back-end is not defined anywhere except in GENERIC builds, we can remove a little bit of unnecessary code in e.g. the Firefox PDF Viewer.
2022-06-16 16:11:47 +02:00
Jonas Jenwald
c3d0858062
Merge pull request #15046 from Snuffleupagus/issue-15044
Add basic support for non-embedded ArialUnicodeMS fonts (issue 15044)
2022-06-15 11:27:19 +02:00
Jonas Jenwald
64cce1269e Add basic support for non-embedded ArialUnicodeMS fonts (issue 15044)
This appears to be a Microsoft-specific version of the regular Arial font, hence we simply map this to Helvetica in the same way that we treat many other Arial-named fonts.
2022-06-15 10:37:20 +02:00
Jonas Jenwald
89cebcb6f9
Merge pull request #15034 from Snuffleupagus/issue-15033
Extend `getGlyphMapForStandardFonts` with some Hebrew entries (issue 15033)
2022-06-13 11:35:34 +02:00
Jonas Jenwald
4902ad8923 Use modern DOM methods a bit more (PR 15031 follow-up)
Apparently the ESLint rule added in PR 15031 wasn't able to catch all cases that can be converted, which is probably not all that surprising given how some of these call-sites look.

 - Use `Element.prepend()` to insert nodes before all other ones in the element, rather than using `firstChild` with `insertBefore`-calls; see https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend

 - Fix one *incorrect* `insertBefore` call, in the AnnotationLayer-code.
   Initially the patch simply changed that to an `Element.before()`-call, however that broke one of the integration-tests. It turns out that the `index` may try to access a non-existent select-child, which triggers undefined behaviour; note the warning in https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore#parameters
2022-06-13 10:47:37 +02:00
Jonas Jenwald
2dca14028d Extend getGlyphMapForStandardFonts with some Hebrew entries (issue 15033)
This only adds the minimum entries required in order to render the referenced document correctly, rather than trying to support "all" Hebrew glyphs, to ensure that all lines in `getGlyphMapForStandardFonts` are covered by tests.
2022-06-13 10:08:39 +02:00
Tim van der Meij
1a6ae5f034
Merge pull request #15031 from Snuffleupagus/prefer-modern-dom-apis
Enable the `unicorn/prefer-modern-dom-apis` ESLint plugin rule
2022-06-12 20:36:40 +02:00
Tim van der Meij
0e1e265c61
Merge pull request #15030 from Snuffleupagus/update-packages
Update packages and translations
2022-06-12 20:16:11 +02:00
Tim van der Meij
720f77c7cd
Merge pull request #15028 from Snuffleupagus/update-compat
[api-minor] Update the minimum supported browsers/environments
2022-06-12 20:12:33 +02:00
Tim van der Meij
26ae50e449
Merge pull request #15023 from Snuffleupagus/prefer-array-flat
Enable the `unicorn/prefer-array-flat` and `unicorn/prefer-array-flat-map` ESLint plugin rules
2022-06-12 20:10:52 +02:00
Jonas Jenwald
4d39898823 Enable the unicorn/prefer-modern-dom-apis ESLint plugin rule
This rule will help enforce slightly shorter code, and according to MDN both `Element.replaceWith()` and `Element.before()` are available in all browsers that we currently support.

Please find additional information here:
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/before
2022-06-12 20:05:05 +02:00
Jonas Jenwald
0c65926d5b
Merge pull request #15029 from Snuffleupagus/prefer-dom-node-append
Enable the `unicorn/prefer-dom-node-append` ESLint plugin rule
2022-06-12 19:58:37 +02:00
Jonas Jenwald
17d2380824 Update l10n files 2022-06-12 14:05:41 +02:00
Jonas Jenwald
f052a12968 Update npm packages 2022-06-12 14:02:31 +02:00
Jonas Jenwald
8129815538 Enable the unicorn/prefer-dom-node-append ESLint plugin rule
This rule will help enforce slightly shorter code, especially since you can insert multiple elements at once, and according to MDN `Element.append()` is available in all browsers that we currently support.

Please find additional information here:
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/append
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md
2022-06-12 13:07:03 +02:00
Jonas Jenwald
2f0ed3a9ca [api-minor] Update the minimum supported browsers/environments
*Please note:* The dates below are still a little ways off, however that obviously won't affect the existing PDF.js releases. Hence I think that we can make these changes now, since by the time of the *next* official PDF.js release they'll likely match up pretty well.[1]

While we "support" some (by now) fairly old browsers, that essentially means that the library (and viewer) will load and that the basic functionality will work as intended.[2]
However, in older browsers, some functionality may not be available and generally we'll ask users to update to a modern browser when bugs (specific to old browsers) are reported.[3]

Since we've previously settled on only supporting browsers/environments that are approximately *three years old*, this patch updates the minimum supported browsers/environments as follows:
 - Chrome 76, which was released on 2019-07-30; see https://en.wikipedia.org/wiki/Google_Chrome_version_history
 - Firefox ESR (as before); see https://wiki.mozilla.org/Release_Management/Calendar
 - Safari 13, which was released on 2019-09-19; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_13
 - Node.js 14, which was release on 2020-04-21 (all older versions have reached EOL); see https://en.wikipedia.org/wiki/Node.js#Releases

---
[1] Given that the releases usually happen every two to three months.

[2] Assuming that a `legacy/`-build is being used, of course.

[3] In general it's never a good idea to use old/outdated browsers, since those may contain *known* security vulnerabilities.
2022-06-11 16:50:01 +02:00
Jonas Jenwald
d7122becaf
Merge pull request #15027 from Snuffleupagus/parseFloat-fixes
Remove superfluous trailing arguments from `parseFloat`-calls (PR 14978 follow-up)
2022-06-11 15:25:24 +02:00
Jonas Jenwald
4b2526ebf2 Remove superfluous trailing arguments from parseFloat-calls (PR 14978 follow-up)
Fixes two recent "Code scanning alerts" on GitHub, which likely happened because these calls originally used `parseInt` instead (during initial development).
2022-06-11 15:11:34 +02:00
Jonas Jenwald
7f4b1c2149
Merge pull request #15026 from Snuffleupagus/rm-unused-annotation-ops
[api-minor] Stop using the `beginAnnotations`/`endAnnotations` operators (PR 14998 follow-up)
2022-06-11 15:04:51 +02:00
Jonas Jenwald
bbf857d635 [api-minor] Stop using the beginAnnotations/endAnnotations operators (PR 14998 follow-up)
After the changes in PR 14998, these operators are now no-ops in the `src/display/canvas.js` code and should no longer be necessary.
Given that `beginAnnotations`/`endAnnotations` are not in the PDF specification, but are rather *custom* PDF.js operators, it seems reasonable to stop using them now that they've become no-ops.
2022-06-11 14:21:26 +02:00
Marco Castelluccio
b5fb6cdb96
Merge pull request #15022 from Snuffleupagus/editorNone-icon-tweak
Tweak the `editorNone` icon to circumvent the "duplicated files"-check
2022-06-11 11:34:21 +02:00
Jonas Jenwald
010d996b74 Enable the unicorn/prefer-array-flat and unicorn/prefer-array-flat-map ESLint plugin rules
These rules will help enforce shorter and more readable code, and according to MDN these Array-methods are available in all browsers/environments that we currently support:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap#browser_compatibility

Please find additional information about these ESLint rules here:
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
2022-06-11 11:33:43 +02:00
Jonas Jenwald
1465471b10 Tweak the editorNone icon to circumvent the "duplicated files"-check
The update in https://bugzilla.mozilla.org/show_bug.cgi?id=1773794 failed, because the `editorNone` icon is identical to a pre-existing one. Given that all of the editor-icons are simply placeholders for now, we can just make a tiny change to the SVG-paths to prevent these kind of problems.
2022-06-11 11:17:08 +02:00
Tim van der Meij
a57a4bc6c2
Merge pull request #15018 from Snuffleupagus/issue-15016
Expose `TextLayerRenderTask` in the TypeScript definitions (issue 15016, PR 14013 follow-up)
2022-06-10 22:18:35 +02:00
Tim van der Meij
f0b5aee6b8
Merge pull request #15014 from Snuffleupagus/prefer-at
Enable the `unicorn/prefer-at` ESLint plugin rule (PR 15008 follow-up)
2022-06-10 22:12:35 +02:00
Jonas Jenwald
e046b811b7 Expose TextLayerRenderTask in the TypeScript definitions (issue 15016, PR 14013 follow-up)
While `TextLayerRenderTask` apparently makes sense in TypeScript environments, given that it's being returned by the `renderTextLayer`-function in the API, we really don't want to extend the *public* API by simply exporting the class directly in `src/pdf.js` since it should never be called/initialized manually.
Hence we follow the same pattern as in PR 14013, and add some very basic unit-tests to ensure that `renderTextLayer` always returns a `TextLayerRenderTask`-instance as expected.
2022-06-10 22:12:32 +02:00
calixteman
6e6d94ab8d
Merge pull request #15020 from calixteman/1773680
Add an empty entry in combo list when nothing is selected (bug 1773680)
2022-06-10 19:18:31 +02:00