Commit Graph

15317 Commits

Author SHA1 Message Date
Jonas Jenwald
0159ec0a12 Remove the backingStorePixelRatio-part of the getOutputScale helper function
The `CanvasRenderingContext2D.backingStorePixelRatio` property was never standardized, and only Safari set (its prefixed version of) it to anything other than `1`.
Note that e.g. MDN doesn't contain any information about this property, and one of the few sources of information (at this point) is the following post: https://stackoverflow.com/questions/24332639/why-context2d-backingstorepixelratio-deprecated

Hence we can simplify the `getOutputScale` helper function, by removing some dead code, and now it no longer requires any parameters when called.
2022-02-18 13:03:48 +01:00
Tim van der Meij
d9a3a24353
Merge pull request #14566 from Snuffleupagus/misc-viewer-cleanup
Miscellaneous small viewer clean-up
2022-02-16 20:33:30 +01:00
Jonas Jenwald
ff6d9c74cc
Merge pull request #14572 from Snuffleupagus/_collectJS-string-check
Add a missing string-check in the `_collectJS` helper function
2022-02-16 14:44:30 +01:00
Jonas Jenwald
fd319e94b3 Add a missing string-check in the _collectJS helper function
Unfortunately I don't have a test-case that breaks without this change, however the `stringToPDFString` helper function will fail if anything other than a string is passed to it.
The changes in this patch thus make this code more-or-less identical to that found in the `Catalog.{_collectJavaScript, parseDestDictionary}` methods.
2022-02-16 13:43:42 +01:00
Jonas Jenwald
996396a914 Change PasswordPrompt.close to an async method
This is consistent with the `open` method, and it actually *ever so slightly* reduces the size of the file.
2022-02-14 12:22:36 +01:00
Jonas Jenwald
2dececf445 Remove the typeof navigator-checks in the web/app_options.js file
Given that the `Navigator` interface has been available since "forever", please see https://developer.mozilla.org/en-US/docs/Web/API/Navigator#browser_compatibility, it's somewhat difficult to see why these checks are actually necessary since the viewer is only intended for usage in browsers.

Looking at the history of the code, this functionality was originally placed in the general `src/shared/compatibility.js` file which could thus run in e.g. worker-threads and Node.js environments (where the `Navigator` interface isn't available).
2022-02-14 12:22:36 +01:00
calixteman
d5f048abe0
Merge pull request #14563 from calixteman/search_eol
[Search] Some matches were incorrectly shifted because of some '-\n'
2022-02-14 10:30:45 +01:00
Calixte Denizet
18f4e560ae [Search] Some matches were incorrectly shifted because of some '-\n'
- it aims to fix #14562;
- 'X-\n' were not correctly positioned;
- when X is a diacritic (e.g. in "sä-\n", which is decomposed into "sa¨-\n") we must handle both things:
  - diacritics on the one hand;
  - "-\n" on the other hand.
2022-02-14 10:12:33 +01:00
calixteman
263c89581f
Merge pull request #14564 from calixteman/bug1755201
[api-minor] Don't add in the text content the chars which are out-of-page (bug 1755201)
2022-02-13 21:48:57 +01:00
Calixte Denizet
18e3a98c2b [api-minor] Don't add in the text content the chars which are out-of-page (bug 1755201)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1755201;
- if the glyph position is not within the view then skip it.
2022-02-13 21:07:11 +01:00
Tim van der Meij
78246719f8
Merge pull request #14559 from Snuffleupagus/revert-9505
Revert "Don't block origin-less blob:-URLs in hosted viewer"
2022-02-13 14:10:22 +01:00
Tim van der Meij
c37d785b2a
Merge pull request #14560 from Snuffleupagus/Node-ReadableStream-polyfill
[api-minor] Remove the, in `legacy` builds, bundled `ReadableStream` polyfill
2022-02-13 14:08:22 +01:00
Tim van der Meij
7ee531d918
Merge pull request #14558 from Snuffleupagus/getFilenameFromContentDispositionHeader-TextDecoder
Remove the UTF-8 fallback, when `TextDecoder` is missing, from the Content-Disposition parser
2022-02-13 14:02:50 +01:00
Tim van der Meij
99fde3cf86
Merge pull request #14557 from Snuffleupagus/issue-14555
Remove unnecessary `font-size` CSS rule from the `html` element (issue 14555, PR 3794 follow-up)
2022-02-13 14:01:02 +01:00
Jonas Jenwald
b89595fd20 [api-minor] Remove the, in legacy builds, bundled ReadableStream polyfill
According to the MDN compatibility data, see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#browser_compatibility, all browsers that we support have native `ReadableStream` implementations (since quite some time too).

Hence only Node.js is now lagging behind w.r.t. `ReadableStream` support, and its experimental implementation doesn't really help us given the life-span of the LTS releases (see https://en.wikipedia.org/wiki/Node.js#Releases).
It seems quite unfortunate to bundle a `ReadableStream` polyfill in the `legacy` builds when it's unnecessary in browsers, given its overall size, but fortunately we can avoid that by simply listing `web-streams-polyfill` as a dependency for the `pdfjs-dist` library.
2022-02-13 10:15:58 +01:00
Jonas Jenwald
911021002e Revert "Don't block origin-less blob:-URLs in hosted viewer"
This reverts commit a6aca3cabe, since no version of Internet Explorer is supported any more.
2022-02-12 11:32:10 +01:00
Jonas Jenwald
d642d34500 Remove the UTF-8 fallback, when TextDecoder is missing, from the Content-Disposition parser
Given that `TextDecoder` is now supported by all modern browsers/environments, please see https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder#browser_compatibility, there's no longer any good reason to keep a UTF-8 fallback in the Content-Disposition parser.
2022-02-12 10:30:25 +01:00
Jonas Jenwald
06190dbbb3 Remove unnecessary font-size CSS rule from the html element (issue 14555, PR 3794 follow-up)
According to https://github.com/mozilla/pdf.js/pull/3794#discussion_r6983639 this was intended to be *temporary*, and the B2G project itself was discontinued years ago.
2022-02-11 19:44:03 +01:00
Tim van der Meij
e9fd67a3f6
Merge pull request #14551 from Snuffleupagus/mv-createObjectURL
[api-minor] Stop exposing the `createObjectURL` helper function in the API
2022-02-11 19:40:25 +01:00
Jonas Jenwald
b87a243222 [api-minor] Stop exposing the createObjectURL helper function in the API
With recent changes, specifically PR 14515 *and* the previous patch, the `createObjectURL` helper function is now only used with the SVG back-end.
All other call-sites, throughout the code-base, are now using `URL.createObjectURL(...)` directly and it no longer seems necessary to keep exposing the helper function in the API.
Finally, the `createObjectURL` helper function is moved into the `src/display/svg.js` file to avoid unnecessarily duplicating this code on both the main- and worker-threads.
2022-02-10 12:01:35 +01:00
Jonas Jenwald
0daab88a48 Update two display_utils unit-tests to use native functionality rather than the createObjectURL helper function
Given that most of the code-base is already using native functionality, we can update these unit-tests similarily as well.
 - For the `blob:`-URL test, we simply use `URL.createObjectURL(...)` and `Blob` directly instead.
 - For the `data:`-URL test, we simply use `btoa` to do the Base64 encoding and then build the final URL-string.
2022-02-10 12:01:29 +01:00
Brendan Dahl
f8b2a99ddc
Merge pull request #14543 from Snuffleupagus/bug-1753983
Let `Lexer.getNumber` treat a single minus sign as zero (bug 1753983)
2022-02-09 14:06:35 -08:00
Tim van der Meij
d57f3a13d7
Merge pull request #14547 from Snuffleupagus/xfa_bug1720182-file
Update the file used with the `xfa_bug1720182` test-case
2022-02-09 19:45:18 +01:00
Tim van der Meij
d3d63cb471
Merge pull request #14548 from Snuffleupagus/bug-1754421
[api-minor] Ensure that the `PDFDocumentLoadingTask`-promise is rejected when cancelling the PasswordPrompt (bug 1754421)
2022-02-09 19:41:22 +01:00
Jonas Jenwald
1f0fb270b1 [api-minor] Ensure that the PDFDocumentLoadingTask-promise is rejected when cancelling the PasswordPrompt (bug 1754421)
This is essentially a *continuation* of PR 7926, where we added support for rejecting the current `PDFDocumentLoadingTask`-promise by throwing inside of the `onPassword`-callback.
Hence the naive way to address [bug 1754421](https://bugzilla.mozilla.org/show_bug.cgi?id=1754421) would be to simply throw in the `onPassword`-callback used in the default viewer. However it unfortunately turns out to not work, since the password input/validation is asynchronous, and we thus need another approach.

The simplest solution that I can come up with here, is thus to *extend* the `onPassword`-callback to also reject the current `PDFDocumentLoadingTask`-instance if an `Error` is explicitly passed as the input to the callback function. (This doesn't feel great, but I cannot see a better solution that isn't really complicated.)
2022-02-09 15:09:20 +01:00
Jonas Jenwald
188752e5f0 Update the test Driver to fail on duplicate files
While it's obviously fine to use the same PDF document in different reference-tests, note how we e.g. have both `eq` and `text` tests for one document, we should always avoid adding *duplicate* files in the `test/pdfs/` folder.
2022-02-08 16:59:18 +01:00
Jonas Jenwald
60efae96fd Update the file used with the xfa_bug1720182 test-case
The file used in this test-case is *identical* to, i.e. the md5 entry perfectly matches, the file used with the `xfa_bug1716380` test-case.
While it's obviously fine to use the same PDF document in different reference-tests, note how we e.g. have both `eq` and `text` tests for one document, we should always avoid adding *duplicate* files in the `test/pdfs/` folder.
2022-02-08 14:23:41 +01:00
Jonas Jenwald
64f3dbeb48 Let Lexer.getNumber treat a single minus sign as zero (bug 1753983)
This appears to be consistent with the behaviour in both Adobe Reader and PDFium (in Google Chrome); this is essentially the same approach as used for a single decimal point in PR 9827.
2022-02-07 17:09:47 +01:00
Tim van der Meij
acc758c40c
Merge pull request #14538 from Snuffleupagus/update-compat
[api-minor] Update the minimum supported browser versions
2022-02-06 14:11:33 +01:00
Tim van der Meij
200615d515
Merge pull request #14539 from mozilla/dependabot/npm_and_yarn/simple-get-3.1.1
Bump simple-get from 3.1.0 to 3.1.1
2022-02-06 13:28:31 +01:00
dependabot[bot]
a26ac162b6
Bump simple-get from 3.1.0 to 3.1.1
Bumps [simple-get](https://github.com/feross/simple-get) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/feross/simple-get/releases)
- [Commits](https://github.com/feross/simple-get/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: simple-get
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-06 12:14:16 +00:00
Tim van der Meij
a4864d0dc2
Merge pull request #14537 from Snuffleupagus/update-packages
Update packages and translations
2022-02-06 13:13:32 +01:00
Jonas Jenwald
03f5f6a421 [api-minor] Update the minimum supported browser versions
Please note that while we "support" some (by now) fairly old browsers, that essentially means that the library (and viewer) will load and that the basic functionality will work as intended.[1]
However, in older browsers, some functionality may not be available and generally we'll ask users to update to a modern browser when bugs (specific to old browsers) are reported.[2]

There's always a question of just how old browsers the PDF.js contributors can realistically support, and here I'm suggesting that we place the cut-off point at approximately *three* years.
With that in mind, this patch updates the *minimum* supported browsers (and environments) as follows:
 - Chrome 73, which was released on 2019-03-12; see https://en.wikipedia.org/wiki/Google_Chrome_version_history
 - Firefox ESR (as before); see https://wiki.mozilla.org/Release_Management/Calendar
 - Safari 12.1, which was released on 2019-03-25; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_12
 - Node.js 12, which was release on 2019-04-23 (and will soon reach EOL); see https://en.wikipedia.org/wiki/Node.js#Releases

---
[1] Assuming a `legacy`-build is being used, of course.

[2] In general it's never a good idea to use an old/outdated browser, since those may contain *known* security vulnerabilities.
2022-02-06 13:06:43 +01:00
Jonas Jenwald
86949cc930 Update l10n files 2022-02-06 11:34:26 +01:00
Jonas Jenwald
38f6e675bc Update the @javascript-obfuscator/escodegen package to the latest version
The only changes are support for [Class static initialization blocks](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Class_static_initialization_blocks), and the diff for the `node_modules\@javascript-obfuscator\escodegen\escodegen.js` file contains only:
```diff
@@ -1506,6 +1506,13 @@
             return result;
         },

+        StaticBlock: function (stmt, flags) {
+            return [
+                'static' + space,
+                this.BlockStatement(stmt, flags)
+            ];
+        },
+
         ThrowStatement: function (stmt, flags) {
             return [join(
                 'throw',
```
2022-02-06 11:26:07 +01:00
Jonas Jenwald
5f7b96c957 Update npm packages 2022-02-06 11:24:14 +01:00
Tim van der Meij
48139a0059
Merge pull request #14530 from Snuffleupagus/findResultsCount-height
Avoid the `findResultsCount` span taking up (vertical) space when hidden (PR 13261 follow-up)
2022-02-05 14:47:45 +01:00
Tim van der Meij
97619ba949
Merge pull request #14532 from Snuffleupagus/rm-moz-fullscreen-prefixes
[GENERIC viewer] Remove the `moz`-prefixed FullScreen API usage from the viewer
2022-02-05 14:44:09 +01:00
Tim van der Meij
ca663d4af9
Merge pull request #14535 from Snuffleupagus/findbar-label-casing
[GENERIC viewer] Use consistent casing, for the labels, in the findbar
2022-02-05 14:42:09 +01:00
Jonas Jenwald
cd7fe27468 [GENERIC viewer] Use consistent casing, for the labels, in the findbar
Note that the *browser* findbar in Firefox uses "Title Case" for the labels, and it thus seem like a good idea to ensure that `PDFFindBar` in consistent with that.
Furthermore, the new label added in PR #13261 uses the "Title Case" format which means that currently the default viewer findbar looks inconsistent.

*Please note:* Based on the official Firefox localization docs, see https://firefox-source-docs.mozilla.org/l10n/overview.html#string-updates, changing only the casing should *not* require updating the key:
> 1) If the change is minor, like fixing a spelling error or case, the developer should update the en-US translation without changing the l10n-id.
2022-02-05 11:18:20 +01:00
Jonas Jenwald
eee057ccd5 [GENERIC viewer] Remove the moz-prefixed FullScreen API usage from the viewer
The unprefixed FullScreen API has been available since Firefox 64, which was [released on 2018-12-11](https://wiki.mozilla.org/Release_Management/Calendar#Past_branch_dates), and has now been included in no less than *three* ESR releases.
Please also see the following MDN compatibility data:
 - https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenEnabled#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event#browser_compatibility
2022-02-04 12:44:27 +01:00
Jonas Jenwald
6fe4b3a5ae Simplify the findResultsCount span toggling, by using the same approach as with the findMsg span 2022-02-03 22:16:56 +01:00
Jonas Jenwald
d0354d20b3 Avoid the findResultsCount span taking up (vertical) space when hidden (PR 13261 follow-up)
When the viewer becomes narrow, the `PDFFindBar` will (forcibly) wrap its elements to prevent it from extending to the full window width.
Currently, after PR 13261, this now leads to the `findResultsCount` span taking up vertical space *unconditionally* when the findbar is wrapped. To avoid a blank space being shown in this case, before searching has begun, place the `findResultsCount` span in a "message" rather than an "options" container.
2022-02-03 21:52:01 +01:00
calixteman
8281e64db3
Merge pull request #13261 from calixteman/diacritics1
[api-minor] Support search with or without diacritics  (bug 1508345, bug 916883, bug 1651113)
2022-02-03 16:30:47 +01:00
Calixte Denizet
1f41028fcb Support search with or without diacritics (bug 1508345, bug 916883, bug 1651113)
- get original index in using a dichotomic seach instead of a linear one;
  - normalize the text in using NFD;
  - convert the query string into a RegExp;
  - replace whitespaces in the query with \s+;
  - handle hyphens at eol use to break a word;
  - add some \s* around punctuation signs
2022-02-03 15:42:55 +01:00
Jonas Jenwald
70073ed81c
Merge pull request #14527 from Snuffleupagus/rm-normalizeWhitespace
[api-minor] Remove the `normalizeWhitespace` option in the `PDFPageProxy.{getTextContent, streamTextContent}` methods (issue 14519, PR 14428 follow-up)
2022-02-03 10:22:20 +01:00
Jonas Jenwald
403baa7bba [api-minor] Remove the normalizeWhitespace option in the PDFPageProxy.{getTextContent, streamTextContent} methods (issue 14519, PR 14428 follow-up)
With these changes, we'll now *always* replace all whitespaces with standard spaces (0x20). This behaviour is already, since many years, the default in both the viewer and the browser-tests.
2022-02-03 09:17:22 +01:00
Tim van der Meij
48c8831a79
Merge pull request #14515 from Snuffleupagus/rm-disableCreateObjectURL
[api-minor] Remove support for browsers/environments without fully working `URL.createObjectURL` implementations
2022-02-02 20:04:07 +01:00
calixteman
1d1e50e8ee
Merge pull request #14522 from Snuffleupagus/rm-xfa_bug1716838
Remove the `xfa_bug1716838` browser-test since it's a duplicate
2022-02-01 12:24:06 +01:00
Jonas Jenwald
e13353cf21 Remove the xfa_bug1716838 browser-test since it's a duplicate
The md5 entry perfectly matches the `xfa_bug1717668_1` test-case, which means that we unnecessarily test the same exact document twice.
2022-02-01 12:05:19 +01:00