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

20014 commits

Author SHA1 Message Date
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
calixteman
2ad8782428
Merge pull request #19023 from calixteman/issue19022
Apply gradient when stroking text
2024-11-11 17:15:50 +01:00
Calixte Denizet
79e1f155ac Apply gradient when stroking text
It fixes #19022.

I noticed that the glyph contours weren't correct (for T and x) and
because we forgot to close the contour.
2024-11-11 15:53:07 +01:00
Jonas Jenwald
16e86878d2 Add a PartialEvaluator helper for fetching CMap and Standard Font data
This avoids a little bit of code duplication, which cannot hurt.
2024-11-11 11:57:28 +01:00
Jonas Jenwald
5524216c23
Merge pull request #19015 from Snuffleupagus/@napi-rs/canvas
[api-minor] Replace the `canvas` package with `@napi-rs/canvas`
2024-11-10 19:45:01 +01:00
Tim van der Meij
b9c17efe35
Merge pull request #19019 from Snuffleupagus/userUnit-shorten
Shorten the `Page.prototype.userUnit` getter slightly
2024-11-10 18:31:00 +01:00
calixteman
34e4c4f9b6
Merge pull request #19018 from calixteman/issue19008
Set the padding of the buttons in the toolbars to zero
2024-11-10 17:05:55 +01:00
Jonas Jenwald
0b864ee7d5 Shorten the Page.prototype.userUnit getter slightly 2024-11-10 16:30:07 +01:00
Calixte Denizet
ca3b777b89 Set the padding of the buttons in the toolbars to zero
It fixes #19008.
In Firefox on mac, the default padding is set to 4px and with Firefox for iOS, it's set to 13px.
The padding is useless for such buttons.
2024-11-09 22:30:50 +01:00
Jonas Jenwald
9b62f2e7d1 Polyfill ImageData in Node.js environments
Given that `ImageData` has been supported for many years in all browsers, see [MDN](https://developer.mozilla.org/en-US/docs/Web/API/ImageData#browser_compatibility), we have a `typeof` check that's only necessary in Node.js environments.
Since the `@napi-rs/canvas` package provides that functionality, we can thus add an `ImageData` polyfill which allows us to ever so slightly simplify the code.
2024-11-09 18:51:32 +01:00
Jonas Jenwald
86f943ca03 [api-minor] Replace the canvas package with @napi-rs/canvas
The `@napi-rs/canvas` package has fewer dependencies, which should *hopefully* make installing and using it easier for `pdfjs-dist` end-users. (Over the years we've seen, repeatedly, that `canvas` can be difficult to install successfully.)
Furthermore, this package includes more functionality (such as `Path2D`) which reduces the overall number of dependencies in the PDF.js project.

One point to note is that `@napi-rs/canvas` is a fair bit newer than `canvas`, and has a lot fewer users, however looking at the commit history it does seem to be actively maintained.

Note that I've successfully tested the [Node.js examples](https://github.com/mozilla/pdf.js/tree/master/examples/node), in particular the `pdf2png` one, with this patch applied and things appear to work fine.

Please see:
 - https://www.npmjs.com/package/@napi-rs/canvas
 - https://github.com/Brooooooklyn/canvas
2024-11-09 18:51:29 +01:00
Jonas Jenwald
bff6738966
Merge pull request #19012 from Snuffleupagus/pr-18819
Fix Typo:XFATemplate class Para Styling paddingight => paddingRight
2024-11-06 12:12:45 +01:00
Pascal Maximilian Bremer
6d7157a875 Fix Typo:XFATemplate class Para Styling paddingight => paddingRight 2024-11-06 12:04:55 +01:00
calixteman
f520d2375b
Merge pull request #19011 from calixteman/roman
Simplify toRomanNumerals function
2024-11-06 09:23:20 +01:00
Jonas Jenwald
b666c4f7be
Merge pull request #19002 from Snuffleupagus/version-4.9
Bump library version to `4.9`
2024-11-06 09:12:07 +01:00
Jonas Jenwald
1a56b35af7
Merge pull request #19003 from Snuffleupagus/api-unittest-image-helpers
Add helper functions to load image blob/bitmap data in `test/unit/api_spec.js`
2024-11-06 09:11:28 +01:00
Calixte Denizet
d59f9648a9 Simplify toRomanNumerals function 2024-11-05 22:35:35 +01:00
Jonas Jenwald
fdfcfbc351
Merge pull request #19005 from Snuffleupagus/core_utils-shorten
Shorten a few helper functions in `src/core/core_utils.js`
2024-11-05 21:46:44 +01:00
Jonas Jenwald
c78eebbace
Merge pull request #19007 from Snuffleupagus/issue-18986
Try to improve handling of missing trailer dictionaries in `XRef.indexObjects` (issue 18986)
2024-11-05 21:45:27 +01:00
Jonas Jenwald
cbb02eb655
Merge pull request #19010 from CyberAndrii/18957-fix-error-on-empty-response-headers
Fix error on empty response headers
2024-11-05 21:22:29 +01:00