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

19983 commits

Author SHA1 Message Date
Jonas Jenwald
c0bf3d3c94 [Editor] Remove event listeners with AbortSignal.any()
There's a fair number of event listeners in the editor-code that we're currently removing "manually", by keeping references to their event handler functions.
This was necessary since we have a "global" `AbortController` that applies to all event listeners used in the editor-code, however it's now possible to combine multiple `AbortSignal`s; please see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static

Since this functionality is [fairly new](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static#browser_compatibility) the viewer will check that `AbortSignal.any()` is available before enabling the editing-functionality.
(It should hopefully be fairly straightforward, famous last words, for users to implement a polyfill to allow editing in older browsers.)

Finally, this patch also adds checks and test-only asserts to ensure that we don't add duplicate event listeners in various editor-code.
2024-08-09 11:24:34 +02:00
Calixte Denizet
bad214fc71 [Editor] Change the background color of the image preview in the new alt text dialog 2024-08-08 21:13:58 +02:00
Tim van der Meij
4569e88778
Merge pull request #18568 from timvandermeij/css-findbar
Group and scope the findbar rules using CSS nesting
2024-08-08 20:27:14 +02:00
Tim van der Meij
fb049b0a05
Merge pull request #18583 from timvandermeij/eslint-plugin-mozilla
Remove the `eslint-plugin-mozilla` dependency
2024-08-08 20:26:52 +02:00
Tim van der Meij
be93d530de
Remove the eslint-plugin-mozilla dependency
We only used two rules from the plugin which can both easily be replaced
nowadays:

- `mozilla/avoid-removeChild` is equal to the already active
  `unicorn/prefer-dom-node-remove` rule; please see [1] and [2].
- `mozilla/import-globals` is mostly obsolete nowadays ever since we
  removed the Firefox extension code from this repository and we
  eliminated most globals usage. The three remaining occurrences can be
  replaced with explicit `/* globals */` comments that we already use
  elsewhere, which overall is also more consistent.

[1] https://firefox-source-docs.mozilla.org/code-quality/lint/linters/eslint-plugin-mozilla/rules/avoid-removeChild.html
[2] https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-remove.md
2024-08-08 19:51:20 +02:00
Tim van der Meij
1fcdcedee1
Group and scope the findbar rules using CSS nesting
The findbar CSS rules predate the general availability of CSS nesting,
which makes them more difficult to understand and change safely. The
primary issues are that the findbar rules are spread all over the
`viewer.css` file, they share blocks with non-findbar elements and the
scope of the rules is sometimes bigger than necessary.

This refactoring groups all findbar-related CSS rules together, scoped
to the top-level `#findbar` element, for improved overview and
isolation. Note that this patch only intends to move the existing rules
around and not change any behavior yet, but it does lay the foundation
for e.g. making the findbar respect the `browser.uidensity` preference
in Firefox in follow-up work.

Co-authored-by: Calixte Denizet <calixte.denizet@gmail.com>
2024-08-08 19:19:32 +02:00
Tim van der Meij
cd3d188f99
Merge pull request #18571 from timvandermeij/linting
Enable the `unicorn/{prefer-includes,throw-new-error}` linting rules
2024-08-08 19:18:26 +02:00
Tim van der Meij
318433b2d8
Enable the unicorn/throw-new-error linting rule
For more information refer to
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md.

This didn't require any changes because we already do this correctly,
but it ensures that new code remains consistent and explicit.
2024-08-08 19:03:07 +02:00
Tim van der Meij
ad95df2214
Enable the unicorn/prefer-includes linting rule
For more information refer to
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md.

Fortunately this only required one change because we already use
`.includes()` everywhere else. Note that that is mostly due to the
`mozilla/use-includes-instead-of-indexOf` rule which we replace with
this new rule now because it's more complete.
2024-08-08 19:01:35 +02:00
calixteman
40aa593b1f
Merge pull request #18580 from calixteman/alt_text_pass_buffer
[Editor] Pass a buffer instead of a typed array when passing image data to the model
2024-08-08 14:48:27 +02:00
Calixte Denizet
d2e8e742eb [Editor] Pass a buffer instead of a typed array when passing image data to the model 2024-08-08 14:43:36 +02:00
calixteman
999403f5ef
Merge pull request #18579 from calixteman/cancel_ai_requests_2
Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)
2024-08-07 23:26:37 +02:00
Calixte Denizet
1d51c3e711 Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)
The user can change a setting in a tab and it must have an effect in the current viewer.
2024-08-07 23:21:38 +02:00
calixteman
e099840100
Merge pull request #18578 from mozilla/revert-18573-cancel_ai_requests
Revert "[Editor] Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)"
2024-08-07 23:14:11 +02:00
calixteman
6c005eabb3
Revert "[Editor] Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)" 2024-08-07 23:11:31 +02:00
calixteman
fef2853263
Merge pull request #18573 from calixteman/cancel_ai_requests
[Editor] Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)
2024-08-07 23:11:04 +02:00
Calixte Denizet
92ade5495b [Editor] Dispatch changes in prefs enableAltTextModelDownload and enableGuessAltText to the viewer (bug 1912024)
The user can change a setting in a tab and it must have an effect in the current viewer.
2024-08-07 22:45:08 +02:00
calixteman
5709b1300d
Merge pull request #18575 from calixteman/ai_disclaimer_icon_position
[Editor] Move the AI icon on the top of its parent div
2024-08-07 19:22:29 +02:00
calixteman
3cad8d1c27
Merge pull request #18574 from calixteman/add_window_uimanager_test
[Editor] Add the uiManager to the window object when testing
2024-08-07 19:17:24 +02:00
Calixte Denizet
f487ed3004 [Editor] Move the AI icon on the top of its parent div
And fix the line-height for all the dialog (which is "normal" in the specs).
Because of the wrong line-height, the icon was slightly misplaced.
2024-08-07 18:50:59 +02:00
Calixte Denizet
e037c5711d [Editor] Add the uiManager to the window object when testing 2024-08-07 18:06:14 +02:00
Tim van der Meij
341a0b6d47
Merge pull request #18566 from calixteman/issue18561
Don't stop calculating field values when a Calculate callback throws
2024-08-06 17:59:15 +02:00
Tim van der Meij
af012c7872
Merge pull request #18567 from timvandermeij/integration-test-otherpages
Remove obsolete `otherPages` variable from the scripting integration tests
2024-08-06 17:23:36 +02:00
calixteman
18284815e7
Merge pull request #18570 from calixteman/new_alt_text_string_change
[Editor] Update the disclaimer string in the new alt-text dialog (bug 1911738)
2024-08-06 14:09:11 +02:00
Calixte Denizet
fc602c65c0 [Editor] Update the disclaimer string in the new alt-text dialog (bug 1911738)
And tweak the css in order to take into account that disclaimer can be on two (or more lines).
2024-08-06 10:17:18 +02:00
Calixte Denizet
ad12f33999 Don't stop calculating field values when a Calculate callback throws
It fixes #18561.
2024-08-05 20:36:04 +02:00
Tim van der Meij
b7b0735192
Remove obsolete otherPages variable from the scripting integration tests
It looks like this has accidentally been copy/pasted from the
`Textfields and focus` block, which is the only one in which a test
actually uses it. We can therefore safely remove it from all other
blocks where no test uses it.
2024-08-05 19:23:39 +02:00
Tim van der Meij
9ac05e797c
Merge pull request #18560 from Snuffleupagus/editor-bind-event-handlers
Define a few editor event handler functions inline
2024-08-05 18:34:36 +02:00
Tim van der Meij
7c896578c2
Merge pull request #18555 from timvandermeij/waitforevent
Use the `waitForEvent` helper function in the text layer integration tests
2024-08-05 18:23:56 +02:00
Tim van der Meij
9844ce01b3
Merge pull request #18554 from timvandermeij/updates
Update dependencies to the most recent versions
2024-08-05 18:19:11 +02:00
Jonas Jenwald
d32b294a60
Merge pull request #18562 from nicolo-ribaudo/babel-static-block
Update the Babel plugin to remove empty static blocks
2024-08-05 16:19:25 +02:00
Nicolò Ribaudo
995f5a29aa
Update the Babel plugin to remove empty static blocks
This commit updates the Babel plugin to:
- apply the same flattening logic that we already
  have for blocks, to flatten blocks nested inside
  class static blocks
- remove class static blocks when, after flattening
  all the blocks they contain, they are empty.

Before this commit, the transform output was the
same as the input.
2024-08-05 15:14:05 +02:00
Jonas Jenwald
0eac5e9d6f Define a few editor event handler functions inline
Given that we're removing event listeners with `AbortSignal` it's no longer necessary to keep a reference to a few of the event handler functions in order to remove them.
Hence we can simply inline the relevant `bind`-calls instead, which reduces the code-size a tiny bit.
2024-08-05 12:27:53 +02:00
Tim van der Meij
356d54175b
Use the waitForEvent helper function in the text layer integration tests
The `waitForClick` helper function is functionality-wise mostly a
reduced copy of the more generic `waitForEvent` helper function that
we use for other integration tests, so we can safely replace it to
reduce the amount of code.

Moreover, the `waitForClick` code is prone to intermittent failures
given recent assertion failures we have seen on the bots (one of them
is linked in #18396) while `waitForEvent` has recently been fixed to
avoid intermittent failures, so usiong it should also get rid of the
flakiness for these integration tests.
2024-08-04 20:14:43 +02:00
Tim van der Meij
f7d2145782
Upgrade postcss-nesting to version 13.0.0
This is a major version bump, but the changelog at
https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-nesting/CHANGELOG.md
doesn't indicate any breaking changes that should impact us.
2024-08-04 19:24:43 +02:00
Tim van der Meij
1dfdb59f0b
Upgrade postcss-dir-pseudo-class to version 9.0.0
This is a major version bump, but the changelog at
https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-dir-pseudo-class/CHANGELOG.md
doesn't indicate any breaking changes that should impact us.
2024-08-04 19:23:10 +02:00
Tim van der Meij
762b16c08a
Update dependencies to the most recent versions 2024-08-04 19:20:36 +02:00
calixteman
c60c0d1c6d
Merge pull request #18552 from calixteman/issue18536
Empty fields are 0 when using AFSimple_Calculate
2024-08-03 15:10:22 +02:00
Calixte Denizet
4b7f9a8d87 Empty fields are 0 when using AFSimple_Calculate
It fixes #18536 and #18532.
2024-08-02 21:51:27 +02:00
Jonas Jenwald
829c9f553d
Merge pull request #18551 from Snuffleupagus/rm-viewer-download-options
Stop sending the unused `options` parameter to various download-methods in the viewer
2024-08-02 21:10:10 +02:00
Jonas Jenwald
ecbd660609 Stop sending the unused options parameter to various download-methods in the viewer
The `options` handling, for the download-methods, was originally added in PR 16391 and became obsolete in PR 17771.

This fixes failures, in mozilla-central tests, which appeared after landing PR 18527.
2024-08-02 20:46:13 +02:00
calixteman
a372bf8f4d
Merge pull request #18541 from calixteman/use_ml_but_no_dialog
[Editor] Guess alt text even when showing the dialog is disabled
2024-08-02 18:02:53 +02:00
Tim van der Meij
7ac87dd6f8
Merge pull request #18544 from Snuffleupagus/app-bind-listeners
Improve the larger event listeners in the `web/app.js` file
2024-08-02 17:56:19 +02:00
Calixte Denizet
d2c519e57a Guess alt text even when showing the dialog is disabled 2024-08-02 17:40:10 +02:00
calixteman
c8ba7b02b0
Merge pull request #18546 from calixteman/load_model_switch_stamp
[Editor] Load the model when the user switch to the stamp editing mode
2024-08-02 17:21:26 +02:00
Calixte Denizet
a81b071d2d [Editor] Load the model when the user switch to the stamp editing mode 2024-08-02 17:14:09 +02:00
Jonas Jenwald
aae223f79b Replace onScrollModeChanged and onSpreadModeChanged with one function
Given that these event handlers are virtually identical, obviously with the exception of the name-parameter, let's reduce a little bit of code duplication.
2024-08-02 16:16:25 +02:00
Jonas Jenwald
22ec252193 Improve the larger event listeners in the web/app.js file
- Shorten the names of the event listeners.

 - Use `bind` to pass in the `PDFViewerApplication`-scope to the event handlers.
   This makes the event handler code (a lot) less verbose, and this change is possible now that we're removing event listeners with `AbortSignal`.

 - Move the GENERIC-only event listeners into the same pre-processor block.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `~4.3` kilo-bytes, which isn't a lot but still cannot hurt.
2024-08-02 16:16:25 +02:00
Tim van der Meij
b80e552760
Merge pull request #18527 from Snuffleupagus/app-inline-short-listeners
Inline single-line event handlers in the `web/app.js` file
2024-08-02 16:08:45 +02:00
Tim van der Meij
5e052af3f6
Merge pull request #18542 from Snuffleupagus/bug-report-browser-description
Link to the list of supported browsers in the bug report template
2024-08-02 15:55:26 +02:00