7762 Commits

Author SHA1 Message Date
calixteman
30ea3216c9
Merge pull request #21175 from calixteman/bug1942304
Send 'Terminate' to the worker when destroy races the load-time handshake (bug 1942304)
2026-04-28 15:22:20 +02:00
Jonas Jenwald
3475806311 Convert Catalog.prototype.getPageIndex to an asynchronous method
This simplifies/shortens a piece of old code, which shouldn't hurt.
2026-04-28 11:34:41 +02:00
Jonas Jenwald
339f755a52 Add more validation in the Catalog.prototype.getPageIndex method
- Ensure that the /Kids-entries are Arrays, before trying to iterate through them.
 - Ensure that the /Count-entries are (positive) integers.
2026-04-28 11:33:50 +02:00
Calixte Denizet
dc3c07b3e3 Allow free-highlighting on top of image placeholders (bug 2034980)
The `textLayerImagePlaceholder` canvas added in #20626 covers scanned
pages and was not recognized as a valid pointerdown target by
`#textLayerPointerDown`, so free highlights couldn't start.
2026-04-27 20:13:39 +02:00
calixteman
01b315a8f3
Merge pull request #21176 from calixteman/bug2035197
Fix merging PDFs with conflicting AcroForm /DR (bug 2035197)
2026-04-27 20:04:43 +02:00
Calixte Denizet
c9a7ff0506 Fix merging PDFs with conflicting AcroForm /DR (bug 2035197) 2026-04-27 18:54:52 +02:00
Calixte Denizet
cffb19e266 Send 'Terminate' to the worker when destroy races the load-time handshake (bug 1942304)
If `PDFDocumentLoadingTask.destroy` ran while `workerIdPromise` was
pending, the inner `.then` in `getDocument` threw "Loading aborted"
before `WorkerTransport` was constructed, so `_transport` was never set
and the "Terminate" message was never posted.
2026-04-27 17:14:45 +02:00
Nicolò Ribaudo
81678f20ca
Fix array type in CanvasBBoxTracker comment
Remove the "Float32Array" mention in the comment, given that the
implementation usesa  Float64Array.

Actually using a Float32Array passes all the tests we currently have and
reduces memory usage (by 16 bytes per op), however to be sure that it
does not introduce rounding bugs we'd need to `Math.fround` all
operations we do on the clipBox and pendingBBox. It reduces the
readibilty of the code, but we can revisit if this memory usage becomes
a problem.
2026-04-27 15:52:12 +02:00
Calixte Denizet
64b25a8f47
Fix merging a PDF after a page deletion (bug 2034804)
When pages carry explicit pageIndices (e.g. after a delete),
resolve insertAfter against that layout instead of the empty
base sequence. Also reject partial pageIndices combined with
insertAfter, which would race against the extraction's auto-fill.
2026-04-26 22:37:22 +02:00
Jonas Jenwald
72011c5088 Get the zIndex correctly in PopupElement.prototype.renderCommentButton
In practice this probably hasn't caused any bugs, however given that `DOMElement.style.zIndex` returns a string the existing code is subtly wrong.
This is also consistent with pre-existing `zIndex` code in the `PopupElement` class, see the `#show` and `#hide` methods.
2026-04-26 14:46:39 +02:00
Jonas Jenwald
5c11bf15b0
Merge pull request #21160 from Snuffleupagus/more-hexNumbers
Move the `hexNumbers` Array into `Util`, to enable using it in the viewer
2026-04-26 13:08:42 +02:00
Tim van der Meij
0d7439e856
Merge pull request #21158 from Snuffleupagus/modifiedIds-proper-hash
Compute a "proper" hash in the `AnnotationStorage.prototype.modifiedIds` getter
2026-04-26 12:10:24 +02:00
Jonas Jenwald
9b238b9719 Move the hexNumbers Array into Util, to enable using it in the viewer
This reduces some code duplication, and the new `Util.hexNums` property is now computed lazily.
2026-04-26 12:05:12 +02:00
Tim van der Meij
2674a9f3e4
Merge pull request #21137 from calixteman/bug2022700
Don't decode name of the checkboxes exported values (bug 2022700)
2026-04-26 12:00:58 +02:00
Jonas Jenwald
b72a229ee8 Compute a "proper" hash in the AnnotationStorage.prototype.modifiedIds getter
Currently the hash-property is just a stringified Array, which means that the hash-property can become arbitrarily long. That's not a good idea since it's used to compute a cache-key, in the API, which is then sent to the worker-thread. Hence the hash-property should be reasonably short, and its length should *not* depend on the number of modified editors, which can be achieved by using `MurmurHash3_64` here as well.
2026-04-25 12:52:29 +02:00
Jonas Jenwald
e6dba6ee34 Enable the radix ESLint rule
Many `parseInt` call-sites already provide the `radix` argument, and this rule helps improve consistency in the code-base; see https://eslint.org/docs/latest/rules/radix

*Please note:* The rule is disabled in `src/scripting_api/util.js` for now, since it's not obvious at a glance (at least to me) what the correct `radix` argument should be there.
2026-04-25 12:13:12 +02:00
calixteman
2d896faa1e
Merge pull request #21142 from calixteman/input_color_alpha
[Ink] Replace the opacity slider with an alpha-enabled color input
2026-04-24 15:46:46 +02:00
Jonas Jenwald
476626eb49
Merge pull request #21153 from Snuffleupagus/rm-MIN_INT_32
Remove the unused `MIN_INT_32` constant (PR 21139 follow-up)
2026-04-24 15:01:16 +02:00
calixteman
c05d87a63f
Merge pull request #21149 from calixteman/switch_quickjs_wasm
Switch to a wasm file for the quickjs sandbox
2026-04-24 14:10:47 +02:00
Jonas Jenwald
aa7289d28b Remove the unused MIN_INT_32 constant (PR 21139 follow-up) 2026-04-24 13:29:22 +02:00
Calixte Denizet
987edbb646
Switch to a wasm file for the quickjs sandbox 2026-04-23 22:34:48 +02:00
calixteman
25204d359a
Merge pull request #21136 from calixteman/bug2033908
Avoid to add outlines having a deleted page which leads to clone a useless page (bug 2033908)
2026-04-23 22:24:58 +02:00
Calixte Denizet
f266c4d8b8
[Ink] Replace the opacity slider with an alpha-enabled color input
The alpha feature is available in Firefox nightly (with the pref `dom.forms.html_color_picker.enabled` set to `true`).
It's available in Safari but not in Chrome.
2026-04-23 21:37:37 +02:00
Jonas Jenwald
a6988582d2 [api-minor] Replace the CCITT and JBig2 fallback decoders with a JS version of the PDFium decoder
*Note:* This is similar to PR 19525, which did the same thing for the OpenJPEG decoder.

The advantages of doing this are:
 - The same JBig2 decoder is used regardless of WASM being supported or not, which means consistent rendering.
 - The old `Jbig2Image` implementation has various bugs and missing features.
 - Less code that needs to be maintained in the PDF.js project, since both the CCITT and the JBig2 decoder is replaced.

The disadvantage of doing this is:
 - Slightly larger bundle size, however the effect is limited since a fair amount of PDF.js code can be removed. For the `gulp mozcentral` target the size increase is approximately 54 kilo-bytes (which is small compared to the 452 kilo-bytes for the JS version of the OpenJPEG decoder).
2026-04-22 23:24:26 +02:00
Calixte Denizet
42ccca7ee8
Don't decode name of the checkboxes exported values (bug 2022700) 2026-04-22 18:30:43 +02:00
Calixte Denizet
a52c8334f5 Avoid to add outlines having a deleted page which leads to clone a useless page (bug 2033908) 2026-04-21 22:23:28 +02:00
Tim van der Meij
e070944ff0
Merge pull request #21131 from Snuffleupagus/fix-CopyLocalImage-unittests
Improve the "CopyLocalImage" unit-tests
2026-04-21 20:18:40 +02:00
Jonas Jenwald
b01eeaf8e1 Improve the "CopyLocalImage" unit-tests
Rather than relying on the time it takes to parse/render the pages, which leads to intermittent failures, add a test-only property and use it to check if the "CopyLocalImage" code-path was exercised.
2026-04-21 11:43:08 +02:00
calixteman
3aab546524 Add code coverage support for browser/ref tests
Instrument JS files on-the-fly via babel-plugin-istanbul when --coverage
or --coverage-per-test is passed, producing an aggregate lcov/HTML report
at the end of the run. A persistent PDFWorker accumulates worker-thread
coverage alongside the main-thread coverage, collected via a new
GetWorkerCoverage message handler.

With --coverage-per-test, an inverted index
(build/coverage/per-test-index.json) is also built as tests run, mapping
each hit source line and function name to the numeric IDs of the tests
that exercised it, keeping the output compact. The new
`gulp test_search --code=file::line_or_function` tool queries the index,
and passing --code to browsertest pre-filters the test run to only those
tests.

Coverage output formats are selectable via --coverage-formats (default:
info; also accepts html, json, text, cobertura, clover).
2026-04-20 21:46:18 +02:00
Calixte Denizet
db89d3a0e6 Correctly compute the bbox when simplifying the path construction
It fixes #21126.
2026-04-20 18:42:09 +02:00
Jonas Jenwald
c155a86733 Store the Type1 program privateData in a Map, rather than an Object
This is nicer when checking if fields exist in `Type1Font.prototype.wrap`, and a couple of loops in that method are also "modernized" slightly.
2026-04-18 12:32:22 +02:00
Jonas Jenwald
92a0a91046 Pre-compute the length of more intermediate tables in createCmapTable (PR 21103 follow-up)
With the exception of `glyphsIds` the length of the other segments can be trivially determined upfront, which is obvious in hindsight. This way unnecessary allocations can be avoided when building the "cmap" table.
2026-04-16 11:46:59 +02:00
Jonas Jenwald
0a4e8d024d Use TypedArrays in the createNameTable function 2026-04-16 11:46:57 +02:00
Jonas Jenwald
445cb9abf9
Merge pull request #21103 from Snuffleupagus/TrueTypeTableBuilder-2
Use TypedArrays in the `createCmapTable` function
2026-04-16 11:44:14 +02:00
calixteman
9159afd633
Merge pull request #21107 from supermar1010/fix-savedocument-jsdoc
Fix saveDocument JSDoc return type
2026-04-15 22:14:39 +02:00
Jonas Jenwald
aced833344 Remove the basic Math.sumPrecise polyfill
This is already polyfilled properly via core-js in `legacy` builds, and the only reason that it wasn't already removed is that the tests (on the bots) use the "modern" builds and Chrome didn't support `Math.sumPrecise` until now; see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sumPrecise#browser_compatibility
2026-04-15 16:32:13 +02:00
Mario
9dd30474c2 Fix saveDocument JSDoc return type
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 14:51:39 +02:00
calixteman
59908ccad3
Merge pull request #21101 from calixteman/improve_smask
Improve SMask compositing by pre-baking backdrop and filter
2026-04-14 20:57:08 +02:00
Jonas Jenwald
b2cc9ae6d5 Move the string32 helper to the src/display/font_loader.js file
After the previous patches the `string32` helper function is now only used in the `FontLoader.prototype._prepareFontLoadEvent` method, which is stubbed out in the Firefox PDF Viewer, hence move it there instead to avoid bundling dead code.
2026-04-14 20:36:34 +02:00
Jonas Jenwald
cb935c35d3 Use TypedArrays in the createCmapTable function 2026-04-14 20:36:34 +02:00
Jonas Jenwald
f9ecebe63c Add a helper class for building TrueType font tables
This helps reduce the amount of boilerplate code needed in multiple spots throughout the font code, and more importantly it'll help when building TrueType tables whose final size is non-trivial to compute upfront.
2026-04-14 20:36:34 +02:00
Jonas Jenwald
7f7ac949ff
Merge pull request #21100 from Snuffleupagus/createTables-TypedArray
Use TypedArrays when building even more TrueType tables
2026-04-14 20:35:22 +02:00
Calixte Denizet
22a4bd79af
Improve SMask compositing by pre-baking backdrop and filter
remove as much as possible some intermediate canvases and avoid to use SVG filter
at each composition.
Rendering all the pages of issue17784.pdf takes 2x less time now.
2026-04-14 20:18:03 +02:00
Nicolò Ribaudo
2ad6b88850
Fix dependency tracking in pattern fill
1. Record `fill` dependencies even if we early return due to `isPatternFill``
2. Isolate the `drawPattern` inner `executeOperationList` in a
   `CanvasNestedDependencyTracker` so that it does not consume pending
   dependencies from the outer list.
2026-04-14 14:16:26 +01:00
Jonas Jenwald
634ce3c163 Convert the return value in createCmapTable and createNameTable to a TypedArray
Compared to the other TrueType table building functions, see previous patches, these ones are not trivial to convert to use TypedArrays properly.
However, in order to simplify the `OpenTypeFileBuilder` implementation a little bit we can at least have these functions return TypedArray data.
2026-04-14 12:28:45 +02:00
Jonas Jenwald
e8ed6c6e24 Use a TypedArray in the createOS2Table function 2026-04-14 10:43:42 +02:00
Jonas Jenwald
aa0bc24e95 Use a TypedArray in the createPostTable function 2026-04-14 10:43:42 +02:00
calixteman
419c2652c3
Merge pull request #21094 from calixteman/issue17784
Correctly sync the transform on the scratch canvas
2026-04-13 23:58:20 +02:00
calixteman
1025af059f
Merge pull request #21099 from calixteman/no_gpu
Use the gpu for drawing meshes only when it has more than 16 triangles (bug 2030745)
2026-04-13 23:55:52 +02:00
calixteman
865b48893a
Correctly sync the transform on the scratch canvas
It fixes #17784.
2026-04-13 23:54:53 +02:00