22255 Commits

Author SHA1 Message Date
Tim van der Meij
a96fb4dbb8
Merge pull request #21014 from calixteman/issue257
Fix radial gradient when the two circles have an intersection
2026-04-03 20:00:37 +02:00
Tim van der Meij
255c3e7c14
Merge pull request #21028 from Snuffleupagus/PDFDataRangeTransport-listener
[api-minor] Change `PDFDataRangeTransport` to use a single (internal)  listener
2026-04-03 19:53:39 +02:00
Tim van der Meij
bb1033053c
Merge pull request #21029 from Snuffleupagus/Object-hasOwn
Replace all `Object.prototype.hasOwnProperty` usage with `Object.hasOwn`
2026-04-03 19:51:09 +02:00
Jonas Jenwald
477f756a76
Merge pull request #21027 from Snuffleupagus/move-MathClamp
Move the `MathClamp` helper function to its own file
2026-04-03 19:08:12 +02:00
Tim van der Meij
38981ce638
Merge pull request #21034 from Snuffleupagus/collectAnnotationsByType-fixes
A couple of small `collectAnnotationsByType` improvements
2026-04-03 18:02:32 +02:00
Tim van der Meij
264c2bf6f9
Merge pull request #21031 from calixteman/fix_font_int16
Fix wrong values when sanitizing fonts
2026-04-03 17:58:31 +02:00
Tim van der Meij
cc5e30b99c
Merge pull request #21021 from Snuffleupagus/PDFThumbnailView-unconditional-OffscreenCanvas
Use `OffscreenCanvas` unconditionally in the `web/pdf_thumbnail_view.js` file
2026-04-03 17:57:04 +02:00
Jonas Jenwald
5b6640eab3 A couple of small collectAnnotationsByType improvements
- Use the same `PartialEvaluator` instance for all annotations on the page, to reduce unnecessary object creation.

 - Use `Object.hasOwn` to check if the annotations were already parsed, to avoid having to keep a separate boolean variable in-sync with the actual code.
2026-04-03 13:20:06 +02:00
calixteman
2414f54675
Merge pull request #21033 from mozilla/update-locales
l10n: Update locale files
2026-04-03 09:18:17 +02:00
github-actions[bot]
b1cedd9daa l10n: Update locale files 2026-04-03 00:34:35 +00:00
Calixte Denizet
535c8d13c2 Fix wrong values when sanitizing fonts
NPUSHW: push signed 16-bits integer: https://learn.microsoft.com/en-us/typography/opentype/spec/tt_instructions#push-n-words
indexToLocFormat: field in the 'head' table: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6head.html#:~:text=indexToLocFormat,-0
2026-04-02 18:13:17 +02:00
Jonas Jenwald
cbfe2abc53 Replace all Object.prototype.hasOwnProperty usage with Object.hasOwn
The newer `Object.hasOwn` method is intended as a replacement for `Object.prototype.hasOwnProperty`, since that one may be problematical; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn#problematic_cases_for_hasownproperty

To ensure that `Object.hasOwn` is used in the future, the ESLint "no-restricted-syntax" rule is extended to catch the old method.
2026-04-02 13:40:10 +02:00
Jonas Jenwald
f09b03c062 Enable the prefer-object-has-own ESLint rule
Please see https://eslint.org/docs/latest/rules/prefer-object-has-own
2026-04-02 13:24:31 +02:00
Jonas Jenwald
f3a2ca08d0 [api-minor] Change PDFDataRangeTransport to use a single (internal) listener
The `PDFDataTransportStream` constructor has always registered exactly one listener for each type of data that an `PDFDataRangeTransport` instance can receive.
Given that an end-user of the `PDFDataRangeTransport` class will supply data through its `onData...` methods, it's also somewhat difficult to understand why additional end-user registered listeners would be needed (since the data is already, by definition, available to the user).
Furthermore, since TypedArray data is being transferred nowadays it's not even clear that multiple listeners (of the same kind) would generally work.

All in all, let's simplify this old code a little bit by using *a single* (internal) listener in the `PDFDataRangeTransport` class.
2026-04-02 12:38:58 +02:00
Jonas Jenwald
68366e31e4 Move the MathClamp helper function to its own file
This allows using it in the `src/scripting_api/` folder, without increasing the size of the scripting-bundle by also importing a bunch of unused code.
2026-04-02 11:22:28 +02:00
Jonas Jenwald
1bd4c4fbde
Merge pull request #21026 from Snuffleupagus/more-MathClamp
Use the `MathClamp` helper function more
2026-04-02 11:21:46 +02:00
Jonas Jenwald
c012ff6e10 Use the MathClamp helper function more
The idea with this helper function is that once https://github.com/tc39/proposal-math-clamp/ becomes stable, all its call-sites should then be replaced by the native functionality.
2026-04-02 10:10:39 +02:00
calixteman
e37709ea76
Merge pull request #21022 from calixteman/bug2028369
Encrypt pdf data when merging the same pdf (bug 2028369)
2026-04-01 22:28:59 +02:00
Calixte Denizet
f373923170 Encrypt pdf data when merging the same pdf (bug 2028369) 2026-04-01 19:01:11 +02:00
Jonas Jenwald
579589a38a Use OffscreenCanvas unconditionally in the web/pdf_thumbnail_view.js file
Given that `OffscreenCanvas` is available in all supported browsers and that the code in the `web/` folder is only intended to run in browsers, the fallback should no longer be necessary.

Please note:
 - https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
 - https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas#browser_compatibility
2026-04-01 16:32:07 +02:00
Calixte Denizet
b42dd39aae
Fix radial gradient when the two circles have an intersection
Fix #257.
2026-04-01 09:43:08 +02:00
calixteman
399fce6471
Merge pull request #21010 from calixteman/ps_js
Add an interpreter for optimized ps code
2026-03-31 22:21:00 +02:00
calixteman
f33f816991
Merge pull request #21012 from calixteman/shading_function
Add support for function-based shadings (bug 1254066)
2026-03-31 22:08:17 +02:00
Calixte Denizet
9f3de1edf6
Add an interpreter for optimized ps code
It'll be used as a fallback when wasm is disabled.
And add in the debugger a view for the generated js code and one for the ps code.
2026-03-31 21:00:22 +02:00
Calixte Denizet
3727b7095a Add support for function-based shadings (bug 1254066)
It fixes #5046.
We just generate a mesh for the pattern rectangle where the color of each vertex is computed from the function.
Since the mesh is generated in the worker we don't really take into account the current transform when it's drawn.
That being said, there are maybe some possible improvements in using directly the gpu for the shading creation
which could then take into account the current transform, but it could only work with ps function we can convert
ino wgsl language and simple enough color spaces (gray and rgb).
2026-03-31 20:46:01 +02:00
Tim van der Meij
58b807d8e8
Merge pull request #21008 from calixteman/ast_cse
Avoid expressions duplication in the ps AST and use a local instead when compiling to WASM
2026-03-31 20:21:59 +02:00
Tim van der Meij
b0c0680bea
Merge pull request #18815 from calixteman/dont_always_use_pattern
Don't use an intermediate canvas when rendering a tiling pattern bigger than the rectangle to fill
2026-03-31 20:18:08 +02:00
Tim van der Meij
48228e2756
Merge pull request #21013 from calixteman/bug2026956
Add attachments when merging/reorganizing a pdf (bug 2026956)
2026-03-31 20:17:54 +02:00
Tim van der Meij
d1c3d3938e
Merge pull request #21007 from Snuffleupagus/Node-getReadableStream-simplify
[Node.js] Remove the `node-readable-to-web-readable-stream` polyfill
2026-03-31 20:03:40 +02:00
Calixte Denizet
5b8c04f383 Add attachments when merging/reorganizing a pdf (bug 2026956) 2026-03-31 14:48:06 +02:00
Calixte Denizet
4c019e7712
Don't use an intermediate canvas when rendering a tiling pattern bigger than the rectangle to fill 2026-03-30 18:38:56 +02:00
Calixte Denizet
63cf35b47f Avoid expressions duplication in the ps AST and use a local instead when compiling to WASM 2026-03-30 16:30:33 +02:00
Jonas Jenwald
bfffb6c0f0 Import fs/promises directly in a few spots in the unit-tests
Also, use the existing PDF.js helper function to fetch text-data when running the "bidi" tests in browsers.
2026-03-30 14:34:53 +02:00
Jonas Jenwald
90fe6c70ff [Node.js] Remove the node-readable-to-web-readable-stream polyfill
While `Readable.toWeb` wasn't marked as stable until more recently, the functionality itself has existed since Node.js version `17.0.0`; note https://nodejs.org/api/stream.html#streamreadabletowebstreamreadable-options

Hence the polyfill shouldn't actually be necessary, which is confirmed by the unit-tests passing in Node.js version `20` in GitHub Actions.
2026-03-30 13:45:13 +02:00
calixteman
a40b91f0bb
Merge pull request #21002 from calixteman/ps_eval
[api-minor] Rewrite the ps lexer & parser and add a small Wasm compiler
2026-03-30 09:23:13 +02:00
calixteman
952952c905
[api-minor] Rewrite the ps lexer & parser and add a small Wasm compiler
The main goal is to remove the eval-based interpreter.
In order to have some good performances, the new parser performs some optimizations
on the AST (similar to the ones in the previous implementation),
and the Wasm compiler generates code for the optimized AST.
For now, in case of errors or unsupported features, the Wasm compiler returns null
and the old interpreter is used as a fallback.
Few things are still missing:
 - a wasm-based interpreter using a stack (in case the ps code isn't stack-free);
 - a better js implementation in case of disabled wasm.

 but they will be added in follow-up patches.
2026-03-30 09:22:33 +02:00
Tim van der Meij
cb2640dc33
Merge pull request #21004 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2026-03-29 20:48:47 +02:00
Tim van der Meij
806d071ea8
Bump the stable version in pdfjs.config 2026-03-29 20:45:34 +02:00
Tim van der Meij
ada3438039
Merge pull request #21001 from Snuffleupagus/getDestFromStructElement-unit-test
Add a unit-test for the `Catalog.#getDestFromStructElement` method
v5.6.205
2026-03-29 16:08:21 +02:00
Tim van der Meij
9026329d3d
Merge pull request #21003 from Snuffleupagus/applyOpacity-map
Simplify the `applyOpacity` helper function
2026-03-29 16:06:28 +02:00
Tim van der Meij
80d0d7349c
Merge pull request #20997 from Snuffleupagus/StatTimer-Map
Re-factor the `StatTimer` class a little bit
2026-03-29 16:05:15 +02:00
Tim van der Meij
37f5902c3c
Merge pull request #20996 from Snuffleupagus/more-logical-assignment
Use more logical assignment in the code-base
2026-03-29 16:03:40 +02:00
Tim van der Meij
8941695fe8
Merge pull request #20998 from Snuffleupagus/statcmp-import
Use a standard import for the `ttest` package in `test/stats/statcmp.js`
2026-03-29 16:01:34 +02:00
Tim van der Meij
cdae7a9b36
Merge pull request #20993 from mozilla/update-locales
l10n: Update locale files
2026-03-29 15:59:53 +02:00
Jonas Jenwald
498daadf3c Simplify the applyOpacity helper function
This function only has a single call-site (if we ignore the unit-tests), where the colors are split into separate parameters.
Given that all the color components are modified in the exact same way, it seems easier (and shorter) to pass the colors as-is to `applyOpacity` and have it use `Array.prototype.map()` instead.
2026-03-29 14:52:06 +02:00
Jonas Jenwald
5d2c4ed211
Merge pull request #20999 from Snuffleupagus/getRGB-rgba-split-limit
Remove a tiny bit of unnecessary "rgba" parsing in the `getRGB` function
2026-03-29 14:04:52 +02:00
Jonas Jenwald
d1f15fe352 Add a unit-test for the Catalog.#getDestFromStructElement method
This code already has an integration-test, however also having a unit-test shouldn't hurt since those are often easier to run and debug (and it nicely complements the existing `outline` unit-tests).

The patch also makes the following smaller changes to the method itself:
 - Avoid creating and parsing an empty Array, when doing the `pageRef` search.
 - Use `XRef.prototype.fetch` directly, when walking the parent chain, since the check just above ensures that the value is a Reference.
 - Use the `lookupRect` helper when parsing the /BBox entry.
2026-03-29 14:01:43 +02:00
Jonas Jenwald
8121bc0dd2 Remove a tiny bit of unnecessary "rgba" parsing in the getRGB function
This obviously won't matter in practice, however it seems more "correct" to only extract the necessary number of color components rather than slicing off excess ones at the end.
2026-03-29 12:13:59 +02:00
Jonas Jenwald
545656007b Use a standard import for the ttest package in test/stats/statcmp.js
Since this code is quite old parts of it can also be simplified a little bit by using modern string methods, which removes the need for the `pad` helper function.
2026-03-29 11:53:44 +02:00
Jonas Jenwald
256be7f3a6 Remove manual loops in the StatTimer.prototype.toString method
We can use Array methods instead, which is a tiny bit shorter.
2026-03-27 15:35:25 +01:00