22644 Commits

Author SHA1 Message Date
Calixte Denizet
94de952b65
Add a Content-Security-Policy to pdf.js' viewer.html (bug 1960363) 2026-05-14 12:50:07 +02:00
calixteman
bf9ae7622f
Merge pull request #21267 from timvandermeij/test-pdf-executable-bit
Remove the executable bit from test PDF files
2026-05-13 09:29:02 +02:00
calixteman
7f151c777b
Merge pull request #21262 from calixteman/issue18032
Fix nested non-isolated groups in knockout rendering
2026-05-12 22:37:31 +02:00
calixteman
0e0f7b7696
Merge pull request #21263 from Snuffleupagus/editor-_l10nAlert
[Editor] Avoid "generating" the l10n-ids used for the `a11yAlert`
2026-05-12 22:07:54 +02:00
Calixte Denizet
0e335d53ee Fix nested non-isolated groups in knockout rendering
It fixes #18032.

Only use the special inner-backdrop compositing path for nested non-isolated groups that actually need isolation.
This preserves the parent/page backdrop for simple nested groups inside knockout groups, preventing later group
compositing from erasing existing backdrop content.
2026-05-12 22:00:44 +02:00
Tim van der Meij
41e47c8b6f
Remove the executable bit from test PDF files
Test PDF files should never be executable because we only read their
contents, so this commit makes sure that all test PDFs have the same
permissions, namely 0644 (read-only for all groups, and writable for the
owner), to limit their permissions for a least-privilege approach.
2026-05-12 20:59:07 +02:00
Tim van der Meij
10abe660e5
Merge pull request #21264 from calixteman/simplify_no_filter
Use FeatureTest.isCanvasFilterSupported in _bakeSMaskCanvas
2026-05-12 20:37:16 +02:00
Tim van der Meij
dc7b6c31ac
Merge pull request #21265 from mozilla/dependabot/github_actions/github/codeql-action-4.35.3
Bump github/codeql-action from 4.35.2 to 4.35.3
2026-05-12 20:28:33 +02:00
Tim van der Meij
a5027bf5e2
Merge pull request #21256 from timvandermeij/updates
Update dependencies to the most recent versions
2026-05-12 20:27:16 +02:00
dependabot[bot]
130aff4257
Bump github/codeql-action from 4.35.2 to 4.35.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.35.2 to 4.35.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](95e58e9a2c...e46ed2cbd0)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.35.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-12 18:17:58 +00:00
Calixte Denizet
1dac67ff54 Use FeatureTest.isCanvasFilterSupported in _bakeSMaskCanvas 2026-05-12 20:02:06 +02:00
Jonas Jenwald
4072d3f835 [Editor] Avoid "generating" the l10n-ids used for the a11yAlert
In the `DrawingEditor.prototype.#createDrawOutlines` method the l10n-id was being "generated", which is bad for maintainability since searching for l10n-id becomes more difficult and the `gulp check_l10n` script actually warns about this.

Hence, similar to e.g. the resizer localization, let's define the `a11yAlert` l10n-ids *once* and provide shorthands for accessing them.
2026-05-12 16:41:53 +02:00
calixteman
0c66063cd4
Merge pull request #21242 from calixteman/knockout
Render knockout transparency groups
2026-05-12 12:02:10 +02:00
Jonas Jenwald
5bc5791a86
Merge pull request #21257 from Snuffleupagus/deepCompare-Refs
Update the `deepCompare` helper function to handle `Ref`s and `Name`s correctly
2026-05-12 11:53:02 +02:00
calixteman
d1e9194e1f
Render knockout transparency groups
In a knockout (KO) group each painting operator ("element") composites against
the group's initial backdrop instead of accumulating onto prior elements
of the same group. The backend renders each element to a per-group pooled
temp canvas (keyed off `#groupStackMeta`), builds a binary alpha mask via
a new `feFuncA` filter (`addKnockoutFilter`), `destination-out`s the
group canvas through that mask, restores the initial backdrop into the
cleared footprint for non-isolated groups (cropped to the same mask so
sparse groups don't bleed the whole rectangle), and finally paints the
element on top with the parent's blend mode. Path / clip / transform ops
are mirrored back to the group canvas via `mirrorContextOperations` so
graphics state stays in sync between elements; only the raster pixels
land on the temp canvas.

The temp canvas is forced to source-over for the element raster (`multiply`
on a transparent backdrop would zero the color) and the original GCO is
restored before `copyCtxState` writes back, so the parent's blend mode
survives for the final composite.

Also handled:
  - Nested KO groups (the level is incremented for KO, reset to 0 for
    non-KO subgroups so an ancestor KO doesn't leak in).
  - Non-isolated non-KO subgroups inside a KO parent (`hasInnerBackdrop`
    path: blend the elements against the subgroup's running backdrop for
    color, mask with the elements-only canvas).
  - Soft masks installed inside a KO element (`applySMaskInPlace` in
    `compose`, which runs the SMask destination-in directly on the temp
    canvas; the existing blit-to-suspended step is gated by `if (!ctx)`).
  - Type-3 text, shading fills, image-mask groups, inline images and the
    solid-color mask path: each is wrapped in `#begin/#endKnockoutElement`.
  - `endDrawing` cleanup so cancelled rendering doesn't leak pooled
    canvases or stale knockout state.
2026-05-11 23:08:06 +02:00
Tim van der Meij
4da7a9aa29
Upgrade typescript to version 6.0.3
This is a major version bump containing two breaking changes for us:

- the `baseUrl` option is removed;
- the `moduleResolution` option doesn't support `node10` (or the `node`
  alias) anymore.

The migration guide at https://github.com/microsoft/TypeScript/issues/62508
indicates that we can remove `baseUrl` and change `moduleResolution` to
`bundler` (the latter is consistent with what other projects do that are
linked to the issue, and more details on that configuration option can
be found at https://www.typescriptlang.org/tsconfig/#moduleResolution).

Note that this is enough to get `npx gulp typestest` green and that is
all validation we can do on our side, so as usual if any follow-up fixes
for types are necessary we rely on the community to provide patches and
extend the types test where possible to improve validation.
2026-05-11 21:05:11 +02:00
Tim van der Meij
c67306b435
Upgrade postcss-discard-comments to version 8.0.0
This is a major version bump, but the changelog at
https://github.com/cssnano/cssnano/blob/master/packages/postcss-discard-comments/CHANGELOG.md
doesn't indicate any breaking changes that should impact us.
2026-05-11 21:05:11 +02:00
Tim van der Meij
dd05ebad71
Upgrade @napi-rs/canvas to version 1.0.0
This is a major version bump, but the changelog at
https://github.com/Brooooooklyn/canvas/releases/tag/v1.0.0
doesn't indicate any breaking changes that should impact us.
2026-05-11 21:05:11 +02:00
Tim van der Meij
25a9196d9c
Update dependencies to the most recent versions 2026-05-11 21:05:11 +02:00
Tim van der Meij
6bbcb46db8
Merge pull request #21258 from Snuffleupagus/mv-getModificationDate
Move the `getModificationDate` helper function into `src/core/core_utils.js`
2026-05-11 20:20:05 +02:00
Jonas Jenwald
aecb571ea6 Move the getModificationDate helper function into src/core/core_utils.js
Given that this function is only ever used in `src/core/` code, let's avoid a little bit of dead code in the *built* `pdf.mjs` file.

Also, place the `AnnotationPrefix` and `AnnotationEditorPrefix` constants together in `src/shared/util.js` since that should aid readability.
2026-05-11 14:13:23 +02:00
Jonas Jenwald
326df1f711 Update the deepCompare helper function to handle Refs and Names correctly
Note that `Ref`s and `Name`s are cached globally[1], since that helps reduce object creation (a lot) during parsing.
That cache will be cleared after a period of inactivity in the viewer[2], which is why those primitives cannot *safely* be compared with just `===`/`!==` and also (partially) why abstractions such as `RefSet`/`RefSetCache` are necessary.

Currently `deepCompare` doesn't handle `Ref`s and `Name`s correctly, which may lead to future *intermittent* bugs in any code using the `deepCompare` helper function.

---

[1] This applies to `Cmd` as well, however that doesn't matter in the context of this patch.

[2] Currently, and for more than a decade, set to 30 seconds.
2026-05-11 13:18:54 +02:00
Tim van der Meij
702d60aa18
Merge pull request #21230 from calixteman/avoid_cycles
Avoid cycles when getting operator list in patterns
2026-05-10 18:15:01 +02:00
Tim van der Meij
3b58a339c8
Merge pull request #21213 from saripovdenis/perf-name-tree-getall-queue-index
perf: Avoid multi-second getDestinations stalls for PDFs with many named destinations
2026-05-10 18:13:12 +02:00
Jonas Jenwald
1079535a1e
Merge pull request #21249 from Snuffleupagus/open-filename-unconditional
Support providing a `filename` unconditionally, when passing binary data to `PDFViewerApplication.open`
2026-05-10 15:48:43 +02:00
Tim van der Meij
02c9051b64
Merge pull request #21245 from Snuffleupagus/getDocument-only-DocumentInitParameters
[api-major] Remove support for calling `getDocument` without  a parameter object, and remove the `PDFDocumentProxy.prototype.destroy` method
2026-05-10 14:30:15 +02:00
Tim van der Meij
559e2f2006
Merge pull request #21236 from calixteman/pixel_fallback_smask
Fall back to pixel-buffer SMask filtering when ctx.filter is unavailable
2026-05-10 14:27:52 +02:00
Tim van der Meij
47e32709b3
Merge pull request #21246 from Snuffleupagus/crypto_spec-fromHex
Use `Uint8Array.fromHex` in `test/unit/crypto_spec.js`
2026-05-10 14:12:33 +02:00
Tim van der Meij
33a6f3e206
Merge pull request #21238 from Snuffleupagus/PDFDataRangeTransport-unittest-faster
Make the `PDFDataRangeTransport` streaming unit-tests faster
2026-05-10 14:11:09 +02:00
Tim van der Meij
e8a051cee5
Merge pull request #21248 from mozilla/dependabot/npm_and_yarn/babel/plugin-transform-modules-systemjs-7.29.4
Bump @babel/plugin-transform-modules-systemjs from 7.29.0 to 7.29.4
2026-05-10 14:07:18 +02:00
Tim van der Meij
e511c88f11
Merge pull request #21244 from mozilla/dependabot/npm_and_yarn/fast-uri-3.1.2
Bump fast-uri from 3.1.0 to 3.1.2
2026-05-10 14:06:27 +02:00
Tim van der Meij
58ee4cd18d
Merge pull request #21243 from mozilla/dependabot/npm_and_yarn/fast-xml-builder-1.2.0
Bump fast-xml-builder from 1.1.5 to 1.2.0
2026-05-10 14:06:00 +02:00
Jonas Jenwald
0763c69b6a Support providing a filename unconditionally, when passing binary data to PDFViewerApplication.open
Previously this was only supported in Firefox, however when merging PDFs the `PDFViewerApplication.onSaveAndLoad` method will provide a `filename` unconditionally.
2026-05-10 13:51:33 +02:00
dependabot[bot]
f6e69b8a20
Bump @babel/plugin-transform-modules-systemjs from 7.29.0 to 7.29.4
Bumps [@babel/plugin-transform-modules-systemjs](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-modules-systemjs) from 7.29.0 to 7.29.4.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.29.4/packages/babel-plugin-transform-modules-systemjs)

---
updated-dependencies:
- dependency-name: "@babel/plugin-transform-modules-systemjs"
  dependency-version: 7.29.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 17:40:37 +00:00
Jonas Jenwald
eb184851a8 Use Uint8Array.fromHex in test/unit/crypto_spec.js
This replaces the old `hex2binary` helper function with the native `Uint8Array.fromHex` method.
2026-05-09 17:17:50 +02:00
Jonas Jenwald
43ce1bb491 [api-major] Remove the PDFDocumentProxy.prototype.destroy method
This is a left-over from very old code, which pre-dates the introduction of the `PDFDocumentLoadingTask` and it's nothing more than an alias for its `destroy` method.
Given that `PDFDocumentProxy` already provides a way to access the underlying `PDFDocumentLoadingTask` instance, it shouldn't be necessary to have an alias for one of its methods.

*Please note:* For any existing code relying on the removed method, updating it should be as simple as replacing `pdfDocument.destroy()` with `pdfDocument.loadingTask.destroy()`.

---

[1] If the `PDFDocumentProxy` class was added today, there's no chance that it'd include a `destroy` method.
2026-05-09 13:20:39 +02:00
Jonas Jenwald
2e7a2215e3 [api-major] Remove support for calling getDocument without a parameter object
This is a left-over from very old code[1], before there were a lot of `getDocument` options and when most of the library configuration was done via the (since removed) `PDFJS` global.
Given all the functionality added through the years, which require configuration[2], in practice it's now unlikely that calling `getDocument` without additional options will work except for the most trivial PDFs.

---

[1] If the `getDocument` function was added today, there's no chance that it'd support anything other than a parameter object.

[2] Note things such as CMaps, standard fonts, wasm-based image decoders, and ICC-based colour spaces.
2026-05-09 13:00:27 +02:00
dependabot[bot]
b5af8151f6
Bump fast-uri from 3.1.0 to 3.1.2
Bumps [fast-uri](https://github.com/fastify/fast-uri) from 3.1.0 to 3.1.2.
- [Release notes](https://github.com/fastify/fast-uri/releases)
- [Commits](https://github.com/fastify/fast-uri/compare/v3.1.0...v3.1.2)

---
updated-dependencies:
- dependency-name: fast-uri
  dependency-version: 3.1.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-09 00:28:57 +00:00
dependabot[bot]
e94f9a9797
Bump fast-xml-builder from 1.1.5 to 1.2.0
Bumps [fast-xml-builder](https://github.com/NaturalIntelligence/fast-xml-builder) from 1.1.5 to 1.2.0.
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-builder/blob/main/CHANGELOG.md)
- [Commits](https://github.com/NaturalIntelligence/fast-xml-builder/compare/v1.1.5...v1.2.0)

---
updated-dependencies:
- dependency-name: fast-xml-builder
  dependency-version: 1.2.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-08 18:32:54 +00:00
Jonas Jenwald
15921243d4 Make the PDFDataRangeTransport streaming unit-tests faster
The delay between chunks when testing streaming is necessary to avoid the entire PDF document arriving all at once, since that would render those unit-tests somewhat pointless.
However, the delay is unnecessarily large which causes these unit-tests to be slower than necessary.

Also, update the range unit-tests to check the expected number of fetches *exactly* since those values are not supposed to vary.
2026-05-08 12:44:32 +02:00
calixteman
e86e9d9465
Merge pull request #21237 from mozilla/update-locales
l10n: Update locale files
2026-05-08 08:39:19 +02:00
github-actions[bot]
80dd1b3ecc l10n: Update locale files 2026-05-08 00:45:17 +00:00
Calixte Denizet
29fcf0aa76
Avoid cycles when getting operator list in patterns 2026-05-07 22:30:51 +02:00
calixteman
a5e9940d14
Merge pull request #21231 from calixteman/simplify_extract
Simplify '#getFilteredPageIndices' and '#resolveInsertAfterIndices'
2026-05-07 22:28:48 +02:00
calixteman
b8232710c8
Fall back to pixel-buffer SMask filtering when ctx.filter is unavailable
For now OffscreenCanvas in worker threads doesn't support ctx.filter,
so we need to fall back to a more expensive pixel-buffer SMask filtering in that case.
As a side effect, this also allows to support correctly smask in Safari.
2026-05-07 22:27:04 +02:00
Calixte Denizet
b39440b6e0
Simplify '#getFilteredPageIndices' and '#resolveInsertAfterIndices' 2026-05-07 21:41:37 +02:00
Tim van der Meij
a328294713
Merge pull request #21235 from calixteman/bug2033095
Improve soft mask composition performance (bug 2033095)
2026-05-07 21:35:09 +02:00
Tim van der Meij
e81507c167
Merge pull request #21228 from calixteman/bug2027682
Place new annotations on the correct page when extracting pages (bug 2027682)
2026-05-07 21:12:15 +02:00
Tim van der Meij
9953501a0d
Merge pull request #21223 from calixteman/bug2034827
Make sure the focus moves on the first page of the added pdf after a merge (bug 2034827)
2026-05-07 21:04:29 +02:00
Tim van der Meij
4b4666e302
Merge pull request #21232 from mozilla/dependabot/npm_and_yarn/ip-address-10.2.0
Bump ip-address from 10.1.0 to 10.2.0
2026-05-07 20:54:27 +02:00