Commit Graph

16705 Commits

Author SHA1 Message Date
Jonas Jenwald
906745de38 [Regression] Avoid showing a black canvas during zooming with a drawingDelay set (PR 15812 follow-up)
After the changes in PR 15812 we'll now *intermittently* display completely black canvases during zooming. To reproduce this, try switching to wrapped-scrolling and zoom in/out very quickly using either the mouse-wheel or pinching.
2023-01-14 23:25:04 +01:00
Tim van der Meij
517d7a6dc3
Merge pull request #15905 from timvandermeij/core-utils-unit-tests
Improve unit test coverage of `src/core/core_utils.js`
2023-01-14 15:24:53 +01:00
Tim van der Meij
9e3adb5ec7
Implement unit tests for the numberToString utility function 2023-01-14 15:09:58 +01:00
Tim van der Meij
a6dfcc89fa
Implement unit tests for the recoverJsURL utility function 2023-01-14 15:09:58 +01:00
Jonas Jenwald
e09ad99973
Merge pull request #15916 from Snuffleupagus/fetch-transfer
[api-minor] Enabling transferring of data fetched with the `PDFFetchStream` implementation
2023-01-13 13:28:12 +01:00
Jonas Jenwald
1d683708e8
Merge pull request #15917 from Snuffleupagus/pr-15908-followup
Improve input validation in `PDFDataTransportStream._onReceiveData` (PR 15908 follow-up)
2023-01-12 15:32:59 +01:00
Jonas Jenwald
1362cd91d0 Improve input validation in PDFDataTransportStream._onReceiveData (PR 15908 follow-up)
The mozilla-central [method `PdfDataListener.readData`](https://searchfox.org/mozilla-central/rev/893a8f062ec6144c84403fbfb0a57234418b89cf/toolkit/components/pdfjs/content/PdfStreamConverter.jsm#207-210) can return `null`, hence it seems like a very good idea to update `PDFDataTransportStream._onReceiveData` to handle that gracefully since the current code will throw in that case.

Also, improves the JSDocs for the `PDFDataRangeTransport` class in the API.
2023-01-12 15:24:59 +01:00
Jonas Jenwald
cee97fcd15 [api-minor] Enabling transferring of data fetched with the PDFFetchStream implementation
Note how in the API we're transferring the PDF data that's fetched over the network[1]:
 - f28bf23a31/src/display/api.js (L2467-L2480)
 - f28bf23a31/src/display/api.js (L2553-L2564)

To support that functionality we have the `PDFDataTransportStream`, `PDFFetchStream`, `PDFNetworkStream`, and `PDFNodeStream` implementations. Here these stream-implementations vary slightly in how they handle `ArrayBuffer`s internally, w.r.t. transferring or copying the data:
 - In `PDFDataTransportStream` we optionally, after PR 15908, allow transferring of the PDF data as provided externally (used e.g. in the Firefox PDF Viewer).
 - In `PDFFetchStream` we're currenly always copying the PDF data returned by the Fetch API, which seems unnecessary. As discussed in PR 15908, it'd seem very weird if this sort of browser API didn't allow transferring of the returned data.
 - In `PDFNetworkStream` we're already, since many years, transferring the PDF data returned by the `XMLHttpRequest` functionality. Note how the `getArrayBuffer` helper function simply returns an `ArrayBuffer` response as-is.
 - In `PDFNodeStream` we're currently copying the PDF data, however this is unfortunately necessary since Node.js returns data as a `Buffer` object[2].

Given that the `PDFNetworkStream` has been, indirectly, supporting transferring of PDF data for years it would seem really strange if this didn't also apply to the `PDFFetchStream`-implementation.
Hence this patch simply enables transferring of PDF data, when accessed using the Fetch API, unconditionally to help reduced main-thread memory usage since the `PDFFetchStream`-implementation is used *by default* in browsers (for the GENERIC build).

---
[1] As opposed to PDF data being provided as e.g. a TypedArray when calling `getDocument` in the API.

[2] This is a "special" Node.js object, see https://nodejs.org/api/buffer.html#buffer, which doesn't exist in browsers.
2023-01-12 13:59:21 +01:00
Jonas Jenwald
f28bf23a31
Merge pull request #15908 from Snuffleupagus/bug-1809164
[api-minor] Add a new `transferPdfData` option to allow transferring more data to the worker-thread (bug 1809164)
2023-01-11 17:34:51 +01:00
calixteman
dafcf82365
Merge pull request #15909 from calixteman/pinch_trackpad
Add support for smooth pinch-to-zoom on a trackpad (bug 1659492)
2023-01-11 16:26:21 +01:00
Calixte Denizet
f5dcc69ea1 Add support for smooth pinch-to-zoom on a trackpad (bug 1659492)
- Scale factor is rounded to only scale by integer percent, hence the unused
  ticks are accumulated (like we already do for zoom with the mouse wheel).
- Use the same thing for the pinch-to-zoom on a touchscreen: it led to slightly
  refactor the code because it happened to ignore a not so small scale which
  led to a not so smooth zooming.
2023-01-11 15:14:33 +01:00
calixteman
633d5e7af0
Merge pull request #15914 from calixteman/15894_followup
Simplify PDFViewerApplication::supportsPrinting (follow-up of #15894)
2023-01-11 14:07:52 +01:00
Calixte Denizet
8068dff9d1 Simplify PDFViewerApplication::supportsPrinting (follow-up of #15894) 2023-01-11 12:33:33 +01:00
Jonas Jenwald
bbe629018d [api-minor] Add a new transferPdfData option to allow transferring more data to the worker-thread (bug 1809164)
Also, removes the `initialData`-parameter JSDocs for the `getDocument`-function given that this parameter has been completely unused since PR 8982 (over five years ago). Note that the `initialData`-parameter is, and always was, intended to be provided when initializing a `PDFDataRangeTransport`-instance.
2023-01-10 21:03:44 +01:00
calixteman
d6f63b5fb7
Merge pull request #15907 from calixteman/bug1809080
Fix pinch-to-zoom on a macbook trackpad (bug 1809080)
2023-01-09 15:41:25 +01:00
Calixte Denizet
0c1cf2c237 Fix pinch-to-zoom on a macbook trackpad (bug 1809080) 2023-01-09 13:48:46 +01:00
Jonas Jenwald
067d3b70aa
Merge pull request #15906 from timvandermeij/nodejs
Upgrade Node.js to version 18 in the CI workflow
2023-01-08 20:32:22 +01:00
Tim van der Meij
588447aa90
Upgrade Node.js to version 18 in the CI workflow
Version 16 that we used before is now in maintenance mode, so we should
upgrade to the most recent LTS version. For more information on the
Node.js release schedule please refer to
https://github.com/nodejs/release#release-schedule.
2023-01-08 17:35:08 +01:00
Tim van der Meij
ca668dfd41
Merge pull request #15904 from Snuffleupagus/tweak-sidebarContent-background
Remove the `background-color` of the sidebarContent (PR 15850 follow-up)
2023-01-08 14:21:15 +01:00
Jonas Jenwald
8ab5476cb8 Remove the background-color of the sidebarContent (PR 15850 follow-up)
After the changes in PR 15850, the `background-color` of the sidebar is now unnecessarily dark in the light-theme. Hence, we can simply remove this CSS rule to improve things overall (and these changes don't affect the dark-theme much at all).
This is even an overall consistency improvement, given the existing `--sidebar-narrow-bg-color` values.
2023-01-08 14:06:02 +01:00
Jonas Jenwald
173bd88dbd
Merge pull request #15903 from mozilla/dependabot/npm_and_yarn/json5-1.0.2
Bump json5 from 1.0.1 to 1.0.2
2023-01-08 11:33:15 +01:00
dependabot[bot]
f51e85e84b
Bump json5 from 1.0.1 to 1.0.2
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-08 06:05:38 +00:00
calixteman
fcaeb5db88
Merge pull request #15901 from calixteman/15289_followup
Avoid null ExpansionFactor in type1 fonts (follow-up of #15289)
2023-01-07 18:20:31 +01:00
Jonas Jenwald
74e4b515c5
Merge pull request #15897 from Snuffleupagus/issue-15893
Support parsing encrypted documents in `XRef.indexObjects` (issue 15893)
2023-01-07 16:55:41 +01:00
Calixte Denizet
c170245fc0 Avoid null ExpansionFactor in type1 fonts (follow-up of #15289) 2023-01-07 16:25:24 +01:00
calixteman
e1f7355de4
Merge pull request #15900 from calixteman/15289
Set ExpansionFactor to 0.06 when it's equals to 0 in the private dict of CFF fonts
2023-01-07 16:13:33 +01:00
Calixte Denizet
e565e455e2 Set ExpansionFactor to 0.06 when it's equals to 0 in the private dict of CFF fonts 2023-01-07 14:53:13 +01:00
Tim van der Meij
d6984f9395
Merge pull request #15899 from Snuffleupagus/tweak-toolbar-border-color
Tweak the `--toolbar-border-color` CSS variable (PR 15850 follow-up)
2023-01-07 13:53:35 +01:00
Jonas Jenwald
bd84bf4ebd Tweak the --toolbar-border-color CSS variable (PR 15850 follow-up)
After the changes in PR 15850, the toolbar-border is now quite difficult to spot in the light-theme. Hence, let's tweak it slightly to improve things.
2023-01-07 13:44:21 +01:00
Tim van der Meij
38e46e7614
Merge pull request #15850 from calixteman/15836
Remove shadow around each pages (fix issue #15836)
2023-01-07 13:29:41 +01:00
Tim van der Meij
69113f08f2
Merge pull request #15887 from Snuffleupagus/rm-setPDFNetworkStreamFactory
Inline the `setPDFNetworkStreamFactory` functionality in `src/display/api.js`
2023-01-07 13:16:23 +01:00
Tim van der Meij
b428824269
Merge pull request #15879 from Snuffleupagus/useWorkerFetch-defaults
[api-minor] Improve the `useWorkerFetch` default value checks
2023-01-07 13:13:25 +01:00
calixteman
91c44ec7ab
Merge pull request #15857 from calixteman/delay_loading_icon
Delay the loading icon display
2023-01-06 16:09:32 +01:00
Jonas Jenwald
1d5de9f4f4 Inline the setPDFNetworkStreamFactory functionality in src/display/api.js
Given that this is internal functionality, not exposed in the official API, it's not entirely clear (at least to me) why we can't just initialize this directly in `src/display/api.js` instead.
When testing both the development viewer and all the ways in which we run tests, everthing still appears to work just fine with this patch.
2023-01-06 13:23:07 +01:00
Jonas Jenwald
7d94fdeb48 Support parsing encrypted documents in XRef.indexObjects (issue 15893)
*Please note:* The reduced test-case is *not* a perfect reproduction of the original PDF document, since this one fails to open in e.g. Adobe Reader, but I do believe that it captures the most important points here.

For corrupt *and* encrypted PDF documents, it's possible that only some trailer dictionaries actually contain an /Encrypt-entry. Previously we'd could easily miss that, since we generally pick the first not obviously corrupt trailer dictionary, and the solution implemented here is to simply pre-parse all trailer dictionaries to see if there's any /Encrypt-entries.
2023-01-06 13:09:37 +01:00
Calixte Denizet
dd29f8705c Delay the loading icon display
In most of the cases, showing the loading icon is useless because
it's for a very short time, consequently it doesn't bring any useful
information for the user.
After a delay (400ms), the icon is shown in order to inform the user
that the viewer isn't stuck but it's doing something.
2023-01-06 12:28:32 +01:00
calixteman
e36564668b
Merge pull request #15896 from calixteman/gv_update_matches_count
[GV] Add an option in the find controller to update matches count only when the last page is reached (bug 1803188).
2023-01-06 12:11:20 +01:00
Calixte Denizet
661f425934 [GV] Add an option in the find controller to update matches count only when the last page is reached (bug 1803188).
In GeckoView, on an event, a callback must be executed with the result of an action,
but the callback can be used only one time.
So for each FindInPage event, we must trigger only one matches count update.
2023-01-06 10:56:26 +01:00
calixteman
8a0ca04399
Merge pull request #15894 from calixteman/gv_disable_print
[GV] Remove print stuff because window.print isn't implemented (bug 1808668)
2023-01-05 13:43:53 +01:00
Calixte Denizet
409c8b344f [GV] Remove print stuff because window.print isn't implemented (bug 1808668) 2023-01-05 13:02:29 +01:00
calixteman
7da591048c
Merge pull request #15892 from calixteman/fix_autoprint
[JS] UserActivation must be enabled before running document actions
2023-01-04 21:50:29 +01:00
Calixte Denizet
dea2471e96 [JS] UserActivation must be enabled before running document actions
else auto-print is broken (it's a regression from patch #15822).
2023-01-04 21:26:36 +01:00
Jonas Jenwald
1e1a2fce49
Merge pull request #15891 from Snuffleupagus/accumulateTicks
Reduce duplication in the `accumulateWheelTicks`/`accumulateTouchTicks` methods (PR 15886 follow-up)
2023-01-04 19:30:47 +01:00
Jonas Jenwald
66a3aa28fd Reduce duplication in the accumulateWheelTicks/accumulateTouchTicks methods (PR 15886 follow-up)
It just occurred to me that we can reduce some duplication by having the, virtually identical, `accumulateWheelTicks`/`accumulateTouchTicks` methods use a common helper instead that takes advantage of [bracket notation](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Basics#bracket_notation).
2023-01-04 18:19:39 +01:00
calixteman
4faf927030
Merge pull request #15886 from calixteman/pinch_to_zoom
[api-minor] Add the pinch-to-zoom feature (bug 1677933)
2023-01-04 17:20:29 +01:00
Calixte Denizet
d6b7a1f034 [api-minor] Add the pinch-to-zoom feature (bug 1677933) 2023-01-04 16:00:46 +01:00
Jonas Jenwald
da1365a309
Merge pull request #15885 from Snuffleupagus/font-update-type-subtype
Update the `type`/`subtype` at the end of font parsing
2023-01-02 17:18:05 +01:00
Jonas Jenwald
6bdbb5c5ca Update the type/subtype at the end of font parsing
This fixes a warning reported by CodeQL, and should also make general sense given that we parse the font-data to determine the *actual* `type`/`subtype` rather than trusting the PDF document.
2023-01-02 16:21:48 +01:00
Jonas Jenwald
42aa08563b
Merge pull request #15880 from Snuffleupagus/rm-docStats
[api-minor] Remove the `PDFDocumentProxy.stats` getter (PR 15758 follow-up)
2023-01-02 16:03:53 +01:00
Jonas Jenwald
1ba6e9437c
Merge pull request #15884 from Snuffleupagus/enable-defaultZoomDelay
Enable the `defaultZoomDelay` option/preference unconditionally, and other (small) improvements
2023-01-02 15:38:29 +01:00