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

20654 commits

Author SHA1 Message Date
Jonas Jenwald
74ab29544e
Merge pull request #19701 from Snuffleupagus/enableAutoLinking-true
[api-minor] Enable `enableAutoLinking` by default
2025-03-25 18:18:08 +01:00
Jonas Jenwald
22107145df
Merge pull request #19691 from Snuffleupagus/xfa-template-rm-reduce
Remove `Array.prototype.reduce` usage from the `src/core/xfa/template.js` file
2025-03-25 18:17:12 +01:00
Jonas Jenwald
532406427b Simplify the StructElementNode.prototype.role getter a tiny bit
Given that the `roleMap` only contains `Name`-strings, the lookup can be simplified thanks to modern JavaScript features.
2025-03-25 18:04:56 +01:00
Jonas Jenwald
3c93d63731 Pass the XRef-instance explicitly to the StructTreeRoot class
This avoids the current situation where we're accessing it through various dictionaries, since that's a somewhat brittle solution given that in the general case a `Dict`-instance may not have the `xref`-field set (see e.g. the empty-Dict).
2025-03-25 18:04:51 +01:00
calixteman
d4c7aaa9d3
Merge pull request #19702 from calixteman/issue19694
In the struct tree a kid can be a reference to an MCID entry (issue #19694)
2025-03-25 18:02:46 +01:00
Calixte Denizet
6146e5fee7 Optimize save-transform-constructPath-restore
The 4 operations can be replaced with just one in applying the transform to the points coordinates.
2025-03-25 15:31:45 +01:00
Calixte Denizet
dee80cb082 In the struct tree a kid can be a reference to an MCID entry (issue #19694) 2025-03-25 15:01:52 +01:00
Jonas Jenwald
8f7d6f4118 Shorten the PDFViewerApplication._initializeViewerComponents method
By tweaking a few local variable names we can shorten various viewer-component initialization code, and we can also reduce some duplication when assigning components to the `PDFViewerApplication`-scope.
2025-03-25 12:51:40 +01:00
calixteman
a8c77633a1
Merge pull request #19717 from calixteman/issue16287
Don't overwrite the global alpha when switching to smask mode (bug 1764587)
2025-03-25 10:08:36 +01:00
Calixte Denizet
1d0227af62 Don't overwrite the global alpha when switching to smask mode
It fixes #issue16287.
2025-03-24 21:35:09 +01:00
calixteman
b57da32d70
Merge pull request #19716 from calixteman/issue16742
Take into account the group bbox
2025-03-24 16:57:34 +01:00
Jonas Jenwald
9456b88f6b Remove Array.prototype.reduce usage from the src/core/xfa/template.js file
Using `Array.prototype.reduce` often leads to less readable code, and in these cases we can replace that with other Array-methods instead.
2025-03-24 16:40:41 +01:00
Jonas Jenwald
fceaab8864
Merge pull request #19713 from Snuffleupagus/Util-minMax-methods
Add new bounding-box helpers in `Util` to reduce code duplication
2025-03-24 16:39:05 +01:00
Jonas Jenwald
d8d4f2a850
Merge pull request #19714 from Snuffleupagus/MathClamp-3
Use the `MathClamp` helper function even more (PR 19617 follow-up)
2025-03-24 16:35:07 +01:00
Calixte Denizet
a3c31904f1 Take into account the group bbox
It fixes #16742.
2025-03-24 15:07:31 +01:00
calixteman
bcba053a5e
Merge pull request #19715 from calixteman/issue18529
Take into account the path and the line width when consuming a stroked path
2025-03-24 14:41:29 +01:00
Jonas Jenwald
b85f0903ca Add new bounding-box helpers in Util to reduce code duplication
Currently we have a `Util`-helper for computing the bounding-box of a Bézier curve, however for simple points and rectangles we repeat virtually identical code in many spots throughout the code-base.

 - Introduce new `Util.pointBoundingBox` and `Util.rectBoundingBox` helpers.

 - Remove the "fallback" from `Util.bezierBoundingBox` and only support passing in a `minMax`-array, since there's only a single call-site using the other format and it could be easily updated.
2025-03-23 19:20:02 +01:00
Calixte Denizet
2369e2d84f Take into account the path and the line width when consuming a stroked path 2025-03-23 18:08:06 +01:00
Jonas Jenwald
4547e582ff Use the MathClamp helper function even more (PR 19617 follow-up)
There's a few more spots that I accidentally missed in PR 19617.
2025-03-23 17:11:06 +01:00
Tim van der Meij
19b4adac03
Merge pull request #19711 from timvandermeij/integration-tests-freetext-isolate-part-2
Isolate the "create editor with keyboard" freetext editor integration tests
2025-03-23 15:06:39 +01:00
calixteman
7c5695f5c6
Merge pull request #19708 from calixteman/fix_save_smask_mode
Fix save/restore while in smask mode
2025-03-23 14:45:09 +01:00
Tim van der Meij
d01913e62e
Isolate the "create editor with keyboard" freetext editor integration tests
This commit reduces the number of freetext editor integration test suite
failures, in full isolation, from 6 to 5 by fixing the following issues
in the "create editor with keyboard" block:

- The second test relied on the first test to enable freetext editing
  mode and put focus on the page (annotation layer). For isolation we
  now do that explicitly in the second test.
- The second test relied on the first test for the editor numbering. For
  isolation we change the editor numbering to the one after initial
  document load.

Moreover, the test names have been updated to clarify with scenario is
being tested, which came up during comparison of the changes against
commit ea5eafa to make sure that we are still testing the originally
intended scenarios (confirmed by disabling the relevant code from the
commit per scenario and noticing the corresponding test failing).
2025-03-23 14:28:03 +01:00
Tim van der Meij
94b2c86251
Merge pull request #19704 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2025-03-23 13:43:28 +01:00
Jonas Jenwald
c7c08bbd07
Merge pull request #19710 from Snuffleupagus/Math-sumPrecise
Introduce `Math.sumPrecise` usage in the code-base
2025-03-23 13:34:28 +01:00
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