Commit Graph

17444 Commits

Author SHA1 Message Date
Jonas Jenwald
4f82dd3932 Create a GrabToPan-instance lazily in the PDFCursorTools class
Unless the user enables the "HandTool" we don't actually need to create a `GrabToPan`-instance.
2023-06-28 12:43:36 +02:00
Jonas Jenwald
789e318cf7 A couple of small tweaks of the PDFCursorTools class
- Introduce a few private fields for internal state.

 - Inline a small method at its only call-site.
2023-06-28 12:43:34 +02:00
Jonas Jenwald
50488d7a47
Merge pull request #16608 from Snuffleupagus/PDFPageView-refactor-filterFactory
Re-factor how HCM highlight-filters are handled in the viewer components (PR 16593 follow-up)
2023-06-27 15:13:00 +02:00
Jonas Jenwald
a024cd0127 Re-factor how HCM highlight-filters are handled in the viewer components (PR 16593 follow-up)
This is something that I completely overlooked during review of PR 16593, since the idea is (obviously) that the viewer-components should be usable as-is without the user needing to manually pass in any *additional* parameters.

To support this we can very easily expose the current `FilterFactory`-instance on the `PDFPageProxy`-class[1], and if needed initialize the highlight-filters when initializing the page (again limited to the viewer-components).
2023-06-26 23:37:39 +02:00
calixteman
c4a61a7692
Merge pull request #16593 from calixteman/popup_hcm
Improve highlightments and popups in HCM (bug 1830850)
2023-06-26 16:34:17 +02:00
Jonas Jenwald
d357906c3f
Merge pull request #16605 from Snuffleupagus/rm-enableFloatingToolbar-pref
[GeckoView] Remove the `enableFloatingToolbar` preference
2023-06-26 15:56:14 +02:00
Jonas Jenwald
80b4708fa3 [GeckoView] Remove the enableFloatingToolbar preference
Note that we'll now display the toolbar unconditionally in GeckoView.
2023-06-26 15:17:03 +02:00
Jonas Jenwald
21383fb2d1
Merge pull request #16602 from Snuffleupagus/gulpfile-TESTING-nullish-coalescing
Use nullish coalescing when handling the `TESTING` build-target
2023-06-26 14:54:45 +02:00
Jonas Jenwald
d7ae2f86e8
Merge pull request #16604 from Snuffleupagus/pdfviewer_api-test-Node
Run the PDF.js-viewer API unit-test in Node.js environments (PR 16592 follow-up)
2023-06-26 14:50:45 +02:00
Calixte Denizet
c519cc821b Improve highlightments and popups in HCM (bug 1830850)
- Modify the text and background colors in popup to fit a11y requirements
- Add a backdrop filter on clickable areas in using a svg filter mapping
  canvas colors to Highlight and HighlightText ones.
2023-06-26 14:45:03 +02:00
Jonas Jenwald
5f5db4b160 Run the PDF.js-viewer API unit-test in Node.js environments (PR 16592 follow-up)
It occurred to me that we can actually run this unit-test in Node.js environments by making use of the preprocessor to stub out the browser globals there.
2023-06-26 09:37:34 +02:00
Jonas Jenwald
9e7023776e Use nullish coalescing when handling the TESTING build-target
Given that nullish coalescing is now available in all environments/browser that we support, we can (ever so slightly) simplify handling of the `TESTING` build-target.
2023-06-25 16:02:31 +02:00
Tim van der Meij
ccb72073b0
Merge pull request #16598 from Snuffleupagus/update-packages
Update packages and translations
2023-06-25 15:19:01 +02:00
Tim van der Meij
0126774e98
Merge pull request #16600 from Rob--W/crx-min-version-88
[CRX] Set minimum_chrome_version to 88
2023-06-25 15:14:20 +02:00
Rob Wu
1f29baad22 Set minimum_chrome_version to 88
Set minimum_chrome_version to 88 to not distribute an incompatible
version of the extension to older Chrome versions.

See https://github.com/mozilla/pdf.js/issues/13669#issuecomment-1510485564
2023-06-25 14:19:50 +02:00
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