1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 00:28:06 +02:00
Commit graph

4326 commits

Author SHA1 Message Date
Jonas Jenwald
58c7b5b635 Consistently dispatch events, if needed, when setting AppOptions
Currently we'll only dispatch events, for the options that support it, when updating preferences. Since this could potentially lead to inconsistent behaviour, let's avoid any future surprises by *always* dispatching events regardless of how the relevant option is being changed.

Obviously we should then also dispatch events in `AppOptions.set`, and to avoid adding even more duplicated code this method is changed into a wrapper for `AppOptions.setAll`.
While this is technically a tiny bit less efficient I don't think it matters in practice, since outside of development- and debug-mode `AppOptions.set` is barely used.
2024-07-27 10:10:38 +02:00
Tim van der Meij
cb737512de
Merge pull request #18486 from Snuffleupagus/AppOptions-replace-locale
Replace the GENERIC-only "locale" with "localeProperties" in AppOptions
2024-07-23 15:50:29 +02:00
calixteman
33493301b3
Merge pull request #18484 from calixteman/bug1909310
Add a pref to know if the alt-text must be automatically generated (bug 1909310)
2024-07-23 10:02:03 +02:00
Jonas Jenwald
7ebfad6d92 Replace the GENERIC-only "locale" with "localeProperties" in AppOptions
Since "localeProperties" is needed in Firefox, let's remove a tiny bit of option duplication by using it in the GENERIC builds as well.
For convenience, the old debug-only "locale" hash-parameter is kept intact.
2024-07-23 09:51:32 +02:00
Calixte Denizet
042183b89b Add a pref to know if the alt-text must be automatically generated (bug 1909310) 2024-07-22 23:10:25 +02:00
Jonas Jenwald
b3ea789286 Add better support for AppOptions with multiple types (PR 18465 follow-up)
For options with varying types, see `useSystemFonts`, we're not sufficiently validating the type when setting a new value. This means that for an option that uses `OptionKind.UNDEF_ALLOWED` we'd allow *any* value, which is obviously not the intention.

Hence we instead introduce a new and *optional* `type`-field that allows specifying exactly which types are valid when multiple ones are supported.

*Note:* This obviously didn't occur to me until after PR 18465 landed, sorry about that!
2024-07-22 17:58:21 +02:00
Jonas Jenwald
12e083f60d Re-factor how the "docBaseUrl" API-option is set in the viewer
This option is old enough that it predates e.g. the introduction of AppOptions, so it probably cannot hurt to re-factor this a little bit now.

 - In development-mode we can just set this directly in AppOptions.

 - In the extension-builds we still need to set it dynamically, however by moving this code we get the benefit of being able to avoid storing a data-URL in that case; note how [the API ignores those anyway](98e772727e/src/display/api.js (L256-L262)).
2024-07-21 22:07:52 +02:00
Tim van der Meij
98e772727e
Merge pull request #18475 from Snuffleupagus/rm-AppOptions-remove
Remove the unused `AppOptions.remove` method
2024-07-21 21:28:52 +02:00
calixteman
998bc07375
Merge pull request #18472 from calixteman/bug1908939
Add the possibility to delete a model (bug 1908939)
2024-07-21 20:53:08 +02:00
Jonas Jenwald
d9ff29a46b Remove the unused AppOptions.remove method
This method has *never* been used anywhere in the code-base, so I really don't know why I added it originally.
2024-07-21 19:26:15 +02:00
Tim van der Meij
0c34efbef9
Merge pull request #18465 from Snuffleupagus/issue-18210
Disable system fonts on Android (issue 18210)
2024-07-21 17:53:49 +02:00
Calixte Denizet
b759470ed5 Add the possibility to delete a model (bug 1908939) 2024-07-21 17:09:41 +02:00
Calixte Denizet
5860c7bcc9 Add a pref containing the url for the sumo page about alt text (bug 1909097) 2024-07-21 16:55:26 +02:00
Jonas Jenwald
80d6bf6319 Disable system fonts on Android (issue 18210)
To avoid introducing any inline "hacks" in the viewer-code this meant adding `useSystemFonts` to the AppOptions, which thus required some new functionality since the default value should be `undefined` given how the option is handled in the API; note [this code](ed83d7c5e1/src/display/api.js (L298-L301)).

Finally, also moves the definition of the development-mode `window.isGECKOVIEW` property to the HTML file such that it's guaranteed to be set regardless of how and when it's accessed.
2024-07-21 15:28:16 +02:00
Jonas Jenwald
45ce3a057f Use shorter local variable names in a few AppOptions methods
Besides being slightly shorter, this should help reduce the risk of confusion given the very similar global Object/Map names.
2024-07-21 15:27:43 +02:00
Tim van der Meij
ebb3d27125
Merge pull request #18469 from Snuffleupagus/AppOptions-Maps
Introduce some `Map`-usage in the AppOptions
2024-07-21 14:47:29 +02:00
Jonas Jenwald
f8aa15aae9 Move the Preferences initialization as early as possible
Given that the entire default viewer initialization depends on the preferences being available, try to do this as early as possible.
2024-07-21 13:42:31 +02:00
Jonas Jenwald
26989fdf24 Add basic validation of the AppOptions BROWSER-kind 2024-07-21 09:32:36 +02:00
Jonas Jenwald
7bd920691f Change the userOptions, used with AppOptions, to a Map
This is needed for upcoming changes, and simplifies both checking if an entry exists and iteration of the entries.
2024-07-21 09:27:23 +02:00
Jonas Jenwald
57ee035573 Change the compatibilityParams, used with AppOptions, to a Map
This is needed for upcoming changes, and simplifies both checking if an entry exists and iteration of the entries.
2024-07-21 09:27:05 +02:00
Tim van der Meij
e92a6a14ff
Merge pull request #18450 from Snuffleupagus/AppOptions-set-validation
Add more validation when setting `AppOptions` (PR 18413 follow-up)
2024-07-20 19:11:54 +02:00
Tim van der Meij
7a8aceef20
Merge pull request #18463 from Snuffleupagus/app-rm-downloadComplete
Re-factor the code to remove all uses of `PDFViewerApplication.downloadComplete`
2024-07-20 18:11:32 +02:00
Jonas Jenwald
482d6211aa Reduce a tiny bit of duplication in PDFViewerApplication.setTitleUsingUrl
Rather than repeating code, we can always fallback to the raw URL instead.
2024-07-20 10:19:45 +02:00
Jonas Jenwald
64a4f0dc7e Avoid downloading the document twice in PDFViewerApplication.download
The old implementation in `PDFViewerApplication.download` means that if the `getDocument`-call hasn't yet downloaded the *entire* PDF document it will be re-downloaded. This seems generally undesirable since:
 - In some (probably rare) cases a URL may not be valid an arbitrary number of times, which means that the download may fail.
 - It will lead to wasted resources, since we'll end up fetching the same PDF document *twice* in that case (once via the `getDocument`-call and once to allow the user to save it).

Hence this patch suggests that we change this very old code to instead always call the `PDFDocumentProxy.getData` method, since that'll trigger immediate downloading of the remaining document via the existing `getDocument`-call.

Finally, the patch removes the `PDFViewerApplication.downloadComplete` property since it's now unused.
2024-07-20 09:57:33 +02:00
Jonas Jenwald
006242489d Stop using downloadComplete in PDFViewerApplication.progress
This was only necessary to prevent (unlikely) visual glitches when `disableAutoFetch = true` is being used.
However, it turns out that we can move this functionality into the `ProgressBar` class instead by checking if the entire PDF document has loaded. This works since the API is always reporting 100% loading progress regardless of how the document was loaded; see [this code](ed83d7c5e1/src/display/api.js (L2735-L2740)).
2024-07-20 09:27:43 +02:00
Jonas Jenwald
216d3a9faf Add more validation when setting AppOptions (PR 18413 follow-up)
After the changes in PR 18413 we're now relying even more on `AppOptions` and it thus seems like a good idea to ensure that no invalid values can be added.
Hence the `AppOptions.{set, setAll}` methods will now *unconditionally* validate that the type of the values agree with the default-options.
2024-07-20 08:53:55 +02:00
Calixte Denizet
b71fa727e1 Load the image-to-text model when opening the pdf viewer in Firefox (bug 1908938) 2024-07-19 21:57:46 +02:00
Calixte Denizet
5946d20dc9 [Editor] Allow to change a preference from the editor UI manager
We want to be able to update a global pref (i.e. enableAltText) in using a toggle button in the new alt-text dialog.
2024-07-18 15:12:39 +02:00
Jonas Jenwald
5be66580e6
Merge pull request #18448 from Snuffleupagus/AppOptions-more-browser-params
Include additional data when fetching browser preferences in the PDF Viewer (bug 1908401)
2024-07-18 14:19:50 +02:00
Jonas Jenwald
d24a61c648 Allow /XYZ destinations without zoom parameter (issue 18408)
According to the PDF specification these destinations should have a zoom parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the zoom parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-18 13:29:32 +02:00
Calixte Denizet
6cc32b699f Add the possibility to change some pdfjs preferences from the viewer (bug 1908483) 2024-07-18 09:52:10 +02:00
Jonas Jenwald
99f34f4c2e Include additional data when fetching browser preferences in the PDF Viewer (bug 1908401)
To avoid having to request and await various browser data early during the PDF Viewer initialization, we can include that data in the existing preference fetching instead. With other planned changes to the PDF Viewer, the current situation would only become worse over time.

*Note:* Technically this data aren't preference-values, however we're already including other non-prefs in this list (e.g. `isInAutomation`) and doing it this way simplifies the overall implementation.
2024-07-17 16:57:55 +02:00
Jonas Jenwald
86eb5ba700
Merge pull request #18441 from Snuffleupagus/api-rm-Outliner
[api-minor] Remove `Outliner` from the official API
2024-07-16 14:32:07 +02:00
Jonas Jenwald
8a979c2d0e [api-minor] Remove Outliner from the official API
As far as I can tell `Outliner` is only exposed in the API because we need to access it when running some of the reference-tests, but is otherwise not used.
Hence this seems like something that should be kept *internal* and thus only exposed in TESTING-builds.
2024-07-16 13:08:26 +02:00
Calixte Denizet
6dd75c0e62 [Editor] When in non-editing mode, add a new editor only once the editing mode has switched
Switching to an editing mode can be asynchronous (e.g. if an editable annotation exists on a
visible page), so we must add a new editor only when the page rendering is done.
2024-07-15 21:04:52 +02:00
calixteman
87e74a753b
Merge pull request #18429 from calixteman/bug1907207
[Editor] Add an option to use the new 'add an image' flow (bug 1907207)
2024-07-15 13:58:08 +02:00
Tim van der Meij
c77b97daff
Update the JS/CSS files for the new Prettier/Stylelint versions 2024-07-13 16:29:47 +02:00
Calixte Denizet
dfccc8ffd9 [Editor] Add an option to use the new 'add an image' flow (bug 1907207)
UX team designed in a new flow we'll implement soon and we want to be able to
make an experiment to be able to compare current flow vs the new one.
2024-07-12 16:28:48 +02:00
Calixte Denizet
4e7c30da9a [Editor] Disable existing highlights when drawing a new one (bug 1879035)
When the mouse was hovering an existing highlight, all the text in the page
was selected.
So when the user is selecting some text or drawing a free highlight, the mouse
is disabled for the existing editors.
2024-07-11 21:34:28 +02:00
calixteman
df5bc544df
Merge pull request #18425 from calixteman/bug1879104
[Editor] Make editor toolbars usable whatever their z-index (bug 1879104)
2024-07-11 19:03:03 +02:00
Calixte Denizet
9a64749dbe [Editor] Make editor toolbars usable whatever their z-index (bug 1879104)
Because of editor z-index, the toolbar belonging to an highlight created
before a second adjacent one, can be overlapped by this new one.
So when the user select an editor we just show it on front of all the other
ones to make sure that it can be used normally.
2024-07-11 18:00:42 +02:00
Jonas Jenwald
6b47ddd4d5 Remove the remaining zoomDisabledTimeout usage (issue 17727)
With https://bugzilla.mozilla.org/show_bug.cgi?id=1882168 now marked as fixed by the landing of https://bugzilla.mozilla.org/show_bug.cgi?id=1902017 we should *hopefully* be able to remove this work-around.
2024-07-11 12:17:41 +02:00
Jonas Jenwald
403d023617 Allow e.g. /FitH destinations without additional parameter (bug 1907000)
According to the PDF specification these destinations should have a coordinate parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870

Hence we try to work-around bad PDF generators by making the coordinate parameter optional when validating explicit destinations in both the worker and the viewer.
2024-07-11 10:36:44 +02:00
Calixte Denizet
d27efb43cd [Editor] Wait for 'pagerendered' to switch to editing mode
The focus can potentially be stolen when the DOM is modified when adding
a new canvas element for the page being redrawn.
2024-07-10 11:29:42 +02:00
Jonas Jenwald
d9f0ec0b87 Re-factor BasePreferences to essentially be a wrapper around AppOptions
In the MOZCENTRAL build the `BasePreferences` class is almost unused, since it's only being used to initialize and update the `AppOptions` which means that theoretically we could move the relevant code there.
However for the other build targets (e.g. GENERIC and CHROME) we still need to keep the `BasePreferences` class, although we can re-factor things to move the necessary validation inside of `AppOptions` and thus simplify the code and reduce duplication.

The patch also moves the event dispatching, for changed preference values, into `AppOptions` instead.
2024-07-09 22:49:59 +02:00
Jonas Jenwald
9e352a8bad Move the "updatedPreference" event listener registration
This patch fixes a situation that'll probably never happen, but nonetheless seems like something that we should address.
Currently the "updatedPreference" listener isn't registered *until after* the preferences have been read and initialized, which leaves a very short window of time where a preference change could theoretically be skipped.
2024-07-06 15:28:03 +02:00
calixteman
db9115625b
Merge pull request #18398 from calixteman/bug1905923
[Editor] Change the enableML pref for enableAltText (bug 1905923)
2024-07-05 22:51:15 +02:00
Calixte Denizet
0fba6e570e [Editor] Change the enableML pref for enableAltText (bug 1905923)
We want to use this pref to make a Nimbus experiment in the next weeks.
2024-07-05 21:01:12 +02:00
Calixte Denizet
0910f17a58 Allow to change the toolbar height when changing the pref toolbar.density in Firefox (bug 1171799)
It's a first step to just dispatch the pref change to the toolbar.
The second one, to effectively use it, will come after PR #18385 is merged.
2024-07-05 18:59:29 +02:00
Calixte Denizet
74cbfbd09f [Editor] Remove the option enableStamp 2024-07-04 22:01:35 +02:00