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

20737 commits

Author SHA1 Message Date
Jonas Jenwald
f1e20cd668
Merge pull request #19824 from Snuffleupagus/getStructTree-catch-errors
Improve error handling when parsing page-structTrees
2025-04-17 15:21:55 +02:00
Jonas Jenwald
bf553f22da Ensure that the /P-entry is actually a dictionary in StructTreePage.prototype.addNode
This may fix issue 19822, but without a test-case it's simply impossible to know for sure.
2025-04-17 14:01:53 +02:00
Jonas Jenwald
76f23ce3b5 Catch, and ignore, errors during Page.prototype.getStructTree
This way any errors thrown during parsing of the page-structTree will not be forwarded to the viewer.
2025-04-17 13:57:30 +02:00
Tim van der Meij
2f7d163dfd
Merge pull request #19812 from timvandermeij/disable-permafail
Remove debug code from the integration tests, and skip the "must check that canvas perfectly fits the page whatever the zoom level" integration test in Chrome
2025-04-13 20:53:58 +02:00
Tim van der Meij
923753a66b
Skip the "must check that canvas perfectly fits the page whatever the zoom level" integration test in Chrome
This is a temporary measure to reduce noise until #19811 is fixed. Note
that this shouldn't be an issue in terms of coverage because we still
run the test in Firefox.
2025-04-13 19:32:39 +02:00
Tim van der Meij
efe4a3455a
Remove debug code from the integration tests
Doing so simplifies the code a bit, and such code is generally not
checked in because it can easily be added locally if needed.
2025-04-13 19:19:13 +02:00
Tim van der Meij
35f85c55bd
Merge pull request #19810 from Snuffleupagus/issue-19808
Update Webpack to version `5.99.5` (issue 19808)
2025-04-13 18:43:19 +02:00
Tim van der Meij
574e4f4ec1
Merge pull request #19809 from timvandermeij/integration-tests-isolate-all-and-random
Run the integration tests in a random order
2025-04-13 18:37:08 +02:00
Jonas Jenwald
6b961c424f Update Webpack to version 5.99.5 (issue 19808)
In Webpack version `5.99.0` the way that `export` statements are handled was changed slightly, with much less boilerplate code being generated, which unfortunately breaks our `tweakWebpackOutput` function that's used to expose the exported properties globally and that e.g. the viewer depends upon.

Given that we were depending on formatting that should most likely be viewed as nothing more than an internal implementation detail in Webpack, we instead work-around this by manually defining the structures that were previously generated.
Obviously this will lead to a tiny bit more manual work in the future, however we don't change the API-surface often enough that it should be a big issue *and* the relevant unit-tests are updated such that it shouldn't be possible to break this.

*NOTE:* In the future we might want to consider no longer using global properties like this, and instead rely only on proper `export`s throughout the code-base.
However changing this would likely be non-trivial (given edge-cases), and it'd be an `api-major` change, so let's just do the minimal amount of work to unblock Webpack updates for now.
2025-04-13 16:48:19 +02:00
Tim van der Meij
938430be5b
Remove workaround from the "must convert input to uppercase" scripting integration test
It's no longer necessary after commit 1c73e52 that caused the document
to be closed properly between tests, and this therefore partly reverts
commit 973b67f.
2025-04-13 15:57:54 +02:00
Tim van der Meij
5f46791887
Run the integration tests in a random order
This commit configures Jasmine to no longer run the tests in a fixed
order, which combined with the previous isolation commits avoids being
able to accidentally introduce dependencies between integration tests.
2025-04-13 15:46:03 +02:00
Tim van der Meij
75b321b000
Isolate the viewer integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:24:15 +02:00
Tim van der Meij
965949c259
Isolate the text layer integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:24:15 +02:00
Tim van der Meij
6308f5eb51
Isolate the text field integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:24:15 +02:00
Tim van der Meij
7c8262ccc9
Isolate the stamp editor integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:24:15 +02:00
Tim van der Meij
44243761a5
Isolate the highlight editor integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:27 +02:00
Tim van der Meij
5011d96a62
Isolate the freetext editor integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:23 +02:00
Tim van der Meij
f043760b54
Isolate the find integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:18 +02:00
Tim van der Meij
179859f54a
Isolate the copy/paste integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:14 +02:00
Tim van der Meij
0e9e4ec64f
Isolate the caret browsing integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:08 +02:00
Tim van der Meij
a60f9bc612
Isolate the autolinker integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:20:03 +02:00
Tim van der Meij
e1cbba4ded
Isolate the annotation integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:19:59 +02:00
Tim van der Meij
193bebd78a
Isolate the accessibility integration tests
To avoid being able to introduce dependencies between tests 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.
2025-04-13 15:18:19 +02:00
Tim van der Meij
c071f44883
Merge pull request #19807 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2025-04-13 11:24:15 +02:00
Tim van der Meij
d5dce6bc42
Update translations to the most recent versions 2025-04-12 19:38:22 +02:00
Tim van der Meij
b61d52c6da
Update dependencies to the most recent versions 2025-04-12 19:38:22 +02:00
Tim van der Meij
e06b32c831
Merge pull request #19806 from Snuffleupagus/more-logical-assign
Add more logical assignment in the `src/` folder
2025-04-12 18:51:28 +02:00
Jonas Jenwald
834423b51d Add more logical assignment in the src/ folder
This patch uses nullish coalescing assignment in cases where it's immediately obvious from surrounding code that doing so is safe, and logical OR assignment elsewhere (mostly the changes in XFA code).
2025-04-12 17:28:33 +02:00
Tim van der Meij
5da507f279
Merge pull request #19805 from Snuffleupagus/_xfaStreams-Map
Change `PDFDocument.prototype._xfaStreams` to return a `Map`
2025-04-12 14:00:09 +02:00
Tim van der Meij
5f3e8806fe
Merge pull request #19789 from Snuffleupagus/generic-SignatureStorage-save
Simplify `Object.fromEntries` usage a tiny bit in the `web/generic_signature_storage.js` file
2025-04-12 13:37:40 +02:00
Tim van der Meij
f482232493
Merge pull request #19790 from Snuffleupagus/test-getAnnotationStorage-rm-entries
Simplify the `getAnnotationStorage` integration-test helper function
2025-04-12 13:36:20 +02:00
Jonas Jenwald
1c80412f61 Change PDFDocument.prototype._xfaStreams to return a Map
Using a `Map` rather than an `Object` is a nicer, since it has better support for both iteration and checking if a key exists.
We also change the initial values to be `null`, rather than empty strings, and reduce duplication when creating the `Map`.

*Please note:* Since this is worker-thread code, these changes are "invisible" at the API-level.
2025-04-12 12:47:22 +02:00
Jonas Jenwald
9c6e2e6df0
Merge pull request #19803 from Snuffleupagus/issue-19800
Catch circular references in /Form XObjects (issue 19800)
2025-04-11 17:03:42 +02:00
Jonas Jenwald
1048508dd1 Catch circular references in /Form XObjects (issue 19800)
For simplicity we will abort /Form XObject parsing *immediately* when encountering a circular reference, rather than letting it continue up until some limit (as e.g. PDFium appears to do), which should be fine since there are never any guarantees if/how *corrupt* PDF documents will render.
2025-04-11 16:54:22 +02:00
Jonas Jenwald
7a94fafd30 Prefer /Resources from the /Contents stream-dict, if available
In rare cases /Resources are also found in the /Contents stream-dict, in addition to in the /Page dict, hence we need to prefer those when available; see `issue18894.pdf`.
2025-04-11 16:54:22 +02:00
Jonas Jenwald
53c5a53668
Merge pull request #19804 from Snuffleupagus/issue-19802
Use `adjustWidths` unconditionally for all embedded fonts (issue 19802)
2025-04-11 16:53:20 +02:00
Jonas Jenwald
835a456767 Use adjustWidths unconditionally for all embedded fonts (issue 19802)
Previously we'd only do this for Type1/CFF fonts, see e.g. PR 6736, since the font-program may update the /FontMatrix.
However, it seems that we should do this unconditionally to account for fonts with non-default /FontMatrix-entries in the font-dictionary (which seem to be pretty rare).
2025-04-11 15:01:35 +02:00
calixteman
539a81c7a3
Merge pull request #19797 from calixteman/issue19793
[Editor] Commit the current drawing before switching the current mode
2025-04-10 21:34:51 +02:00
calixteman
1d8af5fe68
Merge pull request #19799 from calixteman/bug1959774
[Editor] Fix the border line of the thickness slider in the signature modal while in HCM (bug 1959774)
2025-04-10 21:32:19 +02:00
Calixte Denizet
61df54c689 [Editor] Commit the current drawing before switching the current mode
It fixes #19793.
2025-04-10 21:31:24 +02:00
Calixte Denizet
88d58f393b [Editor] Fix the border line of the thickness slider in the signature modal while in HCM (bug 1959774) 2025-04-10 19:55:22 +02:00
Jonas Jenwald
220a28933c
Merge pull request #19791 from Snuffleupagus/IndexedCS-round-clamp
Handle non-integer and out-of-range values correctly in Indexed color spaces
2025-04-09 16:29:23 +02:00
Jonas Jenwald
fbc4f4b12a Handle non-integer and out-of-range values correctly in Indexed color spaces
In PDF version 2.0 the handling of Indexed color spaces was clarified as follows:
> The index value should be an integer in the range 0 to hival. If the value is a real number, it shall be rounded to the nearest integer (0.5 values shall be rounded up); if it is outside the range 0 to hival, it shall be adjusted to the nearest value within that range.

Please refer to https://github.com/pdf-association/pdf-differences/tree/main/IndexedColor
2025-04-09 15:31:49 +02:00
Jonas Jenwald
60bf9b133a Simplify the getAnnotationStorage integration-test helper function
As can be seen [at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries#parameters) the `Object.fromEntries` method accepts a `Map` directly, hence using the `Map.prototype.entries` method is superfluous here.
2025-04-09 13:42:22 +02:00
Jonas Jenwald
1d1e6e7b92 Simplify Object.fromEntries usage a tiny bit in the web/generic_signature_storage.js file
As can be seen [at MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries#parameters) the `Object.fromEntries` method accepts a `Map` directly, hence using the `Map.prototype.entries` method is superfluous here.
2025-04-09 12:06:40 +02:00
Jonas Jenwald
22657e2b6e
Merge pull request #19778 from Snuffleupagus/replace-getAll
[api-minor] Replace various `getAll` methods with iterators
2025-04-08 17:26:24 +02:00
Jonas Jenwald
12c7c7b0af
Merge pull request #19773 from Snuffleupagus/inline-PDFImage-createRawMask
Inline `PDFImage.createRawMask` in the `PDFImage.createMask` method
2025-04-08 17:19:09 +02:00
Jonas Jenwald
19486952c2
Merge pull request #19781 from Snuffleupagus/mv-IDENTITY_MATRIX
Move the `IDENTITY_MATRIX` constant into `src/core/core_utils.js` (PR 19772 follow-up)
2025-04-08 17:16:31 +02:00
Jonas Jenwald
0e50125a6c
Merge pull request #19788 from Snuffleupagus/no-array-reduce
Enable the `no-array-reduce` ESLint plugin rule
2025-04-08 17:09:44 +02:00
Jonas Jenwald
38d01250f4 Enable the no-array-reduce ESLint plugin rule
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reduce.md

Note that this still allows "simple" usage of `Array.prototype.reduce`, however most of those cases will be possible to replace with `Math.sumPrecise` once that becomes generally available (currently not supported in Node.js or QuickJS).
2025-04-08 12:21:20 +02:00