22644 Commits

Author SHA1 Message Date
Calixte Denizet
1658a792ce Improve soft mask composition performance (bug 2033095)
Prepare reusable soft-mask canvases for filtered and backdrop-dependent masks,
and use a faster destination-in composition path where possible.
Handle Alpha SMask /BC correctly, preserve OOB alpha behavior, and mirror canvas path
operations needed while rendering inside soft-mask mode (mirrored clip was buggy).

Add reftest PDFs covering Alpha masks, transfer functions, backdrop/OOB
alpha, and the optimized composition paths.
2026-05-07 19:06:49 +02:00
dependabot[bot]
175c184956
Bump ip-address from 10.1.0 to 10.2.0
Bumps [ip-address](https://github.com/beaugunderson/ip-address) from 10.1.0 to 10.2.0.
- [Commits](https://github.com/beaugunderson/ip-address/commits)

---
updated-dependencies:
- dependency-name: ip-address
  dependency-version: 10.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-07 00:37:45 +00:00
Calixte Denizet
4c62a49483
Place new annotations on the correct page when extracting pages (bug 2027682) 2026-05-06 18:44:02 +02:00
Jonas Jenwald
cce61cb7f4
Merge pull request #21229 from Snuffleupagus/WasmImage-private
Tweak the `WasmImage` implementation a little bit (PR 21225 follow-up)
2026-05-06 18:27:44 +02:00
Jonas Jenwald
3f6a2feef6 Tweak the WasmImage implementation a little bit (PR 21225 follow-up)
This fixes two things that I overlooked in PR 21225, more specifically:

 - Use proper, rather than semi, private class fields in `WasmImage`.

 - Make tracking of `WasmImage` instances optional, to avoid keeping data alive permanently in the `IMAGE_DECODERS` build.
2026-05-06 17:52:35 +02:00
Calixte Denizet
a6cb30a9e5
Make sure the focus moves on the first page of the added pdf after a merge (bug 2034827) 2026-05-06 13:42:49 +02:00
saripovdenis
473f9b4592 Avoid quadratic traversal in NameOrNumberTree.getAll
Using Array.prototype.shift() to drain the traversal queue makes each
visited node move the remaining queued entries. For large name/number
trees this can make getAll() spend quadratic time in queue management.

Iterate over the queue with for...of instead. Children pushed while
iterating are still visited, and the queue no longer needs repeated
front removals.
2026-05-06 09:51:57 +08:00
Jonas Jenwald
cd1b5f57c7
Merge pull request #21226 from Snuffleupagus/unittestcli-coverage-external
Include the `external/` folder in the coverage report for `gulp unittestcli`
2026-05-05 22:52:39 +02:00
Jonas Jenwald
d33d9fc61d Include the external/ folder in the coverage report for gulp unittestcli
Given that the (browser) `gulp unittest` coverage includes the `external/` folder, it seems reasonable to include that folder in the coverage report when running unit-tests in Node.js as well.
2026-05-05 22:12:18 +02:00
Tim van der Meij
ac51bdf745
Merge pull request #21222 from Snuffleupagus/getPdfFilenameFromUrl-tweaks
A couple of small tweaks of the `getPdfFilenameFromUrl` helper
2026-05-05 20:27:55 +02:00
Tim van der Meij
d36e61d020
Merge pull request #21224 from Snuffleupagus/Node-26
Run unit-tests in Node.js version 26
2026-05-05 20:20:48 +02:00
Tim van der Meij
a1d9f13278
Merge pull request #21219 from calixteman/issue21217
Clear the text layer container when cancelling rendering
2026-05-05 20:19:13 +02:00
Jonas Jenwald
5967f720b9
Merge pull request #21225 from Snuffleupagus/WasmImage
Add an abstract `WasmImage` class, that `JBig2CCITTFaxImage` and `JpxImage` inherit from
2026-05-05 20:10:27 +02:00
Jonas Jenwald
6ff0f8690f Add an abstract WasmImage class, that JBig2CCITTFaxImage and JpxImage inherit from
Given that these classes are, with the exception of their `decode` methods, virtually identical this helps reduce code duplication and simplifies maintenance.

These changes reduce the size of the `gulp mozcentral` build-target by `1292` bytes, which obviously isn't a lot but still cannot hurt.
2026-05-05 17:25:18 +02:00
Jonas Jenwald
9efb4aa4aa Run unit-tests in Node.js version 26
This was just released, see https://nodejs.org/en/blog/release/v26.0.0, hence it seems like a good idea to start running unit-tests in that version.

Also, stop running the unit-tests in Node.js version 25 since it'll soon reach EOL anyway and testing in three separate Node.js versions ought to suffice.
2026-05-05 17:09:19 +02:00
Jonas Jenwald
e8d3d19f67
Merge pull request #21220 from Snuffleupagus/DataBuilder
Replace `TrueTypeTableBuilder` and `CompilerOutput` with a single class
2026-05-05 13:07:31 +02:00
Jonas Jenwald
8fc56772e8 A couple of small tweaks of the getPdfFilenameFromUrl helper
- Shorten the `getURL` function slightly, by re-factoring the try-catch blocks.
 - Change how the `decode` function looks for a decoded ".pdf" name, to skip the regular expression matching when it's not needed and to allow re-using the already defined `pdfRegex`.
2026-05-05 12:16:57 +02:00
Jonas Jenwald
ac6a9230d1 Replace TrueTypeTableBuilder and CompilerOutput with a single class
Given that both of these classes are so similar, let's replace them with a single `DataBuilder` class instead to reduce unnecessary code-duplication.
2026-05-04 15:01:53 +02:00
Calixte Denizet
82f55e7dd9
Clear the text layer container when cancelling rendering
It fixes #21217.
2026-05-04 14:36:12 +02:00
Tim van der Meij
a55cec4a0f
Merge pull request #21216 from Snuffleupagus/CFFCharset-rm-raw
Remove the unused `raw` field from the `CFFCharset` class
2026-05-03 19:31:04 +02:00
Jonas Jenwald
53fd89682c Remove the unused raw field from the CFFCharset class
This was necessary before charset compilation was implemented, however that's been supported for many years and this is just dead code now.
 - PR 9340, back in 2018, stopped using the `raw` field.
 - PR 10591, back in 2019, implemented proper charset compilation.
2026-05-03 18:51:24 +02:00
Tim van der Meij
f54f4b606d
Merge pull request #21215 from Snuffleupagus/compileFDSelect-TypedArray-set
Replace a loop with `TypedArray.prototype.set()` in the `compileFDSelect` method
2026-05-03 18:30:18 +02:00
Jonas Jenwald
027671e6dc Replace a loop with TypedArray.prototype.set() in the compileFDSelect method
Given that the `fdSelect.fdSelect` data is a regular Array, this code can simplified a tiny bit.
2026-05-03 16:32:48 +02:00
Tim van der Meij
c196fa8196
Merge pull request #21214 from Snuffleupagus/CFFFont-improvements
Remove the `CompilerOutput.prototype.finalData` getter, and a few other font improvements (PR 21053 follow-up)
2026-05-03 16:07:22 +02:00
Jonas Jenwald
e5e82b9617 Don't create a DataView for the "CFF " TrueType table in readTableEntry
Given that the "CFF " table may be replaced completely, during font-parsing, it shouldn't make sense to read and/or modify it piecewise.
2026-05-03 13:17:23 +02:00
Jonas Jenwald
b65eedc636 Set the correct data if compilation fails in the CFFFont constructor
The `CFFFont.prototype.data` should contain a `Uint8Array`, however if compilation failed it was being set to a `Stream` instance which will thus fail elsewhere in the font-code.

*Please note:* This was found by code inspection, since I don't have a PDF document that's fixed by this change.
2026-05-03 13:17:18 +02:00
Jonas Jenwald
521f4dc554 Remove the CompilerOutput.prototype.finalData getter (PR 21053 follow-up)
Return the data as-is from the `CFFCompiler.prototype.compile` method, rather than making a copy of it first.
The reason that it was implemented this way in PR 21053 was to avoid keeping a potentially large `ArrayBuffer` alive, see https://github.com/mozilla/pdf.js/pull/21053#discussion_r3045402988

Having traced all the call-sites in the font-code that directly or indirectly invoke that code, I've now managed to conclude that the compiled CFF-data is never stored on the `Font` instance and using the data as-is thus shouldn't increase permanent memory usage.
2026-05-03 13:13:50 +02:00
Tim van der Meij
6d5e8696c4
Merge pull request #21211 from Snuffleupagus/JpxStream-rm-params
Don't provide unused /DecodeParms when initializing `JpxStream`
2026-05-02 14:11:36 +02:00
Tim van der Meij
ccf9e03e18
Merge pull request #21210 from timvandermeij/unit-test-optimize-find
Optimize runtime of the find controller unit tests
2026-05-02 14:10:38 +02:00
Jonas Jenwald
a8715f6f96 Don't provide unused /DecodeParms when initializing JpxStream 2026-05-02 12:20:28 +02:00
Tim van der Meij
038ca33f8e
Optimize runtime of the find controller unit tests
The find controller tests consistently show up in the list of slowest
tests reported by Jasmine. Profiling shows that most of the time is
spent waiting for the find results to arrive, even though the find
command itself is quite fast.

It turns out that the slowdown occurs between receiving the `find` event
and actually triggering the search. The find controller has a hardcoded
delay of 250 milliseconds built in, which was introduced for viewer
performance many years ago because otherwise every keystroke would
trigger a search even though the user's query was not complete yet.

For the unit tests we don't need this delay because, contrary to the
viewer use case, we don't have to account for user interaction and
instead dispatch complete `find` events on the event bus ourselves.
However, since the unit tests were introduced well over a year after
the delay was introduced, due to an oversight it was never made
configurable so we could skip it for the unit tests.

This commit fixes the issue, which locally results in the runtime of
`npx gulp unittest --noChrome` dropping from 39.991 seconds before this
patch to 29.116 seconds afterwards, which is a 27% speedup.
2026-05-01 19:31:13 +02:00
Jonas Jenwald
091b172a22
Merge pull request #21209 from Snuffleupagus/version-6.0
Bump library version to `6.0`
2026-05-01 13:26:22 +02:00
Jonas Jenwald
2c445a2bc1 Bump library version to 6.0
See commit e6e06cf6b5307fe39e0de69c6c884f816b0cb21b
2026-05-01 13:12:29 +02:00
Jonas Jenwald
8142937ac4
Merge pull request #20961 from calixteman/use_image_decoder_chrome
[api-minor] Use the ImageDecoder by default on Chrome
2026-05-01 13:09:43 +02:00
Tim van der Meij
e6e06cf6b5
Merge pull request #21152 from Snuffleupagus/update-supported
[api-major] Update the minimum supported browsers, and remove no longer needed polyfills
2026-05-01 12:07:45 +02:00
Tim van der Meij
330ab4d066
Merge pull request #21208 from mozilla/update-locales
l10n: Update locale files
2026-05-01 12:04:06 +02:00
github-actions[bot]
35429af43e l10n: Update locale files 2026-05-01 00:48:41 +00:00
Jonas Jenwald
270b68feb9 [api-major] Update the minimum supported browsers, and remove no longer needed polyfills
By removing support for older browsers it's possible to simplify both the code and the build-scripts, in addition to removing manually implemented polyfills.
Using the PDF.js library/viewer will now require native support for the following features:
 - The `AbortSignal.any()` static method, see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static#browser_compatibility
 - The `:dir()` CSS pseudo-class, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:dir#browser_compatibility
 - The `light-dark()` CSS function, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/light-dark#browser_compatibility
 - The CSS `&` nesting selector, see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Nesting_selector#browser_compatibility

This patch updates the minimum supported browsers as follows:
 - Google Chrome 125, which was released on 2024-05-15; see https://chromereleases.googleblog.com/2024/05/stable-channel-update-for-desktop_15.html
 - Safari 18, which was released on 2024-09-16; see https://developer.apple.com/documentation/safari-release-notes/safari-18-release-notes
   *Note:* This version is the first with experimental support for the `CanvasRenderingContext2D.filter` property, which is a long-standing missing feature in Safari, however it must be *manually enabled*; see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter#browser_compatibility

Note that nowadays we usually try, where feasible and possible, to support browsers that are about two years old. By limiting support to only "recent" browsers we reduce the risk of holding back improvements of the *built-in* Firefox PDF Viewer, and also (significantly) reduce the maintenance/support burden for the PDF.js contributors.

*Please note:* As always, the minimum supported browser version assumes that a `legacy`-build of the PDF.js library is being used; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2026-04-30 20:32:08 +02:00
calixteman
7ebf3a4d7c
Merge pull request #21196 from calixteman/bug2035530
Fix free highlight on pages without images (bug 2035530)
2026-04-30 19:34:02 +02:00
calixteman
4d91026178
Merge pull request #21207 from Snuffleupagus/unittest-11878-reduced
Use a reduced test-case for the "caches image resources at the document/page level as expected (issue 11878)" unit-test
2026-04-30 19:33:12 +02:00
Jonas Jenwald
3eef724d15 Use a reduced test-case for the "caches image resources at the document/page level as expected (issue 11878)" unit-test 2026-04-30 18:47:42 +02:00
Tim van der Meij
468d38e17c
Merge pull request #21206 from Snuffleupagus/unittest-11878-hash
Improve performance of the "caches image resources at the document/page level as expected (issue 11878)" unit-test
2026-04-30 16:19:59 +02:00
Jonas Jenwald
c5296986fa Improve performance of the "caches image resources at the document/page level as expected (issue 11878)" unit-test
Compare `Uint32Array`s of the image-data, since that's more efficient than comparing the `Uint8ClampedArray`s directly.
2026-04-30 16:09:56 +02:00
calixteman
1ebaa03b25
Merge pull request #21192 from calixteman/colored_logs
Add some colors in the logs in order to easily see failures and add a summary of the failures at the end
2026-04-30 14:50:20 +02:00
Tim van der Meij
87e5241ed3
Merge pull request #21203 from timvandermeij/unit-test-obsolete-pdfbug
Remove obsolete `pdfBug: true` flag in the image caching unit test
2026-04-30 14:28:39 +02:00
Tim van der Meij
55e0f7e97f
Remove obsolete pdfBug: true flag in the image caching unit test
In a previous commit the time-based checks, which were based on
statistics provided by the `pdfBug: true` flag, got replaced by
test-only property checks that don't use said statistics anymore.

Fixes b01eeaf8.
2026-04-30 14:07:39 +02:00
Calixte Denizet
46fd67a191
Add some colors in the logs in order to easily see failures and add a summary of the failures at the end 2026-04-30 14:00:54 +02:00
Tim van der Meij
8f170307ed
Merge pull request #21195 from timvandermeij/unit-test-optimizations
Optimize memory usage in the unit tests
2026-04-30 12:59:58 +02:00
Jonas Jenwald
adf07ea51c
Merge pull request #21200 from Snuffleupagus/Intersector-grid-push
Shorten how intersectors are added to the grid in the `Intersector` constructor
2026-04-30 12:56:38 +02:00
Tim van der Meij
232506f4e8
Optimize memory usage in the unit tests
This commit fixes a number of missing cleanup steps in the unit tests
that kept state alive for longer than necessary:

- the loading tasks were not all being destroyed;
- the find controllers were not being reset;
- the state set in `beforeAll`/`beforeEach` was not all being nulled in
  the correspoding `afterAll`/`afterEach` blocks.

Combined this resulted in a steady increase in memory usage of the test
process as the tests ran, climbing up to ~1.5 GB. After this patch the
memory usage remains stable at ~800 MB.
2026-04-30 12:35:59 +02:00