Commit Graph

16753 Commits

Author SHA1 Message Date
Jonas Jenwald
52d61aceda Update l10n files 2023-01-28 08:15:21 +01:00
Jonas Jenwald
07ba352903 Update npm packages 2023-01-28 08:13:13 +01:00
calixteman
075cc8d8df
Merge pull request #15965 from calixteman/bug1811510
[JS] Correctly format field with numbers (bug 1811694, bug 1811510)
2023-01-26 16:10:29 +01:00
Calixte Denizet
6f4d037a8e [JS] Correctly format field with numbers (bug 1811694, bug 1811510)
In PR #15757, a value is automatically converted into a number when it's possible
but the case of numbers like "000123" has been overlooked and their format must
be preserved.
When a script is doing something like "foo.value + bar.value" and the values are
numbers then "foo.value" must return a number but the displayed value must be what
the user entered or what a script set, so this patch is just adding a a field
_orginalValue in order to track the value has it has defined.
Some people are used to use a comma as decimal separator, hence it must be considered
when a value is parsed into a number.
This patch is fixing a regression introduced by #15757.
2023-01-26 14:57:02 +01:00
Jonas Jenwald
1b1ebf6a77
Merge pull request #15960 from Snuffleupagus/issue-15958
Move `ProgressBar`-related CSS variables into the `loadingBar` DOM-element (issue 15958)
2023-01-25 12:17:24 +01:00
Jonas Jenwald
ce941255e2
Merge pull request #15959 from Snuffleupagus/normalizeWheelEventDelta-tweaks
Tweak the `normalizeWheelEventDelta` helper function
2023-01-25 11:13:50 +01:00
Jonas Jenwald
9d5085347a Move ProgressBar-related CSS variables into the loadingBar DOM-element (issue 15958)
This way we avoid reflowing the entire viewer when e.g. updating the loading progress.
2023-01-25 11:09:28 +01:00
Jonas Jenwald
85fd765462 Tweak the normalizeWheelEventDelta helper function
This function is only used in PresentationMode these days, but we can still improve it a little bit:
 - Use the existing web-platform `deltaMode` constants, rather than defining our own constants for those values.
 - Access the `deltaMode` first, before the `delta{X, Y}` properties, to avoid being affected by bug 1392460 (similar to the default viewer).
2023-01-25 10:47:03 +01:00
calixteman
0b9d32bdad
Merge pull request #15957 from calixteman/1810800
Try to avoid to interpret wheel events as pinch-to-zoom ones (bug 1810800)
2023-01-24 21:35:12 +01:00
Calixte Denizet
1cb482be6a Try to avoid to interpret wheel events as pinch-to-zoom ones (bug 1810800) 2023-01-24 20:12:12 +01:00
calixteman
673f6820d1
Merge pull request #15952 from calixteman/l10n
Set up automated l10n review for new English strings
2023-01-22 20:44:37 +01:00
Calixte Denizet
be93a2a7d4 Set up automated l10n review for new English strings 2023-01-22 19:39:31 +01:00
Tim van der Meij
edfdb693e5
Merge pull request #15948 from Snuffleupagus/bug-1811668
Tweak `adjustType1ToUnicode` for fonts with a predefined *named* encoding (bug 1811668, PR 14050 follow-up)
2023-01-21 14:02:40 +01:00
Tim van der Meij
8278abb3f3
Merge pull request #15949 from Snuffleupagus/ProgressBar-setDisableAutoFetch
Move the `disableAutoFetch` functionality into the `ProgressBar`-class
2023-01-21 13:54:18 +01:00
Tim van der Meij
a27d7ba524
Merge pull request #15943 from Snuffleupagus/deprecate-direct-PDFDataRangeTransport
[api-minor] Deprecate calling `getDocument` directly with a `PDFDataRangeTransport`-instance
2023-01-21 13:50:20 +01:00
Jonas Jenwald
d7013bee54 Move the disableAutoFetch functionality into the ProgressBar-class
It seems nicer overall, since we're exporting the `ProgressBar` in the viewer-components, to move this functionality into the `ProgressBar`-class itself rather than handling it "manually" in the default-viewer.
2023-01-21 12:32:34 +01:00
Jonas Jenwald
40a46e4397 Tweak adjustType1ToUnicode for fonts with a predefined *named* encoding (bug 1811668, PR 14050 follow-up)
*Please note:* I cannot reproduce the problem reported in bug 1811668, regarding the context menu, and in any case it's not clear that that part is even a PDF Viewer bug.

Looking at bug 1811668 I couldn't help but noticing that the textLayer isn't correct, and it's unfortunately once again a problem with the `adjustType1ToUnicode` function. That's intended to help improve text-selection for fonts without a /ToUnicode-entry, and in many cases it does help (the original PR fixed lots of issues) however it's also caused some problems.

In order to improve text-selection in bug 1811668, we'll now properly ignore fonts that have a predefined *named* encoding specified since that's really the intention with PR 14050.
2023-01-21 12:21:21 +01:00
calixteman
7b95788248
Merge pull request #15947 from calixteman/gv_dont_update_find
[GV] Avoid to update the finder when the results aren't complete
2023-01-20 18:48:39 +01:00
Calixte Denizet
dc94b750de [GV] Avoid to update the finder when the results aren't complete
At the beginning of a search we can an update can be triggered with 0 over 0
found matches.
In the GeckoView context, we can't update the finder whenever we want but only
when it has been required.
2023-01-20 18:13:16 +01:00
calixteman
deb07aee06
Merge pull request #15941 from calixteman/change_current_view
Change 'Current View' to 'Current Page' in the secondary toolbar
2023-01-20 10:59:18 +01:00
Jonas Jenwald
29cd5ab24e
Merge pull request #15945 from Snuffleupagus/issue-15942
[JBIG2] Ensure that the `decodeInteger` function returns valid integers (issue 15942)
2023-01-19 21:14:47 +01:00
Jonas Jenwald
f2fce93826 [JBIG2] Ensure that the decodeInteger function returns valid integers (issue 15942)
The JBIG2 images in this PDF document are corrupt enough that even Adobe Reader warns about it when opening the file.
*Please note:* I don't really know the JBIG2 image format at all, however from a very brief look at the specification it seems that integers should be 32-bit.
2023-01-19 17:14:17 +01:00
Jonas Jenwald
7976fc7851 [api-minor] Deprecate calling getDocument directly with a PDFDataRangeTransport-instance
In general it's recommended to pass a *parameter object* when calling the `getDocument`-function in the API, since that's the only way to provide additional options, and the fact that it also accepts a URL or TypedArray directly is now mostly for backwards compatibility reasons.
However, the `getDocument`-function also accepts a direct `PDFDataRangeTransport`-instance which just seems unnecessary.

*Please note:* The `PDFDataRangeTransport`-implementation was added specifically for the *built-in* Firefox PDF Viewer, however it's most likely not commonly used by any third-party (given that it requires manual PDF-data loading).
Furthermore, the default-viewer always provides a *parameter object* when calling the `getDocument`-function and it's thus completely unaffected by these changes.
2023-01-19 14:25:55 +01:00
Jonas Jenwald
c629a85a5c
Merge pull request #15935 from Snuffleupagus/_centerAtPos
Add a `PDFViewerApplication` helper method to center the position after wheel/pinch-zooming
2023-01-19 14:25:10 +01:00
Jonas Jenwald
1a95890728
Merge pull request #15937 from Snuffleupagus/textLayer-highlight-color-vars
Use CSS variables for the textLayer `highlight` colors (PR 15921 follow-up)
2023-01-19 13:38:58 +01:00
Jonas Jenwald
eee65e4b6e Add a PDFViewerApplication helper method to center the position after wheel/pinch-zooming
This avoids having to repeat the same code twice, now that we support both wheel- and pinch-zooming.
2023-01-19 13:35:35 +01:00
Calixte Denizet
31ae3a4ba0 Change 'Current View' to 'Current Page' in the secondary toolbar
Content Design team (UX) proposed this change.
2023-01-19 09:54:25 +01:00
Jonas Jenwald
f25e33ee7f
Merge pull request #15940 from Snuffleupagus/license_header_2023
Update the year in the `license_header` files
2023-01-18 22:36:21 +01:00
Jonas Jenwald
7b36686fca Update the year in the license_header files 2023-01-18 22:28:18 +01:00
Jonas Jenwald
4b5817f8ff Use consistent forced-colors media-queries throughout the CSS files
Note how e.g. the `viewer.css` and `pdf_viewer.css` files already used this format.
2023-01-18 10:49:52 +01:00
Jonas Jenwald
67b1d15384 Use CSS variables for the textLayer highlight colors (PR 15921 follow-up)
Rather than adding `@media (forced-colors: active) { ... }`-blocks throughout the CSS code, we should utilize CSS variables instead as in our other CSS files.
2023-01-18 10:42:22 +01:00
Jonas Jenwald
42b1cff7b0
Merge pull request #15934 from Snuffleupagus/issue-15910-2
Fallback to using the `name` table to infer the encoding for TrueType fonts missing such data (issue 15910)
2023-01-17 23:01:23 +01:00
calixteman
e65f1767ab
Merge pull request #15930 from calixteman/15929
Move --scale-factor variable in the viewer container (fix #15929)
2023-01-17 16:37:49 +01:00
Jonas Jenwald
d6be5141e9 Fallback to using the name table to infer the encoding for TrueType fonts missing such data (issue 15910)
The relevant TrueType font is missing both /ToUnicode *and* /Encoding entires, either of which would have prevented the (current) broken textLayer rendering.
My first idea was that we could use the `post` table in the TrueType font, see https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6post.html, to get the actual glyphNames and amend the fallback ToUnicode-map that way. Unfortunately that didn't work, since the `post` table only contained ".notdef" and "" (i.e. empty string) entries.

Instead we try to use the `name` table in the TrueType font, see https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html, to determine if the platform is Windows and thus fallback to generate a ToUnicode-map from the `WinAnsiEncoding`.
2023-01-17 16:04:51 +01:00
Calixte Denizet
089ed6fb65 Move --scale-factor variable in the viewer container (fix #15929)
When a css variable is update in a node then all the children under this
node are updated.
In order to avoid to update all the UI when a page is rescaling, this
patch moves the --scale-factor from the :root to the viewer container.
2023-01-17 10:50:53 +01:00
Jonas Jenwald
d8d5545e03
Merge pull request #15926 from Snuffleupagus/annotation-appearance-stream
Ensure that Annotation `appearance`-entries are actually Streams
2023-01-16 15:00:12 +01:00
Jonas Jenwald
8f3fa18c93
Merge pull request #15920 from Snuffleupagus/transfer-pdf-data
[api-minor] Enable transferring of TypedArray PDF data by default (PR 15908 follow-up)
2023-01-16 13:20:57 +01:00
Jonas Jenwald
cefaecc2e8 Ensure that Annotation appearance-entries are actually Streams
Note how all over the `src/core/annotation.js`-code we're assuming that if an `appearance`-entry exists it's also a Stream. However, we're not actually checking that thoroughly enough which causes issues in some badly generated PDF documents.
2023-01-16 13:02:53 +01:00
calixteman
e9c8aa63e3
Merge pull request #15921 from fchasen/forced-colors-highlights
Update highlight background when forced colors are active (bug 1759886)
2023-01-16 11:16:22 +01:00
Tim van der Meij
0e563ee6da
Merge pull request #15925 from Snuffleupagus/update-rimraf
Update `rimraf` to version 4
2023-01-15 18:15:59 +01:00
Jonas Jenwald
32357e3d17 Update rimraf to version 4
The primary change is that the `rimraf` function now returns a Promise instead of taking a callback; please see https://github.com/isaacs/rimraf#major-changes-from-v3-to-v4
2023-01-15 15:38:30 +01:00
Jonas Jenwald
1ca0a7a26c
Merge pull request #15923 from Snuffleupagus/zoom-black-canvas
[Regression] Avoid showing a black canvas during zooming with a `drawingDelay` set (PR 15812 follow-up)
2023-01-15 12:29:06 +01:00
Tim van der Meij
bc3b59fa5e
Merge pull request #15924 from Snuffleupagus/update-packages
Update packages and translations
2023-01-15 11:35:16 +01:00
Jonas Jenwald
cbf9843a79 Update l10n files 2023-01-15 10:43:46 +01:00
Jonas Jenwald
d527bd0d92 Update npm packages 2023-01-15 10:34:56 +01:00
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
397f943ca3 [api-minor] Enable transferring of TypedArray PDF data by default (PR 15908 follow-up)
This patch removes the recently introduced `transferPdfData` API-option, and simply enables transferring of TypedArray data *by default* instead of copying it. This will help reduce main-thread memory usage, however it will take ownership of the TypedArrays. Currently this only applies to the following cases:
 - TypedArrays passed to the `getDocument`-function in the API, in order to open PDF documents from binary data.
 - TypedArrays passed to a `PDFDataRangeTransport`-instance, used to support custom PDF document fetching/loading (see e.g. the Firefox PDF Viewer).

*PLEASE NOTE:* To avoid being affected by this, please simply *copy* any TypedArray data before passing it to either of the functions/methods mentioned above.

Now that we transfer TypedArray data that we previously only copied, we need to be more careful with input validation. Given how the `{IPDFStreamReader, IPDFStreamRangeReader}.read` methods will always return ArrayBuffer data, which is then transferred to the worker-thread[1], the actual TypedArray data passed to the API thus need to have the same exact size as its underlying ArrayBuffer to prevent issues.
Hence we'll check for this and only allow transferring of *safe* TypedArray data, and fallback to simply copying the data just as before. This obviously shouldn't be an issue in the Firefox PDF Viewer, but for the general PDF.js library we need to be more careful here.

---
[1] See e09ad99973/src/display/api.js (L2492-L2506) respectively e09ad99973/src/display/api.js (L2578-L2590)
2023-01-14 10:39:36 +01:00