Commit Graph

17429 Commits

Author SHA1 Message Date
Jonas Jenwald
a4ddf7baaa Update l10n files 2023-06-25 09:19:03 +02:00
Jonas Jenwald
744b01b637 Update npm packages 2023-06-25 09:18:41 +02:00
Tim van der Meij
fa95bbce12
Merge pull request #16569 from Snuffleupagus/PDFScriptingManager-private
[api-minor] Re-factor the `PDFScriptingManager` class to use private fields/methods
2023-06-24 19:50:17 +02:00
Tim van der Meij
436699b0db
Merge pull request #16592 from Snuffleupagus/rm-viewer-component-default-factory
[api-minor] Remove the default-factories from the viewer components (PR 15811 follow-up)
2023-06-24 19:39:37 +02:00
Tim van der Meij
1ea502aaf9
Merge pull request #16590 from Snuffleupagus/rm-util-unused-const
Remove a couple of unused constants from `src/shared/util.js`
2023-06-24 19:36:11 +02:00
Tim van der Meij
371ee778ff
Merge pull request #16597 from Snuffleupagus/firefox-getPreferences-cleanup
[Firefox] Simplify `FirefoxPreferences._readFromStorage` (PR 16583 follow-up)
2023-06-24 19:34:42 +02:00
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
e153e3a741 Expose FindState in the viewer-components (issue 16589) 2023-06-24 13:23:02 +02:00
Jonas Jenwald
f596490a1b Add a unit-test to check that the *official* PDF.js-viewer API exposes the expected functionality
Until now we've not actually had *any* tests that ensure that the *official* PDF.js-viewer API exposes the intended functionality, which means that things can easily break accidentally.

*Please note:* This unit-test cannot (easily) be run in Node.js-environments, since the `external/webL10n/l10n.js` file contains various browser-specific functionality.
2023-06-23 12:22:54 +02:00
Jonas Jenwald
c5e4a22ee0 [api-minor] Remove the default-factories from the viewer components (PR 15811 follow-up)
The changes in PR 15811 have now been included in no less than six official releases, hence it should hopefully be OK to remove this now.
2023-06-23 11:54:30 +02:00
Jonas Jenwald
b4b9419841 Remove a couple of unused constants from src/shared/util.js
These constants were added "speculatively" in PR 10820, almost four years ago, but have never actually been used. We already have issue 10982 that tracks *potentially* extending support for the affected annotation-format, however until that happens I really don't think that we should keep shipping completely unused code in the PDF.js library.

For the MOZCENTRAL build-target, i.e. the Firefox PDF Viewer, this reduces the total bundle size by 1.1 kilo-byte.
2023-06-23 10:44:08 +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
547b8276e6 [api-minor] Re-factor the PDFScriptingManager class to use private fields/methods
- Change (most) fields/methods into private ones, since that's now supported.
 - Tweak the constructor-parameters, and simplify the sandbox initialization w.r.t. the viewer components.
 - Remove some unused function/method parameters.
 - Slightly simplify the "updatefromsandbox"-handler by using local variables and inverting some conditions.
2023-06-22 08:09:58 +02:00
Jonas Jenwald
cca299eeb9 [GeckoView] Ignore Scroll/Spread-modes in the PDFViewer setters
Rather than sprinkling pre-processor statements throughout the viewer-code, simply "disable" the relevant `PDFViewer` setters instead.

Also, given that the GeckoView-specific viewer doesn't have a sidebar we don't actually need to explicitly ignore a `pageMode` during loading.
2023-06-22 08:09:58 +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