Commit Graph

13635 Commits

Author SHA1 Message Date
Brendan Dahl
56fd01bf8d
Merge pull request #13078 from brendandahl/disable-missing
Disable intermittent unit test "creates pdf doc from non-existent URL"
2021-03-11 21:17:54 -08:00
Brendan Dahl
47a5550f10 Disable intermittent unit test "creates pdf doc from non-existent URL"
Disable this test so we don't have to manually review unit test
failure log all the time.
2021-03-11 11:40:40 -08:00
Brendan Dahl
1b42fe2917
Merge pull request #13015 from calixteman/avoid_dl
JS - Avoid a popup to ask for updating Acrobat.
2021-03-11 08:43:49 -08:00
Brendan Dahl
3d4bb5e5c5
Merge pull request #13018 from calixteman/xfa_bind
XFA - Create Form DOM in merging template and data trees
2021-03-10 10:27:06 -08:00
Calixte Denizet
3243672727 XFA - Create Form DOM in merging template and data trees
- Spec: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.364.2157&rep=rep1&type=pdf#page=171;
  - support for the 2 ways of merging: consumeData and matchTemplate;
  - create additional nodes in template DOM when occur node allows it;
  - support for global values in data DOM.
2021-03-08 14:10:30 +01:00
Tim van der Meij
5e3af62d58
Merge pull request #13063 from Snuffleupagus/more-web-optional-chaining
Use more optional chaining in the web/-folder (PR 12961 follow-up)
2021-03-07 19:00:57 +01:00
Jonas Jenwald
bc13932ac1 Use more optional chaining in the web/-folder (PR 12961 follow-up)
I overlooked these cases previously, but there's no reason why optional chaining (and nullish coalescing) cannot be used here as well.
2021-03-07 16:20:52 +01:00
Jonas Jenwald
bdde621366 Avoid unnecessary size_kb calculation, for large files, in PDFDocumentProperties._parseFileSize (PR 13050 follow-up) 2021-03-07 16:10:11 +01:00
Tim van der Meij
34c9e889ac
Merge pull request #13062 from Snuffleupagus/rm-features
Remove the `test/features` folder, since it's very out of date (issue 11954)
2021-03-07 13:51:49 +01:00
Jonas Jenwald
36bb4fa823 Remove the test/features folder, since it's very out of date (issue 11954)
These tests, and their [accompanying Wiki page](https://github.com/mozilla/pdf.js/wiki/Required-Browser-Features), haven't received any real updates for *many years* and are sufficiently out of date to be effectively useless now.
Providing *irrelevant* compatibility information seems overall worse than not providing any information, and as suggested in the issue it'd probably be better to use https://github.com/mozilla/pdf.js#online-demo for checking if a particular platform/browser is supported.

Thanks to version control, it's easy to restore these files should the need ever arise. However, re-introducing these tests would essentially require updating every single test-case *and* a commitment to keeping them up to date with future code changes.
2021-03-07 13:41:30 +01:00
Tim van der Meij
ba1b4097dc
Merge pull request #13055 from calixteman/reset_radio
JS - reset correctly radio buttons
2021-03-07 13:23:18 +01:00
Tim van der Meij
11d86df4a7
Merge pull request #13060 from Snuffleupagus/update-packages
Update packages and translations
2021-03-07 12:54:13 +01:00
Jonas Jenwald
d4cf751f91 Update l10n files 2021-03-07 12:05:10 +01:00
Jonas Jenwald
75eb2aedaa Update npm packages 2021-03-07 12:00:57 +01:00
Calixte Denizet
c01ef24541 JS - reset correctly radio buttons 2021-03-07 11:04:40 +01:00
Tim van der Meij
709c57a66b
Merge pull request #13054 from Snuffleupagus/scripting-pageOpenClose
Move handling of the PageOpen/PageClose events into the `PDFScriptingManager` (PR 13042 follow-up)
2021-03-06 20:33:07 +01:00
Jonas Jenwald
87dd93b7fc Move handling of the PageOpen/PageClose events into the PDFScriptingManager (PR 13042 follow-up)
By moving this code from the `BaseViewer` and into `PDFScriptingManager`, all of the scripting initialization/handling code is now limited to just one file/class which help overall readability (in my opinion). Also, this patch is a *net reduction* in number of lines of code which can never hurt.

As part of these changes, the intermediary "pageopen"/"pageclose" events are now removed in favor of using the "regular" viewer events directly in `PDFScriptingManager`. Hence this removes some (strictly unnecessary) indirection in the current code, when handling PageOpen/PageClose events, which leads to overall fewer function calls in this part of the code.
2021-03-06 10:12:32 +01:00
Tim van der Meij
fb87704b38
Merge pull request #13042 from Snuffleupagus/PDFScriptingManager
[api-minor] Move the viewer scripting initialization/handling into a new `PDFScriptingManager` class
2021-03-05 21:43:42 +01:00
Jonas Jenwald
a6d1cba38c [api-minor] Move the viewer scripting initialization/handling into a new PDFScriptingManager class
The *main* purpose of this patch is to allow scripting to be used together with the viewer components, note the updated "simpleviewer"/"singlepageviewer" examples, in addition to the full default viewer.
Given how the scripting functionality is currently implemented in the default viewer, trying to re-use this with the standalone viewer components would be *very* hard and ideally you'd want it to work out-of-the-box.

For an initial implementation, in the default viewer, of the scripting functionality it probably made sense to simply dump all of the code in the `app.js` file, however that cannot be used with the viewer components.
To address this, the functionality is moved into a new `PDFScriptingManager` class which can thus be handled in the same way as all other viewer components (and e.g. be passed to the `BaseViewer`-implementations).

Obviously the scripting functionality needs quite a lot of data, during its initialization, and for the default viewer we want to maintain the current way of doing the lookups since that helps avoid a number of redundant API-calls.
To that end, the `PDFScriptingManager` implementation accepts (optional) factories/functions such that we can maintain the current behaviour for the default viewer. For the viewer components specifically, fallback code-paths are provided to ensure that scripting will "just work"[1].

Besides moving the viewer handling of the scripting code to its own file/class, this patch also takes the opportunity to re-factor the functionality into a number of helper methods to improve overall readability[2].
Note that it's definitely possible that the `PDFScriptingManager` class could be improved even further (e.g. for general re-use), since it's still heavily tailored to the default viewer use-case, however I believe that this patch is still a good step forward overall.

---

[1] Obviously *all* the relevant document properties might not be available in the viewer components use-case (e.g. the various URLs), but most things should work just fine.

[2] The old `PDFViewerApplication._initializeJavaScript` method, where everything was simply inlined, have over time (in my opinion) become quite large and somewhat difficult to *easily* reason about.
2021-03-05 20:31:48 +01:00
Jonas Jenwald
5b9638329c Move apiPageLayoutToSpreadMode and apiPageModeToSidebarView from web/app.js and into web/ui_utils.js
These changes will be necessary for the next patch, since we don't want to accidentally pull in the entire default viewer in the standalone viewer components.
2021-03-05 20:31:48 +01:00
Tim van der Meij
583d77a53f
Merge pull request #13053 from Snuffleupagus/dev-enableScripting
Enable scripting by default in the development viewer; remove the standalone `acroforms` example
2021-03-05 20:27:25 +01:00
Jonas Jenwald
bd7868f54c Remove the standalone acroforms example
At this point in time the standalone `acroforms` example is no longer needed, since both the `simpleviewer` and `singlepageviewer` examples already support AcroForms by default.
Moreover, the `acroforms` example no longer illustrate best practices, given the direct usage of `PDFPageView` for a multipage document.
2021-03-04 23:56:51 +01:00
Jonas Jenwald
7dc1bbf05e Enable scripting by default in the development viewer
Given that scripting is now enabled in Firefox Nightly (but only there), it seems weird to not have scripting enabled by default in `gulp server` mode.
2021-03-04 23:56:51 +01:00
Tim van der Meij
4b49db7c95
Merge pull request #13050 from Snuffleupagus/l10n-fallback
Collect all l10n fallback strings, used in the viewer, in one helper function (PR 12981 follow-up)
2021-03-04 23:46:48 +01:00
Jonas Jenwald
038668bf8c Collect all l10n fallback strings, used in the viewer, in one helper function (PR 12981 follow-up)
Rather than having to spell out the English fallback strings at *every* single `IL10n.get` call-site throughout the viewer, we can simplify things by collecting them in *one* central spot.
This provides a much better overview of the fallback l10n strings used, which makes future changes easier and ensures that fallback strings occuring in multiple places cannot accidentally get out of sync.
Furthermore, by making the `fallback` parameter of the `IL10n.get` method *optional*[1] many of the call-sites (and their surrounding code) become a lot less verbose.

---
[1] It's obviously still possible to pass in a fallback string, it's just not required.
2021-03-04 11:34:51 +01:00
Tim van der Meij
8d203b3039
Merge pull request #13045 from mozilla/dependabot/npm_and_yarn/pug-code-gen-2.0.3
Bump pug-code-gen from 2.0.1 to 2.0.3
2021-03-03 19:51:22 +01:00
dependabot[bot]
6312a321df
Bump pug-code-gen from 2.0.1 to 2.0.3
Bumps [pug-code-gen](https://github.com/pugjs/pug) from 2.0.1 to 2.0.3.
- [Release notes](https://github.com/pugjs/pug/releases)
- [Commits](https://github.com/pugjs/pug/compare/pug-code-gen@2.0.1...pug@2.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-03 02:28:49 +00:00
Tim van der Meij
9d91237d14
Merge pull request #13039 from Snuffleupagus/issue-13036
Change the background to ensure that the sidebar is visible/readable when the viewer is narrow (issue 13036)
2021-03-01 23:25:44 +01:00
Jonas Jenwald
7c52c01267 Change the background to ensure that the sidebar is visible/readable when the viewer is narrow (issue 13036)
This is more fallout from PR 11077.
2021-03-01 18:27:27 +01:00
Tim van der Meij
63c5d449f2
Merge pull request #13033 from timvandermeij/annotation-line-without-appearance
Implement rendering line annotations without appearance stream
2021-02-28 20:02:01 +01:00
Tim van der Meij
5828ff6cb0
Implement rendering line annotations without appearance stream 2021-02-28 18:57:58 +01:00
Tim van der Meij
d6e0b2d92e
Merge pull request #13032 from Snuffleupagus/parseDestDictionary-actionName-warn
Don't warn about actions that require scripting support in `Catalog.parseDestDictionary`
2021-02-28 14:52:06 +01:00
Tim van der Meij
5f37d4e2b4
Merge pull request #13031 from timvandermeij/annotation-square-circle-no-appearance-stream
Implement rendering square/circle annotations without appearance stream
2021-02-28 14:47:13 +01:00
Jonas Jenwald
39cf4a0008 Don't warn about actions that require scripting support in Catalog.parseDestDictionary
Now that we have scripting support, warning about e.g. JavaScript actions doesn't seem necessary anymore. Especially considering that scripting-related actions are/will not be parsed by the `Catalog.parseDestDictionary` method anyway, since it's intended for handling "simple" actions.
2021-02-28 13:13:17 +01:00
Tim van der Meij
fa6cebf045
Implement rendering square/circle annotations without appearance stream 2021-02-27 19:05:12 +01:00
Tim van der Meij
8e74278b65
Merge pull request #13030 from Snuffleupagus/cmap-class-async
Modernize some of the code in `src/core/cmap.js` by using classes and async/await
2021-02-27 16:11:37 +01:00
Jonas Jenwald
05de20071a Modernize some of the code in src/core/cmap.js by using classes and async/await
This converts a couple of our old "classes" to proper ECMAScript classes, and replaces a lot of manual Promise-wrapping with async/await instead.
2021-02-27 14:20:43 +01:00
Tim van der Meij
5a8b849944
Merge pull request #13029 from timvandermeij/no-var
Enable the `no-var` linting rule in more core files
2021-02-27 13:35:49 +01:00
Tim van der Meij
4e96d59fca
Use a buffer instead of string concatenation in reverseIfRtl in src/core/unicode.js
This avoids creating intermediate strings and should be slightly more
efficient.
2021-02-27 13:20:09 +01:00
Tim van der Meij
24f80f1e38
Enable the no-var linting rule in src/core/primitives.js 2021-02-27 12:51:01 +01:00
Tim van der Meij
ed33727419
Enable the no-var linting rule in src/core/glyphlist.js 2021-02-27 12:46:57 +01:00
Tim van der Meij
e051d4d029
Enable the no-var linting rule in src/core/ccitt_stream.js 2021-02-27 12:44:55 +01:00
Tim van der Meij
0897dddbbe
Enable the no-var linting rule in src/core/unicode.js 2021-02-27 12:44:50 +01:00
Tim van der Meij
cb82dda755
Enable the no-var linting rule in src/core/metrics.js 2021-02-27 12:44:45 +01:00
Tim van der Meij
052db45e7a
Merge pull request #13023 from calixteman/fix_color_test
Fix integration test with js-colors
2021-02-26 23:22:23 +01:00
Tim van der Meij
2da850d8c9
Merge pull request #13024 from Snuffleupagus/Puppeteer-8
Update Puppeteer to version 8
2021-02-26 22:42:11 +01:00
Tim van der Meij
55786a4880
Merge pull request #13026 from Snuffleupagus/crypto-classes
Convert code in `src/core/crypto.js` to use "normal" classes
2021-02-26 22:39:30 +01:00
Tim van der Meij
848753671f
Merge pull request #13025 from Snuffleupagus/function-classes
Convert code in `src/core/function.js` to use "normal" classes
2021-02-26 22:22:38 +01:00
Brendan Dahl
5dd749cd60
Merge pull request #13014 from Snuffleupagus/Firefox-contentDispositionFilename
[api-minor] Support the Content-Disposition filename in the Firefox PDF Viewer (bug 1694556, PR 9379 follow-up)
2021-02-26 07:50:00 -08:00
Jonas Jenwald
6b4c4f80e4 Convert code in src/core/crypto.js to use "normal" classes
All of this code predates the existence of native JS classes, however we can now clean this up a bit. This patch thus let us remove some variable "shadowing" from the code.
2021-02-26 15:51:45 +01:00