Commit Graph

13033 Commits

Author SHA1 Message Date
Tim van der Meij
c10aac9a1d
Upgrade Puppeteer to version 5.3.1 2020-10-03 23:06:31 +02:00
Tim van der Meij
2823beba69
Merge pull request #12441 from Snuffleupagus/src-eslint-config
Re-factor how the ESLint `no-var` rule is enabled in the `src/` folder
2020-10-03 22:36:13 +02:00
Jonas Jenwald
9416b14e8b Re-factor how the ESLint no-var rule is enabled in the src/ folder
This simplifies/consolidates the ESLint configuration slightly in the `src/` folder, and prevents the addition of any new files where `var` is being used.[1]
Hence we no longer need to manually add `/* eslint no-var: error */` in files, which is easy to forget, and can instead disable the rule in the `src/core/` files where `var` is still in use.

---
[1] Obviously the `no-var` rule can, in the same way as every other rule, be disabled on a case-by-case basis where actually necessary.
2020-10-03 20:15:29 +02:00
Tim van der Meij
48e27a1a22
Merge pull request #12437 from Snuffleupagus/src-display-no-var
Enable the ESLint `no-var` rule in the `src/display/` folder
2020-10-03 19:59:56 +02:00
Tim van der Meij
6ff1fe4ea9
Merge pull request #12333 from calixteman/tooltip
Add tooltip if any in annotations layer
2020-10-03 19:50:39 +02:00
Tim van der Meij
76e96d4364
Merge pull request #12436 from Snuffleupagus/src-shared-no-var
Enable the ESLint `no-var` rule in the `src/shared/` folder
2020-10-03 18:47:13 +02:00
Tim van der Meij
d86546e14c
Merge pull request #12439 from Snuffleupagus/viewer-version-build
Add `version`/`build` info at the top of the *built* `web/viewer.js` file
2020-10-03 18:39:54 +02:00
Jonas Jenwald
eb0cc7f9c3 Add version/build info at the top of the *built* web/viewer.js file
This should be helpful to easily determine the *exact* version of the viewer itself, when looking at a *built* `web/viewer.js` file.
Note that we're already including this information in other built files, such as e.g. `pdf.js`, `pdf.worker.js`, `pdf_viewer.js`, and `pdf.image_decoders.js`.
2020-10-03 09:19:53 +02:00
Jonas Jenwald
2a7d1557f9 Enable the ESLint no-var rule in the src/shared/ folder
Previously this rule has been enabled in the `web/` folder, and in select files in the `src/` sub-folders.
In this case, enabling of this rule didn't actually require any further code changes.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-var
2020-10-03 08:27:45 +02:00
Jonas Jenwald
52f6016e6c Fix the remaining ESLint no-var errors in the src/display/ folder
While most of necessary changes were fixed automatically, see the previous patch, there's a number of cases that needed to be fixed manually.
2020-10-02 16:29:13 +02:00
Jonas Jenwald
e557be5a17 Re-format the src/display/ files to enforce the ESLint no-var rule
This was done automatically, using `gulp lint --fix`.
2020-10-02 16:17:28 +02:00
Jonas Jenwald
2a8983d76b Enable the ESLint no-var rule in the src/display/ folder
Previously this rule has been enabled in the `web/` folder, and in select files in the `src/` sub-folders.
Note that a number of the files in the `src/display/` folder were already enforcing the `no-var` rule, and thanks to Prettier the necessary re-writing will be (mostly) handled automatically.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-var
2020-10-02 16:16:23 +02:00
calixteman
20b12d2bda Add tooltip if any in annotations layer 2020-10-02 10:11:18 +02:00
Tim van der Meij
88f72d6b1c
Merge pull request #12426 from Snuffleupagus/app-triggerPrinting
Re-factor how printing is triggered in the default viewer
2020-09-30 22:12:42 +02:00
Tim van der Meij
8e7a6e010d
Merge pull request #12419 from Snuffleupagus/fallbackToSystemFont-cidToGidMap
Use the `cidToGidMap`, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418)
2020-09-30 21:53:16 +02:00
Jonas Jenwald
89ce326d12 Re-factor how printing is triggered in the default viewer
This adds a new `PDFViewerApplication.triggerPrinting` method, which takes care of checking that printing is actually supported before calling `window.print`, to remove the need to duplicate that code in multiple places.

Also, removes the `PDFViewerApplication.printing` getter since it's not really necessary any more.
2020-09-30 15:10:19 +02:00
Tim van der Meij
d49b2f6cc2
Merge pull request #12422 from Snuffleupagus/find-not-shiftKey
Don't trigger searching, in the `GENERIC` viewer, when <kbd>Shift</kbd> is used together with the regular keyboard shortcut (issue 12421)
2020-09-29 22:30:53 +02:00
Tim van der Meij
8fa4e48f46
Merge pull request #12423 from Snuffleupagus/escodegen-2
Update `escodegen` to version 2.0
2020-09-29 22:27:42 +02:00
Jonas Jenwald
db4cefbac3 Add basic support for the optional chaining operator ?.
For now we need to use a Babel-plugin, since part of our build system doesn't support this fully (e.g. Babel-loader, Webpack 4.x, and SystemJS).

While the `?.` operator will thus always be transpiled by Babel, even in modern builds, simply supporting it for development purposes seems like a step in the right direction.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
2020-09-29 15:56:34 +02:00
Jonas Jenwald
5107259176 Update escodegen to version 2.0
This release contains support for additional modern ECMAScript features, such as e.g. the nullish coalescing operator `??` and the optional chaining operator `?.`.
2020-09-29 15:56:24 +02:00
Jonas Jenwald
f399ac7f16 Don't trigger searching, in the GENERIC viewer, when <kbd>Shift</kbd> is used together with the regular keyboard shortcut (issue 12421)
Please note that this change won't affect the Firefox built-in PDF Viewer, since it uses the native browser findbar. However, it brings the `GENERIC` viewer inline with how searching is normally triggered in browsers.

Note that in Firefox searching is only triggered by <kbd>Ctrl</kbd>+<kbd>F</kbd> (or <kbd>command</kbd>+<kbd>F</kbd> on Mac), but <kbd>Shift</kbd> isn't used; see https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly#w_search

Furthermore, looking at the "Miscellaneous" section of https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly#firefox:mac:fx81 the <kbd>command</kbd>+<kbd>Shift</kbd>+<kbd>F</kbd> shortcut is even reserved for the "Toggle Full Screen" functionality on Mac.
2020-09-29 11:50:20 +02:00
Jonas Jenwald
bd3b15b897 Use the cidToGidMap, if it exists, when building the glyph mapping for non-embedded composite fonts (issue 12418) 2020-09-28 14:40:43 +02:00
Tim van der Meij
6728c8fa61
Merge pull request #12405 from nickyc975/fixed-active-element-in-shadow-dom
Fixed keydown event handling problem with shadow DOM.
2020-09-26 23:02:13 +02:00
Tim van der Meij
8608f0e611
Merge pull request #12417 from Snuffleupagus/pageView-error
Remove the `PDFPageView.{error, stats}` properties, and some related viewer clean-up
2020-09-26 19:49:00 +02:00
Jonas Jenwald
2043596035 Use template strings when calculating the CSS transforms, in the PDFPageView.cssTransform method
In my opinion this slightly improves readability, by grouping related properties together.
2020-09-25 14:42:55 +02:00
Jonas Jenwald
8467f45ab7 Change the finishRenderTask helper function, in PDFThumbnailView.draw, to be asynchronous
This simplifies the implementation slightly, and is also (almost) identical to the `finishPaintTask` helper function in `PDFPageView.draw`.
2020-09-25 14:42:46 +02:00
Jonas Jenwald
a4e5458774 Update all BaseViewer.getPageView/PDFThumbnailViewer.getThumbnail call-sites, in web/app.js, to check the returned value properly
Given how those are used, there *should* not be any situation in which e.g. `undefined` is ever returned. However, actually checking that the pageView/thumbnail is defined cannot hurt.

Also, re-factor `webViewerPageRendered` slightly since the `pageView` is no longer unconditionally necessary after the previous patches; note in particular that the thumbnails will only be updated when the sidebar *and* the thumbnailView is visible.

Finally, fixes a bug in `webViewerPageChanging` whereby an empty string would not be treated as a valid pageLabel and instead be replaced by `null`.
2020-09-25 14:42:46 +02:00
Jonas Jenwald
e46055a92c Remove the PDFPageView.stats property, and fetch it manually only when debugging is enabled
Given that the default viewer only uses the "page stats" when debugging is enabled, it seems much simpler and more straightforward to simply query the API *directly* when this information is actually required. That way, there's a bit less information that needs to be stored/updated on each `PDFPageView`-instance.

Finally, since the `EventBus` now exists, we no longer need to handle the "page stats"-case in the regular listeners in `web/app.js`, but can instead add special "page stats"-listeners only when debugging is enabled.
2020-09-25 14:42:44 +02:00
Jonas Jenwald
9efc1784b2 Remove the PDFPageView.error property, and simply include Errors in the "pagerendered" event instead
The way that rendering errors are handled in `PDFPageView` is *very* old, and predates e.g. the introduction of the `EventBus` by several years.
Hence we should be able to simplify things a bit here, by including the Error (when it exists) in the "pagerendered" event and thus avoid having to reach into `PDFPageView` for it.
2020-09-25 14:21:12 +02:00
Jonas Jenwald
7b15094cdf Ignore RenderingCancelledException when logging errors in PDFRenderingQueue.renderView
Note that a `RenderingCancelledException` *should* never actually reach this method, but better safe than sorry I suppose, considering that both `PDFPageView` and `PDFThumbnailView` are already catching `RenderingCancelledException`s since those are *not* Errors in the normal sense of the word.
2020-09-25 14:21:05 +02:00
Tim van der Meij
120c5c2261
Merge pull request #12409 from Snuffleupagus/bug-1627030
Compute the `transformOrigin` correctly, for negative values, when rendering `AnnotationElement`s (bug 1627030)
2020-09-24 23:48:21 +02:00
Tim van der Meij
740e07cad4
Merge pull request #12414 from calixteman/bug_1666753
Need to reset the streams when printing
2020-09-24 22:57:00 +02:00
Calixte Denizet
5af352e65a Need to reset the streams when printing 2020-09-24 19:13:09 +02:00
Jonas Jenwald
fca53a8eb0 Compute the transformOrigin correctly, for negative values, when rendering AnnotationElements (bug 1627030)
This changes the `transformOrigin` calculations in `AnnotationElement._createContainer` and `PopupAnnotationElement.render`, to ensure that e.g. the clickable area of annotations and/or popups are both positioned correctly.

The problem occurs for *negative* values, since they're not negated correctly because of how the `transformOrigin` strings were build; see issue 12406 for a more in-depth explanation. Previously, for negative values, the `transformOrigin` strings would thus be ignored since they're not valid.
2020-09-24 10:28:29 +02:00
Nicky Chen
252e258a59 Fixed keydown event handling problem with shadow DOM.
Editable elements in shadow DOMs can not be detected in old version.
2020-09-24 08:17:56 +08:00
Tim van der Meij
139c8a8cb5
Merge pull request #12397 from Snuffleupagus/webpack-stream-update
Update the `webpack-stream` dependency (issue 11996)
2020-09-21 23:24:38 +02:00
Jonas Jenwald
3e9c489b8b Update the webpack-stream dependency (issue 11996)
Given that the long-standing `webpack-stream` issue 201 was recently fixed in PR 207, and a new version released, we should now finally be able to update the dependency.
However, depending on if/when `webpack-stream` gets support for Webpack 5 (which is currently in beta) we may still want remove our `webpack-stream` dependency.
2020-09-20 15:35:56 +02:00
Tim van der Meij
b8c856a53a
Merge pull request #12396 from Snuffleupagus/update-packages
Update packages and translations
2020-09-20 15:34:36 +02:00
Jonas Jenwald
fcfbc06a9c Update l10n files 2020-09-20 11:43:35 +02:00
Jonas Jenwald
4dcedeb98e Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2020-09-20 11:40:20 +02:00
Jonas Jenwald
36b8d5e72d Update npm packages 2020-09-20 11:34:24 +02:00
Tim van der Meij
c98046e5e3
Merge pull request #12393 from Snuffleupagus/issue-12392
Prevent errors if the `InkList` property, in InkAnnotations, is missing and/or not an Array (issue 12392)
2020-09-19 16:28:53 +02:00
Jonas Jenwald
2497e8eab9 Prevent errors if the InkList property, in InkAnnotations, is missing and/or not an Array (issue 12392)
To prevent a future bug, the `Vertices` property in PolylineAnnotations are handled the same way.
2020-09-19 15:34:32 +02:00
Tim van der Meij
26ae7ba2ad
Merge pull request #12387 from calixteman/fix_12386
Use the same kind of strings for radio values
2020-09-17 23:45:17 +02:00
Tim van der Meij
802b4c0850
Merge pull request #12388 from jsg2021/patch-1
Refactor the container/viewer checks in the BaseViewer constructor
2020-09-17 23:05:18 +02:00
Jonathan Grimes
d37a445369 Refactor the container/viewer checks in the BaseViewer constructor
The previous checks prevented specifying a container/viewer that was in another
document/window.
Fixes #12385
2020-09-17 20:29:10 +00:00
Calixte Denizet
d51e7e86ff Use the same kind of strings for radio values 2020-09-16 18:47:25 +02:00
Tim van der Meij
558d3870d3
Merge pull request #12369 from emilio/better-cancelation-follow-up
canvas: fix restore() with existing SMask groups and re-land #12363.
2020-09-15 23:19:17 +02:00
Tim van der Meij
374aad77c4
Merge pull request #12375 from Snuffleupagus/emptyDict-set
Ensure that the empty dictionary won't be accidentally modified, and slightly improve the "SaveDocument" handler in `src/core/worker.js`
2020-09-15 23:04:57 +02:00
Brendan Dahl
e73354a32d
Merge pull request #12377 from calixteman/fix_radio_saving
Set parent of radio annotation even if there is no 'V' field
2020-09-15 11:30:14 -07:00