22675 Commits

Author SHA1 Message Date
Tim van der Meij
600a4bb1ee
Fix missing page closing for two viewer integration tests
This caused the tab to remain open after the tests ran, which meant
that a total of ~120 MB of memory was not being freed.
2026-05-16 19:30:42 +02:00
Tim van der Meij
c66f9f2497
Reduce the protocol delay for Chrome in the integration tests
Originally we introduced a small delay for Puppeteer operations in
Chrome to avoid intermittent failures where protocol calls were
happening too quickly in succession. However, since then a number of
improvements were made, both locally and upstream, that reduce the need
for this delay:

- the integration tests have been hardened to remove (potential) sources
  of intermittent failures in many places;
- the browsers and Puppeteer have been updated to improve performance
  and support for testing infrastructure;
- the conversion to WebDriver BiDi has been completed, which replaced
  the Chrome-specific CDP protocol with a formalized protocol that could
  provide more safety guarantees.

This commit therefore reduces the Chrome-specific delay from 5 to 3
milliseconds, which should nowadays be a better value to speed up the
Chrome tests and bring them closer to Firefox in terms of runtime.
2026-05-16 19:30:42 +02:00
Tim van der Meij
62b88aa56e
Use Puppeteer's ElementHandle.boundingBox() API in the integration tests
The custom solution for obtaining the bounding box of a given element
that we have now was necessary during the original introduction of the
integration tests because at the time the `ElementHandle.boundingBox()`
API in Puppeteer didn't work correctly in Chrome.

However, `getRect`, where this is used, is a hot utility function
because most tests call it multiple times, either directly or indirectly
via other utility functions, and it turns out that the approach we use
is slower than the native `ElementHandle.boundingBox()` API.

Fortunately, most likely after a combination of Chrome/Puppeteer updates
and the conversion to the formalized WebDriver BiDi protocol the custom
solution is no longer necessary because all tests pass without it too,
so this commit converts `getRect` to use `ElementHandle.boundingBox()`
instead to speed up the tests.
2026-05-16 19:30:34 +02:00
Tim van der Meij
65b8aec420
Merge pull request #21286 from Snuffleupagus/ColorConverters-tests
Add a couple of very basic `ColorConverters` unit-tests
2026-05-16 18:11:16 +02:00
Jonas Jenwald
7f2bb0e991 Add a couple of very basic ColorConverters unit-tests
These tests could obviously be improved/extended, but it's at least a start to ensure that `ColorConverters` is tested since it's used in both the annotation-layer and the scripting-implementation.
2026-05-16 17:17:41 +02:00
Tim van der Meij
3450e95179
Merge pull request #21284 from Snuffleupagus/mv-SVG_NS
Move the `SVG_NS` definition into `src/shared/util.js`
2026-05-16 16:03:10 +02:00
Jonas Jenwald
7c5087cc16 Move the SVG_NS definition into src/shared/util.js
This constant is already defined in both the `src/core/` and `src/display/` folders, and in a few spots the same string was also inlined.
2026-05-16 15:17:04 +02:00
Jonas Jenwald
d27b9ab5fa
Merge pull request #21283 from Snuffleupagus/mv-getXfaPageViewport
[api-minor] Move the `getXfaPageViewport` helper into the `XfaLayer` class
2026-05-16 14:18:22 +02:00
Jonas Jenwald
e8f07d7ca3 [api-minor] Move the getXfaPageViewport helper into the XfaLayer class
This small helper function only exists to support printing of XFA documents, in the viewer, hence it seems like a good idea to (ever so slightly) reduce the official API surface a little bit.
2026-05-16 12:31:53 +02:00
Jonas Jenwald
eda97fe8fc Move the PageViewport class into its own file
This is necessary to prevent import cycles with the next patch.

It also shouldn't hurt to reduce the size of `src/display/display_utils.js` a little bit, since utility-files have a tendency to increase in size over time.
2026-05-16 12:31:40 +02:00
Tim van der Meij
26474b09cb
Merge pull request #21277 from calixteman/issue21276
Clear the full SMask scratch canvas in compose()
2026-05-15 20:04:11 +02:00
Tim van der Meij
77a2dc8532
Merge pull request #21281 from Snuffleupagus/rm-domMatrixToTransform
Remove the `Util.domMatrixToTransform` method
2026-05-15 20:03:19 +02:00
Jonas Jenwald
367f994d94 Remove the Util.domMatrixToTransform method
This method is unused in the worker-thread and has only *a single* call-site in the main-thread, which can be trivially replaced with the `getCurrentTransform` helper function.
2026-05-15 15:07:44 +02:00
Jonas Jenwald
69efba1ca2
Merge pull request #21279 from Snuffleupagus/mv-stringToPDFString
Move the `stringToPDFString` helper function to the worker-thread
2026-05-15 15:01:15 +02:00
Jonas Jenwald
e5330f06fa Move the stringToPDFString helper function into the src/core/string_utils.js file
Given that this function is only ever used during *parsing* of the PDF document, which happens in the worker-thread, this has always added (a little bit of) dead code in the built `pdf.mjs` file.
2026-05-15 12:10:30 +02:00
Jonas Jenwald
7a7e7049c1 Shorten the isAscii helper function a tiny bit 2026-05-15 11:56:33 +02:00
Jonas Jenwald
153cef615e Move a couple of src/core/ string helper functions into their own file
Given that the various utility-files naturally increase in size over time, it shouldn't hurt to shorten `src/core/core_utils.js` a little bit by moving a few of its string helper functions to their own file.
2026-05-15 11:49:54 +02:00
calixteman
d9491ffce3
Merge pull request #21278 from mozilla/update-locales
l10n: Update locale files
2026-05-15 09:34:50 +02:00
github-actions[bot]
0fab33c2e6 l10n: Update locale files 2026-05-15 00:47:51 +00:00
calixteman
5e18cfd8f0
Clear the full SMask scratch canvas in compose()
PR #21101 narrowed `compose()`'s `clearRect` from full canvas to the
caller-supplied dirty box. That leaves pixels outside the current
dirty box on the SMask scratch canvas between `compose()` calls;
subsequent draws into scratch are then source-over-blended on top of
those leftovers, so the output depends on the cumulative draw history
rather than just the current draw.
2026-05-14 23:02:14 +02:00
calixteman
cd4fd7563c
Merge pull request #21218 from RolandWArnold/fix/text-layer-hidden-canvas-layout-neutral
Ensure TextLayer hiddenCanvasElement is layout-neutral by default
2026-05-14 22:11:06 +02:00
Tim van der Meij
d9665c4e0f
Merge pull request #21274 from calixteman/issue21273
Enable Codecov flag carryforward for accurate coverage badge
2026-05-14 18:26:11 +02:00
calixteman
195bfdcfbd
Enable Codecov flag carryforward for accurate coverage badge
It fixes #21273.
2026-05-14 18:13:11 +02:00
Tim van der Meij
b708f59d04
Merge pull request #21271 from Snuffleupagus/unittest-BrotliDecode
Add a simple API unit-test for /BrotliDecode
2026-05-14 16:05:34 +02:00
Jonas Jenwald
949497a3c4 Add a simple API unit-test for /BrotliDecode
This is a new feature in PDF documents, hence it shouldn't hurt to complement the existing ref-test with a simple unit-test as well.
This should also improve test coverage for the `external/` folder, which can't hurt since the other external decoders are already fairly well covered.
2026-05-14 15:44:42 +02:00
Roland Arnold
16d82e094f fix: inline styles for hidden helper elements
Set layout-neutral styles at the creation sites for the hidden TextLayer
canvas and PDFViewer copy element rather than relying on the shared
web/pdf_viewer.css rule.

This keeps the helper elements invisible and out of layout when viewer CSS
selectors are scoped or omitted, and removes the obsolete hiddenCanvasElement
class and shared CSS rule.
2026-05-14 14:28:41 +01:00
Tim van der Meij
7ade637449
Merge pull request #21268 from calixteman/lint_chmod
Add a lint-chmod task to catch stray executable bits
2026-05-14 15:16:08 +02:00
Calixte Denizet
f8f497a03a
Add a lint-chmod task to catch stray executable bits 2026-05-14 13:55:14 +02:00
Tim van der Meij
056837dace
Merge pull request #21173 from timvandermeij/github-actions-integration-tests-coverage
Collect coverage information for the integration tests
2026-05-14 13:40:05 +02:00
Tim van der Meij
71e9eb25f6
Merge pull request #21269 from Snuffleupagus/WORKER_THREAD-define
Avoid bundling DOM-related code in the built `pdf.worker.mjs` file
2026-05-14 13:02:08 +02:00
Tim van der Meij
26dc195a65
Collect coverage information for the integration tests
Note that for the integration tests the coverage information ends up
being processed in the Node.js context where `window` is not available,
so we use `globalThis` instead for the function that merges individual
test's coverage information into the global object because that is
available in all contexts we support. For clarity we also rename said
function since we're not exclusively dealing with `window` nor worker
data anymore.
2026-05-14 12:34:12 +02:00
Jonas Jenwald
204f9203bd Avoid bundling DOM-related code in the built pdf.worker.mjs file
Currently the `isCanvasFilterSupported`/`isAlphaColorInputSupported` getters, on the `FeatureTest` class, contains code that cannot run in the worker-thread since it relies on the DOM being available.
To avoid that a new DEFINE is added, in `gulpfile.mjs`, to allow skipping this sort of dead code in the built `pdf.worker.mjs` file.
2026-05-14 12:21:36 +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