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

4595 commits

Author SHA1 Message Date
Jonas Jenwald
221eba29b9 Don't close the secondaryToolbar when clicking inside it (PR 18385 follow-up)
When the DOM structure of the viewer was updated in PR 18385 it caused the `secondaryToolbar` to accidentally start closing when clicking inside of it, since the `secondaryToolbar` now reside *under* the `toolbar` in the DOM.

**Steps to reproduce:**
 - Open the viewer.
 - Open the `secondaryToolbar`.
 - Try to change document rotation at least *twice*.

**Expected behaviour:**
 The document rotation can be changed an arbitrary number of times.

**Actual results:**
 The `secondaryToolbar` closes after changing rotation just once.
2025-03-11 19:26:23 +01:00
calixteman
febf59ce75
Merge pull request #19636 from calixteman/bug1952558
[Editor] Make sure the save checkbox isn't focusable when saving is disabled (bug 1952558)
2025-03-10 18:46:40 +01:00
Calixte Denizet
69a2e5137d [Editor] Make sure the save checkbox isn't focusable when saving is disabled (bug 1952558)
And fix the the width of the warning message when the limit of signatures has been reached:
in french the string is longer than the dialog's one.
2025-03-10 18:08:42 +01:00
calixteman
13474aca63
Merge pull request #19620 from calixteman/cmyk_icc
[api-minor] Use an icc profile for converting CMYK to RGB
2025-03-10 16:55:48 +01:00
Calixte Denizet
7280540901 [api-minor] Use an icc profile for converting CMYK to RGB 2025-03-10 14:18:20 +01:00
Jonas Jenwald
fc22d3afc7 Support the maxCanvasPixels option in the thumbnails code
This addresses an inconsistency in the viewer, since the thumbnails don't respect the `maxCanvasPixels` option.
Note that, as far as I know, this has not lead to any bugs since the thumbnails render with a fixed (and small) width, however it really cannot hurt to address this (especially after the introduction of the `maxCanvasDim` option).

To support this a new `OutputScale`-method was added, to avoid having to duplicate code in multiple files.
2025-03-10 14:12:07 +01:00
Jonas Jenwald
1bc98dfbd9
Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
2025-03-10 11:32:08 +01:00
Nicolò Ribaudo
a1dc46aa9d
Do not constantly render the detail canvas on zoom
When zooming, we should skip rendering the detail canvas until the
zoom is done, similarly to how normal page rendering is delayed.
To do so is enough to skip details view while zooming, since the
main view rendering that already happens after the delay will also
trigger rendering of the detail views.
2025-03-07 12:38:52 +01:00
Jonas Jenwald
eef15a30cd Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
The changes in PR 19604 weren't enough for thumbnail canvases in some cases, see e.g. https://web.archive.org/web/20231204152348if_/https://user.informatik.uni-bremen.de/cabo/rfc9000.pdf#pagemode=thumbs
2025-03-06 23:00:20 +01:00
Jonas Jenwald
07bbbf75a5 Introduce a helper function for clamping a value to a range
Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using `Math.min`/`Math.max` or with a local helper function, which leads to some unnecessary duplication.

Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.
2025-03-06 14:05:26 +01:00
Jonas Jenwald
9f9de4508c [api-minor] Limit the maximum canvas width/height, in addition to its total area (bug 1943094)
Browsers not only limit the maximum total canvas area, but additionally also limit their maximum width/height which affects PDF documents with e.g. very tall and narrow pages.
To address this we add a new `maxCanvasDim` viewer-option, which in Firefox will use a browser preference, such that both the total canvas area and the width/height will affect when CSS-zooming is used.
2025-03-04 15:23:45 +01:00
Jonas Jenwald
3cd1b10433
Merge pull request #19576 from nicolo-ribaudo/fix-linkannotation
Fix autolinking with highlighted search results
2025-03-02 19:51:15 +01:00
Nicolò Ribaudo
b47d81536c
Fix autolinking with highlighted search results
The current logic assumes that all spans in the text layer contain
only one text node, and thus that the position information
returned by `highlighter._convertMatches` can be directly used
on the element's only child.

This is not true in case of highlighted search results: they will be
injected in the DOM as `<span>` elements, causing the `<span>`s
in the text layer to have more than one child.

This patch fixes the problem by properly converting the (span, offset)
pair in a (textNode, offset) pair that points to the right text node.
2025-03-02 17:09:58 +01:00
Tim van der Meij
146bc58f32
Merge pull request #19596 from Snuffleupagus/Array-methods-arrow-functions
Use arrow function with various Array methods
2025-03-02 16:09:09 +01:00
Tim van der Meij
be6ef64a2c
Merge pull request #19577 from Snuffleupagus/isValidExplicitDest-reuse
Re-use the `isValidExplicitDest` helper function in the worker/viewer
2025-03-02 15:50:54 +01:00
Tim van der Meij
27c82ab8cc
Merge pull request #19568 from Snuffleupagus/FakeMLManager-no-bundle
Don't bundle the `FakeMLManager` class in regular builds
2025-03-02 15:30:03 +01:00
Jonas Jenwald
2e62f426fe Use arrow function with various Array methods
A lot of this is quite old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
2025-03-02 15:19:04 +01:00
Jonas Jenwald
165d90fe26 Re-use the isValidExplicitDest helper function in the worker/viewer
Currently we re-implement the same helper function twice, which in hindsight seems like the wrong decision since that way it's quite easy for the implementations to accidentally diverge.
The reason for doing it this way was because the code in the worker-thread is able to check for `Ref`- and `Name`-instances directly, which obviously isn't possible in the viewer but can be solved by passing validation-functions to the helper.
2025-03-01 12:08:56 +01:00
calixteman
84a5e90a43
Merge pull request #19544 from hecerinc/hecerinc/viewerCssFF
Reenable viewerCssTheme option for Firefox
2025-02-28 21:27:20 +01:00
Jonas Jenwald
7273db2e35 Don't attempt to use auto-linking in XFA documents (PR 19110 follow-up)
Auto-linking requires a normal textLayer which XFA documents obviously don't have, and currently XFA documents cause "pointless" error messages to be logged in the console.
2025-02-28 14:47:48 +01:00
Jonas Jenwald
b5ac96da19 Don't bundle the FakeMLManager class in regular builds
Given that this functionality is only used in the development viewer and in TESTING builds, there's no reason to include this in the regular builds.
2025-02-27 12:59:58 +01:00
Jonas Jenwald
4a48a7ec0f
Merge pull request #19557 from Snuffleupagus/PDFViewer-cleanupTimeouts
Abort various timeouts, in `PDFViewer`, when closing the document (PR 19128 follow-up)
2025-02-27 11:17:02 +01:00
Jonas Jenwald
21829f4157
Merge pull request #19556 from Snuffleupagus/_initializeViewerComponents-more-local-vars
Use more local variables in `PDFViewerApplication._initializeViewerComponents`
2025-02-27 11:16:04 +01:00
calixteman
a4fea2dafd
Merge pull request #19565 from calixteman/signature_fix_telemetry
[Editor] Fix the telemetry for the signature stuff
2025-02-27 10:10:13 +01:00
Calixte Denizet
bbf9bfc3c2 [Editor] Fix the telemetry for the signature stuff 2025-02-27 09:34:31 +01:00
Hector Rincon
4069c3a422 Reenable viewerCssTheme option for Firefox
The `viewerCssTheme` was removed in #17222  and subsequently reenabled in #17293,
but only for Chromium and generic builds. This commit reenables the
function using the new method introduced in #17293.
2025-02-25 22:00:32 -08:00
Jonas Jenwald
d50d3b0b0e Reset #renderError on RenderingCancelledException (PR 19128 follow-up)
This restores the behaviour that existed prior to PR 19128, see e.g. 8727a04ae5/web/pdf_page_view.js (L908-L911), since `RenderingCancelledException` should still overwrite any previously seen Error.
2025-02-25 16:46:01 +01:00
Jonas Jenwald
71ad9fd0b7 Abort various timeouts, in PDFViewer, when closing the document (PR 19128 follow-up)
Looking at recent integration-test logs there's occasionally warnings about trying to invoke `PDFViewer.prototype.update` too late, which probably started with PR 19128 (see log excerpt below).
Given that we already had another timeout before that PR the problem was pre-existing, but it seems to trigger more easily now.

```
JavaScript warning: http://127.0.0.1:42333/build/generic/web/viewer.mjs, line 12668: Script terminated by timeout at:
update@http://127.0.0.1:42333/build/generic/web/viewer.mjs:12668:9
@http://127.0.0.1:42333/build/generic/web/viewer.mjs:12373:12
setTimeout handler*_scrollUpdate@http://127.0.0.1:42333/build/generic/web/viewer.mjs:12371:29
viewAreaElementScrolled@http://127.0.0.1:42333/build/generic/web/viewer.mjs:154:15
FrameRequestCallback*debounceScroll@http://127.0.0.1:42333/build/generic/web/viewer.mjs:140:18
EventListener.handleEvent*watchScroll@http://127.0.0.1:42333/build/generic/web/viewer.mjs:165:19
PDFViewer@http://127.0.0.1:42333/build/generic/web/viewer.mjs:11777:19
_initializeViewerComponents@http://127.0.0.1:42333/build/generic/web/viewer.mjs:15081:23
initialize@http://127.0.0.1:42333/build/generic/web/viewer.mjs:14931:16
async*run@http://127.0.0.1:42333/build/generic/web/viewer.mjs:15227:16
webViewerLoad@http://127.0.0.1:42333/build/generic/web/viewer.mjs:17078:24
@http://127.0.0.1:42333/build/generic/web/viewer.mjs:17082:3
```
2025-02-25 13:11:51 +01:00
Jonas Jenwald
cec32c6177 Use more local variables in PDFViewerApplication._initializeViewerComponents
This, ever so slightly, shortens the code which can never hurt.
2025-02-25 12:33:13 +01:00
Calixte Denizet
9e672ff05e [Editor] Add some telemetry for the signature editor (bug 1945827) 2025-02-24 21:10:04 +01:00
Nicolò Ribaudo
dc5d6aad8a
Avoid degrading scroll performance due to the detail view
When scrolling quickly, the constant re-rendering of the detail view
significantly affects rendering performance, causing Firefox to
not render even the _background canvas_, which is just a static canvas
not being re-drawn by JavaScript.

This commit changes the viewer to only render the detail view while
scrolling if its rendering hasn't just been cancelled. This means that:
- when the user is scrolling slowly, we have enough time to render the
  detail view before that we need to change its area, so the user always
  sees the full screen as high resolution.
- when the user is scrolling quickly, as soon as we have to cancel a
  rendering we just give up, and the user will see the lower resolution
  canvas. When then the user stops scrolling, we render the detail view
  for the new visible area.
2025-02-21 10:00:57 -08:00
Nicolò Ribaudo
458b2ee402
[api-minor] Render high-res partial page views when falling back to CSS zoom (bug 1492303)
When rendering big PDF pages at high zoom levels, we currently fall back
to CSS zoom to avoid rendering canvases with too many pixels. This
causes zoomed in PDF to look blurry, and the text to be potentially
unreadable.

This commit adds support for rendering _part_ of a page (called
`PDFPageDetailView` in the code), so that we can render portion of a
page in a smaller canvas without hiting the maximun canvas size limit.

Specifically, we render an area of that page that is slightly larger
than the area that is visible on the screen (100% larger in each
direction, unless we have to limit it due to the maximum canvas size).
As the user scrolls around the page, we re-render a new area centered
around what is currently visible.
2025-02-21 10:00:55 -08:00
Nicolò Ribaudo
06257f782e
Extract PDFPageViewBase class out of PDFPageView
This base class contains the generic logic for:
- Creating a canvas and showing when appropriate
- Rendering in the canvas
- Keeping track of the rendering state
2025-02-21 09:48:31 -08:00
Jonas Jenwald
e3ea92603d
Merge pull request #19493 from Snuffleupagus/URL-parse
Introduce some `URL.parse()` usage in the code-base
2025-02-21 10:40:32 +01:00
Calixte Denizet
cd94c19f9a [Editor] Fix the color of the labels in the editing doorhangers
The fix in #19522 wasn't correct.
This one should be better.
2025-02-20 19:31:57 +01:00
Calixte Denizet
8be6d744cd [Editor] Fix the outline of a focused button in the doorhanger while navigating with the keyboard
It's a follow-up of #19507.
Without this patch the outline is partially hidden.
2025-02-20 18:33:19 +01:00
Calixte Denizet
b7e65b854b [Editor] Make the editing toolbar buttons text visible when hovered in HCM with Desert theme (bug 1949417) 2025-02-20 15:01:52 +01:00
Calixte Denizet
12ba81718c [Editor] Remove the error panel when the user click on an other tab (bug 1949201) 2025-02-20 14:03:59 +01:00
Ujjwal Sharma
38ab358fb1 Fix autolinking error due to redundant annotations on zooming
Fix an issue where redundant links were being added to the annotation
layer on zooming on the page with the links.
2025-02-19 13:18:31 +01:00
Ujjwal Sharma
70e2873430 Fix autolinking errors due to regex and email validation
Fix some edge cases in the autolinking logic with the regex as well as
validating email domains and add unit tests for them.

Fixes: https://github.com/mozilla/pdf.js/issues/19462
2025-02-19 13:18:31 +01:00
Calixte Denizet
cde7d83319 [Editor] Add a scrollbar to the signature doorhanger when it's overflowing (bug 1948771) 2025-02-17 21:09:56 +01:00
Jonas Jenwald
affce70a09
Merge pull request #19503 from Snuffleupagus/web-rm-some-eslint-disable
Remove a few `eslint-disable` statements in the `web/` folder
2025-02-17 15:21:57 +01:00
Calixte Denizet
b8993cfcc8 [Editor] Add two integration tests for the signature UI 2025-02-17 13:58:54 +01:00
Jonas Jenwald
a2d15ceb84 Remove a few eslint-disable statements in the web/ folder
These cases could be easily re-written to avoid having to disable ESLint rules.
2025-02-17 13:40:09 +01:00
Jonas Jenwald
c2e33307b1 Introduce some URL.parse() usage in the code-base
This (fairly new) static method allows parsing URLs without having to wrap `new URL(...)` calls within `try...catch` blocks, thus simplifying the code; see https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static

For older browsers/environments the functionality will be polyfilled, but *only* in `legacy` builds, via `core-js`; see https://github.com/zloirock/core-js?tab=readme-ov-file#url-and-urlsearchparams

*Please note:* This is currently limited to the `src/`- and `web/`-folders, such that we don't break development/testing, since the functionality is not available in all Node.js versions that we support; see https://developer.mozilla.org/en-US/docs/Web/API/URL/parse_static#browser_compatibility
2025-02-15 19:10:36 +01:00
Jonas Jenwald
96f5dcbd91 Add a new closeIfActive method in the OverlayManager class
It's now pretty common that we only want to close a `dialog` *if* it's currently active, to avoid throwing errors, and this new method provides a shorter and more convenient way to achieve that.
2025-02-14 15:43:00 +01:00
calixteman
6258a77bd7
Merge pull request #19486 from calixteman/signature_edit_desc
[Editor] Add the possibility to change a signature description (bug 1948116)
2025-02-14 15:41:45 +01:00
Jonas Jenwald
6ad56135c9
Merge pull request #19481 from Snuffleupagus/GenericL10n-fetch-bundles-parallel
[GenericL10n] Fetch the language bundles in parallel to reduce load time
2025-02-14 15:33:29 +01:00
Jonas Jenwald
c81a404138
Merge pull request #19475 from Snuffleupagus/injectLinkAnnotations-method-event
Move the auto-link handling into its own `PDFPageView` helper-method, and dispatch a "linkannotationsadded" event
2025-02-14 14:05:06 +01:00
Calixte Denizet
1d82b2ce94 [Editor] Add the possibility to change a signature description (bug 1948116) 2025-02-14 14:00:45 +01:00