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

20630 commits

Author SHA1 Message Date
Jonas Jenwald
e73224ded7 Introduce Math.sumPrecise usage in the code-base
This is a new JavaScript feature that makes it easy to compute the sum of list of values; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sumPrecise

This allows us to remove most cases of `Array.prototype.reduce`, which helps improve readability since that (in my opinion) often isn't the most intuitive code.
2025-03-23 13:03:56 +01:00
Tim van der Meij
7352d1d683
Update translations to the most recent versions 2025-03-23 12:46:06 +01:00
Tim van der Meij
4522c6c071
Update dependencies to the most recent versions 2025-03-23 12:46:02 +01:00
Tim van der Meij
80d4d7058f
Merge pull request #19706 from timvandermeij/integration-tests-freetext-isolate-part-1
Isolate the "move editor with arrows" freetext editor integration tests
2025-03-23 12:01:30 +01:00
Calixte Denizet
c275c72977 Fix save/restore while in smask mode
The rendering bug with issue17779.pdf is due to the fact that we call save on the suspended ctx
but not on the the current ctx. So each time we've something like save/transform/restore then
the transform not "removed" when restoring.
So this patch just apply the save/restore operations to ctx which are mirrored on the suspended one.
2025-03-22 23:26:51 +01:00
calixteman
d009e4b3a7
Merge pull request #19689 from calixteman/use_path2d
[api-minor] Use a Path2D when doing a path operation in the canvas (bug 1946953)
2025-03-22 21:46:27 +01:00
Tim van der Meij
440d519326
Isolate the "move editor with arrows" freetext editor integration tests
This commit reduces the number of freetext editor integration test suite
failures, in full isolation, from 8 to 6 by fixing the following issues
in the "move editor with arrows" block:

- The second and third test relied on the first test to enable freetext
  editing mode. For isolation we now do it explicitly in both tests.
- The second test relied on the first test having created an editor. For
  isolation we now create the editor explicitly in the second test.
- The third test relied on the previous tests for the editor numbering.
  For isolation we change the editor numbering to the one after initial
  document load. Since we can't have state (editors) from a previous
  test anymore we can remove the `clearAll` call as well.
2025-03-22 20:46:21 +01:00
Tim van der Meij
72212a892b
Merge pull request #19705 from timvandermeij/integration-tests-scripting-isolate
Isolate the scripting integration tests
2025-03-22 20:38:50 +01:00
Calixte Denizet
be1f5671bb [api-minor] Use a Path2D when doing a path operation in the canvas (bug 1946953)
With this patch, all the paths components are collected in the worker until a path
operation is met (i.e., stroke, fill, ...).
Then in the canvas a Path2D is created and will replace the path data transfered from the worker,
this way when rescaling, the Path2D can be reused.
In term of performances, using Path2D is very slightly improving speed when scaling the canvas.
2025-03-22 20:35:24 +01:00
Tim van der Meij
1c73e526e0
Isolate the scripting integration tests
To avoid being able to introduce dependencies between tests, and to
bring existing dependencies to the surface, this commit makes sure that
we close the document between tests so that we can't accidentally rely
on state set by a previous test. This prevents multiple tests from
failing if one of them fails and makes debugging easier by being able to
run each test on their own independent of other tests.

This commit, combined with the previous ones, is enough to make the
scripting integration test suite pass consistently if random mode in
Jasmine is enabled, proving that the tests are fully isolated now.
2025-03-22 18:31:23 +01:00
Tim van der Meij
0f3692a621
Remove the dependency between the order-dependent scripting integration tests
The integration tests are order-dependent because they rely on input
field state set by a previous test. This commit fixes the issue by
updating the values to match the initial state of the document, which
makes sure that we don't build upon values from previous tests while
still testing the intended logic in the individual tests like before.
2025-03-22 18:31:23 +01:00
Tim van der Meij
334d681359
Refactor the order-dependent scripting integration tests
By checking for the expected value directly we can shorten the code, and
it simplifies removing the dependencies between the tests in the next
commit (by having fewer places to change). Note that this follows the
same pattern as PRs #19192, #19001 and #18399 and also helps to remove
any further possibilities for intermittent failures.
2025-03-22 18:31:10 +01:00
Tim van der Meij
11e89b74d9
Merge pull request #19696 from Snuffleupagus/issue-19695
Extend `getSupplementalGlyphMapForCalibri` with Pound-sign (issue 19695)
2025-03-22 13:21:07 +01:00
Tim van der Meij
9023395550
Merge pull request #19681 from Snuffleupagus/AbortSignal-any-basic-polyfill
[api-minor] Add a basic `AbortSignal.any` polyfill in PDF.js `legacy` builds
2025-03-22 13:20:18 +01:00
Tim van der Meij
7f70835830
Merge pull request #19703 from Snuffleupagus/bidi-rm-setValues
Replace the `setValues` function with `Array.prototype.fill()` in the `src/core/bidi.js` file
2025-03-22 13:13:42 +01:00
Jonas Jenwald
fe19d9666f Replace the setValues function with Array.prototype.fill() in the src/core/bidi.js file
This code is originally from 2012, see PR 1218, and the Array-method wasn't available until Firefox 31 (released on 2014-07-22).
2025-03-21 23:00:38 +01:00
Jonas Jenwald
abcddb51e0 [api-minor] Enable enableAutoLinking by default
It's already enabled by default in Firefox, and since there's no open issues regarding auto-linking I suppose that we can attempt to enable it unconditionally.
2025-03-21 11:49:03 +01:00
Jonas Jenwald
8f4c0169a0
Merge pull request #19692 from Snuffleupagus/writer-improve
Improve the implementation in `src/core/writer.js` a little bit
2025-03-20 21:43:21 +01:00
Jonas Jenwald
50eb97afb3 Improve the implementation in src/core/writer.js a little bit
- Let the `writeString` helper function return the new offset, to avoid having to recompute that in multiple spots.

 - In the `computeMD5` helper function we can create the `md5Buffer` via Array-destructuring, rather than using a manual loop.
2025-03-20 21:13:34 +01:00
Jonas Jenwald
f90732e4c3 Extend getSupplementalGlyphMapForCalibri with Pound-sign (issue 19695) 2025-03-20 20:12:24 +01:00
Jonas Jenwald
a229914b46
Merge pull request #19693 from Snuffleupagus/writer-fix-md5
Fix the MD5 computation in the `src/core/writer.js` file
2025-03-20 16:30:57 +01:00
Jonas Jenwald
e6c869c127 Fix the MD5 computation in the src/core/writer.js file
Currently the MD5 computation doesn't actually work (at all?), since we're invoking the `calculateMD5` function without providing all of the necessary parameters and the PDF-data thus isn't taken into account.

Fixing this caused unit-tests to fail, which isn't that surprising since the current date/time is used in the MD5 computation, and we thus utilize Jasmine to work-around that.
2025-03-20 14:41:25 +01:00
calixteman
cd4a30341f
Merge pull request #19685 from calixteman/issue19424
[Editor] Take into account the parent rotation when switch to edit mode (issue #19424)
2025-03-19 15:15:25 +01:00
Calixte Denizet
276c8f3518 [Editor] Take into account the parent rotation when switch to edit mode (issue #19424) 2025-03-19 14:26:55 +01:00
Jonas Jenwald
1a39e2dac1
Merge pull request #19684 from Snuffleupagus/issue-19683
Improve `addSignatureDescription`/`editSignatureDescription` handling (issue 19683)
2025-03-19 13:43:54 +01:00
Jonas Jenwald
79058c92e3 Improve addSignatureDescription/editSignatureDescription handling (issue 19683)
- Point the `addSignatureDescription` respectively `editSignatureDescription` labels to their actual `input`-elements (this way clicking the label will actually focus the input).

 - Add the event listener to the `addSignatureDescription`-input, rather than its `span`-element (this is consistent with the `editSignatureDescription` case).

 - Correctly check if the `addSignatureDescription`-input is empty, since we're accidentally comparing with its `span`-element.

 - Remove unbalanced, and likely accidentally added, `</span>` tags.
2025-03-19 11:38:56 +01:00
Jonas Jenwald
028e4f7ea8 [api-minor] Add a basic AbortSignal.any polyfill in PDF.js legacy builds
This is an admittedly very basic polyfill, to allow us to remove a bunch of inline feature testing, that I've thrown together based on reading https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static and related MDN articles.

Compared to PR 19218 it's obviously much more "primitive", however the implementation is simple and it doesn't suffer from any licensing issues (since I wrote the code myself).
2025-03-18 10:54:49 +01:00
Jonas Jenwald
00e3a4d87a
Merge pull request #19674 from Snuffleupagus/core-document-more-async
Introduce more `async` code in the `src/core/document.js` file
2025-03-17 21:40:16 +01:00
Jonas Jenwald
6243afa85e
Merge pull request #19675 from Snuffleupagus/IccColorSpace-fetchSync
Introduce a `fetchSync` helper function for the `IccColorSpace` classes
2025-03-17 20:22:00 +01:00
Jonas Jenwald
2f1497c9c4
Merge pull request #19677 from Snuffleupagus/issue-19676
For JPEG images with CMYK-data, ensure that the alpha-component is set correctly when WebAssembly is disabled (issue 19676)
2025-03-17 20:17:00 +01:00
Jonas Jenwald
afb14bdc0b For JPEG images with CMYK-data, ensure that the alpha-component is set correctly when WebAssembly is disabled (issue 19676) 2025-03-17 16:15:32 +01:00
Jonas Jenwald
1fb6edc713 Introduce a fetchSync helper function for the IccColorSpace classes
This reduces code duplication a tiny bit, which shouldn't hurt.
2025-03-17 14:58:53 +01:00
Jonas Jenwald
e37236e9af
Merge pull request #19673 from Snuffleupagus/rm-ftl-comment
Remove documentation for unused l10n variable (PR 18492 follow-up)
2025-03-17 14:28:12 +01:00
Jonas Jenwald
d00482380a Introduce more async code in the src/core/document.js file 2025-03-17 13:20:51 +01:00
Jonas Jenwald
e5e0856f99 Remove documentation for unused l10n variable (PR 18492 follow-up)
Looking at PR 18492 it doesn't seem that the `$percent` variable, for the `pdfjs-editor-new-alt-text-ai-model-downloading-progress` l10n-string, was ever used.
2025-03-17 12:20:30 +01:00
Tim van der Meij
92d7b6d09f
Merge pull request #19671 from timvandermeij/integration-tests-signature-intermittent
Fix the "Signature Editor Basic operations must check copy and paste" integration test
2025-03-16 21:35:25 +01:00
Tim van der Meij
2a4f970e00
Fix the "Signature Editor Basic operations must check copy and paste" integration test
This integration test fails intermittently because of concurrent
clipboard access due to running the test in parallel in both browsers.
It can be reproduced by introducing `await waitForTimeout(1000)` between
the copy and paste operations.

This commit fixes the issue by running the test sequentially instead,
mirroring the change from commit 0e94f2bd.
2025-03-16 20:35:36 +01:00
Tim van der Meij
e738566900
Merge pull request #19669 from timvandermeij/icc-colorspace-404
Don't get ICC color space files if required API options are missing
2025-03-16 18:45:21 +01:00
Tim van der Meij
f44cba86d5
Don't get ICC color space files if required API options are missing
This commit improves validation of the API options for the ICC color
space logic. If `useWasm` is `true` but the corresponding `wasmUrl`
or `iccUrl` API options are not provided we can avoid requesting
files with `null` URLs which always results in a 404 response.
2025-03-16 16:29:42 +01:00
Jonas Jenwald
4c5ad92584
Merge pull request #19667 from Snuffleupagus/version-5.1
Bump library version to `5.1`
2025-03-16 13:51:35 +01:00
Jonas Jenwald
e3e2396230 Bump library version to 5.1 2025-03-16 13:47:18 +01:00
Tim van der Meij
d86045eacb
Merge pull request #19632 from Snuffleupagus/issue-15085
[api-minor] Attempt to support fetching the raw data of the PDF document from the `PDFDocumentLoadingTask`-instance (issue 15085)
2025-03-16 12:32:20 +01:00
Tim van der Meij
f8c2a949b7
Merge pull request #19665 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2025-03-16 11:31:08 +01:00
Jonas Jenwald
9e8d4e4d46 [api-minor] Attempt to support fetching the raw data of the PDF document from the PDFDocumentLoadingTask-instance (issue 15085)
The new API-functionality will allow a PDF document to be downloaded in the viewer e.g. while the PasswordPrompt is open, or in cases when document initialization failed.
Normally the raw data of the PDF document would be accessed via the `PDFDocumentProxy.prototype.getData` method, however in these cases the `PDFDocumentProxy`-instance isn't available.
2025-03-16 10:09:44 +01:00
Tim van der Meij
33af8b5c2c
Update translations to the most recent versions 2025-03-15 20:42:08 +01:00
Tim van der Meij
85818f404f
Upgrade babel-loader to version 10.0.0
This is a major version bump, but the changelog at
https://github.com/babel/babel-loader/releases/tag/v10.0.0
doesn't indicate any breaking changes that should impact us.
2025-03-15 20:42:08 +01:00
Tim van der Meij
cfe6cc6a7e
Upgrade @metalsmith/layouts to version 3.0.0
This is a major version bump, and the changelog at
https://github.com/metalsmith/layouts/releases/tag/v3.0.0
indicates a breaking change that impacts us, namely that we need to
explicitly define the pattern and transformer that we wish to use.
2025-03-15 20:42:08 +01:00
Tim van der Meij
ef7e0ddae4
Update dependencies to the most recent versions 2025-03-15 20:42:08 +01:00
Jonas Jenwald
d1d88cc09e
Merge pull request #19662 from Snuffleupagus/xfa-rm-regex
Replace a few simple regular expressions in the XFA-code with string parsing
2025-03-15 19:44:30 +01:00
Tim van der Meij
2d1833b566
Merge pull request #19663 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2025-03-15 19:19:22 +01:00