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

19512 commits

Author SHA1 Message Date
Jonas Jenwald
7c3aa9445c Move all event listeners into Toolbar.prototype.#bindListeners
Over time a couple of event listeners have been placed in the constructor, despite there being an existing helper method for that purpose. To improve the code organization, let's move these to the intended method instead.
2024-07-31 09:49:25 +02:00
Tim van der Meij
e3838c1c70
Introduce a CSS variable for the toolbar height (bug 1171799)
This refactoring lays the foundation for making the toolbar height
configurable in Firefox via the `browser.uidensity` preference. For
this to work correctly the toolbar height must be defined in a single
place that can easily be updated dynamically, hence this patch which
moves it to a CSS variable in such a way that the rest of the UI adapts
correctly if the value is changed.

Co-authored-by: Calixte Denizet <calixte.denizet@gmail.com>
2024-07-30 21:22:49 +02:00
calixteman
f6b356eff7
Merge pull request #18516 from calixteman/add_bg_for_alpha
[Editor] Add a checkerboard behind the image preview in the new alt-text dialog in order to see its potential transparency
2024-07-30 18:53:24 +02:00
Tim van der Meij
f1f58bbe67
Give all HTML button elements a type
The HTML button elements we use are all regular buttons that don't
submit form data to a server. According to
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#notes
those buttons should all have their type set to `button` explicitly, but
we only do that a handful of them. This commit fixes the issue by
consistently giving all our buttons the `button` type.

Co-authored-by: Calixte Denizet <calixte.denizet@gmail.com>
2024-07-30 18:49:18 +02:00
Calixte Denizet
16a66383bb [Editor] Add a checkerboard behind the image preview in the new alt-text dialog in order to see its potential transparency 2024-07-30 17:54:54 +02:00
calixteman
8f45374881
Merge pull request #18492 from calixteman/new_stamp_dialog
[Editor] Implement the new alt text flow (bug 1909604)
2024-07-30 10:25:02 +02:00
Tim van der Meij
7199c967e6
Merge pull request #18510 from timvandermeij/findbar-button
Improve how the findbar's toggle button is referenced in the viewer code
2024-07-29 20:33:04 +02:00
Tim van der Meij
f430a6bfd4
Improve how the findbar's toggle button is referenced in the viewer code
The sidebar and secondary toolbar both have a reference to their toggle
buttons in their own sections in `getViewerConfiguration`, so it makes
sense for the findbar to do the same.

While we actually have a findbar-specific reference to the toggle
button, I noticed that we don't use it consistently because the toolbar
also has a reference to the exact same toggle button and we use both in
the code. This is probably for historical reasons: the docstring in the
toolbar file indicates that the `viewFind` element is an input to the
component, but that option is never actually used in the code itself.

This commit fixes the issue by removing the toolbar-specific reference,
since it's not actually used (anymore) in the toolbar code, so that we
consistently use the findbar-specific reference everywhere.
2024-07-29 19:55:32 +02:00
Tim van der Meij
45e42cc6e4
Merge pull request #18509 from timvandermeij/globals
Remove the `globals` dependency
2024-07-29 19:16:38 +02:00
Tim van der Meij
7e3d56a308
Remove the globals dependency
This dependency got introduced in PR #10293, almost six years ago now,
because `eslint-plugin-mozilla` didn't work without it but also didn't
require it as a dependency itself.

However, nowadays `eslint-plugin-mozilla` works just fine without it,
and other dependencies that need it correctly require it themselves.
This can be seen using `npm ls globals`:

```
$ npm ls globals
pdf.js
├─┬ @babel/core@7.24.9
│ └─┬ @babel/traverse@7.25.0
│   └── globals@11.12.0
├─┬ @babel/preset-env@7.25.0
│ └─┬ @babel/plugin-transform-classes@7.25.0
│   └── globals@11.12.0
├─┬ eslint-plugin-unicorn@55.0.0
│ └── globals@15.8.0 deduped
├─┬ eslint@8.57.0
│ ├─┬ @eslint/eslintrc@2.1.4
│ │ └── globals@13.24.0
│ └── globals@13.24.0
└── globals@15.8.0
```

Further proof that `eslint-plugin-mozilla` (no longer) uses `globals` is
from a source code search in
https://searchfox.org/mozilla-central/search?q=globals&path=&case=false&regexp=false.
The only results for `eslint-plugin-mozilla` refer to a file named
`globals.js`, but the `globals` NPM package is not actually imported
anywhere.

Given this we should be able to safely get rid of this explicit
dependency on our end now.
2024-07-29 18:16:28 +02:00
Tim van der Meij
300e806efe
Merge pull request #18507 from Snuffleupagus/rm-PDFWorkerUtil
Remove `PDFWorkerUtil` and move its contents into `PDFWorker` instead
2024-07-29 17:45:51 +02:00
Calixte Denizet
ed22d934e5 Implement the new alt text flow (bug 1909604)
For the Firefox pdf viewer, we want to use AI to guess an alt-text when adding an image to a pdf.
For now the telemtry stuff is not implemented and will come soon.
In order to test it locally:
 - set enableAltText, enableFakeMLManager and enableUpdatedAddImage to true.
or in Firefox:
 - set browser.ml.enable, pdfjs.enableAltText and pdfjs.enableUpdatedAddImage to true.
2024-07-29 14:31:47 +02:00
Jonas Jenwald
c4fdb28573 Remove PDFWorkerUtil and move its contents into PDFWorker instead
This is possible thanks to features, i.e. private fields and in particular static initialization blocks, that didn't exist back when we started using classes in the code-base.
2024-07-29 11:22:43 +02:00
Tim van der Meij
582866ee50
Merge pull request #18506 from timvandermeij/updates
Update dependencies to the most recent versions
2024-07-28 19:56:54 +02:00
Tim van der Meij
100fafa9fb
Disable the WebDriver BiDi protocol for Chrome
This should avoid the timeouts and OOM issues we have on the Linux bot,
which started since PR #18473.
2024-07-28 17:37:11 +02:00
Tim van der Meij
b4f368c180
Upgrade eslint-plugin-unicorn to version 55.0.0
This is a major version bump, but the changelog at
https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v55.0.0
doesn't indicate any breaking changes that should impact us.
2024-07-28 17:26:49 +02:00
Tim van der Meij
69d3186745
Update dependencies to the most recent versions 2024-07-28 17:26:45 +02:00
Tim van der Meij
2eea0c8cf3
Merge pull request #18505 from Snuffleupagus/ci-rm-Node-21
Stop testing in Node.js 21 since it's reached end-of-life
2024-07-28 13:33:11 +02:00
Jonas Jenwald
70bc136ea6 Stop testing in Node.js 21 since it's reached end-of-life
According to https://github.com/nodejs/release?tab=readme-ov-file#end-of-life-releases Node.js 21 stopped being supported on 2024-06-01, which is almost two months ago now, hence it seems pointless to keep testing in that environment.
2024-07-28 13:15:43 +02:00
Tim van der Meij
0ef1132563
Merge pull request #18504 from Snuffleupagus/issue-18503
Ignore non-dictionary nodes when parsing StructTree data (issue 18503)
2024-07-28 13:06:08 +02:00
Jonas Jenwald
c4cd405a8f Ignore non-dictionary nodes when parsing StructTree data (issue 18503) 2024-07-28 12:08:44 +02:00
Tim van der Meij
6f9fc70926
Merge pull request #18481 from nicolo-ribaudo/fix-selection-with-links
Disable link annotations during text selection
2024-07-28 12:08:38 +02:00
Tim van der Meij
d3384c0e3c
Merge pull request #18501 from Snuffleupagus/AppOptions-init
Initialize all user-options upfront in AppOptions
2024-07-28 11:09:11 +02:00
Tim van der Meij
0ed4521ad5
Merge pull request #18502 from Snuffleupagus/base_factory-shorter-errors
Shorten the errors mentioning API parameters in `BaseCMapReaderFactory` and `BaseStandardFontDataFactory`
2024-07-27 20:48:39 +02:00
Jonas Jenwald
d116ab1a22 Shorten the errors mentioning API parameters in BaseCMapReaderFactory and BaseStandardFontDataFactory
The current error-messages also mention internal parameters, which an end-user obviously don't have to care about. So, let's try to avoid confusion here by only including the API parameters.
2024-07-27 16:54:54 +02:00
Jonas Jenwald
935d9047fc Initialize all user-options upfront in AppOptions
- Initialize all user-options upfront, to allow getting the options without having to check if they exist first. (This is easier to implement after PR 18475 landed.)

 - Move the user-options into a private field in `AppOptions`. (This code is old enough to pre-date general availability of that class feature.)

 - Move code/methods limited to GENERIC-builds into `AppOptions`.
2024-07-27 14:16:09 +02:00
Tim van der Meij
8378c40f4c
Merge pull request #18500 from timvandermeij/bump
Bump the stable version in `pdfjs.config`
2024-07-27 14:10:16 +02:00
Tim van der Meij
33d1506c50
Bump the stable version in pdfjs.config 2024-07-27 14:06:52 +02:00
Jonas Jenwald
3a21f03b07
Merge pull request #18495 from Snuffleupagus/AppOptions-setAll-EVENT_DISPATCH
Consistently dispatch events, if needed, when setting AppOptions
2024-07-27 10:55:58 +02:00
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
calixteman
2efa3e460c
Merge pull request #18493 from calixteman/fix_utf16_alt_text
[Editor] Correctly save a non-ascii alt text
2024-07-24 19:59:22 +02:00
Calixte Denizet
c3065629ca [Editor] Correctly save a non-ascii alt text 2024-07-24 19:13:45 +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
Tim van der Meij
1c65ad3adc
Merge pull request #18483 from timvandermeij/streamqueue
Remove the `streamqueue` dependency
2024-07-23 15:46:51 +02:00
Nicolò Ribaudo
64a0e59662
Disable link annotations during text selection
When selecting text, hovering over an element
causes all the text between (according the the dom
order) the current selection and that element to
be selected.

This means that when, while selecting, the cursor
moves over a link, all the text in the page gets
selected. Setting `user-select: none` on the link
annotations would improve the situation, but it
still makes it impossible to extend the selection
within a link without using Shift+arrows keys on
the keyboard.

This commit fixes the problem by setting
`pointer-events: none` on the `<section>`s in the
annotation layer while selecting some text. This
way, they are ignored for hit-testing and do not
affect selection.

It is still impossible to _start_ a selection
inside a link, as the link text is covered by the
link annotation.

Fixes #18266
2024-07-23 10:42:34 +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
Tim van der Meij
1b9981cd92
Remove the streamqueue dependency
The `streamqueue` dependency is only used for the test targets in the
Gulpfile to make sure that the test types are run in series. This is
done by modelling the test processes as readable streams and then having
`streamqueue` combine them into a single readable stream for Gulp that
processes the inner readable streams in series (in contrast to the
`ordered-read-streams` dependency which is very similar but processes
the inner streams in parallel).

However, modelling the test processes as readable streams is a bit odd
because we're not actually streaming any data as one might expect.
Instead, we only use them to signal test process completion/abortion.

Fortunately nowadays, with modern Gulp versions, we don't need readable
streams and `streamqueue` anymore because we can achieve the same result
with simple asynchronous functions that can be passed to e.g.
`gulp.series()` calls. Note that we already do this in various places,
and overall it should be a better fit for test process invocations.
2024-07-22 20:27:31 +02:00
Tim van der Meij
5184a38e3d
Merge pull request #18480 from Snuffleupagus/AppOptions-optional-type
Add better support for AppOptions with multiple types (PR 18465 follow-up)
2024-07-22 18:10:29 +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
Tim van der Meij
deaac2839e
Merge pull request #18476 from Snuffleupagus/viewer-mv-docBaseUrl
Re-factor how the "docBaseUrl" API-option is set in the viewer
2024-07-22 17:29:18 +02:00
calixteman
91655aae7f
Merge pull request #18467 from calixteman/issue18466
Use a transparent color when setting fill/stroke colors in a pattern context but with no colorspace
2024-07-22 12:23:57 +02:00
Calixte Denizet
482994cc04 Use a transparent color when setting fill/stroke colors in a pattern context but with no colorspace 2024-07-22 09:56:10 +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
422b3e4a4a
Merge pull request #18468 from calixteman/dont_throw_with_invalid_cs
Fallback on DeviceGray when a colorspace cannot be parsed
2024-07-21 20:53:46 +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
Calixte Denizet
71bae38afb Fallback on DeviceGray when a colorspace cannot be parsed 2024-07-21 17:56:31 +02:00