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

19983 commits

Author SHA1 Message Date
Jonas Jenwald
445b7ece61
Merge pull request #19084 from Snuffleupagus/getUuid-shorten
Simplify the `getUuid` helper function
2024-11-21 15:17:14 +01:00
Jonas Jenwald
c290a12ce1 Simplify the getUuid helper function
We can remove most feature testing from this helper function, with the exception of `randomUUID` since that's only available in "secure contexts", and also remove the fallback code-path.
Note that this code was only added for Node.js compatibility, and it's no longer necessary now that the minimum support version is `20`; see also https://developer.mozilla.org/en-US/docs/Web/API/Crypto#browser_compatibility

Finally, this patch also adds a basic unit-test for the helper function.
2024-11-21 13:11:10 +01:00
Tim van der Meij
07765e993e
Merge pull request #19069 from calixteman/stamp_test
Fix 'must load a SVG, delete it and undo' integration test
2024-11-19 20:42:12 +01:00
Tim van der Meij
c31ccc6847
Merge pull request #19071 from Snuffleupagus/no-single-promise-in-promise-methods
Enable the `unicorn/no-single-promise-in-promise-methods` ESLint plugin rule
2024-11-19 20:33:33 +01:00
Tim van der Meij
e8fbb602c5
Merge pull request #19064 from timvandermeij/fix-intermittent
Fix the "must check that an infinite loop is not triggered" integration test
2024-11-19 20:31:49 +01:00
Jonas Jenwald
b38b12d48a Enable the unicorn/no-single-promise-in-promise-methods ESLint plugin rule
Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-single-promise-in-promise-methods.md
2024-11-19 11:39:02 +01:00
Calixte Denizet
eefaca07c3 Fix 'must load a SVG, delete it and undo' integration test
We wait for the canvas before trying to serialize the annotation in order to make sure the image has been loaded.
2024-11-18 21:25:59 +01:00
Jonas Jenwald
f4061190fa
Merge pull request #19068 from nicolo-ribaudo/json-imports
Use JSON imports instead of PDFJSDev.json
2024-11-18 16:37:37 +01:00
Nicolò Ribaudo
a8592d86a9
Use JSON imports instead of PDFJSDev.json
JSON imports are now supported by all tools used in PDF.js' build
process. The `chromecom.js` file is bundled by webpack and
import attributes are thus removed, so browser compatibility for this
new syntax is not relevant.
2024-11-18 16:21:12 +01:00
calixteman
658a0a16c1
Merge pull request #18669 from calixteman/stylint_update
Update svglint to 3.1.0
2024-11-18 15:11:57 +01:00
Calixte Denizet
1c5d93cf2d Update svglint to 3.1.0
The new release contains:
 - https://github.com/simple-icons/svglint/pull/110
 - https://github.com/simple-icons/svglint/pull/111

which allow us to slightly simplify our code.
2024-11-18 15:00:07 +01:00
Tim van der Meij
973b67f047
Fix the "must check that an infinite loop is not triggered" integration test
This integration test fails intermittently, locally at least in Chrome
with Puppeteer 23.4.0+, with the following errors:

```
In chrome: Expected '123Hello' to equal 'Hello123'.
In chrome: Expected '123Hello' to equal '123'.
```

This happens because the test before it left queued sandbox events
behind. We don't close the document between tests, so those get run
when we click the textbox in this test and that interferes with our
selection/typing actions. This commit fixes the issue by flushing the
queued sandbox events in the first test, which makes sure that state
no longer leaks through to the next test and thus improves isolation.

Morever, similar to commit 3adf8b6 we use safer assertions to avoid
further intermittent failures, and we replace the `page.$eval` call
with a simpler Home button push like we already do in e.g. the test
helpers. This combined makes the code shorter and simpler.
2024-11-17 21:23:04 +01:00
Tim van der Meij
3219d4905d
Merge pull request #19061 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-11-17 19:59:15 +01:00
Tim van der Meij
21137963b2
Merge pull request #19062 from timvandermeij/gitpod
Remove obsolete Gitpod files
2024-11-17 19:57:53 +01:00
Tim van der Meij
e18cf97733
Update translations to the most recent versions 2024-11-17 19:55:28 +01:00
Tim van der Meij
50d79736f5
Update dependencies to the most recent versions 2024-11-17 19:55:28 +01:00
Tim van der Meij
093485d491
Remove obsolete Gitpod files
In PR #11300 Gitpod support got introduced, but we re-evaluated that
decision in #11732. In PR #11800 the support was partially reverted,
but the actual Gitpod files were kept to not outright break potential
workflows because at the time we were not sure if, and if so how often,
Gitpod was actually used for contributing to PDF.js.

However, in addition to the concerns mentioned in #11732 after five
years we haven't seen any contributions that clearly originated from
Gitpod, and the files have not been updated after e.g. PR #11807 and
PR #17913 because it's not a workflow that we maintain or are able
to test (nor have we seen Gitpod community contributions for this).

This commit therefore removes the remaining Gitpod files to reduce
maintainance burden for PDF.js. Note that users of Gitpod can still
contribute to PDF.js via the platform; we just don't provide/manage
workspace files from this repository anymore.
2024-11-17 19:52:48 +01:00
calixteman
8a8b69f456
Merge pull request #19054 from calixteman/issue18630
When saving some annotations with the same name, set the value in the parent
2024-11-17 18:00:48 +01:00
Tim van der Meij
e2bbcb544a
Merge pull request #19045 from Snuffleupagus/api-rm-isChrome
[api-minor] Disable `ImageDecoder` usage by default in Chromium browsers
2024-11-17 16:32:48 +01:00
Tim van der Meij
fc0484904e
Merge pull request #19059 from Snuffleupagus/DOMFilterFactory-rm-_hcmCache
Improve clean-up of `#_hcmCache`-data in `DOMFilterFactory.prototype.destroy`
2024-11-17 16:31:37 +01:00
Calixte Denizet
2da586527f When saving some annotations with the same name, set the value in the parent
It fixes #18630.
2024-11-17 15:55:20 +01:00
Jonas Jenwald
4c57ec4da7 Improve clean-up of #_hcmCache-data in DOMFilterFactory.prototype.destroy
- Use optional chaining when clearing various data-structures, since that's slightly shorter.

 - Ensure that checking for the existence of `#_hcmCache`-data won't cause it to be initialized. (Note how `this.#hcmCache` is actually a getter.)

 - Actually reset the `#_hcmCache`-data when that's appropriate, e.g. when closing the PDF document.
2024-11-17 15:31:42 +01:00
Jonas Jenwald
bc91985941
Merge pull request #19051 from Snuffleupagus/Dict-Map
Convert the `Dict`-implementation to use a `Map` internally
2024-11-17 12:59:02 +01:00
Jonas Jenwald
823e700b3b
Merge pull request #19057 from Snuffleupagus/extendCMap-avoid-lookup
Avoid redundant CMap-value lookup in `extendCMap` (PR 5101 follow-up)
2024-11-17 12:49:20 +01:00
Tim van der Meij
15a5e47e64
Merge pull request #19042 from Snuffleupagus/eslint-no-console
Enable the ESLint `no-console` rule in parts of the code-base
2024-11-17 12:45:50 +01:00
Jonas Jenwald
2c0cc48d1b Replace the forEach method in Dict with "proper" iteration support 2024-11-17 12:45:32 +01:00
Jonas Jenwald
691be77f65 Convert the Dict-implementation to use a Map internally
With all the recent work happening under https://bugzilla.mozilla.org/show_bug.cgi?id=1851662, the performance of `Map` is already good enough that I believe that we should now be able to utilize it in the `Dict`-class without problem.

This patch was tested in Firefox Nightly, specifically build https://hg.mozilla.org/mozilla-central/rev/6c508a387477e3b72db913a9e1761e9a433d06a2, with the following manifest file:
```
[
  {
    "id": "tracemonkey-eq",
    "file": "pdfs/tracemonkey.pdf",
    "md5": "9a192d8b1a7dc652a19835f6f08098bd",
    "rounds": 100,
    "type": "eq"
  },
  {
    "id": "issue2618",
    "file": "pdfs/issue2618.pdf",
    "md5": "2c554a99a52288ca1a44a422eeafb8fb",
    "rounds": 100,
    "type": "eq"
  }
]
```
which gave the following results, indicating no significant regression, when comparing this patch against the `master` branch:
 - Overall
   ```
   -- Grouped By browser, pdf, stat --
   browser | pdf            | stat         | Count | Baseline(ms) | Current(ms) | +/- |    %  | Result(P<.05)
   ------- | -------------- | ------------ | ----- | ------------ | ----------- | --- | ----- | -------------
   firefox | issue2618      | Overall      |   100 |          678 |         678 |   0 |  0.04 |
   firefox | issue2618      | Page Request |   100 |            1 |           1 |   0 | -3.88 |
   firefox | issue2618      | Rendering    |   100 |          677 |         677 |   0 |  0.05 |
   firefox | tracemonkey-eq | Overall      |  1400 |           35 |          36 |   0 |  0.96 |
   firefox | tracemonkey-eq | Page Request |  1400 |            1 |           1 |   0 | -8.08 |
   firefox | tracemonkey-eq | Rendering    |  1400 |           34 |          35 |   0 |  1.26 |
   ```

 - Page-specific
   ```
   -- Grouped By browser, pdf, page, stat --
   browser | pdf            | page | stat         | Count | Baseline(ms) | Current(ms) | +/- |     %  | Result(P<.05)
   ------- | -------------- | ---- | ------------ | ----- | ------------ | ----------- | --- | ------ | -------------
   firefox | issue2618      | 0    | Overall      |   100 |          678 |         678 |   0 |   0.04 |
   firefox | issue2618      | 0    | Page Request |   100 |            1 |           1 |   0 |  -3.88 |
   firefox | issue2618      | 0    | Rendering    |   100 |          677 |         677 |   0 |   0.05 |
   firefox | tracemonkey-eq | 0    | Overall      |   100 |           23 |          24 |   0 |   1.24 |
   firefox | tracemonkey-eq | 0    | Page Request |   100 |            1 |           1 |   0 |  19.77 |
   firefox | tracemonkey-eq | 0    | Rendering    |   100 |           23 |          23 |   0 |   0.40 |
   firefox | tracemonkey-eq | 1    | Overall      |   100 |           32 |          32 |  -1 |  -1.89 |
   firefox | tracemonkey-eq | 1    | Page Request |   100 |            1 |           1 |   0 | -28.13 |
   firefox | tracemonkey-eq | 1    | Rendering    |   100 |           31 |          31 |   0 |  -0.77 |
   firefox | tracemonkey-eq | 2    | Overall      |   100 |           17 |          18 |   1 |   4.60 |
   firefox | tracemonkey-eq | 2    | Page Request |   100 |            1 |           1 |   0 |  23.53 |        slower
   firefox | tracemonkey-eq | 2    | Rendering    |   100 |           17 |          17 |   1 |   3.71 |
   firefox | tracemonkey-eq | 3    | Overall      |   100 |           23 |          24 |   0 |   1.71 |
   firefox | tracemonkey-eq | 3    | Page Request |   100 |            1 |           1 |   0 |   7.79 |
   firefox | tracemonkey-eq | 3    | Rendering    |   100 |           23 |          23 |   0 |   1.55 |
   firefox | tracemonkey-eq | 4    | Overall      |   100 |           31 |          31 |   1 |   2.49 |
   firefox | tracemonkey-eq | 4    | Page Request |   100 |            1 |           1 |   0 |  48.96 |
   firefox | tracemonkey-eq | 4    | Rendering    |   100 |           30 |          30 |   0 |   1.05 |
   firefox | tracemonkey-eq | 5    | Overall      |   100 |           31 |          30 |  -1 |  -2.42 |
   firefox | tracemonkey-eq | 5    | Page Request |   100 |            2 |           1 |  -1 | -49.33 |
   firefox | tracemonkey-eq | 5    | Rendering    |   100 |           29 |          29 |   0 |  -0.03 |
   firefox | tracemonkey-eq | 6    | Overall      |   100 |           27 |          27 |   0 |   1.81 |
   firefox | tracemonkey-eq | 6    | Page Request |   100 |            1 |           1 |   0 |   4.94 |
   firefox | tracemonkey-eq | 6    | Rendering    |   100 |           26 |          27 |   0 |   1.68 |
   firefox | tracemonkey-eq | 7    | Overall      |   100 |           26 |          26 |   1 |   3.13 |
   firefox | tracemonkey-eq | 7    | Page Request |   100 |            1 |           1 |   0 |   6.98 |
   firefox | tracemonkey-eq | 7    | Rendering    |   100 |           25 |          25 |   1 |   2.92 |
   firefox | tracemonkey-eq | 8    | Overall      |   100 |           25 |          26 |   1 |   5.16 |
   firefox | tracemonkey-eq | 8    | Page Request |   100 |            1 |           1 |  -1 | -41.84 |
   firefox | tracemonkey-eq | 8    | Rendering    |   100 |           23 |          25 |   2 |   8.19 |
   firefox | tracemonkey-eq | 9    | Overall      |   100 |           33 |          33 |   0 |   0.03 |
   firefox | tracemonkey-eq | 9    | Page Request |   100 |            1 |           1 |   0 |   0.79 |
   firefox | tracemonkey-eq | 9    | Rendering    |   100 |           32 |          32 |   0 |  -0.10 |
   firefox | tracemonkey-eq | 10   | Overall      |   100 |          144 |         144 |   1 |   0.52 |
   firefox | tracemonkey-eq | 10   | Page Request |   100 |            2 |           1 |  -1 | -43.52 |
   firefox | tracemonkey-eq | 10   | Rendering    |   100 |          141 |         143 |   2 |   1.18 |
   firefox | tracemonkey-eq | 11   | Overall      |   100 |           24 |          25 |   1 |   2.51 |
   firefox | tracemonkey-eq | 11   | Page Request |   100 |            1 |           1 |   0 |  -4.71 |
   firefox | tracemonkey-eq | 11   | Rendering    |   100 |           23 |          24 |   1 |   2.78 |
   firefox | tracemonkey-eq | 12   | Overall      |   100 |           40 |          39 |  -1 |  -1.67 |
   firefox | tracemonkey-eq | 12   | Page Request |   100 |            1 |           1 |   0 |  14.71 |
   firefox | tracemonkey-eq | 12   | Rendering    |   100 |           39 |          38 |  -1 |  -1.98 |
   firefox | tracemonkey-eq | 13   | Overall      |   100 |           19 |          20 |   1 |   3.09 |
   firefox | tracemonkey-eq | 13   | Page Request |   100 |            1 |           1 |   0 |  24.79 |
   firefox | tracemonkey-eq | 13   | Rendering    |   100 |           18 |          19 |   0 |   1.70 |
   ```
2024-11-17 12:44:06 +01:00
Jonas Jenwald
729e3190eb Fix a couple of bugs affecting benchmarking
- Ensure that `pdfjsTestingUtils` is available when running benchmarking, since that shouldn't be done in TESTING-mode.

 - Exclude the `test/stats/results/` folder from linting, since it'll contain *generated* JSON-files.
2024-11-17 12:44:06 +01:00
Tim van der Meij
a719c3c067
Merge pull request #19050 from Snuffleupagus/evaluator-no-var
Enable the ESLint `no-var` rule in the `src/core/evaluator.js` file
2024-11-17 12:23:49 +01:00
Tim van der Meij
cab98b8ca9
Merge pull request #19052 from Snuffleupagus/pr-19029
Remove the `extensions/chromium/.eslintrc` file (PR 19029 follow-up)
2024-11-17 12:21:33 +01:00
Jonas Jenwald
8783dd0178 Avoid redundant CMap-value lookup in extendCMap (PR 5101 follow-up)
When iterating through `useCMap` the value is already available, without having to manually invoke the `lookup`-method.
While this will likely not affect performance in any noticeable way, it's nonetheless unnecessary to lookup an already available value twice.
2024-11-17 11:57:45 +01:00
Jonas Jenwald
6f3f3be7a3 Remove the extensions/chromium/.eslintrc file (PR 19029 follow-up)
This file became unused in PR 19029, but we apparently forgot to remove it.
2024-11-16 14:48:44 +01:00
Jonas Jenwald
c082169cae Enable the ESLint no-var rule in the src/core/evaluator.js file
This was previously attempted in PR 13371, but had to be reverted because of issues related to SystemJS (which has since been removed).

Also, while unrelated, shortens an existing conditional assignment.
2024-11-15 12:36:51 +01:00
Jonas Jenwald
af3c1f2a0d Enable the ESLint no-console rule in parts of the code-base
The purpose of these changes is to make it more difficult to accidentally include logging statements, used during development and debugging, when submitting patches for review.

For (almost) all code residing in the `src/` folder we should use our existing helper functions to ensure that all logging can be controlled via the `verbosity` API-option.

For the `test/unit/` respectively `test/integration/` folders we shouldn't need any "normal" logging, but it should be OK to print the *occasional* warning/error message.

Please find additional details about the ESLint rule at https://eslint.org/docs/latest/rules/no-console
2024-11-14 12:41:39 +01:00
Jonas Jenwald
471284f51b [api-minor] Disable ImageDecoder usage by default in Chromium browsers
Given that there are multiple issues with `ImageDecoder` in Chromium browsers, affecting both BMP and JPEG images, for now we (by default) disable that functionality there to avoid problems.

This also means that we can remove the previously added, and separate, `isChrome` API-option.
2024-11-14 12:05:15 +01:00
Jonas Jenwald
9bf9bbda0b
Merge pull request #19031 from Snuffleupagus/api-isImageDecoderSupported
[api-minor] Add a `getDocument` option to disable `ImageDecoder` usage
2024-11-13 09:19:05 +01:00
Tim van der Meij
f197c9faec
Merge pull request #19033 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-11-12 21:43:00 +01:00
Tim van der Meij
172e1bf2c2
Merge pull request #19035 from timvandermeij/python3.13
Use Python 3.13 in the GitHub workflows
2024-11-12 21:42:15 +01:00
Tim van der Meij
913738644a
Use Python 3.13 in the GitHub workflows
Python 3.13 is the current version and was released over a month ago
(see https://devguide.python.org/versions). The dependencies we use now
support Python 3.13, most importantly `fonttools` which uses OS-specific
builds and for which compatibility got introduced in
https://github.com/fonttools/fonttools/pull/3656 and the corresponding
`cp313` wheels for all distributions are published on
https://pypi.org/project/fonttools/#files.

Moreover, we fix forgotten `npx` usage in the font tests README which
was encountered while testing this patch.
2024-11-12 20:59:01 +01:00
Tim van der Meij
cfbbf61dd9
Update translations to the most recent versions 2024-11-12 20:36:16 +01:00
Tim van der Meij
499fab998e
Upgrade eslint to version 9
This is unblocked now that all dependencies have been updated and the
flat configuration format (compatible with ESLint 8 and 9) was
introduced first. The following deprecation warnings during `npm
install` are resolved by this upgrade:

```
npm warn deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
```

Note that according to https://eslint.org/version-support ESLint 8 is
officially EOL now, and ESLint 9 has been released for over seven
months and is the only officially supported version.

Fixes #17928.
2024-11-12 20:35:50 +01:00
Tim van der Meij
cdb32dae45
Update dependencies to the most recent versions 2024-11-12 20:22:27 +01:00
Tim van der Meij
6676492920
Merge pull request #19021 from Snuffleupagus/PartialEvaluator-#fetchData
Add a `PartialEvaluator` helper for fetching CMap and Standard Font data
2024-11-12 19:56:39 +01:00
Jonas Jenwald
65eedfb0fc [api-minor] Add a getDocument option to disable ImageDecoder usage
This allows end-users to forcibly disable `ImageDecoder` usage, even if the browser appears to support it (similar to the pre-existing option for `OffscreenCanvas`).
2024-11-12 17:12:42 +01:00
Jonas Jenwald
fe5967c84e
Merge pull request #19029 from nicolo-ribaudo/eslint-flat-config
Migrate to ESLint flat config
2024-11-12 16:22:54 +01:00
Nicolò Ribaudo
9e6ff979db
Migrate to ESLint flat config
Flat config is the new config system used by ESLint 9.
To make the migration easier, they also added
flat config support to ESLint 8.

This commit migrates the various ESLint configs in the repository to use
the new system, **without** upgrading to ESLint 9 yet.
2024-11-12 16:15:17 +01:00
calixteman
13a231cd3b
Merge pull request #19026 from calixteman/refactor_newrefs_saving
Simplify saving added/modified annotations.
2024-11-12 13:52:20 +01:00
Calixte Denizet
4bf7787084 Simplify saving added/modified annotations.
Having this map to collect the different changes will allow to know if some objects have already been modified.
2024-11-12 10:59:38 +01:00
calixteman
7a962031e9
Merge pull request #19024 from calixteman/disable_test_chrome
Disable ref test 'issue18896' for Chrome because it takes too much time
2024-11-11 19:11:30 +01:00
Calixte Denizet
92b7374aad Disable ref test 'issue18896' for Chrome because it takes too much time 2024-11-11 18:55:56 +01:00