Commit Graph

11943 Commits

Author SHA1 Message Date
Jonas Jenwald
8852991c60 Simplify the handling of EXCLUDE_LANG_CODES (PR 11213 follow-up) 2019-10-26 13:49:37 +02:00
Tim van der Meij
4a5a4328f4
Merge pull request #11273 from Snuffleupagus/getViewport-offsets
[api-minor] Support custom `offsetX`/`offsetY` values in `PDFPageProxy.getViewport` and `PageViewport.clone`
2019-10-24 00:08:40 +02:00
Tim van der Meij
9c7f691ba6
Merge pull request #11271 from Snuffleupagus/rm-DummyStatTimer
Re-factor `StatTimer` usage, in `src/display/api.js`, and remove `DummyStatTimer`
2019-10-24 00:03:36 +02:00
Jonas Jenwald
681bc9d70e [api-minor] Support custom offsetX/offsetY values in PDFPageProxy.getViewport and PageViewport.clone
There's no good reason, as far as I can tell, to not also support `offsetX`/`offsetY` in addition to e.g. `dontFlip`.
2019-10-23 20:48:14 +02:00
Jonas Jenwald
2046adcc49 Change the 'gets viewport respecting "dontFlip" argument' unit-test to use a valid rotation angle
As can be seen in `PageViewport` only multiples of 90 degrees are really supported by the code, hence the unit-test doesn't really make sense.
(Possibly this should be enforced in the API, to avoid surprises, but given that this problem has always existed I'm passing on that for now.)
2019-10-23 20:30:25 +02:00
Jonas Jenwald
6f7f8257bc Slightly re-factor the String handling in StatTimer
This uses template strings in a couple of spots, and a buffer in the `toString` method.
2019-10-23 14:45:18 +02:00
Jonas Jenwald
8e5d3836d6 Remove the enable argument from the StatTimer constructor
This argument is a left-over from older API code, where we unconditionally initialized `StatTimer` instances for every page. For quite some time that's only been done when `pdfBug` is set, hence it seems unnecessary to keep this functionality.
2019-10-23 14:45:18 +02:00
Jonas Jenwald
9fc40f8b84 Remove DummyStatTimer since it's unused now
Since this isn't part of the API surface, removing it now that it's unused shouldn't cause any problems.
2019-10-23 14:45:16 +02:00
Jonas Jenwald
860da8b840 Stop using the DummyStatTimer in the API, and check if this._stats exists when trying to report statistics
Even though the currect situation only results in six unnecessary function calls per page, it nonetheless seems completely unnecessary to call dummy functions when `pdfBug` is *not* set (i.e. the default behaviour).
2019-10-23 13:23:41 +02:00
Tim van der Meij
7aca15da70
Merge pull request #11268 from Zdobnov/refactor/avoid-css-duplication
refactor: viewer.css refactored, duplications removed
2019-10-22 23:41:35 +02:00
siarhei.zdabnou
fea102b235 border & box-shadow duplications removed 2019-10-22 14:25:42 +02:00
Tim van der Meij
d7f651aa98
Merge pull request #11263 from Snuffleupagus/viewer-disableAutoFetch-pagesCount
Attempt to reduce resource usage, by not eagerly fetching all pages, for long/large documents
2019-10-20 15:24:17 +02:00
Jonas Jenwald
ce816eed8e Attempt to reduce resource usage, by not eagerly fetching all pages, for long/large documents
For *very* long/large documents fetching all pages on load may cause quite bad performance, both memory and CPU wise. In order to at least slightly alleviate this, we can let the viewer treat these kind of documents[1] as if `disableAutoFetch` were set.

---
[1] One example of a really bad case is https://bugzilla.mozilla.org/show_bug.cgi?id=1588435, which this patch should at least help somewhat. In general, for these cases, we'd probably need to implement switching between `PDFViewer`/`PDFSinglePageViewer` (as already tracked on GitHub) and use the latter for these kind of long documents.
2019-10-20 13:21:36 +02:00
Tim van der Meij
826a2a69a0
Merge pull request #11262 from Snuffleupagus/mozcentral-chrome.properties
Re-add the en-US `chrome.properties` l10n file, to avoid it being removed at mozilla-central (PR 11256 follow-up)
2019-10-20 00:02:37 +02:00
Jonas Jenwald
0a17fca46e Ensure that we'll never, accidentally, try and fetch the default en-US locale (PR 11213 follow-up) 2019-10-19 18:00:15 +02:00
Jonas Jenwald
ee57832de2 Re-add the en-US chrome.properties l10n file, to avoid it being removed at mozilla-central (PR 11256 follow-up)
Unfortunately I forgot to test `gulp mozcentraldiff` with PR 11256, which is really bad since it will cause the en-US `chrome.properties` l10n file to be deleted at mozilla-central; sorry about breaking this!

In order to address this we'll have to re-add (only) the en-US `chrome.properties` l10n file, which is simple enough. Furthermore, since we're not doing any sort of build-specific parsing of the l10n files, we can just copy the en-US files as-is rather than having to run `gulp locale` during `gulp mozcentral`.
2019-10-19 17:28:37 +02:00
Tim van der Meij
3c23ac212e
Merge pull request #11261 from Snuffleupagus/DocException
Re-factor sending of various Exceptions from the worker to the API
2019-10-19 15:31:12 +02:00
Jonas Jenwald
df0e1edab5 Re-factor sending of various Exceptions from the worker to the API
As can be seen in the API, there's a number of document loading Exception handlers which are both really simple and highly similar. Hence these are changed such that all the relevant Exceptions are sent via *one* message instead.

Furthermore, the patch also avoids unnecessarily re-creating `UnknownErrorException`s at the worker side and removes an unnecessary `bind` call.
2019-10-19 12:54:54 +02:00
Tim van der Meij
11f3851a97
Merge pull request #11243 from Snuffleupagus/issue-11242
Add a fallback for non-embedded *composite* Verdana fonts (issue 11242)
2019-10-18 23:56:46 +02:00
Tim van der Meij
884e1ef234
Merge pull request #11260 from Snuffleupagus/update-npm-packages
Update npm packages
2019-10-18 23:53:35 +02:00
Jonas Jenwald
a5d0fa5fe1 Fix (most) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.

*Please note:* There's two vulnerabilities left, however they couldn't be fixed automatically and may thus benefit from being handled separately.
2019-10-18 16:46:35 +02:00
Jonas Jenwald
c0c5a8282d Update packages 2019-10-18 16:42:02 +02:00
Tim van der Meij
c54bb222ca
Merge pull request #11231 from Snuffleupagus/indexObjects-entries-gen
Allow over-writing entries, in `XRef.indexObjects`, only when the generation number matches (issues 11230, 11139, 9552, 9129, 7303)
2019-10-17 23:56:26 +02:00
Tim van der Meij
d0d92d34b0
Merge pull request #11257 from Snuffleupagus/skipPages
Remove/update `skipPages` annotations from `test/test_manifest.json`
2019-10-17 23:55:57 +02:00
Tim van der Meij
90d7d2103e
Merge pull request #11256 from Snuffleupagus/firefox-rm-addon-l10n
[Firefox] Remove unused addon `l10n` files (PR 9566 follow-up)
2019-10-17 23:45:58 +02:00
Jonas Jenwald
2fcb5afc7b Add a fallback for non-embedded *composite* Verdana fonts (issue 11242)
Obviously this won't look exactly right, but considering that the PDF file doesn't bother embedding non-standard fonts this is the best that we can do here.
2019-10-17 17:00:55 +02:00
Jonas Jenwald
17a3af3fc0 Replace a couple of skipPages annotations with firstPage in test/test_manifest.json
Originally only `skipPages` existed, but given that `firstPage`/`lastPage` has existed for a long time now using them whenever possible looks simpler overall.
2019-10-17 13:20:56 +02:00
Jonas Jenwald
f3c5a690fc Remove unnecessary skipPages annotations from test/test_manifest.json
- In the `ibwa-bad` case the sixteenth page contains corrupt/incomplete commands, but given that we're suppressing `Error`s by default now skipping hardly seems warranted any more.

 - In the `geothermal.pdf` case the first page contains an unsupported ColourSpace, but again we're suppressing `Error`s by default now and skipping hardly seems warranted any more.
2019-10-17 13:20:49 +02:00
Jonas Jenwald
b7ddd10741 Update l10n files 2019-10-17 12:27:16 +02:00
Jonas Jenwald
b663cec383 [Firefox] Stop fetching the chrome.properties files during gulp importl10n (PR 9566 follow-up)
With the removal of the (standalone) Firefox building code in PR 9566 (a year and a half ago), these files are now completely unused in the GitHub repository[1].
Hence it doesn't really seem necessary to keep fetching them with `gulp importl10n`, and the existing files in the `l10n` folder can also be removed (thanks to version control, they're easy enough to restore should the need ever arise).

The patch also allows an additional simplification, for the `gulp locale` and `gulp mozcentral` commands, since it's now possible to stop writing `l10n` files to the `extensions/firefox/` folder and instead just copy them similar to other build targets.

---
[1] They're obviously still used in `mozilla-central`, for fallback messages displayed through `PdfStreamConverter.jsm`, but that doesn't make it necessary to keep them *here* as far as I'm concerned.
2019-10-17 12:27:11 +02:00
Jonas Jenwald
8a057dcf90 [Firefox] Stop building the metadata.inc/chrome.manifest.inc files during gulp locale (PR 9566 follow-up)
With the removal of the (standalone) Firefox building code in PR 9566 (a year and a half ago), these files are now completely unused.
Hence it doesn't really make sense to keep building them as part of `gulp locale`, and the existing files in the `l10n` folder can also be removed (thanks to version control, they're easy enough to restore should the need ever arise).
2019-10-17 11:49:30 +02:00
Tim van der Meij
af61d48899
Merge pull request #11250 from Snuffleupagus/silence-Autoprefixer-message
Silence the Autoprefixer message being printed with all build logs
2019-10-17 00:28:52 +02:00
Tim van der Meij
50573019b1
Merge pull request #11253 from Snuffleupagus/issue-7156
Avoid handling keyboard shortcuts for `contentEditable` DOM elements (issue 7156)
2019-10-17 00:26:40 +02:00
Jonas Jenwald
d67a5d395c Avoid handling keyboard shortcuts for contentEditable DOM elements (issue 7156)
The issue has been open for years now, and has even been marked with `5-good-beginner-bug` for *months*, without any movement.
Considering just how simple the suggested solution is, I'm submitting this patch just to close out a long-standing issue.
2019-10-16 16:50:43 +02:00
Jonas Jenwald
171c886570 Silence the Autoprefixer message being printed with all build logs
The following is printed with every build, which gets kind of annoying when looking at the logs:
```
Replace Autoprefixer browsers option to Browserslist config.
Use browserslist key in package.json or .browserslistrc file.

Using browsers option cause some error. Browserslist config
can be used for Babel, Autoprefixer, postcss-normalize and other tools.

If you really need to use option, rename it to overrideBrowserslist.

Learn more at:
https://github.com/browserslist/browserslist#readme
https://twitter.com/browserslist
```

Given how we're using Autoprefixer, with a number of build-specific configs, simply changing the option name seems like the easiest solution here.

(I'm also adding a couple of newlines at the `autoprefixer` call-sites, to aid readability.)
2019-10-16 13:10:16 +02:00
Pedro Luiz Cabral Salomon Prado
4d0c759b7f Change variable assignment (#11247)
Remove unused variable assignment in `src/core/fonts.js`
2019-10-16 00:39:25 +02:00
Tim van der Meij
ecdf1375b8
Merge pull request #11246 from Snuffleupagus/issue-11245
Tweak the `isIOS` check, in `web/viewer_compatibility`, to attempt to support newer Safari versions (issue 11245)
2019-10-16 00:34:31 +02:00
Jonas Jenwald
f964cbc961 Tweak the isIOS check, in web/viewer_compatibility, to attempt to support newer Safari versions (issue 11245)
Obviously userAgent checks aren't that great, since it's very easy to spoof, but it probably doesn't hurt to attempt to extend this (since it's limited to `GENERIC` builds).
Besides, anyone using the default viewer can always set the `maxCanvasPixels` option to a value of their choosing.
2019-10-15 17:22:28 +02:00
Jonas Jenwald
ffc847eaa5 Allow over-writing entries, in XRef.indexObjects, only when the generation number matches (issues 11230, 11139, 9552, 9129, 7303)
This patch is making me somewhat worried about future regressions, since it's certainly easy to imagine this completely breaking certain kinds of corrupt/edited PDF documents while fixing others.[1]

Obviously it passes all existing reference tests (and even improves one), however compared to many other patches there's no telling how much it could break.
The only reason that I'm even submitting this patch, is because of the number of open issues that it would address.

Generally speaking though, the best course of action would probably be if `XRef.indexObjects` was re-written to be much more robust (since it currently feels somewhat hand-wavy in parts). E.g. by actually checking/validating more of the objects before committing to them.

---
[1] Especially given that it's reverting part of PR 5910, however in the case of issue 5909 it seems that other (more recent) changes have actually made that PR redundant.
2019-10-14 22:10:04 +02:00
Tim van der Meij
16ae7c6960
Merge pull request #11235 from timvandermeij/jsdoc
Improve the JSDoc comments
2019-10-13 21:28:18 +02:00
Tim van der Meij
ec6a99d781
Bundle all API documentation in a module
This commit allows JSDoc to generate all API documentation in the
`pdfjsLib` module (namespace) so the documentation becomes easier to
navigate.
2019-10-13 21:23:00 +02:00
Tim van der Meij
92155f6a5f
Don't include src/shared/util.js for the API documentation
This file only contains helper functions and should not be listed in the
documentation since they are not part of the public API.
2019-10-13 21:23:00 +02:00
Tim van der Meij
9f4d45ddf4
Don't include private methods in the the PDFPageProxy API documentation 2019-10-13 21:23:00 +02:00
Tim van der Meij
36c01c2c2a
Deduplicate the documentation for PDFDocumentLoadingTask and PDFWorker
Both classes live inside a closure with the same name, which confuses
JSDoc. Move the documentation to the inner class to deduplicate them.
2019-10-13 21:23:00 +02:00
Tim van der Meij
ca3a58f93a
Consistently use @returns for returned data types in JSDoc comments
Sometimes we also used `@return`, but `@returns` is what the JSDoc
documentation recommends. Even though `@return` works as an alias, it's
good to use the recommended syntax and to be consistent within the
project.
2019-10-13 13:58:17 +02:00
Tim van der Meij
8b4ae6f3eb
Consistently use @type for getter data types in JSDoc comments
Sometimes we also used `@return` or `@returns`, but `@type` is what
the JSDoc documentation recommends. This also improves the documentation
because before this commit the types were not shown and now they are.
2019-10-13 13:58:17 +02:00
Tim van der Meij
f4daafc077
Consistently use square brackets for optional parameters in JSDoc comments
Square brackets are recommended to indicate optional parameters. Using
them helps for automatically generating correct documentation.
2019-10-13 13:58:17 +02:00
Tim van der Meij
efd331daa1
Consistently use string for string data types in JSDoc comments
Sometimes we also used `String`, but `string` is the what the JSDoc
documentation recommends.
2019-10-13 13:58:17 +02:00
Tim van der Meij
e75991b49e
Consistently use number for numeric data types in JSDoc comments
Sometimes we also used `Number` and `integer`, but `number` is what
the JSDoc documentation recommends.
2019-10-13 13:58:13 +02:00
Tim van der Meij
ff37cdb5d7
Merge pull request #11237 from Snuffleupagus/compatibility-SKIP_BABEL
Update `src/shared/compatibility.js` to only run with `SKIP_BABEL = false` set
2019-10-13 12:22:22 +02:00