Commit Graph

12441 Commits

Author SHA1 Message Date
Tim van der Meij
404d698dd2
Merge pull request #11734 from Snuffleupagus/rm-throw-methods
Remove old API methods which were previously converted to throwing (PR 11219 follow-up)
2020-03-24 00:06:02 +01:00
Jonas Jenwald
216cbca16c Remove variable shadowing from the JavaScript files in the src/core/ folder
*This is part of a series of patches that will try to split PR 11566 into smaller chunks, to make reviewing more feasible.*

Once all the code has been fixed, we'll be able to eventually enable the ESLint no-shadow rule; see https://eslint.org/docs/rules/no-shadow
2020-03-23 18:28:30 +01:00
Jonas Jenwald
59eada6972 Add passive: false to the wheel event listener used in PDFPresentationMode (issue 11735, PR 10765 follow-up) 2020-03-23 17:07:32 +01:00
Jonas Jenwald
5eabe08c74 Exclude the setPDFNetworkStreamFactory function from the built API docs
Please note that the `setPDFNetworkStreamFactory` functionality isn't exposed in the public API, i.e. not listed among the exports in the `src/pdf.js` file, and that even if it were it wouldn't really be useful considering that none of the `PDFNetworkStream`/`PDFFetchStream`/`PDFNodeStream` classes are exported either.
2020-03-23 16:41:06 +01:00
Jonas Jenwald
c3c197d87a Remove old API methods which were previously converted to throwing (PR 11219 follow-up)
These methods were deprecated already in PDF.js version `2.1.266`, see PRs 10246 and 10369, and were converted to throw `Error`s upon invocation in PDF.js version `2.4.456`, see PR 11219.
Hence it ought to be possible to remove these methods now.
2020-03-23 16:41:03 +01:00
Tim van der Meij
b86df97725
Merge pull request #11725 from Snuffleupagus/app-ViewHistory-init
Re-factor `PDFViewerApplication.load` such that `{PDFViewer, PDFThumbnailViewer}.setDocument` happens slightly earlier
2020-03-22 17:15:44 +01:00
Tim van der Meij
c551c332ec
Merge pull request #11723 from Snuffleupagus/no-shadow-src-display
Remove variable shadowing from the JavaScript files in the `src/display/` folder
2020-03-22 16:38:13 +01:00
Tim van der Meij
066ff62527
Merge pull request #11724 from Snuffleupagus/default_preferences-web-files
Only build the necessary `web/` files during the `gulp default_preferences` task
2020-03-22 16:30:56 +01:00
Tim van der Meij
f53db81c20
Merge pull request #11728 from Snuffleupagus/PDFDocumentProperties-constructor-props
Remove unnecessary checks from the `PDFDocumentProperties` constructor
2020-03-22 16:26:18 +01:00
Jonas Jenwald
d3044ac394 Remove unnecessary checks from the PDFDocumentProperties constructor
Given that none of the relevant options are marked as optional in the code/JSDocs, and that the `PDFDocumentProperties` class is specific to the default viewer (and not exposed as part of the viewer components), there's no good reason as far as I can tell for these checks.
2020-03-22 15:49:41 +01:00
Jonas Jenwald
9f70bca12c Re-factor PDFViewerApplication.load such that {PDFViewer, PDFThumbnailViewer}.setDocument happens slightly earlier
The `BaseViewer.setDocument` method in particular is necessary for rendering to start when the viewer loads, hence you obviously want that to happen as soon as possible and without any unnecessary delays.
Unfortunately *some* API calls need to be done before that, note existing comments, however the `ViewHistory` initialization (and subsequent fetching of data) in particular can be moved slightly without any adverse effects.

As part of testing I've used logging with `performance.now()` inserted in various parts of this code, and there's *obviously* no discernible changes between `master` and this patch for e.g. rendering starting in the viewer.

*Note:* The vast majority of this patch is simple indentation changes, which were forced by Prettier (and done automatically with `gulp lint --fix`).
2020-03-22 10:21:05 +01:00
Jonas Jenwald
08f9718a37 Add a bit more validation in the ViewHistory constructor
- Ensure that `database.files` actually contains an Array, rather than some arbitrary data.

 - Only try to lookup an existing entry when the `database` existed on load, since there's obviously nothing to find when `database.files = []` was set (this case is very common in the MOZCENTRAL build since `sessionStorage` is being used there).
2020-03-21 13:55:06 +01:00
Jonas Jenwald
29ee2590d4 Only build the necessary web/ files during the gulp default_preferences task
By explicitly specifying only the required `web/` files, the runtime of the gulp task is reduced by approximately 30 percent.
2020-03-21 11:34:32 +01:00
Jonas Jenwald
3539a17d2a Remove variable shadowing from the JavaScript files in the src/display/ folder
*This is part of a series of patches that will try to split PR 11566 into smaller chunks, to make reviewing more feasible.*

Once all the code has been fixed, we'll be able to eventually enable the ESLint no-shadow rule; see https://eslint.org/docs/rules/no-shadow
2020-03-20 23:09:41 +01:00
Tim van der Meij
3cebb430c2
Merge pull request #11721 from Snuffleupagus/travis-no-npm-update
Don't let Travis run `npm update` during setup
2020-03-20 21:06:45 +01:00
Tim van der Meij
6ecc9fae1c
Merge pull request #11720 from Snuffleupagus/eslint-no-unsanitized
Update the `eslint-plugin-no-unsanitized` package to the latest version
2020-03-20 21:04:24 +01:00
Tim van der Meij
ab2b2ae30b
Merge pull request #11719 from Snuffleupagus/rm-fonts-widechars
Remove the unused `wideChars` property on `Font` instances
2020-03-20 21:00:09 +01:00
Jonas Jenwald
62a9c26cda Always prefer the PDF.js JPEG decoder for very large images, in order to reduce peak memory usage (issue 11694)
When JPEG images are decoded by the browser, on the main-thread, there's a handful of short-lived copies of the image data; see c3f4690bde/src/display/api.js (L2364-L2408)
That code thus becomes quite problematic for very big JPEG images, since it increases peak memory usage a lot during decoding. In the referenced issue there's a couple of JPEG images whose dimensions are `10006 x 7088` (i.e. ~68 mega-pixels), which causes the *peak* memory usage to increase by close to `1 GB` (i.e. one giga-byte) in my testing.

By letting the PDF.js JPEG decoder, rather than the browser, handle very large images the *peak* memory usage is considerably reduced and the allocated memory also seem to be reclaimed faster.

*Please note:* This will lead to movement in some existing `eq` tests.
2020-03-20 16:37:19 +01:00
Jonas Jenwald
78b1dad2a9 Don't let Travis run npm update during setup
Letting Travis update npm packages can lead to unexpected and completely unrelated failures for any PR and/or merge, see e.g. 11719, if there's ever backwards *incompatible* changes when a package is updated.

The *exact* package versions are specified in `package-lock.json`, and they should thus be used when running tests. Note that the bots won't update npm packages, and neither should Travis as far as I'm concerned.
2020-03-20 15:45:15 +01:00
Jonas Jenwald
b02be3b268 Update the eslint-plugin-no-unsanitized package to the latest version 2020-03-20 11:25:39 +01:00
Jonas Jenwald
1cd9d5a8fd Remove the unused wideChars property on Font instances
This property was added in PR 1599 (almost eight years ago), but has been unused ever since PR 3674 (six and a half years ago).
2020-03-20 10:37:32 +01:00
Tim van der Meij
4893b14a52
Merge pull request #11717 from timvandermeij/bump
Bump versions in `pdfjs.config` and update the getting started page of the website for the new release
2020-03-19 23:14:59 +01:00
Tim van der Meij
1bca1e3823
Update the getting started page of the website for the new release 2020-03-19 23:07:45 +01:00
Tim van der Meij
a94407f983
Bump versions in pdfjs.config 2020-03-19 23:01:17 +01:00
Tim van der Meij
228a591ca3
Merge pull request #11716 from Snuffleupagus/private-PDFPageProxy-pageIndex
[api-minor] Change the pageIndex, on `PDFPageProxy` instances, to a private property
2020-03-19 22:35:29 +01:00
Tim van der Meij
caabaab4a5
Merge pull request #11711 from Snuffleupagus/update-packages
Update packages and translations
2020-03-19 22:30:13 +01:00
Tim van der Meij
3d06e4af66
Merge pull request #11714 from Snuffleupagus/eslint-prefer-exponentiation-operator
Enable the `prefer-exponentiation-operator` ESLint rule
2020-03-19 22:28:32 +01:00
Jonas Jenwald
ae2900e510 [api-minor] Change the pageIndex, on PDFPageProxy instances, to a private property
This property has never been documented and/or *intentionally* exposed through the API, instead the `PDFPageProxy.pageNumber` property is the documented/intended API to use here.
Hence pageIndex is changed to a "private" property on `PDFPageProxy` instances, and internal API functionality is also updated to *consistently* use `this._pageIndex` rather than a mix of formats.
2020-03-19 15:47:11 +01:00
Jonas Jenwald
e011be037e Enable the prefer-exponentiation-operator ESLint rule
Please see https://eslint.org/docs/rules/prefer-exponentiation-operator for additional information.
2020-03-19 12:41:25 +01:00
Jonas Jenwald
4ac34c6283 Update l10n files 2020-03-19 09:58:49 +01:00
Jonas Jenwald
577ada48d0 Update npm packages 2020-03-19 09:55:14 +01:00
Tim van der Meij
c3f4690bde
Merge pull request #11706 from Snuffleupagus/mv-webViewerOpenFile
Move the `webViewerOpenFile` function, and the "openfile" eventBus listener, since they only matter in GENERIC builds of the default viewer
2020-03-17 22:38:11 +01:00
Jonas Jenwald
300a663458 Move the webViewerOpenFile function, and the "openfile" eventBus listener, since they only matter in GENERIC builds of the default viewer
This is similar to the existing implementation of the `webViewerFileInputChange` function and its associated "fileinputchange" event.
2020-03-17 13:30:38 +01:00
Tim van der Meij
f9ce22c08a
Merge pull request #11700 from Snuffleupagus/viewer-JS-warn
Ensure that the JavaScript-warning is always displayed, in the viewer, regardless of browser printing support
2020-03-16 21:47:27 +01:00
Jonas Jenwald
b3d7d1c614 Ensure that the JavaScript-warning is always displayed, in the viewer, regardless of browser printing support
The viewer doesn't currently support executing of any JavaScript, as found in some PDF documents, for security reasons. (Although there's a small hack to at least provide basic support for automatic printing on document load, without running scripts.)

However, in the event that the browser doesn't support printing we're not run *any* of this code. In particular that means that we're also not displaying the "Warning: JavaScript is not supported" message, which seems strange since JavaScript found in a PDF document can really contain *anything* (and not only printing instructions).

It thus seem reasonable, as far as I'm concerned, to always display the JavaScript-warning *even* if printing happens to be unsupported.
2020-03-15 14:41:13 +01:00
Tim van der Meij
1bc5cef2b5
Merge pull request #11698 from Snuffleupagus/issue-11697
Don't accidentally accept invalid glyphNames which *appear* to follow the Cdd{d}/cdd{d} format in `PartialEvaluator._buildSimpleFontToUnicode` (issue 11697)
2020-03-15 13:36:09 +01:00
Tim van der Meij
4dc1058ceb
Merge pull request #11553 from tamuratak/svg_texthscale
Fix the horizontal scaling of texts with SVG backend. #10988
2020-03-15 13:25:08 +01:00
Tim van der Meij
aa3e5a2b8f
Merge pull request #11644 from Snuffleupagus/openAction
[api-minor] Add more general OpenAction support (PR 10334 follow-up, issue 11642)
2020-03-15 13:16:37 +01:00
Tim van der Meij
6db227d82a
Merge pull request #11699 from mozilla/dependabot/npm_and_yarn/acorn-6.4.1
Bump acorn from 6.4.0 to 6.4.1
2020-03-14 22:58:35 +01:00
Jonas Jenwald
15e8692eff Don't accidentally accept invalid glyphNames which *appear* to follow the Cdd{d}/cdd{d} format in PartialEvaluator._buildSimpleFontToUnicode (issue 11697)
The /Differences array of the problematic font contains a `/c.1` entry, which is consequently detected as a *possible* Cdd{d}/cdd{d} glyphName by the existing heuristics.
Because of how the base 10 conversion is implemented, which is necessary for the base 16 special case, the parsed charCode becomes `0.1` thus causing `String.fromCodePoint` to throw since that obviously isn't a valid code point.

To fix the referenced issue, and to hopefully prevent similar ones in the future, the patch adds *additional* validation of the charCode found by the heuristics.
2020-03-13 23:35:47 +01:00
dependabot[bot]
977839c046
Bump acorn from 6.4.0 to 6.4.1
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-03-13 22:13:33 +00:00
Tim van der Meij
960fdf9113
Merge pull request #11695 from Snuffleupagus/no-shadow-web
Remove variable shadowing from the JavaScript files in the `web/` folder
2020-03-13 22:42:32 +01:00
Jonas Jenwald
886b256ada Remove variable shadowing from the JavaScript files in the web/ folder
*This is part of a series of patches that will try to split PR 11566 into smaller chunks, to make reviewing more feasible.*

Once all the code has been fixed, we'll be able to eventually enable the ESLint `no-shadow` rule; see https://eslint.org/docs/rules/no-shadow
2020-03-13 12:59:58 +01:00
Tim van der Meij
a23ce6b483
Merge pull request #11692 from Snuffleupagus/no-shadow-prepare
Move `IsLittleEndianCached`/`IsEvalSupportedCached` to `src/shared/util.js`, and rename the `isSpace` helper function to `isWhiteSpace`
2020-03-12 23:31:07 +01:00
Jonas Jenwald
c5f67300e9 Rename the isSpace helper function to isWhiteSpace
Trying to enable the ESLint rule `no-shadow`, against the `master` branch, would result in a fair number of errors in the `Glyph` class in `src/core/fonts.js`.
Since the glyphs are exposed through the API, we can't very well change the `isSpace` property on `Glyph` instances. Thus the best approach seems, at least to me, to simply rename the `isSpace` helper function to `isWhiteSpace` which shouldn't cause any issues given that it's only used in the `src/core/` folder.
2020-03-12 11:36:59 +01:00
Jonas Jenwald
e4758beaaa Move IsLittleEndianCached and IsEvalSupportedCached to src/shared/util.js
Rather than duplicating the lookup and caching in multiple files, it seems easier to simply move all of this functionality into `src/shared/util.js` instead.
This will also help avoid a bunch of ESLint errors once the `no-shadow` rule is eventually enabled.
2020-03-12 11:36:26 +01:00
Tim van der Meij
6db8e085ee
Merge pull request #11686 from janpe2/reftest-image-dim
Magnifier positioning in reftest analyzer
2020-03-11 21:02:06 +01:00
Tim van der Meij
4ff67a518e
Merge pull request #11690 from Snuffleupagus/rm-toolbarButton-transition
Remove transition effects from toolbar buttons/fields
2020-03-11 20:58:48 +01:00
Jonas Jenwald
1dd617e091 Remove transition effects from toolbar buttons/fields
While Firefox originally used transition effects for browser UI toolbar buttons, that was removed years ago in https://bugzilla.mozilla.org/show_bug.cgi?id=1393057

Since the PDF.js viewer toolbar transitions were likely based on the Firefox ones, it seems reasonable that these transition effects are removed from PDF.js as well. Besides removing a bunch of CSS, this also makes the toolbar feel ever so slightly more "snappy" without these delays on mouse interaction.

(In order to make it more feasible to modernize/improve the viewer UI, trying to clean-up/simplify existing rules iteratively seems like the most reasonble way to make any progress here w.r.t. being able to test/review things.)
2020-03-11 14:02:39 +01:00
Jani Pehkonen
e0daabd2dd Magnifier positioning in reftest analyzer
When reftest analyzer shows magnified pixels, there is a seemingly random offset between the mouse position and the magnified position. The reason for this is that reftest analyzer assumes all images have 800 * 1000 pixels but actually the test images have varying sizes.
2020-03-10 19:09:15 +02:00