7475 Commits

Author SHA1 Message Date
Jonas Jenwald
40bd73551c
Merge pull request #20793 from Snuffleupagus/more-getRawEntries
Use the `Dict.prototype.getRawEntries` method more
2026-03-04 16:05:57 +01:00
calixteman
ce5f34ba13
Merge pull request #20780 from wooorm/wooorm/dismiss-popups
Add support for dismissing comment popups with click outside
2026-03-04 15:24:29 +01:00
calixteman
72f98d4e00
Merge pull request #20788 from calixteman/organize_context_menu
Add the pages organization actions in the Firefox context menu (bug 2018138)
2026-03-04 15:20:00 +01:00
Jonas Jenwald
50d66d7d34 Use the Dict.prototype.getRawEntries method more
This changes a number of loops currently using `Dict.prototype.{getKeys, getRaw}`, since it should be a tiny bit more efficient to use an iterator directly rather than first iterating through `Map`-keys to create a temporary `Array` that we finally iterate through at the call-site.

Note that the `getKeys` method is much older than `getRawEntries`, and originally the `Dict` class stored its data in a regular `Object`, hence why the old code was written that way.
2026-03-04 12:46:25 +01:00
Nicolò Ribaudo
2f2d5c9e27
Add script to check license headers 2026-03-04 10:40:39 +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
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
Titus Wormer
8b4f9048cf
Add support for dismissing comment popups with click outside
This solves [bug 1989406](https://bugzilla.mozilla.org/show_bug.cgi?id=1989406).
(“The user should be able to dismiss the in-content message displayed by clicking somewhere else in the PDF”)
There’s a good gif there that shows the problematic behavior.

In the thread, there are also mentions of 2 similar but slightly separate problems:

* clicking on another highlight should also dismiss
* the mention that hitting the escape key does not dismiss

I found the last point, the escape key, to work already (first test case here).
But this PR solves the main bug (second test case) and the adjacent one
(third test case).
It works by using the existing `unselectAll` handling.
2026-03-03 11:14:22 +01:00
Tim van der Meij
f32b9d2677
Merge pull request #20738 from Snuffleupagus/function-shorten
Slightly shorten some code in the `src/core/function.js` file
2026-03-01 20:06:29 +01:00
Jonas Jenwald
86573cc995
Merge pull request #20757 from Snuffleupagus/getPdfFilenameFromUrl-fix-decode-regex
Fix the broken regular expression in the `decode` helper in the `getPdfFilenameFromUrl` function (issue 20664)
2026-02-27 23:14:18 +01:00
calixteman
9c3a752388
Merge branch 'master' into scientific 2026-02-27 18:39:44 +01:00
Jonas Jenwald
e3a7c0779d Fix the broken regular expression in the decode helper in the getPdfFilenameFromUrl function (issue 20664)
This will ignore filenames that become effectively empty, i.e. ones that are only ".pdf" and nothing more.

*Please note:* While this passes all existing unit-tests, I don't know if this is necessarily the "correct" solution here.
2026-02-27 15:19:43 +01:00
Jeff Muizelaar
8fa6ef36e4 Remove scientific notation parsing.
This behaviour comes from the initial pdf.js commit but is wrong and
doesn't match other PDF readers like muPDF or pdfium.

From PDF Spec 7.3.3:

A PDF writer shall not use the PostScript language syntax for numbers with non-decimal radices (such
as 16#FFFE) or in exponential format (such as 6.02E23).
2026-02-26 20:22:34 -05:00
Jonas Jenwald
8ced999803 Slightly shorten some code in the src/core/function.js file 2026-02-26 10:42:56 +01:00
Jonas Jenwald
82fc2c94f0 Include transfers correctly in the "GetOperatorList" message (PR 16588 follow-up)
Currently the transfers aren't actually being used with the "GetOperatorList" message, since the placement of the parameter is wrong; note the method signature: 909a700afa/src/shared/message_handler.js (L219-L229)
This goes back to PR 16588, which added the transfers parameter, and unfortunately we all missed that :-(

Simply fixing the parameter isn't enough however, since that broke printing of Stamp-editors (and possibly others). The solution here is to *not* transfer data during printing, given that a single `PrintAnnotationStorage` instance is being used for all pages.
2026-02-25 15:55:43 +01:00
Jonas Jenwald
80db3609f4 Remove unused lastCode property from the LZWStream class (PR 324 follow-up)
This appear to have been unused already in PR 324 all the way back in 2011.
2026-02-25 13:31:44 +01:00
Tim van der Meij
4ecbd0cbe2
Merge pull request #20726 from Snuffleupagus/getOrInsertComputed-fewer-functions
Reduce allocations and function creation when using `getOrInsert` and `getOrInsertComputed`
2026-02-24 23:32:36 +01:00
Tim van der Meij
b43c8eab73
Merge pull request #20725 from calixteman/bug2018162
After cut & paste, the thumbnail must be correctly rendered (bug 2018162)
2026-02-24 23:27:07 +01:00
Jonas Jenwald
0d4e587a5f Reduce allocations when using Map.prototype.getOrInsert() with Arrays
Change all these cases to use `Map.prototype.getOrInsertComputed()` instead, in combination with a helper function for creating the `Array`s (similar to the previous patch).
2026-02-24 09:03:32 +01:00
Jonas Jenwald
2e07715c9d Reduce function creation when using Map.prototype.getOrInsertComputed()
With the exception of the first invocation the callback function is unused, which means that a lot of pointless functions may be created.
To avoid this we introduce helper functions for simple cases, such as creating `Map`s and `Objects`s.
2026-02-24 08:58:28 +01:00
calixteman
15e7a551ab
Reset transfer functions when entering in a new group
It fixes #20722.
2026-02-23 22:37:20 +01:00
Calixte Denizet
97d973ce09
After cut & paste, the thumbnail must be correctly rendered (bug 2018162) 2026-02-23 18:38:33 +01:00
Jonas Jenwald
c2f5e19eb0 Use Map.prototype.getOrInsertComputed() in the src/core/xfa/ folder 2026-02-22 22:57:50 +01:00
Jonas Jenwald
e2c8fc6140 Use Map.prototype.getOrInsertComputed() in the src/display/api.js file 2026-02-22 21:01:13 +01:00
Jonas Jenwald
c81904ac0a Use Map.prototype.getOrInsertComputed() in the src/display/canvas.js file 2026-02-22 17:55:51 +01:00
Jonas Jenwald
ab8e67ecff Use Map.prototype.getOrInsert() in the src/display/annotation_layer.js file 2026-02-22 17:54:17 +01:00
Jonas Jenwald
bfe265ad31 Use Map.prototype.getOrInsertComputed() in the editorStats getter 2026-02-22 15:10:02 +01:00
Tim van der Meij
cc516d0dd4
Merge pull request #20709 from Snuffleupagus/scripting-unconditional-FinalizationRegistry
Use `FinalizationRegistry` unconditionally in the `src/scripting_api/app.js` file
2026-02-22 14:59:03 +01:00
Tim van der Meij
a5a27a5ca7
Merge pull request #20705 from Snuffleupagus/#collectParents-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectParents` method
2026-02-22 12:55:41 +01:00
Tim van der Meij
8189ca358c
Merge pull request #20703 from Snuffleupagus/#collectFieldObjects-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectFieldObjects` method
2026-02-22 12:39:54 +01:00
Jonas Jenwald
ad0a310394
Merge pull request #20706 from Snuffleupagus/ensureDebugMetadata-getOrInsertComputed
Use `Map.prototype.getOrInsertComputed()` in the `ensureDebugMetadata` helper
2026-02-22 10:35:44 +01:00
Jonas Jenwald
2631750038
Merge pull request #20702 from Snuffleupagus/getNewAnnotationsMap-getOrInsert
Use `Map.prototype.getOrInsert()` in the `getNewAnnotationsMap` helper
2026-02-22 10:29:33 +01:00
Jonas Jenwald
956eb10329 Use FinalizationRegistry unconditionally in the src/scripting_api/app.js file
After the QuickJS update in PR 20708 this code can now be simplified.
2026-02-21 22:37:30 +01:00
Jonas Jenwald
0d8bc689b9 Add missing license header in src/display/canvas_dependency_tracker.js 2026-02-21 13:26:20 +01:00
Jonas Jenwald
c7bdf5b508 Use Map.prototype.getOrInsertComputed() in the ensureDebugMetadata helper
Also, shorten the function by using optional chaining.
2026-02-21 12:02:45 +01:00
Jonas Jenwald
3e7ad8d6bf Use Map.prototype.getOrInsert() in the #collectParents method 2026-02-21 11:42:42 +01:00
Jonas Jenwald
210c969c4c Use Map.prototype.getOrInsert() in the #collectFieldObjects method 2026-02-21 11:23:32 +01:00
Jonas Jenwald
76a5aed05f Use Map.prototype.getOrInsert() in the getNewAnnotationsMap helper 2026-02-21 11:03:00 +01:00
Jonas Jenwald
350f3fa7e5 Slightly shorten some code in the src/scripting_api/ folder
- Use nullish coalescing assignment more.
 - Use ternary expressions more.
2026-02-20 22:47:22 +01:00
Tim van der Meij
e07e8ed172
Merge pull request #20690 from Snuffleupagus/getPdfFilenameFromUrl-searchParams-findLast
Reduce duplication when parsing `searchParams` in the `getPdfFilenameFromUrl` function
2026-02-20 21:42:48 +01:00
Tim van der Meij
82de22428a
Merge pull request #20660 from Snuffleupagus/ChunkedStream-async-sendRequest
Convert `ChunkedStreamManager.prototype.sendRequest` to an asynchronous method
2026-02-20 21:39:26 +01:00
calixteman
a5c62b7489
Merge pull request #20691 from Snuffleupagus/rm-unnecessary-Map-entries
Remove unnecessary `Map.prototype.entries()` usage
2026-02-20 17:44:19 +01:00
Jonas Jenwald
374f524c29 Remove unnecessary Map.prototype.entries() usage
A `Map` instance can be iterated directly with a `for...of` loop, hence using its `entries` method is not actually necessary.
2026-02-20 13:44:00 +01:00
Jonas Jenwald
34f27187f8 Reduce duplication when parsing searchParams in the getPdfFilenameFromUrl function
Currently we essentially "duplicate" the same code for parsing the `values` and `keys` of the `searchParams`, which seems a little unnecessary.

To be able to parse the `searchParams` from the end, we currently create an Array (from the Iterator) and then reverse it before finally looping through it. Here the latter two steps can be replaced with the `Array.prototype.findLast()` method instead.

*Please note:* I completely understand if this patch is rejected, on account of being less readable than the current code.
2026-02-19 17:37:12 +01:00
Jonas Jenwald
7fd939763e Remove unnecessary class constructors in the src folder
There's a number of classes where the constructors can be removed completely by instead using class fields, which help to slightly shorten the code.

It seems that `unicorn/prefer-class-fields` ESLint plugin, see PR 20657, unfortunately isn't able to detect all of these cases.
2026-02-19 00:08:57 +01:00
Jonas Jenwald
74ab1a98a6
Merge pull request #20685 from Snuffleupagus/Annotation-set-annotationType
Set the `annotationType` automatically in the `Annotation` constructor
2026-02-19 00:03:37 +01:00
Calixte Denizet
d755fba96a
Add support for deleting, cutting, copying and pasting pages (bug 2010830, 2010831) 2026-02-18 16:43:00 +01:00
Jonas Jenwald
e1cc24c595 Set the annotationType automatically in the Annotation constructor
Rather than assigning it manually in every extending class, we can utilize the fact that the `AnnotationType`-entries are simply the upper-case version of the `/Subtype` (when it exists) in the Annotation dictionary.
2026-02-18 14:47:42 +01:00
Jonas Jenwald
336cda0c64 Remove unused CanvasGraphics properties (PR 700 follow-up)
These are probably a copy-and-paste mistake, since they appear to have been unused already in PR 700 all the way back in 2011.
2026-02-17 21:36:08 +01:00
Jonas Jenwald
6323afab46 Convert the PDFObjects class to use a Map internally
This patch also adds unconditional `Map.prototype.getOrInsertComputed()` usage, which should be fine since it's [supported in the latest browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/getOrInsertComputed#browser_compatibility) and it'll be polyfilled (via core-js) in the `legacy` builds.
2026-02-17 09:42:27 +01:00