21673 Commits

Author SHA1 Message Date
Tim van der Meij
b8a091107d
Merge pull request #20655 from calixteman/pdfium_update
Update jbig2 decoder (pdfium@0455e822ded1a5537d826703988e986a33d2d4a1)
2026-02-13 19:50:35 +01:00
Tim van der Meij
3302b3d5b6
Merge pull request #20656 from Snuffleupagus/mv-stripPath
Move and re-use the `stripPath` helper function more
2026-02-13 19:49:57 +01:00
Jonas Jenwald
520928719c Move and re-use the stripPath helper function more
There's a couple of spots that essentially re-implement that function.
2026-02-13 17:38:21 +01:00
Calixte Denizet
5a146a8d2f
Update jbig2 decoder (pdfium@0455e822ded1a5537d826703988e986a33d2d4a1) 2026-02-13 14:40:32 +01:00
calixteman
fa28ca1468
Merge pull request #20651 from Snuffleupagus/Response-bytes
Start using `Response.prototype.bytes()` in the code-base
2026-02-13 10:31:54 +01:00
calixteman
ae9fc13d8f
Merge pull request #20649 from calixteman/bug2015385
Ends the current drawing session when closing the tab (bug 2015385)
2026-02-13 08:27:16 +01:00
calixteman
1b20ba5c3f
Ends the current drawing session when closing the tab (bug 2015385) 2026-02-12 22:21:55 +01:00
calixteman
f24768d7b4
Merge pull request #20648 from Snuffleupagus/api-async-getTextContent
Convert `PDFPageProxy.prototype.getTextContent` to an asynchronous method
2026-02-12 13:47:04 +01:00
Jonas Jenwald
722f1ffbc6 Remove type === "arraybuffer" support from the fetchData helper function
After the previous patch there's no longer any call-site using that type.
2026-02-12 11:23:28 +01:00
Jonas Jenwald
8ba83e73fa Start using Response.prototype.bytes() in the code-base
In all cases where we currently use `Response.prototype.arrayBuffer()` the result is immediately wrapped in a `Uint8Array`, which can be avoided by instead using the newer `Response.prototype.bytes()` method; see https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes
2026-02-12 11:20:05 +01:00
Jonas Jenwald
c1b824f2e5 Convert PDFPageProxy.prototype.getTextContent to an asynchronous method
This is a tiny bit shorter, which cannot hurt.
2026-02-11 19:14:10 +01:00
calixteman
7077b2a998
Merge pull request #20644 from marco-c/mcp
Add firefox-devtools-mcp to let AI agents test and debug in Firefox
2026-02-10 09:58:05 +01:00
Tim van der Meij
96dbe92b53
Merge pull request #20643 from calixteman/fix_integration_test2
Fix a 'FreeText accessibility' integration test
2026-02-09 20:46:05 +01:00
calixteman
0b5f402158
Merge pull request #20639 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2026-02-09 17:48:10 +01:00
Jonas Jenwald
4f40a5427c
Merge pull request #20645 from Snuffleupagus/Chrome-118
[api-minor] Update the minimum supported Google Chrome version to 118
2026-02-09 13:59:51 +01:00
Jonas Jenwald
385c936318 [api-minor] Update the minimum supported Google Chrome version to 118
This patch updates the minimum supported browsers as follows:
 - Google Chrome 118, which was released on 2023-10-10; see https://chromereleases.googleblog.com/2023/10/stable-channel-update-for-desktop_10.html

We haven't made any changes to the supported Google Chrome version for a year, and this change allows us to remove "hacks" needed to support `float: inline-start/inline-end` in old browsers; see https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/float#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-02-09 12:16:46 +01:00
Marco Castelluccio
c0c0dfb2fa
Add firefox-devtools-mcp to let AI agents test and debug in Firefox 2026-02-09 11:00:02 +01:00
calixteman
d0a6531939
Merge pull request #20642 from Snuffleupagus/version-5.5
Bump library version to `5.5`
2026-02-09 10:32:03 +01:00
calixteman
9870d898b4
Merge pull request #20640 from calixteman/issue20629
Set a pages mapper per loaded document
2026-02-09 10:27:33 +01:00
Calixte Denizet
0f9d20fa32
Fix a 'FreeText accessibility' integration test
It's a regression from #20624.
2026-02-09 10:14:43 +01:00
Jonas Jenwald
f0e8807f04 Bump library version to 5.5 2026-02-08 23:31:21 +01:00
calixteman
babd030a77
Merge pull request #20638 from calixteman/avoid_branching
Avoid branching in convertBlackAndWhiteToRGBA
2026-02-08 21:16:29 +01:00
calixteman
4b4ab10c54
Set a pages mapper per loaded document
It fixes #20629.
2026-02-08 21:09:27 +01:00
Tim van der Meij
2a2806dc07
Merge pull request #20637 from Snuffleupagus/issue-20246
Normalize the font name in `getBaseFontMetrics` (issue 20246)
2026-02-08 19:48:16 +01:00
Tim van der Meij
47d51feb22
Update translations to the most recent versions 2026-02-08 18:57:35 +01:00
Tim van der Meij
08b6fef5fa
Fix vulnerabilities in dependency versions
This patch is generated automatically using `npm audit fix`.
2026-02-08 18:56:55 +01:00
Tim van der Meij
0c5a590bbd
Update dependencies to the most recent versions 2026-02-08 18:55:55 +01:00
calixteman
a9870adfa3
Avoid branching in convertBlackAndWhiteToRGBA
The function is now almost 8x faster than before.
And make the code in the file slightly more readable.
2026-02-08 18:36:40 +01:00
Jonas Jenwald
6a3d5fea6c Replace a few cases of "manual" font name normalization with the normalizeFontName helper function 2026-02-08 16:56:50 +01:00
Jonas Jenwald
e9c509aca9 Normalize the font name in getBaseFontMetrics (issue 20246)
We tried to lookup the font metrics using the font name as-is, which didn't work since the PDF file in question has non-embedded fonts with names that include commas.
Hence the font names need to be normalized here as well, similar to elsewhere in the font code.
2026-02-08 16:56:15 +01:00
Tim van der Meij
2b95a8eb38
Merge pull request #20634 from Snuffleupagus/progressiveDone-resolve-requests
Ensure that pending requests are resolved when calling `PDFDataTransportStreamReader.prototype.progressiveDone`
2026-02-08 14:56:41 +01:00
Tim van der Meij
025d658a9c
Merge pull request #20635 from Snuffleupagus/Node-update-support
[api-minor] Update the supported Node.js "patch" versions
2026-02-08 14:47:01 +01:00
Jonas Jenwald
0306e6c7ed Re-use the getArrayBuffer helper from src/display/fetch_stream.js with PDFNodeStreamReader and PDFNodeStreamRangeReader
Given that the Node.js code uses standard `ReadableStream`s now, see PR 20594, it can use the same `getArrayBuffer` as the Fetch API implementation.

Also, change the `getArrayBuffer` fallback case to an Error (rather than a warning) since that should never actually happen.
2026-02-08 13:20:55 +01:00
Jonas Jenwald
916b58a027 Add a helper function to resolve pending requests in src/display/transport_stream.js and src/display/network.js
Currently the same identical code is duplicated four times per file, which seems completely unnecessary.
Note that the function isn't placed in `src/display/network_utils.js`, since that file isn't included in MOZCENTRAL builds.
2026-02-08 13:20:50 +01:00
Jonas Jenwald
a80f8ff014 [api-minor] Update the supported Node.js "patch" versions
We haven't made any changes to the supported Node.js versions for close to a year, however now seems like a good time to do so in order to unblock future (major version) package upgrades.

 - Babel version `8` is now close to release, since https://github.com/babel/babel/releases contain an 8-RC version and according to [this article](https://babel.dev/blog/2026/01/31/7.29.0) no new `7` releases are planned.
   See also https://babel.dev/blog/2025/05/30/babel-8-beta and note the supported Node.js versions in https://next.babeljs.io/docs/v8-migration/#nodejs-support

 - ESLint version `10` was just released, see https://eslint.org/blog/2026/02/eslint-v10.0.0-released/ and note the supported Node.js versions in https://eslint.org/docs/latest/use/migrate-to-10.0.0#-nodejs--v2019-v21-v23-are-no-longer-supported
2026-02-08 12:32:09 +01:00
Jonas Jenwald
2d643efce5 Ensure that pending requests are resolved when calling PDFDataTransportStreamReader.prototype.progressiveDone
Doing skip-cache reloading of https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#disableRange=true in the latest Firefox Nightly version I noticed an *intermittent* bug, where the loadingBar would fill up but without the PDF ever rendering.
Initially I was quite worried that the changes in PR 20602 had somehow caused this, however after a bunch of testing in a slightly older Nightly I was able to reproduce the problem there as well.[1]

Instead I believe that this problem goes all the back to PR 10675, so still my fault, since the `progressiveDone` handling there was incomplete.
Note how we only set the `this._done` property, but don't actually resolve any still pending requests. For reference, compare with the handling in the `PDFDataTransportStreamRangeReader.prototype._enqueue` method.
Depending on the exact order in which the `PDFDataTransportStreamReader.prototype.{_enqueue, read, progressiveDone}` methods are invoked, which depends on how/when the PDF data arrives, the bug might occur.

The reason that this bug hasn't been caught before now is likely that `disableRange=true` isn't used by default and Firefox users are unlikely to manually set that in e.g. `about:config`.

---
[1] Possibly some timings changed to make it slightly more common, but given the intermittent nature of this it's difficult to tell.
2026-02-07 22:24:20 +01:00
calixteman
c00591c1b6
Merge pull request #20623 from calixteman/bug2014080
In tagged pdfs, TH can be either a column header or a row header (bug 2014080)
2026-02-06 16:42:22 +01:00
Calixte Denizet
280a02150e
In tagged pdfs, TH can be either a column header or a row header (bug 2014080) 2026-02-06 10:04:13 +01:00
calixteman
58ac273f1f
Merge pull request #20503 from andriivitiv/Fix-Worker-was-terminated-error
Fix `Worker was terminated` error when loading is cancelled
2026-02-06 09:59:05 +01:00
calixteman
b92bdf80a2
Merge pull request #20628 from calixteman/bug2014399
Cap the max canvas dimensions in order to avoid to downscale large images in the worker (bug 2014399)
2026-02-06 09:42:04 +01:00
Tim van der Meij
f302323c7e
Merge pull request #20627 from Snuffleupagus/ChunkedStream-onReceiveData-rm-copy
Improve progress reporting in `ChunkedStreamManager`, and prevent unnecessary data copy in `ChunkedStream.prototype.onReceiveData`
2026-02-05 21:27:42 +01:00
Tim van der Meij
a0f3528053
Merge pull request #20624 from calixteman/bug2013793
Flush the text content chunk only on real font changes (bug 2013793)
2026-02-05 21:14:49 +01:00
Calixte Denizet
ff42c0bd50
Cap the max canvas dimensions in order to avoid to downscale large images in the worker (bug 2014399) 2026-02-05 20:25:36 +01:00
Jonas Jenwald
b3cd042ded Prevent unnecessary data copy in ChunkedStream.prototype.onReceiveData
This method is only invoked via `ChunkedStreamManager.prototype.sendRequest`, which currently returns data in `Uint8Array` format (since it potentially combines multiple `ArrayBuffer`s).
Hence we end up doing a short-lived, but still completely unnecessary, data copy[1] in `ChunkedStream.prototype.onReceiveData` when handling range requests. In practice this is unlikely to be a big problem by default, given that streaming is used and the (low) value of the `rangeChunkSize` API-option. (However, in custom PDF.js deployments it might affect things more.)

Given that no data copy is better than a short lived one, let's fix this small oversight and add non-production `assert`s to keep it working as intended.
This way we also improve consistency, since all other streaming and range request methods (see e.g. `BasePDFStream` and related code) only return `ArrayBuffer` data.

---
[1] Remember that `new Uint8Array(arrayBuffer)` only creates a view of the underlying `arrayBuffer`, whereas `new Uint8Array(typedArray)` actually creates a copy of the `typedArray`.
2026-02-05 16:16:36 +01:00
Jonas Jenwald
01deb085f8 Improve progress reporting in the ChunkedStreamManager
Currently there's two small bugs, which have existed around a decade, in the `loaded` property that's sent via the "DocProgress" message from the `ChunkedStreamManager.prototype.onReceiveData` method.

 - When the entire PDF has loaded the `loaded` property can become larger than the `total` property, which obviously doesn't make sense.
   This happens whenever the size of the PDF is *not* a multiple of the `rangeChunkSize` API-option, which is a very common situation.

 - When streaming is being used, the `loaded` property can become smaller than the actually loaded amount of data.
   This happens whenever the size of a streamed chunk is *not* a multiple of the `rangeChunkSize` API-option, which is a common situation.
2026-02-05 16:04:45 +01:00
calixteman
222a24c623
Merge pull request #20622 from calixteman/bug2014167
Let the toggle button in the alt-text dialog downloading (resp. delete) the model and enabling (resp. disabling) alt-text guessing (bug 2014167)
2026-02-04 14:13:05 +01:00
calixteman
1e0ba4dfec
Merge pull request #20621 from calixteman/bug2013899
Avoid to have to download the model when toggling the button in the alt-text image settings dialog (bug 2013899)
2026-02-04 14:12:27 +01:00
calixteman
22b97d1741
Flush the text content chunk only on real font changes (bug 2013793) 2026-02-03 23:11:31 +01:00
Calixte Denizet
ea993bfc1b
Let the toggle button in the alt-text dialog downloading (resp. delete) the model and enabling (resp. disabling) alt-text guessing (bug 2014167) 2026-02-03 20:27:06 +01:00
Calixte Denizet
c7bea3b342
Avoid to have to download the model when toggling the button in the alt-text image settings dialog (bug 2013899) 2026-02-03 19:26:33 +01:00