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

20667 commits

Author SHA1 Message Date
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
Jonas Jenwald
08fa4eba20 Fix the #savedHasOwnCanvas handling in the StampAnnotation class
This may not be possible to trigger in practice, however it seems that if `StampAnnotation.prototype.mustBeViewedWhenEditing` is called back-to-back with `isEditing === true` set then the second invocation could overwrite the `#savedHasOwnCanvas`-field and thus lose its initial state.
2025-03-06 15:17:52 +01:00
Jonas Jenwald
07bbbf75a5 Introduce a helper function for clamping a value to a range
Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using `Math.min`/`Math.max` or with a local helper function, which leads to some unnecessary duplication.

Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.
2025-03-06 14:05:26 +01:00
Jonas Jenwald
4ec5f08803 [Editor] Remove the unused opacityToHex helper function (PR 19093 follow-up)
The only call-site was removed in PR 19093, hence this is now dead code.
2025-03-05 23:10:56 +01:00
Jonas Jenwald
dea35aed4a
Merge pull request #19608 from Snuffleupagus/l10n-update
Update l10n files
2025-03-05 15:25:55 +01:00
Jonas Jenwald
c2fa55420c
Merge pull request #19607 from Snuffleupagus/ColorSpaceUtils-rm-singletons
Simplify the `ColorSpaceUtils.singletons` handling (PR 19564 follow-up)
2025-03-05 15:25:19 +01:00
Jonas Jenwald
de47041e77 Update l10n files
Given the recently added l10n-strings, let's do another update before the upcoming release to avoid needlessly "broken" translations.
2025-03-05 15:08:39 +01:00
Jonas Jenwald
d8d7235876 Simplify the ColorSpaceUtils.singletons handling (PR 19564 follow-up)
With the changes in PR 19564 the actual `ColorSpace`-classes where separated from the various static "helper" methods.
Hence it seems that we can now simplify/shorten this old code to instead cache the "standard" ColorSpaces directly on the `ColorSpaceUtils`-class.
2025-03-05 15:02:05 +01:00
Jonas Jenwald
fedfdf9d10
Merge pull request #19599 from Snuffleupagus/ColorSpace-rm-parseAsync
Remove `ColorSpaceUtils.parseAsync` and simplify the ColorSpace "API-surface"
2025-03-05 13:11:45 +01:00
Jonas Jenwald
fbf1f2ba15 Remove ColorSpaceUtils.parseAsync and simplify the ColorSpace "API-surface"
This patch reduces the number of `ColorSpaceUtils` static-methods, and in particular the `parseAsync` method is removed and it's now instead possible to have `parse` optionally return a Promise.
This thus removes the need to manually check if a `ColorSpace`-instance is cached, note the changes in the `src/core/evaluator.js` file.
2025-03-05 12:43:58 +01:00
calixteman
19bc5dcb0e
Merge pull request #19564 from calixteman/qcms_icc
[api-minor] Support using ICC profiles in using qcms (bug 860023)
2025-03-05 10:34:23 +01:00
Calixte Denizet
971be48b60 Support using ICC profiles in using qcms (bug 860023) 2025-03-05 10:29:59 +01:00
calixteman
4693b7ad2f
Merge pull request #19585 from calixteman/update_openjpeg2
Use the latest emsdk version to compile openjpeg decoder
2025-03-05 10:07:11 +01:00
Calixte Denizet
559ff28db3 Use the latest emsdk version to compile openjpeg decoder 2025-03-04 18:41:20 +01:00
Jonas Jenwald
ab8ebc9b77
Merge pull request #19604 from Snuffleupagus/bug-1943094
[api-minor] Limit the maximum canvas width/height, in addition to its total area (bug 1943094)
2025-03-04 17:53:31 +01:00
Jonas Jenwald
9f9de4508c [api-minor] Limit the maximum canvas width/height, in addition to its total area (bug 1943094)
Browsers not only limit the maximum total canvas area, but additionally also limit their maximum width/height which affects PDF documents with e.g. very tall and narrow pages.
To address this we add a new `maxCanvasDim` viewer-option, which in Firefox will use a browser preference, such that both the total canvas area and the width/height will affect when CSS-zooming is used.
2025-03-04 15:23:45 +01:00
Jonas Jenwald
5e6cfbe163
Merge pull request #19598 from Snuffleupagus/ColorSpace#subParse
Also cache "sub" ColorSpaces globally (PR 19583 follow-up)
2025-03-03 17:30:14 +01:00
Jonas Jenwald
ba640e5cdc Shorten various static ColorSpace method signatures
By passing around common parameters, i.e. everything that's not the ColorSpace-data, in an object we can shorten this code a little bit.
2025-03-03 11:08:05 +01:00
Jonas Jenwald
33dfc4dd5f Also cache "sub" ColorSpaces globally (PR 19583 follow-up)
Some ColorSpaces can reference other ColorSpaces, and since it's fairly common for many pages to use the same ColorSpaces (see e.g. `issue17061.pdf`) this can help reduce a lot of unnecessary re-parsing especially for e.g. `ICCBased` ColorSpaces.
2025-03-03 10:07:41 +01:00
Tim van der Meij
0c1ac54f48
Merge pull request #19597 from Snuffleupagus/then-arrow-functions
Use arrow functions with some `Promise.then` calls
2025-03-02 22:14:53 +01:00
Jonas Jenwald
7b5cd9cddd Use arrow functions with some Promise.then calls
A lot of this is fairly old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
2025-03-02 19:57:38 +01:00
Jonas Jenwald
3cd1b10433
Merge pull request #19576 from nicolo-ribaudo/fix-linkannotation
Fix autolinking with highlighted search results
2025-03-02 19:51:15 +01:00
Nicolò Ribaudo
b47d81536c
Fix autolinking with highlighted search results
The current logic assumes that all spans in the text layer contain
only one text node, and thus that the position information
returned by `highlighter._convertMatches` can be directly used
on the element's only child.

This is not true in case of highlighted search results: they will be
injected in the DOM as `<span>` elements, causing the `<span>`s
in the text layer to have more than one child.

This patch fixes the problem by properly converting the (span, offset)
pair in a (textNode, offset) pair that points to the right text node.
2025-03-02 17:09:58 +01:00
Tim van der Meij
146bc58f32
Merge pull request #19596 from Snuffleupagus/Array-methods-arrow-functions
Use arrow function with various Array methods
2025-03-02 16:09:09 +01:00
Tim van der Meij
be6ef64a2c
Merge pull request #19577 from Snuffleupagus/isValidExplicitDest-reuse
Re-use the `isValidExplicitDest` helper function in the worker/viewer
2025-03-02 15:50:54 +01:00
Tim van der Meij
e8bbb60869
Merge pull request #19582 from dhdaines/consume_response
Be sure to consume responses in case of error in downloading test files (issue 19580)
2025-03-02 15:48:26 +01:00
Tim van der Meij
1aee9d5c61
Merge pull request #19581 from Snuffleupagus/issue-19579
Write string-data into the `.error`-file created for broken test-manifest links (issue 19579)
2025-03-02 15:39:11 +01:00
Tim van der Meij
dfa6370161
Merge pull request #19589 from Snuffleupagus/RunLengthStream-fill
Replace a loop with `TypedArray.prototype.fill()` in the `RunLengthStream` class
2025-03-02 15:36:49 +01:00
Tim van der Meij
27c82ab8cc
Merge pull request #19568 from Snuffleupagus/FakeMLManager-no-bundle
Don't bundle the `FakeMLManager` class in regular builds
2025-03-02 15:30:03 +01:00
Tim van der Meij
93759f34f4
Merge pull request #19571 from yjoer/master
Add the missing return type for `PDFWorker.fromPort()`
2025-03-02 15:27:10 +01:00
Jonas Jenwald
2e62f426fe Use arrow function with various Array methods
A lot of this is quite old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
2025-03-02 15:19:04 +01:00
Jonas Jenwald
a3d259a681 Replace a loop with TypedArray.prototype.fill() in the RunLengthStream class
This is a tiny bit shorter, which cannot hurt.
2025-03-02 13:10:34 +01:00
Jonas Jenwald
7081a1f112
Merge pull request #19578 from nicolo-ribaudo/flaky-test
Try reducing flakiness of CSS-only zoom test
2025-03-02 10:28:11 +01:00
Nicolò Ribaudo
de9b041b5e
Fix flakiness of CSS-only zoom test
Update the test to wait for the `pagerendered`` event of a specific
page (1), so that the `pagerendered`` event of other pages from a
previously running render doesn't resolve the `waitForPageRendered`
promise.
2025-03-01 19:10:28 +01:00
Jonas Jenwald
89ccc3a526
Merge pull request #19583 from Snuffleupagus/GlobalColorSpaceCache
Add a `GlobalColorSpaceCache` to reduce unnecessary re-parsing
2025-03-01 14:24:49 +01:00
Jonas Jenwald
4be79748c9 Add a GlobalColorSpaceCache to reduce unnecessary re-parsing
This complements the existing `LocalColorSpaceCache`, which is unique to each `getOperatorList`-invocation since it also caches by `Name`, which should help reduce unnecessary re-parsing especially for e.g. `ICCBased` ColorSpaces once we properly support those.
2025-03-01 14:21:05 +01:00
David Huggins-Daines
962f972aea Be sure to consume responses in case of error in downloading test files (issue 19580)
As mentioned in https://nodejs.org/docs/latest-v20.x/api/http.html#httpgeturl-options-callback
if a request results in an error, you still need to consume the data, or call
`response.resume()`, or your code will hang waiting for the request to close.
2025-03-01 07:53:56 -05:00
Jonas Jenwald
165d90fe26 Re-use the isValidExplicitDest helper function in the worker/viewer
Currently we re-implement the same helper function twice, which in hindsight seems like the wrong decision since that way it's quite easy for the implementations to accidentally diverge.
The reason for doing it this way was because the code in the worker-thread is able to check for `Ref`- and `Name`-instances directly, which obviously isn't possible in the viewer but can be solved by passing validation-functions to the helper.
2025-03-01 12:08:56 +01:00
calixteman
5f4d923618
Merge pull request #19584 from calixteman/update_openjpeg1
Fix the build of the openjpeg decoder in order to use an optimized build of the openjpeg library (bug 1951128)
2025-02-28 22:55:46 +01:00