1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00
Commit graph

4181 commits

Author SHA1 Message Date
Jonas Jenwald
3596a03279 Fix the RTL-rule for the editorHighlightShowAll button, such that it works outside of the Firefox PDF Viewer
These CSS rules were imported straight from mozilla-central, and contains a property that causes the RTL-rule to be skipped everywhere else (even when using the development viewer in Firefox).
2024-04-10 11:35:04 +02:00
calixteman
77ee914bd6
Merge pull request #17882 from calixteman/bug1889122
Use the string value of the field when calling the Format callback (bug 1889122)
2024-04-10 09:40:54 +02:00
Calixte Denizet
b643c0fcfb Use the string value of the field when calling the Format callback (bug 1889122) 2024-04-09 22:52:11 +02:00
Tim van der Meij
862c27ee67
Convert the thumbnail view(er) code to use proper private methods
This allows us to get rid of the `@private` JSDoc comments, which were
used to convey intent back when proper private methods could not be used
yet in JavaScript. This improves code readability/maintenance and enables
better usage validation by tooling such as ESlint.
2024-04-05 14:44:48 +02:00
Tim van der Meij
2e5282928f
Merge pull request #17854 from Snuffleupagus/rm-PromiseCapability
[api-minor] Replace the `PromiseCapability` with  `Promise.withResolvers()`
2024-04-02 15:21:43 +02:00
Tim van der Meij
10312105a4
Merge pull request #17861 from Snuffleupagus/compatibilityParams-init
Limit all `compatibilityParams` handling to the GENERIC viewer
2024-04-02 14:47:37 +02:00
calixteman
26466b50bc
Merge pull request #17855 from calixteman/bug1888657
Avoid useless CSS animation when nothing is done (bug 1888657)
2024-04-01 19:01:14 +02:00
Calixte Denizet
d3a613dd5b Avoid useless CSS animation when nothing is done (bug 1888657) 2024-04-01 17:32:38 +02:00
Jonas Jenwald
0fdea4b05c Remove the addWindowResolutionChange listener unconditionally (PR 17767 follow-up)
Given that `PDFViewerApplication.unbindWindowEvents` can be invoked in mozilla-central tests, we should ensure that the listener is always removed.
2024-04-01 16:00:25 +02:00
Jonas Jenwald
e4d0e84802 [api-minor] Replace the PromiseCapability with Promise.withResolvers()
This replaces our custom `PromiseCapability`-class with the new native `Promise.withResolvers()` functionality, which does *almost* the same thing[1]; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers

The only difference is that `PromiseCapability` also had a `settled`-getter, which was however not widely used and the call-sites can either be removed or re-factored to avoid it. In particular:
 - In `src/display/api.js` we can tweak the `PDFObjects`-class to use a "special" initial data-value and just compare against that, in order to replace the `settled`-state.
 - In `web/app.js` we change the only case to manually track the `settled`-state, which should hopefully be OK given how this is being used.
 - In `web/pdf_outline_viewer.js` we can remove the `settled`-checks, since the code should work just fine without it. The only thing that could potentially happen is that we try to `resolve` a Promise multiple times, which is however *not* a problem since the value of a Promise cannot be changed once fulfilled or rejected.
 - In `web/pdf_viewer.js` we can remove the `settled`-checks, since the code should work fine without them:
     - For the `_onePageRenderedCapability` case the `settled`-check is used in a `EventBus`-listener which is *removed* on its first (valid) invocation.
     - For the `_pagesCapability` case the `settled`-check is used in a print-related helper that works just fine with "only" the other checks.
 - In `test/unit/api_spec.js` we can change the few relevant cases to manually track the `settled`-state, since this is both simple and *test-only* code.

---
[1] In browsers/environments that lack native support, note [the compatibility data](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility), it'll be polyfilled via the `core-js` library (but only in `legacy` builds).
2024-04-01 11:42:37 +02:00
Jonas Jenwald
62568b27dc Limit all compatibilityParams handling to the GENERIC viewer
With recent improvements to the `AppOptions`, e.g. with better validation and testing, one remaining "annoyance" is the `compatibilityParams` handling. Especially since there's only *a single* parameter left, limited to GENERIC builds.

To further reduce the amount of unnecessary code in e.g. the Firefox PDF Viewer, we can move the `compatibilityParams` handling into the user-options instead since that keeps the previous precedence order between default/user-options.
2024-03-30 12:16:53 +01:00
Jonas Jenwald
5e08396696 A couple of small tweaks of the BasePreferences class
- Use slightly shorter variable names when initializing the preferences.
 - Correctly copy the "old" preference-values before writing to storage, since Objects are passed by reference in JavaScript. (Only applies to the GENERIC viewer.)
 - Use `await` fully when writing new preference-values to storage. (Only applies to the GENERIC viewer.)
 - Stub the `get`-method in the Firefox PDF Viewer, since it's unused there nowadays.
2024-03-26 13:38:40 +01:00
calixteman
3d7ea6076d
Merge pull request #17837 from calixteman/increase_max_canvas_pixels
Increase the maxCanvasPixels value to 2 ** 25
2024-03-25 19:55:48 +01:00
Calixte Denizet
a4aca8a20d Increase the maxCanvasPixels value to 2 ** 25 2024-03-25 17:57:23 +01:00
Calixte Denizet
77b2a456d1 [Editor] Add a divider before the show all button
I overlooked it when implementing the toggle button.
2024-03-25 14:59:34 +01:00
Calixte Denizet
63c1c787b4 [Editor] Add a label to the highight floating button readable with NVDA (bug 1886964) 2024-03-23 16:12:03 +01:00
Tim van der Meij
e7203f558f
Merge pull request #17813 from Snuffleupagus/initPassiveLoading-simplify
Remove `PDFViewerApplication.initPassiveLoading` and directly invoke the `open`-method from the extension-specific code
2024-03-22 10:02:51 +01:00
Jonas Jenwald
44427fa7b2 Allow listening for preference changes in the Firefox PDF viewer (bug 1886586) 2024-03-21 17:07:49 +01:00
Calixte Denizet
918b500ca5 Avoid wrong scrolling when calling zoomReset
The goal of this patch is to fix the test:
https://searchfox.org/mozilla-central/source/toolkit/components/pdfjs/test/browser_pdfjs_zoom.js

It's a regression due to #17790.
2024-03-21 16:04:36 +01:00
Calixte Denizet
3ac52ac359 [Editor] Make sure the text in the mark has null dimensions to avoid to see a meaningless rectangle in voiceover (bug 1886427) 2024-03-20 15:25:13 +01:00
Jonas Jenwald
ea1c910a66 Remove PDFViewerApplication.initPassiveLoading and directly invoke the open-method from the extension-specific code
This old method is essentially just adding, a small amount of, unnecessary indirection and we can easily invoke `PDFViewerApplication.open` directly from the extension-specific code instead.
2024-03-20 14:52:23 +01:00
Jonas Jenwald
b5e00e1fae Move the error message localization into PDFViewerApplication._otherError
When reporting errors in the viewer we currently localize the error messages "manually" at every call-site, which seems like unnecessary repetition.
2024-03-20 14:52:16 +01:00
Calixte Denizet
a3873e4c68 Don't hide the editor layer when rotating (follow-up of #17802)
Before the patch in #17802, the layer was made visible when calling updateMode
after the rotation angle was set.
2024-03-19 18:36:55 +01:00
Calixte Denizet
1b00511301 [Editor] Make the text layer focusable before the editors (bug 1881746)
Keep the different layers in a constant order to avoid the use of a z-index
and a tab-index.
2024-03-19 16:14:55 +01:00
Calixte Denizet
65d618635c When zooming the scrollbar can disappear and then no scrollend is triggered 2024-03-15 15:37:06 +01:00
Jonas Jenwald
30e69956db
Merge pull request #17694 from Snuffleupagus/validate-defaultOptions
Add better validation for the "PREFERENCE" kind `AppOptions`
2024-03-12 18:24:37 +01:00
Calixte Denizet
b4267cd294 [Editor] Add a floating button close to the selected text to highlight it (bug 1867742)
For now keep this feature behind a pref in order to make some experiments before
deciding to enable it.
2024-03-12 15:06:46 +01:00
Jonas Jenwald
70b6ddc5d9 Move the /SetOCGState handling into the OptionalContentConfig class (PR 15377 follow-up)
This helps ensure that /SetOCGState actions always take the `Usage` dictionary into account as expected.
2024-03-12 13:18:15 +01:00
Jonas Jenwald
3c78ff5fb0 [api-minor] Implement basic support for OptionalContent Usage dicts (issue 5764, bug 1826783)
The following are some highlights of this patch:
 - In the Worker we only extract a *subset* of the potential contents of the `Usage` dictionary, to avoid having to implement/test a bunch of code that'd be completely unused in the viewer.

 - In order to still allow the user to *manually* override the default visible layers in the viewer, the viewable/printable state is purposely *not* enforced during initialization in the `OptionalContentConfig` constructor.

 - Printing will now always use the *default* visible layers, rather than using the same state as the viewer (as was the case previously).
   This ensures that the printing-output will correctly take the `Usage` dictionary into account, and in practice toggling of visible layers rarely seem to be necessary except in the viewer itself (if at all).[1]

---
[1] In the unlikely case that it'd ever be deemed necessary to support fine-grained control of optional content visibility during printing, some new (additional) UI would likely be needed to support that case.
2024-03-12 13:18:15 +01:00
Calixte Denizet
f676c2c0c8 [Editor] Improve the accessibility of the highlight editor (bug 1881743) 2024-03-11 14:21:43 +01:00
Calixte Denizet
39aeea3e94 [Editor] Add a toggle button to show/hide all the highlights (bug 1867740) 2024-03-07 13:16:59 +01:00
Calixte Denizet
6d0835dc52 In the m-c automation, give the possibility to remove window listeners when a test ended
The goal is to avoid to have some exceptions in the logs when a test finished.
2024-03-06 14:21:57 +01:00
calixteman
f1272ee435
Merge pull request #17771 from calixteman/bug1832519
[GeckoView] Remove the open-in-app button (bug 1832519)
2024-03-05 14:11:12 +01:00
Calixte Denizet
ba3e559583 Don't stringify data for telemetry 2024-03-04 20:17:47 +01:00
Calixte Denizet
3cb58f84a2 [GeckoView] Remove the open-in-app button (bug 1832519) 2024-03-04 19:32:12 +01:00
Jonas Jenwald
e781b553cb [Editor] Reduce a bit of CSS duplication for the highlight-thickness "indicators" 2024-03-01 16:18:39 +01:00
Jonas Jenwald
c7e7122e25 [Editor] Indicate if the highlight-thickness slider is disabled
The fact that the highlight-thickness can only be changed in "free" mode isn't really obvious visually in the toolbar, so attempt to provide at least some indication of the `disabled`-state by "dimming" the slider.
2024-03-01 16:18:31 +01:00
Calixte Denizet
65342d2bee [Editor] Add some telemetry for the highlight feature (bug 1866437) 2024-02-28 10:17:11 +01:00
Calixte Denizet
9e042e7acc Avoid to have to wait to zoom after scrolling
Allow to zoom with the wheel once the scrolling is finished.
It's now possible to know that thanks to the scrollend event.

Fixes #17707.
2024-02-25 21:40:48 +01:00
Calixte Denizet
bb19cf9b64 [Editor] In caret browsing mode, get the caret position in the text layer (bug 1881692)
The function caretPositionFromPoint return the position within the last visible element
and sometimes there are some elements on top of the ones in the text layer.
So the idea is to hide the visible elements which aren't in the text layer in order
to get the right caret position.
2024-02-23 16:50:19 +01:00
Calixte Denizet
e1f6f5179f [Editor] Add the possibility to create an highlight from the context menu when some text is selected (bug 1867739) 2024-02-23 16:18:03 +01:00
calixteman
72b8b29147
Merge pull request #17701 from calixteman/alt_text_ai
[Editor] Add the possibility to query some ML stuff to guess an alt text for an image
2024-02-21 10:14:40 +01:00
Calixte Denizet
46416bb131 [Editor] Add the possibility to query some ML stuff to guess an alt text for an image
It's only for an experimental purpose.
2024-02-20 21:29:33 +01:00
Calixte Denizet
95f9bedc7c [Editor] Disable annotation layer when highlighting (bug 1868759)
When highlighting, the annotation editor layer is disabled to get pointer events
from the text layer, but the annotation layer must be then disabled either in
order to avoid bad interactions.
2024-02-20 21:17:05 +01:00
Jonas Jenwald
38004b65b1 Re-factor how the compatibilityParams, in the viewer, are handled
Previously we'd simply export this directly from `web/app_options.js`, which meant that it'd be technically possible to *accidentally* modify the `compatibilityParams` Object when accessing it.
To avoid this we instead introduce a new `AppOptions`-method that is used to lookup data in `compatibilityParams`, which means that we no longer need to export this Object.

Based on these changes, it's now possible to simplify some existing code in `AppOptions` by taking full advantage of the nullish coalescing (`??`) operator.
2024-02-20 18:38:18 +01:00
Jonas Jenwald
90b2664622 Add better validation for the "PREFERENCE" kind AppOptions
Given that the "PREFERENCE" kind is used e.g. to generate the preference-list for the Firefox PDF Viewer, those options need to be carefully validated.
With this patch we'll now check this unconditionally in development mode, during testing, and when creating the preferences in the gulpfile.
2024-02-20 18:38:15 +01:00
Tim van der Meij
fd5d040073
Merge pull request #17667 from Snuffleupagus/createPrintService-params
Change `PDFPrintServiceFactory.createPrintService` to take a parameter object
2024-02-17 14:54:53 +01:00
Jonas Jenwald
b420bd8b20 Access PDFViewerApplication.findBar safely in more spots (PR 15831 follow-up)
Note that this patch is the result of code-inspection, and the code as written doesn't (currently) cause any bugs in e.g. the GeckoView PDF Viewer.
2024-02-15 11:25:29 +01:00
Jonas Jenwald
a204f434f3 Change PDFPrintServiceFactory.createPrintService to take a parameter object
By "modernizing" the method to use a parameter object instead, we avoid having to pass along the needed parameters individually.
2024-02-13 21:28:02 +01:00
calixteman
5cfaff508c
Merge pull request #17651 from calixteman/add_enableStamp_pref
Revert "Remove the `enableStampEditor` preference" (bug 1879588)
2024-02-11 18:53:09 +01:00