1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00
Commit graph

20655 commits

Author SHA1 Message Date
Jonas Jenwald
319d239f41 Add an OutputScale static method to get the devicePixelRatio
Currently we lookup the `devicePixelRatio`, with fallback handling, in a number of spots in the code-base.
Rather than duplicating code we can instead add a new static method in the `OutputScale` class, since that one is now exposed in the API.
2025-03-12 21:07:06 +01:00
Jonas Jenwald
e4795f639c
Merge pull request #19644 from Snuffleupagus/crypto-PDFBase
Introduce a common base class for the `PDF17` and `PDF20` crypto classes
2025-03-12 21:05:39 +01:00
Jonas Jenwald
643c44b631
Merge pull request #19643 from Snuffleupagus/l10n-update
Update l10n files
2025-03-12 21:02:24 +01:00
Jonas Jenwald
0cbb2b1d13
Merge pull request #19646 from Snuffleupagus/dont-cache-MIN_TOUCH_DISTANCE_TO_PINCH
Don't shadow the `TouchManager.prototype.MIN_TOUCH_DISTANCE_TO_PINCH` value
2025-03-12 21:02:02 +01:00
Jonas Jenwald
bec6287b0a
Merge pull request #19647 from Snuffleupagus/bug-1953099
Let `Lexer.prototype.getNumber` treat more cases of a single minus sign as zero (bug 1953099)
2025-03-12 19:34:07 +01:00
calixteman
7bc7416111
Merge pull request #19642 from calixteman/bug1953003
[Editor] Fix the style of the buttons in dialog (bug 1953003)
2025-03-12 19:24:53 +01:00
Jonas Jenwald
ee34c5c648 Let Lexer.prototype.getNumber treat more cases of a single minus sign as zero (bug 1953099)
This patch extends the approach of PR 14543, by also treating e.g. minus signs followed by '(' or '<' as zero.
Inside of a /Contents stream those characters will generally mean the start of one or more glyphs.
2025-03-12 17:50:13 +01:00
Jonas Jenwald
92adc7ea1b Don't shadow the TouchManager.prototype.MIN_TOUCH_DISTANCE_TO_PINCH value
The `devicePixelRatio` may change if the window resolution changes, which can happen e.g. if the viewer is moved to another monitor.
2025-03-12 14:53:20 +01:00
Jonas Jenwald
2ff6829e47 Introduce a common base class for the PDF17 and PDF20 crypto classes
With the exception of a different hashing function these classes are identical, and the base class thus help reduce code duplication.

This patch reduces the size of the `gulp mozcentral` build with 1344 bytes, which isn't a lot but still cannot hurt.
2025-03-12 12:25:55 +01:00
Jonas Jenwald
4ebcc996d0 Update l10n files
Given the recently added l10n-strings, let's do yet another update before the upcoming release to avoid needlessly "broken" translations.
2025-03-12 09:58:52 +01:00
Calixte Denizet
216e17afc5 [Editor] Fix the style of the buttons in dialog (bug 1953003)
This patch fixes:
 - the style of the primary/secondary buttons in the dialog which weren't fully compliant to the last specs.
 - the style of the input field in HCM (wrong background)
 - the color of the link in the image tab.
2025-03-11 20:03:23 +01:00
Jonas Jenwald
d74619847d
Merge pull request #19640 from Snuffleupagus/secondaryToolbar-fix-close
Don't close the `secondaryToolbar` when clicking inside it (PR 18385 follow-up)
2025-03-11 19:42:36 +01:00
Jonas Jenwald
221eba29b9 Don't close the secondaryToolbar when clicking inside it (PR 18385 follow-up)
When the DOM structure of the viewer was updated in PR 18385 it caused the `secondaryToolbar` to accidentally start closing when clicking inside of it, since the `secondaryToolbar` now reside *under* the `toolbar` in the DOM.

**Steps to reproduce:**
 - Open the viewer.
 - Open the `secondaryToolbar`.
 - Try to change document rotation at least *twice*.

**Expected behaviour:**
 The document rotation can be changed an arbitrary number of times.

**Actual results:**
 The `secondaryToolbar` closes after changing rotation just once.
2025-03-11 19:26:23 +01:00
calixteman
391e84c34b
Merge pull request #19639 from calixteman/issue19633
Always use the absolute value of the line thickness (issue 19633)
2025-03-11 14:35:33 +01:00
Calixte Denizet
4b4f85484e Always use the absolute value of the line thickness (issue 19633) 2025-03-11 14:03:23 +01:00
calixteman
d008452e80
Merge pull request #19637 from calixteman/bug1952571
[Editor] Add an aria label to an added signature (bug 1952571)
2025-03-10 20:44:42 +01:00
Calixte Denizet
b5a7b827b5 [Editor] Add an aria label to an added signature (bug 1952571) 2025-03-10 19:15:05 +01:00
calixteman
febf59ce75
Merge pull request #19636 from calixteman/bug1952558
[Editor] Make sure the save checkbox isn't focusable when saving is disabled (bug 1952558)
2025-03-10 18:46:40 +01:00
Calixte Denizet
69a2e5137d [Editor] Make sure the save checkbox isn't focusable when saving is disabled (bug 1952558)
And fix the the width of the warning message when the limit of signatures has been reached:
in french the string is longer than the dialog's one.
2025-03-10 18:08:42 +01:00
calixteman
13474aca63
Merge pull request #19620 from calixteman/cmyk_icc
[api-minor] Use an icc profile for converting CMYK to RGB
2025-03-10 16:55:48 +01:00
Jonas Jenwald
4152eae3fb
Merge pull request #19635 from Snuffleupagus/thumbnails-maxCanvasPixels
Support the `maxCanvasPixels` option in the thumbnails code
2025-03-10 16:30:25 +01:00
Jonas Jenwald
26b5c8f821
Merge pull request #19625 from Snuffleupagus/issue-19624
Improve text-selection for Type3 fonts, using `d0` operators, with empty /FontBBox-entries (issue 19624)
2025-03-10 16:26:04 +01:00
Jonas Jenwald
0edfd29a3e Improve text-selection for Type3 fonts, using d0 operators, with empty /FontBBox-entries (issue 19624)
For Type3 glyphs with `d1` operators it's easy to compute a fallback bounding box, however for `d0` the situation is more difficult.
Given that we nowadays compute the min/max of basic path-rendering operators on the worker-thread, we can utilize that by parsing these Type3 operatorLists to guess a more suitable fallback bounding box.
2025-03-10 16:21:54 +01:00
Jonas Jenwald
b9e8844541
Merge pull request #19613 from Snuffleupagus/issue-19611
Let SMask/Mask images fallback to the parent image dimensions (issue 19611)
2025-03-10 16:12:48 +01:00
Calixte Denizet
7280540901 [api-minor] Use an icc profile for converting CMYK to RGB 2025-03-10 14:18:20 +01:00
Jonas Jenwald
fc22d3afc7 Support the maxCanvasPixels option in the thumbnails code
This addresses an inconsistency in the viewer, since the thumbnails don't respect the `maxCanvasPixels` option.
Note that, as far as I know, this has not lead to any bugs since the thumbnails render with a fixed (and small) width, however it really cannot hurt to address this (especially after the introduction of the `maxCanvasDim` option).

To support this a new `OutputScale`-method was added, to avoid having to duplicate code in multiple files.
2025-03-10 14:12:07 +01:00
Jonas Jenwald
10a99ea0a7 Let SMask/Mask images fallback to the parent image dimensions (issue 19611)
One of the images have a corrupt SMask, where the /Height-entry is bogus; see the excerpt below (via https://brendandahl.github.io/pdf.js.utils/browser/).
```
SMask (stream) [id: 17, gen: 0]

    ColorSpace = /DeviceGray
    Height = /Length
    Subtype = /Image
    Filter = /FlateDecode
    Type = /XObject
    Width = 157
    Matte (array)
    BitsPerComponent = 8
    Length = 3893
    <view contents> download
```

Hence we enable SMask/Mask images to fallback to the parent image dimensions, and also add more validation of the width/height to get a better error message when that data is wrong.
2025-03-10 12:37:44 +01:00
Jonas Jenwald
1bc98dfbd9
Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
2025-03-10 11:32:08 +01:00
Tim van der Meij
81baa16c8b
Merge pull request #19629 from Snuffleupagus/split-crypto
Re-factor the `src/core/crypto.js` file
2025-03-09 13:08:40 +01:00
Tim van der Meij
621258f85c
Merge pull request #19623 from Snuffleupagus/PDFFunctionFactory-rm-createFromArray
Remove the `PDFFunctionFactory.createFromArray` method
2025-03-09 12:58:55 +01:00
Tim van der Meij
66af403f10
Merge pull request #19628 from Snuffleupagus/MathClamp-2
Use the `MathClamp` helper function more (PR 19617 follow-up)
2025-03-09 12:49:53 +01:00
Jonas Jenwald
0a2c176027 Remove the unused or/shiftLeft methods from the Word64 class (PR 4938 follow-up)
These methods were introduced in *the first* commit of PR 4938, however they became unused in *the second* commit of that PR.
Hence it seems that we've been accidentally shipping, a small amount of, unused code for over a decade.
2025-03-08 17:33:16 +01:00
Jonas Jenwald
67065e43f5 Replace loops with TypedArray.prototype.set in the CipherTransformFactory class
Also, adds `TypedArray.prototype.fill` usage in one spot.
2025-03-08 16:17:45 +01:00
Jonas Jenwald
c65f1b0dae Move a couple of AESBaseCipher fields from the constructors
Thanks to modern JS class features we can, ever so slightly, shorten some class field definitions.
2025-03-08 16:06:30 +01:00
Jonas Jenwald
461488cb16 Initialize the defaultPasswordBytes, in CipherTransformFactory, lazily 2025-03-08 16:06:30 +01:00
Jonas Jenwald
139d27aa7d Simplify various calculate... methods a tiny bit
While initializing the `padded` Uint8Arrays we're manually assigning zeros to some entries, which is completely unnecessary since that's the default value for a TypedArray, and instead we can just increment the index.
2025-03-08 16:06:27 +01:00
Jonas Jenwald
facf34606f Move the calculateSHA384 and calculateSHA512 functions into their own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:22 +01:00
Jonas Jenwald
a1eac86037 Move the calculateSHA256 function into its own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:16 +01:00
Jonas Jenwald
3e8d01ad7c Move the calculateMD5 function into its own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:05 +01:00
Jonas Jenwald
1b5151f969 Remove pointless Math.min usage in the XFA parsing
When creating the `StyleMapping` for the "xfa-font-horizontal-scale" and "xfa-font-vertical-scale" properties there's currently pointless `Math.min` usage, since we're not actually comparing with anything.
2025-03-08 12:22:33 +01:00
Jonas Jenwald
bee0f53c65 Use the MathClamp helper function more (PR 19617 follow-up)
There's a few spots that I accidentally missed in PR 19617.
2025-03-08 12:19:56 +01:00
Jonas Jenwald
cef4fcf025
Merge pull request #19622 from nicolo-ribaudo/zoom-detail-view-constant-redraw
Do not constantly render the detail canvas on zoom (bug 1952496)
2025-03-07 13:56:13 +01:00
Nicolò Ribaudo
a1dc46aa9d
Do not constantly render the detail canvas on zoom
When zooming, we should skip rendering the detail canvas until the
zoom is done, similarly to how normal page rendering is delayed.
To do so is enough to skip details view while zooming, since the
main view rendering that already happens after the delay will also
trigger rendering of the detail views.
2025-03-07 12:38:52 +01:00
Jonas Jenwald
17d7943758 Remove the PDFFunctionFactory.createFromArray method
This combines the `PDFFunctionFactory.create` and `PDFFunctionFactory.createFromArray` methods, which helps simplify and shorten the code.
Additionally, to simplify the parameter handling we pass the `PDFFunctionFactory`-instance directly to the various `PDFFunction`-methods.
2025-03-07 12:28:14 +01:00
Jonas Jenwald
eef15a30cd Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
The changes in PR 19604 weren't enough for thumbnail canvases in some cases, see e.g. https://web.archive.org/web/20231204152348if_/https://user.informatik.uni-bremen.de/cabo/rfc9000.pdf#pagemode=thumbs
2025-03-06 23:00:20 +01:00
Jonas Jenwald
af89e77124
Merge pull request #19619 from Snuffleupagus/fix-#savedHasOwnCanvas
Fix the `#savedHasOwnCanvas` handling in the `StampAnnotation` class
2025-03-06 17:59:14 +01:00
calixteman
1abb7be11a
Merge pull request #19618 from calixteman/non_editable_stamp
[Editor] In edit mode, a non-editable stamp must be visible after the page is rendered
2025-03-06 16:23:55 +01:00
Jonas Jenwald
4f2cf38bfa
Merge pull request #19617 from Snuffleupagus/MathClamp
Introduce a helper function for clamping a value to a range
2025-03-06 15:48:14 +01:00
Jonas Jenwald
d646b2b270
Merge pull request #19610 from Snuffleupagus/rm-opacityToHex
[Editor] Remove the unused `opacityToHex` helper function (PR 19093 follow-up)
2025-03-06 15:42:38 +01:00
Calixte Denizet
f3454a738d [Editor] In edit mode, a non-editable stamp must be visible after the page is rendered 2025-03-06 15:37:27 +01:00