21984 Commits

Author SHA1 Message Date
Jonas Jenwald
63b4874b39 Remove the enableHWA option from viewer components (PR 20016 follow-up)
In PR 20016 the actual uses of the `enableHWA` option was removed from the viewer, but for some reason it's still being provided when initializing `PDFViewer` and `PDFThumbnailViewer` despite the fact that it's now dead code.
2026-03-11 15:28:43 +01:00
Jonas Jenwald
79df166e06
Merge pull request #20846 from Snuffleupagus/internal-viewer-followup
A couple of small improvements of the new internal viewer
2026-03-11 12:01:11 +01:00
calixteman
9d093d9607
Merge pull request #20626 from nicolo-ribaudo/images-right-click
Add support for right-clicking on images (bug 1012805)
2026-03-11 11:45:51 +01:00
calixteman
98f7e859ac
Merge pull request #20837 from calixteman/bug2021934
Disable dragging a thumbnail when the user has to paste what they copied (bug 2021934)
2026-03-11 09:13:25 +01:00
Jonas Jenwald
60d6abdf4f A couple of small improvements of the new internal viewer
- Mention the internal viewer in the README, such that it's easier to find.

 - Implement a new `INTERNAL_VIEWER` define, such that it's easier to limit code to only the "internal-viewer" gulp target.

 - Only include the "GetRawData" message-handler when needed. Note that the `MessageHandler` [already throws](eb159abd6a/src/shared/message_handler.js (L121-L123)) for any missing handler.

 - Move the various new helper functions from `src/core/document.js` and into their own file. The reasons for doing this are:
    - That file is already quite large and complex as-is, and these helper functions are slightly orthogonal to its main functionality.
    - Babel isn't able to remove all of the new code, and by moving this into a separate file we can guarantee that no extra code ends up in e.g. Firefox.
2026-03-10 23:41:35 +01:00
Tim van der Meij
eb159abd6a
Merge pull request #20822 from mozilla/update-locales
l10n: Update locale files
2026-03-10 21:39:05 +01:00
Tim van der Meij
654190366f
Merge pull request #20828 from timvandermeij/refactor-reporter
Refactor the custom reporters for testing
2026-03-10 21:31:00 +01:00
Tim van der Meij
5fb9f12d3e
Ignore pending tests in the custom reporters
Similar to excluded tests pending tests should not count towards runs or
result in console logging because they are effectively not (fully) run.
This reduces visual noise and helps to get the tests running on GitHub
Actions where non-passed tests will count towards a non-zero exit code.
2026-03-10 20:51:08 +01:00
Tim van der Meij
8a5f6f5157
Use the status property of Jasmine's result object in the custom reporters
This improves readability of the code and makes it consistent with the
recently added check for excluded tests.
2026-03-10 20:51:08 +01:00
Tim van der Meij
9c21d7016b
Check for passed tests first in test/integration/jasmine-boot.js
This makes the order of checks consistent with the one in
`test/reporter.js` and improves safety because now any status other
than passed will be treated as a failure (also if Jasmine adds more
statuses later on).
2026-03-10 20:51:02 +01:00
Tim van der Meij
44a63549b0
Merge pull request #20831 from calixteman/internal_viewer
Add a new internal viewer to explore the structure of PDF files.
2026-03-10 20:48:40 +01:00
Tim van der Meij
15e58f3912
Merge pull request #20830 from Snuffleupagus/validateRangeRequestCapabilities-fix-tests
Improve the `validateRangeRequestCapabilities` unit-tests
2026-03-10 20:23:14 +01:00
Tim van der Meij
bf20d3c7e8
Merge pull request #20838 from calixteman/bug2021886
Avoid to have a thumbnail with two paste buttons (bug 2021886)
2026-03-10 20:21:34 +01:00
Tim van der Meij
99dcb88dac
Merge pull request #20834 from calixteman/update_context_menu
Update the context menu after copying thumbnails
2026-03-10 20:15:51 +01:00
Tim van der Meij
3f75c4e511
Merge pull request #20829 from Snuffleupagus/Blob-bytes
Start using `Blob.prototype.bytes()` in the code-base
2026-03-10 20:14:49 +01:00
Tim van der Meij
0dce6f40d2
Merge pull request #20839 from calixteman/bug2020698
Fix the border & background colors of the placeholder for a dragged thumbnail (bug 2020698)
2026-03-10 20:14:05 +01:00
Tim van der Meij
27db42d6bc
Merge pull request #20841 from Snuffleupagus/misc-improvements
A couple of small improvements
2026-03-10 20:06:35 +01:00
Jonas Jenwald
51cde824ec
Merge pull request #20844 from nicolo-ribaudo/fix-lint-licenses-windows
Fix `lint-licenses` task on windows
2026-03-10 18:05:58 +01:00
Nicolò Ribaudo
f11d12dcc2
Fix lint-licenses task on windows 2026-03-10 17:49:52 +01:00
Jonas Jenwald
e6f32f2d3b Remove the "check_l10n.mjs" entry from the ESLint config
Linting works fine with this removed, since there's apparently no top-level file with that name.
2026-03-10 16:02:27 +01:00
Jonas Jenwald
bfa2753f3c Remove the "abort" listener, on the globalAbortSignal, in the web/sidebar.js file
This is consistent with a bunch of other viewer code, since an `AbortSignal` can only be aborted once any "abort" listeners can thus be removed when invoked.
2026-03-10 15:51:10 +01:00
Jonas Jenwald
5ef582fb20 Use optional chaining a little bit more in the src/display/api.js file
That format is preferred where possible, since it leads to ever so slightly shorter code overall.
2026-03-10 15:51:05 +01:00
Nicolò Ribaudo
4f7a025e21
Separate bbox tracking from dependencies tracking
When recording bboxes for images, it's enough to record their
clip box / bounding box without needing to run the full bbox
tracking of the image's dependencies.
2026-03-10 14:51:03 +01:00
Nicolò Ribaudo
886c90d1a5
Add support for right-clicking on images
This patch adds right-click support for images in the PDF, allowing
users to download them. To minimize memory consumption, we:
- Do not store the images separately, and instead crop them out of the
  PDF page canvas
- Only extract the images when needed (i.e. when the user right-clicks
  on them), rather than eagery having all of them available.

To do so, we layer one empty 0x0 canvas per image, stretched to cover
the whole image, and only populate its contents on right click.
These images need to be inside the text layer: they cannot be _behind_
it, otherwise they would be covered by the text layer's container and
not be clickable, and they cannot be in front of it, otherwise they
would make the text spans unselectable.

This feature is managed by a new preference, `imagesRightClickMinSize`:
- when it's set to `-1`, right-click support is disabled
- when set to `0`, all images are available for right click
- when set to a positive integer, only images whose width and height are
  greater than or equal to that value (in the PDF page frame of
  reference) are available for right click.

This features is disabled by default outside of MOZCENTRAL, as it
significantly degrades the text selection experience in non-Firefox
browsers.
2026-03-10 14:51:03 +01:00
Calixte Denizet
ad7a415220
Fix the border & background colors of the placeholder for a dragged thumbnail (bug 2020698) 2026-03-09 20:47:39 +01:00
Jonas Jenwald
873378b718
Merge pull request #20836 from Snuffleupagus/FontFaceObject-fix-asserts
Fix the `disableFontFace` and `fontExtraProperties` asserts in the `FontFaceObject` constructor (PR 20197 follow-up)
2026-03-09 20:08:58 +01:00
Jonas Jenwald
4bae676af1
Merge pull request #20835 from Snuffleupagus/return-iterators
Use iterators a little bit more, to avoid creating temporary Arrays
2026-03-09 20:07:19 +01:00
Calixte Denizet
645ef08764
Avoid to have a thumbnail with two paste buttons (bug 2021886) 2026-03-09 19:10:12 +01:00
Calixte Denizet
7010086cd5
Disable dragging a thumbnail when the user has to paste what they copied (bug 2021934) 2026-03-09 18:10:33 +01:00
Jonas Jenwald
9f69617109 Fix the disableFontFace and fontExtraProperties asserts in the FontFaceObject constructor (PR 20197 follow-up)
In PR 19548 these checks were added to ensure that the font-data sent from the worker-thread *always* include correct `disableFontFace` and `fontExtraProperties` data.

For some reason PR 20197 then changed the code such that these checks became effectively pointless, since these properties are now checked after the fact *and* the new getters provide fallback values.
2026-03-09 18:00:11 +01:00
Jonas Jenwald
dbb6ffb8d5 Change the Font.prototype.glyphCacheValues method to return an iterator
This method is only used with loops, and it should be a tiny bit more efficient to use an iterator directly rather than first iterating through the underlying data to create a temporary `Array` that we finally iterate through at the call-site.

*Please note:* As port of these changes the chars/glyph caches, on the `Font` instances, are changed to use `Map`s rather than Objects.
2026-03-09 16:18:48 +01:00
Jonas Jenwald
8bbb7c88d3 Change the AnnotationLayer.prototype.getEditableAnnotations method to return an iterator
This method is only used with loops, and it should be a tiny bit more efficient to use an iterator directly rather than first iterating through the underlying `Map` to create a temporary `Array` that we finally iterate through at the call-site.
2026-03-09 16:11:21 +01:00
Calixte Denizet
210b859a54
Update the context menu after copying thumbnails 2026-03-09 15:36:22 +01:00
calixteman
cc680f68c3
Merge pull request #20832 from calixteman/fix_labels
Fix the label and tooltip on the paste buttons
2026-03-09 15:20:59 +01:00
calixteman
c7d1a48f5e
Merge pull request #20833 from nicolo-ribaudo/claude-ignore-eslint
Do not lint folders for project-level AI coding agents
2026-03-09 15:02:44 +01:00
Nicolò Ribaudo
e69432cd89
Do not lint folders for project-level AI coding agents 2026-03-09 14:57:54 +01:00
Calixte Denizet
18a05354fb
Fix the label and tooltip on the paste buttons 2026-03-09 14:21:15 +01:00
calixteman
9d81fafa8c
Add a new internal viewer to explore the structure of PDF files.
The one from pdf.js.utils is a bit too old: a lot of bugs have been fixed
in the code that parses PDF files since then.
It's just an internal development tool, so it doesn't need to be perfect,
but it should be good enough to be useful.
2026-03-09 14:16:12 +01:00
calixteman
d5653a1f7c
Merge pull request #20646 from nicolo-ribaudo/allow-any-host
Add option allow external connections to `npx gulp server`
2026-03-09 11:37:22 +01:00
calixteman
4ef5ea9681
Merge pull request #20810 from calixteman/bug2010832
Add a UI to undo cut/delete and cancel a copy (bug 2021352, bug 2010832)
2026-03-09 11:36:37 +01:00
Nicolò Ribaudo
384f1af067
Add --host option npx gulp server
Using `0.0.0.0` instead of `localhost` allows connecting from other
devices, significantly simplifying testing on mobile devices.

This is controlled by the `--host` CLI flag and not enabled by
default, since allowing external connections comes with security
implications (e.g. when on a public network without a properly
configured firewall).

There might be reasons to want to listen on custom hostnames, but as
the most common usage will probably be `--host 0.0.0.0`, there is a
shorter alias `--host 0` for it.
2026-03-09 11:03:20 +01:00
Calixte Denizet
0e48c16c3c
Add a UI to undo cut/delete and cancel a copy (bug 2021352, bug 2010832)
This happens in a bar on top of the thumbnails sidebar.
The label depending on the selected thumbnails is fixed.
2026-03-09 10:44:11 +01:00
Jonas Jenwald
a1b769caea Improve the validateRangeRequestCapabilities unit-tests
A number of these unit-tests didn't actually cover the intended code-paths, since many of them *accidentally* matched the "file size is smaller than two range requests"-check.

The patch also updates `validateRangeRequestCapabilities` to use return-value names that are consistent with the class fields used in the various stream implementations.
2026-03-08 18:28:50 +01:00
Jonas Jenwald
2598b0dcdd Start using Blob.prototype.bytes() in the code-base
Note that this isn't motivated by the miniscule reduction in code-size, but rather by wanting to unblock using this newer feature; see https://developer.mozilla.org/en-US/docs/Web/API/Blob/bytes
2026-03-08 14:06:03 +01:00
Tim van der Meij
46f4bc805e
Merge pull request #20826 from calixteman/outline_se
Handle outline with Structure Element (SE) destination
2026-03-08 13:16:11 +01:00
calixteman
253ce6e323
Handle outline with Structure Element (SE) destination 2026-03-08 12:28:24 +01:00
Tim van der Meij
2ffd2e65dd
Merge pull request #20827 from Snuffleupagus/worker-DocProgress-contentLength
Ensure that `percent === NaN` is consistently reported by the `onProgress` callback
2026-03-08 10:58:29 +01:00
Tim van der Meij
43fd680f6a
Merge pull request #20825 from timvandermeij/updates
Update dependencies to the most recent versions
2026-03-08 10:56:33 +01:00
Jonas Jenwald
ddd69ce4e0 Remove the "DocProgress" loaded fallback from the getPdfManager function
Falling back to use the `loaded` byteLength if the server `contentLength` is unknown doesn't make a lot of sense, since it'd lead to the `onProgress` callback reporting `percent === 100` repeatedly while the document is loading despite that being obviously wrong.
Instead we'll now report `percent === NaN` in that case, thus showing the indeterminate progressBar, which seems more correct if the `contentLength` is unknown.

Please note that this code-path is normally not even reached, since streaming is enabled by default (applies e.g. to the Firefox PDF Viewer).
2026-03-08 10:22:01 +01:00
Jonas Jenwald
1f69cf964c Ensure that percent === NaN is consistently reported by the onProgress callback
With these changes `0`, `NaN`, `null`, and `undefined` in the `total`-property all result in `percent === NaN` being reported by the callback, since previously e.g. `0` would result in `percent === 100` being reported unconditionally which doesn't make a lot of sense.

Also, remove the "indeterminate" loadingBar (in the viewer) if the `PDFDocumentLoadingTask` fails since there won't be any more data arriving and displaying the animation thus seems wrong.
2026-03-08 10:21:55 +01:00