4976 Commits

Author SHA1 Message Date
calixteman
a3a205d69b
Merge pull request #20871 from calixteman/refactor_debugger
Split the new debugger into multiple files
2026-03-15 14:29:13 +01:00
calixteman
7bac644731
Split the new debugger into multiple files
Instead of having all the code for the new debugger in a single file,
split it into multiple files.
This makes it easier to navigate and maintain the codebase.
It'll be make hacking and fixing bugs in the debugger easier.
2026-03-15 13:21:26 +01:00
Tim van der Meij
820b70eb25
Merge pull request #20858 from calixteman/move_save_as_to_export_selected
Move 'Save as...' menu to 'Export selected...'
2026-03-13 22:04:12 +01:00
Tim van der Meij
94b7f8f998
Merge pull request #20863 from calixteman/fix_intermittent_undo_bar
Only focus the undo bar when the focus isn't inside
2026-03-13 22:03:45 +01:00
Jonas Jenwald
75739a173b Bundle the necessary files and set the correct cMapUrl, iccUrl, and standardFontDataUrl when building gulp internal-viewer
Without these changes none of the relevant functionality would work in the *built* internal-viewer.
2026-03-13 18:16:10 +01:00
calixteman
1d25607b9c
Move 'Save as...' menu to 'Export selected...' 2026-03-13 17:29:12 +01:00
Calixte Denizet
df4a5638d0
Add a button for unchecking all the checked thumbnails (bug 2022769) 2026-03-13 14:18:51 +01:00
calixteman
fbfccebb81
Merge pull request #20850 from calixteman/bug2021828
Don't let the user delete/cut all the pages (bug 2021828)
2026-03-13 14:06:01 +01:00
Calixte Denizet
bbf178c5ee Only focus the undo bar when the focus isn't inside
It should fix the test "must work properly when selecting undo by keyboard"
which calls focus() but it can be steal by fixed callback in setTimeout.
2026-03-13 13:53:51 +01:00
calixteman
2381ac6b16
Update the internal viewer to use a new debugger.
It has few cool features:
 - all the canvas used during the rendering can be viewed;
 - the different properties in the graphics state can be viewed;
 - the different paths can be viewed.
2026-03-12 22:38:08 +01:00
Calixte Denizet
1291f5a32b
Don't let the user delete/cut all the pages (bug 2021828)
And dispatch an event only when the context menu is displayed.
2026-03-11 17:23:56 +01:00
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
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
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
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
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
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
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
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
Calixte Denizet
210b859a54
Update the context menu after copying thumbnails 2026-03-09 15:36:22 +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
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
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
Calixte Denizet
d489ad0b5b
Once a page has been deleted or pasted, make sure the focus stays in the sidebar (bug 2020731) 2026-03-05 21:52:12 +01:00
Tim van der Meij
d3e04d29ac
Merge pull request #20798 from calixteman/bug2016437
Fix the position of the thumbnails on the last line (bug 2016437)
2026-03-05 21:19:39 +01:00
Tim van der Meij
874ba23afc
Merge pull request #20802 from calixteman/rm_sidebar_resize_observer
Remove the sidebar resize observer when killing the UI
2026-03-05 20:39:28 +01:00
Tim van der Meij
60a0e24605
Merge pull request #20792 from calixteman/bug2020758
Add some aria-labels to the paste button in order to know where the buttons are (bug 2020758)
2026-03-05 20:32:20 +01:00
Tim van der Meij
a8d1aa9db8
Merge pull request #20797 from calixteman/bug2020774
Fix few colors in the Manage menu in HCM (bug 2020774)
2026-03-05 20:29:44 +01:00
Tim van der Meij
2463f4dc73
Merge pull request #20794 from calixteman/bug2020737
Move the heading role on the sidebar label (bug 2020737)
2026-03-05 20:29:07 +01:00
Tim van der Meij
cbc0362357
Merge pull request #20787 from Snuffleupagus/improve-PdfTextExtractor
Improve and simplify the `PdfTextExtractor` implementation
2026-03-05 20:23:23 +01:00
Calixte Denizet
dd52343d58
Fix downloading the current pdf 2026-03-05 13:05:03 +01:00
Calixte Denizet
1ac5dfeba8 Remove the sidebar resize observer when killing the UI 2026-03-05 09:51:35 +01:00
Calixte Denizet
7f76a111c4
Fix the position of the thumbnails on the last line (bug 2016437)
The original issue can only be reproduce when the thumbnails are on two lines.
The fix is just a matter of computing the number of elements on the last line once we've
finished the first line.
2026-03-04 17:30:10 +01:00
Calixte Denizet
f9c50bb7ce
Fix few colors in the Manage menu in HCM (bug 2020774) 2026-03-04 16:47:48 +01:00
Calixte Denizet
f6401e4344
Move the heading role on the sidebar label (bug 2020737) 2026-03-04 15:25:11 +01:00
Calixte Denizet
18bafeb1c6
Add some aria-labels to the paste button in order to know where the buttons are (bug 2020758) 2026-03-04 10:32:57 +01:00
Calixte Denizet
d90530b86c
Add the pages organization actions in the Firefox context menu (bug 2018138) 2026-03-04 09:02:39 +01:00
calixteman
68cca32e20
Merge pull request #20785 from calixteman/extract_pages
Add a way to extract some pages from a pdf (bug 2019682)
2026-03-04 08:44:13 +01:00
Calixte Denizet
27aea732a2
Fix the paste button position and add a button before the first thumbnail 2026-03-03 21:46:51 +01:00
Calixte Denizet
a474e81b8a
Add a way to extract some pages from a pdf (bug 2019682)
The user has to select some pages and then click on the "Save As" menu item in the Manage menu.
If they modify the structure of the pdf (deleted, moved, copied pages), they have to use the usual
save button.
2026-03-03 21:39:13 +01:00
calixteman
973add845f
Merge pull request #20779 from calixteman/fix_sidebar_css
Fix layout of thumbnails when split/merge is disabled
2026-03-03 16:19:03 +01:00
Jonas Jenwald
c70ff5a7c0 Improve and simplify the PdfTextExtractor implementation
Working on PR 20784, I couldn't help noticing that this code can be improved a little bit.

 - Only initialize `PdfTextExtractor` in development mode and MOZCENTRAL builds, since it's unused elsewhere.

 - Re-factor how `PdfTextExtractor` waits for the viewer to be available/ready, by using existing (internal) events.
   This simplifies the `PdfTextExtractor` class and removes its `setViewer` method, which improves general consistency since normally the viewer-components don't use such a method in that way (here it was effectively used as a stand-in for a `setDocument` method).

 - Finally, while slightly unrelated, rename the `#getAllTextInProgress` field in the `PDFViewer` class to `#copyAllInProgress` to clearly indicate what it's for since the `getAllText` method is used more generally now.
2026-03-03 15:51:08 +01:00
Jonas Jenwald
54a8c049fd Prevent PdfTextExtractor.prototype.extractTextContent from failing intermittently
Given that extracting all text can take a while to complete, especially in long PDF documents[1], it's technically possible for the user to "select all", copy, and finally abort copying (with the `Esc` key) while `PdfTextExtractor.prototype.extractTextContent` is still running.
If that happens the `PDFViewer.prototype.getAllText` code would be interrupted, and text-extraction would thus fail in an intermittent and (likely) hard to debug way. To avoid this we replace the current "global" interrupt handling with an optional `AbortSignal` instead.

---

[1] See e.g. `pdf.pdf` in the test-suite.
2026-03-03 11:55:33 +01:00
Calixte Denizet
cdc1c8af40
Fix layout of thumbnails when split/merge is disabled 2026-03-02 15:16:16 +01:00
calixteman
d859d78bb5
Merge pull request #20775 from Snuffleupagus/hide-select-pages
Hide the "Select pages" label, in the thumbnails sidebar, when split-merge is disabled
2026-03-02 14:53:15 +01:00