Commit Graph

17417 Commits

Author SHA1 Message Date
Jonas Jenwald
7667f55e45 [Firefox] Simplify FirefoxPreferences._readFromStorage (PR 16583 follow-up)
Now that https://bugzilla.mozilla.org/show_bug.cgi?id=1840064 has landed in mozilla-central we can implement the final piece of clean-up for the `FirefoxPreferences._readFromStorage` method.
2023-06-24 18:37:43 +02:00
Jonas Jenwald
e9ccbd2856
Merge pull request #16587 from Snuffleupagus/test-pdfjs-API
Add a unit-test to check that the *official* PDF.js API exposes the expected functionality
2023-06-22 17:53:45 +02:00
Jonas Jenwald
0bbadce066 Add a unit-test to check that the *official* PDF.js API exposes the expected functionality
Until now we've not actually had *any* tests that ensure that the *official* PDF.js API exposes the intended functionality, which means that things can easily break accidentally.
2023-06-22 15:21:10 +02:00
Jonas Jenwald
25a07d92d0 [Firefox] Stub out the isValidFetchUrl function in MOZCENTRAL builds
This helper function is completely unused in the Firefox PDF Viewer.
2023-06-22 15:02:54 +02:00
Jonas Jenwald
03059e1f86
Merge pull request #16573 from Snuffleupagus/move-fixupLangCode
Move the `fixupLangCode` helper function into the `web/genericl10n.js` file
2023-06-21 22:18:26 +02:00
Jonas Jenwald
fe1c36a0ed Move the fixupLangCode helper function into the web/genericl10n.js file
This helper function was added almost two years ago, in PR 13696, and it still has only a single call-site. Furthermore, with the changes made in PR 16572 it also cannot hurt to reduce the size of the `web/l10n_utils.js` file slightly.
2023-06-21 21:42:53 +02:00
Jonas Jenwald
24b2c3a5e3
Merge pull request #16583 from Snuffleupagus/Firefox-disable-pref-changes
[Firefox] Disable the ability to change preferences directly from the viewer
2023-06-21 21:07:28 +02:00
Jonas Jenwald
5c0872d1b0 [Firefox] Avoid unnecessary string-parsing when reading preferences
Note how the [`ChromeActions.getPreferences` method](https://searchfox.org/mozilla-central/rev/4e8f62a231e71dc53eb50b6d74afca21d6b254e9/toolkit/components/pdfjs/content/PdfStreamConverter.sys.mjs#497-530) returns the preferences as a string, which we then have to convert back into an Object in the viewer.
Back when that code was originally written it wasn't possible to send Objects from the platform-code, however that's no longer the case and we should be able to (eventually) remove this unnecessary string-parsing now.

*Please note that in order to prevent breakage we'll need to land these changes in stages:*
 - Land this patch in mozilla-central, as part of regular the PDF.js updates.
 - Change the return type in the `ChromeActions.getPreferences` method, in a mozilla-central patch.
 - Remove the string-handling from the `FirefoxPreferences._readFromStorage` method.
2023-06-21 20:14:46 +02:00
Jonas Jenwald
1f9d1f3696 [Firefox] Disable the ability to change preferences directly from the viewer
Please note that we've never had any functionality in the viewer itself that *set* preferences, and we've thus only ever read them.
For the GENERIC viewer it obviously makes sense for the user to be able to modify preferences, e.g. via the console, but that doesn't really apply to the *built-in* Firefox PDF Viewer since preferences are already accessible via `about:config` there. Hence it does seems somewhat strange to expose, a limited part of, the Firefox preference system in this way when we're not even using it.

Note that the unused preference setting-code also include a fair amount of *additional* validation on the platform-side, such as limiting any possible preference changes to the `pdfjs.`-branch and also an explicit white-list of preference names[1], to make sure that this is safe; please see:
 - https://searchfox.org/mozilla-central/rev/4e8f62a231e71dc53eb50b6d74afca21d6b254e9/toolkit/components/pdfjs/content/PdfStreamConverter.sys.mjs#458-495
 - https://searchfox.org/mozilla-central/rev/4e8f62a231e71dc53eb50b6d74afca21d6b254e9/toolkit/modules/AsyncPrefs.sys.mjs#21-48

Assuming that this patch lands, I'll follow-up with a mozilla-central patch to remove the code mentioned above.

---
[1] This hard-coded list contains preferences that no longer exist, and also at least one (fairly obvious) typo.
2023-06-21 20:14:16 +02:00
Jonas Jenwald
7742d6e4a6
Merge pull request #16581 from Snuffleupagus/Lexer-getNumber-sign
Simplify the `sign` handling in the `Lexer.getNumber` method
2023-06-21 15:34:55 +02:00
Jonas Jenwald
fe869aca38 Simplify the sign handling in the Lexer.getNumber method
After the changes in PR 15606, we can (slightly) simplify the `sign` handling.
2023-06-21 14:47:29 +02:00
calixteman
9a6f439dc7
Merge pull request #16578 from calixteman/issue16576
[Editor] Hide visible popups when editing
2023-06-21 13:55:51 +02:00
Jonas Jenwald
71c60d523d
Merge pull request #16580 from Snuffleupagus/rm-OverlayManager-unregister
Remove the `OverlayManager.unregister` method since it's completely unused
2023-06-21 13:23:07 +02:00
Jonas Jenwald
7f53fb82a5 Remove the OverlayManager.unregister method since it's completely unused
This method was added only for consistency with the `register`-method, however it's never actually been used. To avoid including dead code in the builds, let's just remove the `unregister`-method for now.

*Please note:* If this method ever becomes useful, it'll be trivial to revert this commit.
2023-06-21 13:13:53 +02:00
Calixte Denizet
8ae1c8dd81 [Editor] Hide visible popups when editing 2023-06-21 12:30:05 +02:00
calixteman
b8f5a14925
Merge pull request #16579 from calixteman/issue16577
[Editor] Don't make editable an empty freetext annotation
2023-06-21 12:26:02 +02:00
Calixte Denizet
19f7a8b899 [Editor] Don't make editable an empty freetext annotation 2023-06-21 11:48:20 +02:00
Jonas Jenwald
7588418b09
Merge pull request #16572 from Snuffleupagus/annotationLayer-NullL10n
[api-minor] Ensure that the `AnnotationLayer` gets a default l10n-instance in GENERIC builds (PR 16552 follow-up)
2023-06-20 21:20:19 +02:00
Jonas Jenwald
19880fcf9a [api-minor] Move the l10n-translation into the AnnotationLayer
With the changes in PR 16552 we can now move general translation into the `AnnotationLayer` itself, which should improve things ever so slightly in third-party implementations where the default viewer isn't used.
2023-06-20 20:28:35 +02:00
Jonas Jenwald
197e806c86 [api-minor] Ensure that the AnnotationLayer gets a default l10n-instance in GENERIC builds (PR 16552 follow-up)
*This is something that I completely overlooked during review of PR 16552, despite leaving a l10n-related comment.*

The new l10n-handling of PopupAnnotations assume that the `AnnotationLayer` is always initialized with a l10n-instance, which might not actually be the case in third-party implementations where the default viewer isn't used.
To work-around that we'll now bundle, and fallback on, the existing `NullL10n`-implementation in GENERIC builds of the PDF.js library. This will only result in a slight file-size increase for the *built* `pdf.js` file, again limited to GENERIC builds, since the `web/l10n_utils.js` file has no dependencies.

Also, tweaks a couple of TESTING pre-processor checks to *only* include that code when running the reference tests.
2023-06-20 20:28:29 +02:00
calixteman
a656d71959
Merge pull request #16570 from calixteman/it
Fix integration tests
2023-06-20 18:10:50 +02:00
Calixte Denizet
5ffaa64167 Fix integration tests 2023-06-20 17:52:20 +02:00
calixteman
fc487c8aa9
Merge pull request #16552 from calixteman/simplify_popup
[api-minor] Make the popup independent of their associated annotations
2023-06-20 16:10:45 +02:00
Calixte Denizet
d1e172458f [api-minor] Make the popup independent of their associated annotations
- it'll help to be able to move popups on screen to let the user read the text
- popups won't inherit some properties from their parent:
  - the popup can be misrendered if for example the parent has a clip-path property.
- add an outline to the popup when the parent is focused.
- hide a popup when it's clicked.
2023-06-20 15:30:39 +02:00
calixteman
d01efc6767
Merge pull request #16567 from calixteman/issue16566
[Editor] Show hidden annotations once editing is finished
2023-06-19 23:50:40 +02:00
Calixte Denizet
ae3cee95a6 [Editor] Show hidden annotations once editing is finished 2023-06-19 23:03:45 +02:00
calixteman
a5c10b6d89
Merge pull request #16563 from calixteman/bug1838855
Guess that a checkbox belongs to a group in using its T value (bug 1838855)
2023-06-16 20:40:34 +02:00
Calixte Denizet
5c0054d58d Guess that a checkbox belongs to a group in using its T value (bug 1838855) 2023-06-16 18:45:09 +02:00
calixteman
46b8f9e2f2
Merge pull request #16561 from calixteman/editor_copy_existing
[Editor] Avoid an exception when copying an existing editor
2023-06-16 14:47:55 +02:00
Calixte Denizet
ca3e45755c [Editor] Avoid an exception when copying an existing editor 2023-06-16 14:19:37 +02:00
Jonas Jenwald
04c31a55d2
Merge pull request #16558 from Snuffleupagus/writeStream-filter-fixes
Improve handling of /Filter-entries in `writeStream`
2023-06-16 13:07:41 +02:00
Jonas Jenwald
2cb113b545 Improve handling of /Filter-entries in writeStream
Fix handling of /Filter-entries, since the current implementation could potentially corrupt the data if there's multiple filters present.
Please note that filters are applied *sequentially* during decoding, starting from the first one in the Array, hence the first Array-entry needs to be /FlateDecode in order for things to actually work correctly.

To prevent a future bug, if we want to save more "complex" data such as images, also ensure that we include any existing /DecodeParms-entries when updating the /Filter-entry.
2023-06-16 10:27:23 +02:00
Jonas Jenwald
bd46a934ec
Merge pull request #16559 from calixteman/test_compression
Add a test to check that the compression is ok when saving an annotation
2023-06-16 10:27:10 +02:00
Calixte Denizet
85b38fc247 Add a test to check that the compression is ok when saving an annotation 2023-06-16 10:05:42 +02:00
calixteman
8937cac621
Merge pull request #16556 from calixteman/no_dup_when_saving
[Editor] Avoid to have duplicated entries in the Annot array when saving an existing and modified annotation
2023-06-15 23:47:25 +02:00
calixteman
5f1fba503c
Merge pull request #16557 from calixteman/no_events_on_canvas
Disable events on canvas in the annotation layer
2023-06-15 22:18:12 +02:00
Calixte Denizet
71479fdd21 [Editor] Avoid to have duplicated entries in the Annot array when saving an existing and modified annotation 2023-06-15 22:02:10 +02:00
Calixte Denizet
dd21139405 Disable events on canvas in the annotation layer 2023-06-15 21:10:40 +02:00
calixteman
64520a0c63
Merge pull request #16555 from calixteman/empty_freetext
[Editor] Don't add an editor for empty FreeText annotations
2023-06-15 19:44:13 +02:00
Calixte Denizet
1ab34d2ae4 [Editor] Don't add an editor for empty FreeText annotations 2023-06-15 18:33:03 +02:00
calixteman
5581e22cc7
Merge pull request #16535 from calixteman/restore_freetext
[Editor] Allow to edit FreeText annotations
2023-06-15 18:10:41 +02:00
calixteman
9f60686c59
Merge pull request #16554 from calixteman/issue16553
Add a container for Signature with their own canvas
2023-06-15 16:20:54 +02:00
Calixte Denizet
be25ee12bb Add a container for Signature with their own canvas 2023-06-15 16:11:52 +02:00
Calixte Denizet
0116a8f484 [Editor] Allow to edit FreeText annotations 2023-06-15 16:06:29 +02:00
Jonas Jenwald
a37f7d2477
Merge pull request #16543 from Snuffleupagus/limit-more-to-GENERIC
Limit more code to GENERIC builds
2023-06-15 13:58:52 +02:00
Jonas Jenwald
877884029d
Merge pull request #16551 from Snuffleupagus/page-destroyed-complete
Ensure that `cleanup` during rendering is actually ignored, to prevent a blank canvas
2023-06-15 12:26:57 +02:00
Jonas Jenwald
0650be4641
Merge pull request #16550 from Snuffleupagus/rm-RenderingCancelledException-type
[api-minor] Remove the `type` from `RenderingCancelledException` (PR 16226 follow-up)
2023-06-15 12:26:27 +02:00
Jonas Jenwald
033228a2fc
Merge pull request #16544 from Snuffleupagus/eslint-prefer-optional-catch-binding
Enable the `unicorn/prefer-optional-catch-binding` ESLint plugin rule
2023-06-15 12:25:42 +02:00
Jonas Jenwald
a591c3de84 Ensure that cleanup during rendering is actually ignored, to prevent a blank canvas
The existing unit-test doesn't work as intended, since the page never actually renders. Note how `cleanup` is *not* allowed to run when parsing and/or rendering is ongoing, however an (old) incorrect condition could prevent rendering from ever starting.

This is very old code, which has been slightly re-factored a couple of times (many years ago), however this doesn't appear to affect e.g. the default viewer since the incorrect behaviour seem highly dependent on "unlucky" timing.
Note also how at the start of the `PDFPageProxy.prototype.render`-method we purposely cancel any pending `cleanup`-call, to prevent unnecessary re-parsing for multiple sequential `render`-calls.

Finally, avoid running `cleanup` when document/page destruction has already started since it's pointless in that case.
2023-06-15 11:39:26 +02:00
Jonas Jenwald
89f29192a5 Actually limit SVGGraphics to GENERIC builds (PR 16226 follow-up)
After PR 16226 the deprecated SVG back-end is now unused in development mode, with the exception of unit-tests, hence we can re-factor how it's exposed in the API to avoid including a useless webpack-closure in e.g. the *built-in* Firefox PDF Viewer.
2023-06-14 21:38:10 +02:00