Commit Graph

17647 Commits

Author SHA1 Message Date
Tim van der Meij
1ef6fbc525
Merge pull request #16768 from Snuffleupagus/pr-15335-followup
Ensure that failing to open the password dialog once won't permanently disable it (PR 15335 follow-up)
2023-07-30 12:18:49 +02:00
Jonas Jenwald
930cbc4d27 Make the passwordCapability field, in WorkerTransport, actually private as intended 2023-07-30 11:45:35 +02:00
Jonas Jenwald
81dfa61777 Ensure that failing to open the password dialog once won't permanently disable it (PR 15335 follow-up)
*Please note:* This situation should never happen in practice, but it nonetheless cannot hurt to fix this.

If the `PasswordPrompt.open` method would ever be called synchronously back-to-back *and* if opening of the dialog fails the first time, then the second invocation would remain pending indefinitely since we just clear out the capability.
2023-07-30 08:46:11 +02:00
Tim van der Meij
7ae5a0fef7
Merge pull request #16731 from Snuffleupagus/rm-useOnlyCssZoom
[api-minor] Replace the `useOnlyCssZoom` option with `maxCanvasPixels = 0` instead (PR 16729 follow-up)
2023-07-29 14:07:45 +02:00
Jonas Jenwald
0ee2a352ec [api-minor] Replace the useOnlyCssZoom option with maxCanvasPixels = 0 instead (PR 16729 follow-up)
Given that the `useOnlyCssZoom` option is essentially just a special-case of the `maxCanvasPixels` functionality, we can combine the two options in order to simplify the overall implementation.
Note that the `useOnlyCssZoom` functionality was only ever used, by default, in the PDF Viewer for the B2G/FirefoxOS project (which was abandoned years ago).
2023-07-29 13:58:03 +02:00
Tim van der Meij
2a77f0877c
Merge pull request #16765 from Snuffleupagus/bug-858128-test
Add an `eq` test for bug 858128
2023-07-29 13:48:30 +02:00
Tim van der Meij
aea13b4478
Merge pull request #16744 from Snuffleupagus/app-small-simplifications
A few small `web/app.js` simplifications
2023-07-29 13:41:01 +02:00
Jonas Jenwald
69a9d777d7 Add an eq test for bug 858128
The ten year old bug 858128 was recently fixed upstream, see https://bugzilla.mozilla.org/show_bug.cgi?id=858128#c25, and it seems like a good idea for us to add a test-case to help catch any future regressions here.
2023-07-29 12:37:58 +02:00
calixteman
cfd179f23f
Merge pull request #16163 from Snuffleupagus/bug-1810111
[GeckoView] Bundle the Firefox printing code in the viewer (bug 1810111)
2023-07-28 14:28:57 +02:00
Jonas Jenwald
e77c7f336d [GeckoView] Bundle the Firefox printing code in the viewer (bug 1810111)
This may not be enough, on its own, to completely fix [bug 1810111](https://bugzilla.mozilla.org/show_bug.cgi?id=1810111) however it's impossible for printing to work in GeckoView without this patch.
2023-07-28 14:10:40 +02:00
calixteman
0b715e2a73
Merge pull request #16762 from calixteman/editor_focus
[Editor] When an editor is unselected give the focus to the current page
2023-07-27 21:31:24 +02:00
Calixte Denizet
9d576d5097 [Editor] When an editor is unselected give the focus to the current page
Follow-up of #16756.
2023-07-27 21:12:26 +02:00
Jonas Jenwald
0ad5a5551a
Merge pull request #16760 from Snuffleupagus/issue-16759
Avoid eagerly matching "trailer"-strings when searching for incomplete objects in `XRef.indexObjects` (issue 16759, PR 15854 follow-up, bug 1845762)
2023-07-27 18:39:50 +02:00
Jonas Jenwald
d6c0950389 Avoid eagerly matching "trailer"-strings when searching for incomplete objects in XRef.indexObjects (issue 16759, PR 15854 follow-up, bug 1845762)
When searching for "endobj"-operators, make sure that we don't accidentally match a "trailer"-string in /Content-streams without /Filter-entries (i.e. streams that contain "raw" and thus human-readable data).
2023-07-27 17:57:12 +02:00
Jonas Jenwald
5560643597
Merge pull request #16758 from Snuffleupagus/cMapUrl-standardFontDataUrl-validation
Tweak the `useWorkerFetch` default value checks (PR 15879 follow-up)
2023-07-27 17:52:57 +02:00
calixteman
8679199a2f
Merge pull request #16756 from calixteman/editor_blur_unselected
[Editor] Blur unselected editors
2023-07-27 16:57:20 +02:00
Jonas Jenwald
c09bd5568c Tweak the useWorkerFetch default value checks (PR 15879 follow-up)
Currently we accidentally accept `cMapUrl` and `standardFontDataUrl` parameters that are empty strings or `null`, since e.g. `new URL(null, document.baseURI)` doesn't throw, when validating the `useWorkerFetch` parameter via the `isValidFetchUrl` helper function.
Please note that we are currently failing gracefully in this case, as intended, however the warning-messages printed in the console are perhaps less helpful without this patch.
2023-07-27 16:26:39 +02:00
Calixte Denizet
59bcfd9b9e [Editor] Blur unselected editors
When an editor is selected in using the keyboard then it has the focus.
But then if the editor is unselected with Escape key then the focus must
be removed otherwise we still have a blue outline around it.
And add few missing timeout in the integration tests.
2023-07-27 16:26:38 +02:00
Jonas Jenwald
611acf52c4
Merge pull request #16755 from Snuffleupagus/_keyboardManager-proto
[Editor] Reduce a bit of duplication on `_keyboardManager` initialization
2023-07-27 12:43:11 +02:00
Jonas Jenwald
2fbfd9517f Remove the unneeded error-handling at the end of PDFViewerApplication.run
This is quite old code, however the error-handling no longer seems necessary for a couple of reasons:
 - The `PDFViewerApplication.open` method is asynchronous, which means that it cannot throw a "raw" `Error` and the try-catch is not needed in that case.
 - None of the other affected methods should throw, and if they do that'd rather indicate an *implementation* error in the code.
 - Finally, and most importantly, with the `PDFViewerApplication.run` method now being asynchronous an (unlikely) `Error` thrown within it will lead to a rejected `Promise` and not affect execution of other code.
2023-07-27 12:14:14 +02:00
Jonas Jenwald
ecf95e552f Simplify handling of any ViewHistory errors during document loading in the viewer
We can use modern JavaScript features, in this case optional chaining, to (ever so slightly) simplify how `ViewHistory` errors are handled.

Also, use arrow functions when handling a few other (very rare) errors during loading since that's a tiny bit shorter.
2023-07-27 12:12:19 +02:00
Jonas Jenwald
34f2e7d4f9 [Editor] Reduce a bit of duplication on _keyboardManager initialization
The way that the callback-methods are specified feels unnecessarily verbose, however we can introduce a short-hand to improve this.

Also, adds a couple of new-lines to improve overall readability.
2023-07-27 11:42:01 +02:00
calixteman
82faae26c0
Merge pull request #16750 from calixteman/editor_keeboard_freetext
[Editor] Add the possibility to move an empty freetext editor with the keyboard (bug 1845088)
2023-07-27 11:38:17 +02:00
Jonas Jenwald
ef776eaacd
Merge pull request #16753 from Snuffleupagus/eslint-prefer-ternary
Enable the `unicorn/prefer-ternary` ESLint plugin rule
2023-07-27 10:39:12 +02:00
Calixte Denizet
93b09f6320 [Editor] Add the possibility to move an empty freetext editor with the keyboard (bug 1845088) 2023-07-27 09:56:26 +02:00
Jonas Jenwald
c0fe96b8fe Additional *manual* unicorn/prefer-ternary changes
Not all cases could be automatically fixed, and the changes also triggered a number of `prefer-const` errors that needed to be handled manually.
2023-07-27 09:48:24 +02:00
Jonas Jenwald
674e7ee381 Enable the unicorn/prefer-ternary ESLint plugin rule
To limit the readability impact of these changes, the `only-single-line` option was used; please find additional details at https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-ternary.md

These changes were done automatically, using the `gulp lint --fix` command.
2023-07-27 09:18:26 +02:00
calixteman
8f83a1359e
Merge pull request #16749 from calixteman/editor_mac_shortcut
[Editor] Use the same keyboard shortcut as in Preview to move an editor on mac
2023-07-26 21:40:20 +02:00
Calixte Denizet
9078587422 [Editor] Use the same keyboard shortcut as in Preview to move an editor on mac 2023-07-26 21:23:38 +02:00
calixteman
7f634e468f
Merge pull request #16746 from calixteman/editor_keyboard_movable
[Editor] Make editors movable in using the keyboard (bug 1845088)
2023-07-26 21:17:15 +02:00
Calixte Denizet
bb6936c931 [Editor] Make editors movable in using the keyboard (bug 1845088)
Selected editors can be moved in using the arrows:
 - up/down/left/right will move the editors of 1 in page unit;
 - ctrl (or meta)+up/down/left/right will move them of 10 in page unit.
2023-07-26 21:05:26 +02:00
calixteman
a2eca47ed1
Merge pull request #16748 from calixteman/hcm_toolbar_button
Improve rendering of buttons in the toolbar in HCM (bug 1845515)
2023-07-26 17:20:38 +02:00
Calixte Denizet
7ce4e288e1 Improve rendering of buttons in the toolbar in HCM (bug 1845515)
With this patch, in HCM, make a button visible when it's active and
add an outline around toggled buttons when they're hovered.
2023-07-26 16:49:55 +02:00
calixteman
48cc67f17e
Merge pull request #16741 from calixteman/editor_no_ed_when_pinching
[Editor] Avoid to trigger an editor creation when pinching on a touchscreen
2023-07-25 20:25:30 +02:00
calixteman
e40fd171e9
Merge pull request #16740 from calixteman/editor_keyevent_on_window
[Editor] Set keyboard events on window instead of the main container
2023-07-25 19:54:29 +02:00
Jonas Jenwald
7448e89d1f
Merge pull request #16738 from Snuffleupagus/debugger-import
Re-factor how the `debugger` accesses API-functionality
2023-07-25 19:31:15 +02:00
Calixte Denizet
6b545d666e [Editor] Avoid to trigger an editor creation when pinching on a touch screen 2023-07-25 19:00:05 +02:00
Calixte Denizet
76caaab195 [Editor] Set keyboard events on window instead of the main container
The keyboard shortcuts (copy, paste, ...) didn't work correctly when the
main container was not focused.
This patch adds few waitForTimeout in the integration test for FreeText
in order to avoid possible intermittent failures.
2023-07-25 18:38:31 +02:00
calixteman
86165a7ba6
Merge pull request #16737 from calixteman/insets
[Editor] Use inset instead of top/left in css
2023-07-25 15:17:29 +02:00
Jonas Jenwald
690adb093e Re-factor how the debugger accesses API-functionality
Given that the `debugger` is loaded as a module we can use "top level await" in development mode to access the necessary API-functionality, which removes the need to manually pass in the required properties.
2023-07-25 15:08:02 +02:00
Calixte Denizet
84e6154b0f [Editor] Use inset instead of top/left in css 2023-07-25 15:05:35 +02:00
calixteman
e00629966d
Merge pull request #16732 from calixteman/editor_resize
[Editor] Add some resizers all around an editor (bug 1843302)
2023-07-25 14:17:09 +02:00
Calixte Denizet
2688bf2ebd [Editor] Add some resizers all around an editor (bug 1843302)
- it'll improve the way to resize images: diagonally (in keeping ratio between dimensions)
  or horizontally/vertically.
- the resizer was almost invisible in HCM.
- make a resize undoable/redoable.
2023-07-25 13:53:30 +02:00
Jonas Jenwald
24d01ec682
Merge pull request #16735 from Snuffleupagus/reduced-Planck-constant-copy
Fix copying of the reduced Planck constant
2023-07-24 21:57:12 +02:00
calixteman
f508084c21
Merge pull request #16736 from calixteman/editor_avoid_text_selection
[Editor] Avoid spurious text selection when double clicking to add a FreeText
2023-07-24 21:03:45 +02:00
Calixte Denizet
3f58e25961 [Editor] Avoid spurious text selection when double clicking to add a FreeText
In order to reproduce the original issue:
 - switch to freetext mode
 - add a text somewhere
 - double click outside and add some text
 - repeat the previous step several times

no text is selected during the edition.
2023-07-24 19:38:00 +02:00
Jonas Jenwald
3b6d2554a8 Fix copying of the reduced Planck constant
Please see https://en.wikipedia.org/wiki/H_with_stroke
2023-07-24 18:42:46 +02:00
Jonas Jenwald
fb3ae82820
Merge pull request #16733 from Snuffleupagus/node-polyfills-catch
[api-minor] Attempt to prevent Node.js-specific polyfill errors from completely breaking the library
2023-07-24 14:50:56 +02:00
Jonas Jenwald
d188b66af6 [api-minor] Attempt to prevent Node.js-specific polyfill errors from completely breaking the library
The existing Node.js-specific polyfills depend on the `node-canvas` package, which has unfortunately (repeatedly) shown to cause trouble for many users. We attempted to improve the situation by listing the relevant packages as `optionalDependencies`, but that didn't seem to really fix the problem.

With this patch the library should be able to load in Node.js-environments even if polyfilling fails, and any errors will instead occur during rendering. Obviously this is *not* a proper solution, since it basically moves the problem to another part of the code-base.
However for certain "simpler" use-cases, such as e.g. text-extraction, these changes should hopefully improve general usability of the PDF.js library in Node.js-environments.

*Please note:* For most PDF documents rendering should still work though, since `DOMMatrix` is *currently* only used with Patterns and `Path2D` only with Type3-fonts and Patterns.
2023-07-24 13:00:34 +02:00
calixteman
71f113bf85
Merge pull request #16718 from calixteman/bug1844572
Don't replace Acroform dictionary if nothing has changed when saving (bug 1844572)
2023-07-24 10:00:43 +02:00