Commit Graph

16980 Commits

Author SHA1 Message Date
Calixte Denizet
aac073feeb Remove the loading icon div and replace it by a pure css solution using :after.
This way we don't have a lot of useless divs and we let the css engine handle the
creation/destruction of the :after pseudo-element.
It'll help to slightly improve performance when zooming.
2023-02-02 15:33:53 +01:00
calixteman
1bdee0b59b
Merge pull request #15970 from calixteman/editor_invisible
[Editor] Make the annotation editor layer invisible when disabled and empty
2023-02-01 21:25:32 +01:00
Calixte Denizet
185281957d [Editor] Make the annotation editor layer invisible when disabled and empty
It'll help to avoid to consider them when the browser is restyling.
2023-02-01 17:53:44 +01:00
Jonas Jenwald
cf8ee47589 Remove unused parameters from the onOpenWithTransport method in PDFViewerApplication.initPassiveLoading
The only parameter that we actually need here is the `PDFDataRangeTransport`-instance, since the others are not necessary.
 - The `url` parameter, as passed to the `getDocument` function in the API, is simply being ignored; see 2d87a2eb1c/src/display/api.js (L447-L458)
 - The `length` parameter, as passed to the `getDocument` function in the API, is always being overwritten; see 2d87a2eb1c/src/display/api.js (L519-L525)
2023-02-01 09:33:22 +01:00
Jonas Jenwald
2d87a2eb1c
Merge pull request #15984 from Snuffleupagus/optional-workerModules
Allow, optionally, using worker-modules during local development
2023-01-31 13:05:59 +01:00
Jonas Jenwald
5e88228767 Allow, optionally, using worker-modules during local development
Until PR 12563 is deemed safe to land, I'd still like to be able to use worker-modules in the viewer during local development.
Hence this patch which *temporarily* adds a new `workerModules` hash-parameter, only available in non-PRODUCTION mode, that allows using worker-modules in the development viewer.

To enable this functionality, simply use http://localhost:8888/web/viewer.html#workerModules=true
2023-01-31 12:09:44 +01:00
Jonas Jenwald
c5d6391898 [api-minor] Let the cMapPacked parameter, in getDocument, default to true
The initial CMap support was added in PR 4259 using the "raw" Adobe files, however they were quickly deemed to be unnecessarily large. As a result PR 4470 introduced the more compact "binary" CMap format, with both of those PRs being included in the very same release (version `0.8.1334`) .

Please note that we've thus never shipped anything *except* the "binary" CMap files with the PDF library, and furthermore note that we've not even once updated the CMap files since they were originally added almost nine years ago.

Requiring users to remember that `cMapPacked = true` is necessary, in addition to setting the `cMapUrl` parameter, in order for CMap loading to work feels like a less than ideal API.
Hence this patch, which suggests that we simply let `cMapPacked` default to `true` now.
2023-01-30 15:35:02 +01:00
Jonas Jenwald
3d35b48f46
Merge pull request #15979 from Snuffleupagus/issue-15977
Extend `getGlyphMapForStandardFonts` with additional entries (issue 15977)
2023-01-30 14:46:43 +01:00
Jonas Jenwald
808ca828f1 Extend getGlyphMapForStandardFonts with additional entries (issue 15977) 2023-01-30 12:13:21 +01:00
calixteman
2ebbeb7499
Merge pull request #15973 from calixteman/1813138
Remove the transition when displaying the sidebar when the user prefers reduced motion (bug 1813138)
2023-01-30 11:26:16 +01:00
Calixte Denizet
f14413989c Remove the transition when displaying the sidebar when the user prefers reduced motion (bug 1813138)
In Firefox, it can be easily testesd in setting the pref `ui.prefersReducedMotion` to 1.
2023-01-30 10:56:37 +01:00
Jonas Jenwald
ca996d2546 [api-minor] Update the minimum supported browsers, and remove the PostCSS logical plugin
The patch updates the minimum supported browsers/environments as follows:
 - Chrome 87, which was released on 2020-11-17; see https://en.wikipedia.org/wiki/Google_Chrome_version_history
 - Firefox ESR (no change); see https://wiki.mozilla.org/Release_Management/Calendar
 - Safari 14.1, which was released on 2021-04-26; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_14
 - Node.js 14 (no change); see https://en.wikipedia.org/wiki/Node.js#Releases

The recent *major* release of the PostCSS `logical` plugin effectively removed support for all of the things that we used it for, which includes (but may not be limited to): preserving the original CSS code (for up-to-date browsers), re-writing the `:dir` pseudo-class, and support for re-writing `float: inline-start;`/`float: inline-end;` properties.
Please find additional details at https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-logical/CHANGELOG.md#600-january-24-2023
Hence the primary reason for these changes are related to native support for *logical* CSS properties/values. Currently, in the default viewer, we're using the following ones:
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/text-align#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/float#browser_compatibility

By updating the minimum supported browsers, we thus only have to worry about the *last* case here. Thankfully there's not that many `float: inline-start;`/`float: inline-end;` occurrences, and we can utilize CSS variables together with the pre-processor to support those in a way that won't affect the Firefox PDF Viewer.
2023-01-29 20:25:05 +01:00
Tim van der Meij
f492d96301
Merge pull request #15974 from timvandermeij/bump
Bump versions in `pdfjs.config`
2023-01-29 13:53:41 +01:00
Tim van der Meij
e3aaaa378d
Bump versions in pdfjs.config 2023-01-29 13:47:28 +01:00
Tim van der Meij
5620456072
Merge pull request #15972 from Snuffleupagus/PDFViewerApplication-open-signature
Change the `PDFViewerApplication.open` method to only accept objects
2023-01-28 19:10:01 +01:00
Tim van der Meij
ee3be2f979
Merge pull request #15951 from Snuffleupagus/polyfill-Path2D
Polyfill `Path2D` in Node.js environments
2023-01-28 19:06:54 +01:00
Jonas Jenwald
6129be7b68 Change the PDFViewerApplication.open method to only accept objects
If this method was added today, I really can't imagine that we'd support anything *except* objects. Unfortunately we cannot just remove this now, since the code has existed since "forever", however we can deprecate this and limit it to only the GENERIC build.

Furthermore, we can avoid a redundant `PDFViewerApplication.setTitleUsingUrl` call in the Firefox PDF Viewer since the title has already been set previously in that case.
2023-01-28 18:55:22 +01:00
Tim van der Meij
e539d2da1e
Merge pull request #15964 from Snuffleupagus/getDocument-non-object
Only accept non-objects passed to `getDocument` in GENERIC builds
2023-01-28 18:42:09 +01:00
Jonas Jenwald
cf0369d622 Polyfill Path2D in Node.js environments
Until just recently the only existing `Path2D` polyfill didn't have support for Node.js and/or the `node-canvas` package. Given that this was just fixed, in the latest version, we can now finally remove our inline-checks at the relevant call-sites; please also see https://github.com/nilzona/path2d-polyfill#usage-with-node-canvas
2023-01-28 18:28:22 +01:00
Tim van der Meij
cb5a28ceca
Merge pull request #15954 from Snuffleupagus/getDocument-URL-tweaks
Tweak the internal handling of the `url`-parameter in `getDocument` (PR 13166 follow-up)
2023-01-28 18:18:17 +01:00
Tim van der Meij
16aef95937
Merge pull request #15966 from Snuffleupagus/GlobalWorkerOptions-defaults
Simplify setting the `GlobalWorkerOptions` default values (PR 9480 follow-up)
2023-01-28 18:15:32 +01:00
Tim van der Meij
42caf64ae8
Merge pull request #15963 from Snuffleupagus/README-support-info
Update various README files to be less specific about the supported JavaScript features
2023-01-28 18:10:16 +01:00
Tim van der Meij
7c6324f3d4
Merge pull request #15971 from Snuffleupagus/update-packages
Update packages and translations
2023-01-28 18:08:46 +01:00
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
1c4af2727c Simplify setting the GlobalWorkerOptions default values (PR 9480 follow-up)
There's really no need for these "complicated" default value assignments, since `GlobalWorkerOptions` is a local variable at this point, and this is rather a case of too much copy-and-paste.
Note that years ago, when all options were set using a global `PDFJS` object, it's possible that options had been set (from the outside) *before* the object had been properly initialized; see e.g. a89071bdef/src/display/global.js
2023-01-26 14:16:01 +01:00
Jonas Jenwald
4758e6649c Only accept non-objects passed to getDocument in GENERIC builds
In general it's always 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.
Unfortunately we cannot really remove this, since that code has existed since "forever", however we can limit it to only the GENERIC build to avoid completely unnecessary checks in e.g. the Firefox PDF Viewer.

Finally, note that the default-viewer always provides a *parameter object* when calling the `getDocument`-function and it's thus completely unaffected by these changes.
2023-01-26 10:48:58 +01:00
Jonas Jenwald
c0a023eaf9 Update various README files to be less specific about the supported JavaScript features
By being less specific about which *exact* JavaScript features are required for the default vs `legacy` build, we don't need to worry about keeping multiple README files up-to-date.
These README files will now refer back to the FAQ for current browser/environment support information.
2023-01-25 15:46:53 +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
Jonas Jenwald
755319130e Tweak the internal handling of the url-parameter in getDocument (PR 13166 follow-up)
- Use a `URL`-instance directly, since it's by definition an absolute URL.
 - Actually limit the "raw" url-string handling to Node.js environments, as intended.
 - Skip the warning, since we're already throwing an Error if the `url`-parameter is invalid.
2023-01-24 11:18:41 +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