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

4281 commits

Author SHA1 Message Date
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
Tim van der Meij
ccad2f889a
Merge pull request #18349 from Snuffleupagus/rm-renderTextLayer
[api-minor] Remove the deprecated `renderTextLayer` and `updateTextLayer` functions (PR 18104 follow-up)
2024-07-02 17:23:54 +02:00
Calixte Denizet
68175323f1 [Editor] Make sure everything is cleaned up when we switch to annotation editor mode 2024-07-02 16:54:19 +02:00
Calixte Denizet
64635f3b35 [api-minor][Editor] When switching to editing mode, redraw pages containing editable annotations
Right now, editable annotations are using their own canvas when they're drawn, but
it induces several issues:
 - if the annotation has to be composed with the page then the canvas must be correctly
   composed with its parent. That means we should move the canvas under canvasWrapper
   and we should extract composing info from the drawing instructions...
   Currently it's the case with highlight annotations.
 - we use some extra memory for those canvas even if the user will never edit them, which
   the case for example when opening a pdf in Fenix.

So with this patch, all the editable annotations are drawn on the canvas. When the
user switches to editing mode, then the pages with some editable annotations are redrawn but
without them: they'll be replaced by their counterpart in the annotation editor layer.
2024-07-02 14:11:40 +02:00
Jonas Jenwald
f3d177e3e4 [api-minor] Remove the deprecated renderTextLayer and updateTextLayer functions (PR 18104 follow-up) 2024-06-30 15:16:00 +02:00
Jonas Jenwald
4dad1e34b9 Cancel the requestAnimationFrame in the watchScroll helper (PR 18193 follow-up)
While the event listener is removed during testing, the `requestAnimationFrame` isn't cancelled and that occasionally shows up when the integration-tests are run on the bots.
2024-06-26 16:31:07 +02:00
calixteman
2fbd61944b
Merge pull request #18332 from calixteman/bug1904585
Add the possibility to dispatch some pdf.js events at the chrome level (bug 1904585)
2024-06-25 21:15:15 +02:00
Calixte Denizet
35474f8ef4 Add the possibility to dispatch some pdf.js events at the chrome level (bug 1904585) 2024-06-25 21:03:34 +02:00
Jonas Jenwald
f676ce5760 Remove the requestAnimationFrame work-around in L10n.prototype.destroy (PR 18313 follow-up)
With `@fluent/dom 0.10.0` just published this work-around is no longer necessary.
2024-06-25 17:23:57 +02:00
Jonas Jenwald
6492587066 Try to shutdown Fluent "more" when closing the viewer during testing
Even with PR 18280 fixed, we still *occasionally* see l10n-related errors when closing the integration-tests on the bots.
2024-06-22 16:40:12 +02:00
bootleq
890c567eca Expose entireWord in updateFindControlState
Allow apps with supportsIntegratedFind to better monitor the find state.

A recognized use case is the Firefox findbar, its "not found" sound must
consider `entireWord` and only make noise when it is off.

See related implementation in
https://hg.mozilla.org/mozilla-central/rev/16b902cbcf26

This change can help if we have to move the implementation from cpp to jsm.
2024-06-21 13:12:59 +08:00
Tim van der Meij
1cf19e907d
Merge pull request #18302 from Snuffleupagus/testingClose-findbar-close
Close `PDFFindBar` when closing the viewer during testing
2024-06-20 15:55:36 +02:00
Jonas Jenwald
02c03154b3 Close PDFFindBar when closing the viewer during testing
By closing `PDFFindBar` we also disconnect the `ResizeObserver`, since we've seen at least one case where that's running during shutdown: http://54.193.163.58:8877/91c40554d1b07c0/output.txt
2024-06-20 11:51:21 +02:00
Tim van der Meij
3e1d779859
Merge pull request #18218 from nicolo-ribaudo/test-maxCanvasPixels
Respect `maxCanvasPixels` when computing canvas dimensions
2024-06-19 16:47:09 +02:00
Nicolò Ribaudo
de23bb9b82
Respect maxCanvasPixels when computing canvas dimensions
Ensure that we never round the canvas dimensions above `maxCanvasPixels`
by rounding them to the preceeding multiple of the display ratio rather
than the succeeding one.
2024-06-19 15:23:16 +02:00
Jonas Jenwald
c771ac81cd Add a new helper, in the viewer, to close everything during testing
This has two advantages, as far as I'm concerned:
 - The tests don't need to manually invoke multiple functions to properly clean-up, which reduces the risk of missing something.
 - By collecting all the relevant clean-up in one method, rather than spreading it out, we get a much better overview of exactly what is being reset.
2024-06-19 13:48:08 +02:00
Tim van der Meij
4b5d5a557c
Merge pull request #18280 from calixteman/issue18279
Pause l10n (i.e. disconnect the mutation observer in fluent) when closing the viewer
2024-06-18 21:47:06 +02:00
Calixte Denizet
34389d4e47 Pause l10n (i.e. disconnect the mutation observer in fluent) when closing the viewer 2024-06-18 21:08:47 +02:00
Tim van der Meij
0d8828f93d
Merge pull request #18282 from Snuffleupagus/issue-18274
Don't save modified documents, when running tests, upon closing the viewer (issue 18274)
2024-06-18 20:55:27 +02:00
Jonas Jenwald
9e811b97b1 Don't save modified documents, when running tests, upon closing the viewer (issue 18274) 2024-06-18 20:05:11 +02:00
Calixte Denizet
acf8600a3d [Editor] Set the canvas in the stamp editor at the right position in odd spread mode 2024-06-18 18:44:29 +02:00
calixteman
4c041586fb
Merge pull request #18271 from calixteman/clean_before_closing
Clean up before closing the tab in integration tests
2024-06-18 16:55:53 +02:00
Tim van der Meij
c07dd17162
Merge pull request #18270 from Snuffleupagus/issue-18264
Only use the l10n fallback bundle when normal ftl-file fetching failed (issue 18264)
2024-06-18 14:53:45 +02:00
Calixte Denizet
43be717ce3 Clean up before closing the tab in integration tests 2024-06-18 14:23:19 +02:00
Jonas Jenwald
0981716bfa Only use the l10n fallback bundle when normal ftl-file fetching failed (issue 18264) 2024-06-18 11:54:49 +02:00
calixteman
06800cd966
Merge pull request #18255 from calixteman/disable_hwa_only_for_mc
Only disable HWA in m-c build and for local dev
2024-06-16 21:47:34 +02:00
Calixte Denizet
52a06e64f6 Only disable HWA in m-c build and for local dev
This way, we keep pdf.js working as before except for Firefox.
2024-06-16 12:14:33 +02:00
Jonas Jenwald
f4912db2ae Remove the _ensureDownloadComplete helper method in web/app.js
After the previous commit this method has only a single call-site, hence we can inline the needed part of that check directly in `PDFViewerApplication.download` instead.
2024-06-15 18:00:18 +02:00
Jonas Jenwald
7c5e9cf8be Ensure that saving, in the viewer, works for partially loaded documents
Currently saving a modified PDF document may fail *intermittently*, if it's triggered before the entire document has been downloaded.
When saving was originally added we only supported forms, and such PDF documents are usually small/simple enough for this issue to be difficult to trigger. However, with editing-support now available as well it's possible to modify much larger documents and this issue thus becomes easier to trigger.

One way to reproduce this issue *consistently* is to:
 - Open http://localhost:8888/web/viewer.html?file=/test/pdfs/pdf.pdf#disableHistory=true&disableStream=true&disableAutoFetch=true
 - Add an annotation on the first page, it doesn't matter what kind.
 - Save the document.
 - Open the resulting document, and notice that with the `master` branch the annotation is missing.
2024-06-15 17:58:58 +02:00
Tim van der Meij
f9693b4d16
Merge pull request #18244 from Snuffleupagus/CSS-copyAll
Improve how the wait-cursor is toggled when copying all text
2024-06-14 18:23:03 +02:00
calixteman
e3caa3c6ee
Merge pull request #18243 from calixteman/disable_ui_when_saving
Display a wait cursor when saving
2024-06-14 10:48:18 +02:00
Jonas Jenwald
97686c410c Improve how the wait-cursor is toggled when copying all text
- Use a CSS rule to display the wait-cursor during copying. Since copying may take a little while in long documents, there's a theoretical risk that something else could change the cursor in the meantime and just resetting to the saved-cursor could thus be incorrect.

 - Remove the `interruptCopyCondition` listener with an AbortController, since that's slightly shorter code.
2024-06-14 10:06:27 +02:00
Calixte Denizet
5ae936eb87 Display a wait cursor when saving
When the document is a bit long to save (for example in modifying a large document)
we must have something indicating that pdf.js is doing something.
2024-06-13 22:54:52 +02:00
Tim van der Meij
47791a4c80
Merge pull request #18236 from Snuffleupagus/rm-downloadUrl
Remove the `DownloadManager.downloadUrl` method
2024-06-13 15:44:42 +02:00
Calixte Denizet
ff6180a4c9 Add an option to enable/disable hardware acceleration (bug 1902012) 2024-06-12 18:41:07 +02:00
Jonas Jenwald
42999e5bef Remove the DownloadManager.downloadUrl method
This method has only a single call-site in the viewer, since it's used as a fallback, and the functionality can be moved into the `DownloadManager.download` method instead.
2024-06-12 13:27:45 +02:00
Calixte Denizet
412e03e576 [Editor] Support dragging & dropping images on a pdf (bug 1900907) 2024-06-07 14:26:01 +02:00
Tim van der Meij
b557fba118
Merge pull request #18217 from Snuffleupagus/inline-finishRendering
Inline the `#finishRendering` helper in `TextLayerBuilder.prototype.render`
2024-06-07 14:16:07 +02:00
Jonas Jenwald
f7cbd7d16b Inline the #finishRendering helper in TextLayerBuilder.prototype.render
This helper method is simpler/shorter than it originally was[1] and with recent refactoring so is the `render`-method, hence we can just inline this code now.

---
[1] It used to e.g. dispatch the "textlayerrendered" event.
2024-06-07 13:32:28 +02:00
Jonas Jenwald
66e189c9aa Change DownloadManager.download to use Uint8Array-data
Part of this code is really old and pre-dates general availability of things such as `Blob` and `URL.createObjectURL`. To avoid having to duplicate the Blob-creation in the viewer, we can move this into `DownloadManager.download` instead.

Also, remove a couple of unnecessary `await` statements since the methods in question are synchronous.
2024-06-07 13:23:02 +02:00
Calixte Denizet
018649f13b Switch to page-scrolling mode when the pdf has more than 10000 pages (bug 1895050) 2024-05-31 15:35:26 +02:00
Calixte Denizet
4430b6b703 Disconnect the resize observer and remove scroll listener when unbinding window events 2024-05-30 22:09:52 +02:00
Jonas Jenwald
0cec644372
Merge pull request #18179 from nicolo-ribaudo/zooming-utilities
[api-minor] Simplify API to implement zoom in custom viewers
2024-05-28 16:39:06 +02:00
Tim van der Meij
027ada81a7
Merge pull request #18170 from Snuffleupagus/TextLayerBuilder-rm-setTextContentSource
[api-minor] Remove the `setTextContentSource` method in `TextLayerBuilder` (PR 18104 follow-up)
2024-05-28 16:38:52 +02:00
Nicolò Ribaudo
b7933d8750
Add origin parameter to updateScale
This parameter allows defining which point should remain
fixed while scaling the document. It can be used, for example,
to implement "zoom around the cursor" or "zoom around
pinch center".

The logic was previously implemented in `web/app.js`, but
moving it to the viewer scaling utilities themselves makes it
easier to implement similar zooming functionalities in
other embedders.
2024-05-28 16:19:47 +02:00
Nicolò Ribaudo
161c7045f6
Unify increaseScale/decreaseScale logic as updateScale
`updateScale` receives a `drawingDelay`, a `scaleFactor` and/or a number of `steps`.
If `scaleFactor` is a positive number different from `1` the current scale is multiplied by
that number. Otherwise, if `steps` if a positive integer the current scale is multiplied by
`DEFAULT_SCALE_DELTA` `steps` times. Finally, if `steps` is a negative integer, the
current scale is divided by `DEFAULT_SCALE_DELTA` `abs(steps)` times.
2024-05-28 14:02:39 +02:00