Commit Graph

11918 Commits

Author SHA1 Message Date
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
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
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
Jonas Jenwald
03387ebaa8 Update src/shared/compatibility.js to only run with SKIP_BABEL = false set
Rather than specifying certain build targets manually, it seems much more appropriate (and future-proof) to use the `SKIP_BABEL` build target instead.

Also, the patch adds a missing `/* eslint no-var: error */` line since I'm touch the file anyway and no code-changes were necessary for it.
2019-10-13 11:33:41 +02:00
Tim van der Meij
4af2755f71
Merge pull request #11234 from Snuffleupagus/indexObjects-eq-tests
Convert a number of reference tests, for documents with corrupt XRef tables, from `load` to `eq`
2019-10-12 19:27:35 +02:00
Jonas Jenwald
259551d144 Convert a number of reference tests, for documents with corrupt XRef tables, from load to eq
As part of attempting to fix a number issues containing PDF documents with corrupt XRef tables, I'd like to improve the reference test-coverage slightly *first*.
Obviously this will increase the runtime of the tests a bit, however I'd rather "waste" resources on the bots instead of developer time fixing regressions which could have been avoided.
2019-10-12 18:49:59 +02:00
Tim van der Meij
c701ae3f4c
Merge pull request #11232 from Snuffleupagus/hasBlendModes-improvements
Cache processed 'ExtGState's in `PartialEvaluator.hasBlendModes` to avoid unnecessary parsing/lookups
2019-10-12 14:09:53 +02:00
Jonas Jenwald
bfcbf2d78d Cache processed 'ExtGState's in PartialEvaluator.hasBlendModes to avoid unnecessary parsing/lookups
This simply extends the already existing caching of processed resources to avoid duplicated parsing of 'ExtGState's, which should help with badly generated PDF documents.

This patch was tested using the PDF file from issue 6961, i.e. https://github.com/mozilla/pdf.js/files/121712/test.pdf, with the following manifest file:
```
[
    {  "id": "issue6961",
       "file": "../web/pdfs/issue6961.pdf",
       "md5": "",
       "rounds": 200,
       "type": "eq"
    }
]
```

which gave the following *overall* results when comparing this patch against the `master` branch:
```
-- Grouped By browser, stat --
browser | stat         | Count | Baseline(ms) | Current(ms) | +/- |    %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | --- | ----- | -------------
Firefox | Overall      |   400 |         1063 |        1051 | -12 | -1.17 |        faster
Firefox | Page Request |   400 |          552 |         543 |  -9 | -1.69 |        faster
Firefox | Rendering    |   400 |          511 |         508 |  -3 | -0.61 |
```

and the following *page-specific* results:
```
-- Grouped By page, stat --
page | stat         | Count | Baseline(ms) | Current(ms) | +/- |    %  | Result(P<.05)
---- | ------------ | ----- | ------------ | ----------- | --- | ----- | -------------
0    | Overall      |   200 |         1122 |        1110 | -12 | -1.03 |
0    | Page Request |   200 |          552 |         544 |  -8 | -1.48 |        faster
0    | Rendering    |   200 |          570 |         566 |  -4 | -0.62 |
1    | Overall      |   200 |         1005 |         992 | -13 | -1.33 |        faster
1    | Page Request |   200 |          552 |         542 | -11 | -1.91 |        faster
1    | Rendering    |   200 |          452 |         450 |  -3 | -0.61 |
```
2019-10-12 12:35:42 +02:00
Jonas Jenwald
af71f9b40a Inline all the possible type checks in PartialEvaluator.hasBlendModes to avoid unnecessary function calls
For badly generated PDF documents, with issue 6961 being one example, there's well over one hundred thousand function calls being made in total for just the *two* pages.
2019-10-12 11:24:37 +02:00
Tim van der Meij
dcf49ac753
Merge pull request #11228 from Snuffleupagus/eslint-accessor-pairs
Enable the ESLint rule `accessor-pairs` for Classes
2019-10-11 22:25:52 +02:00
Jonas Jenwald
4bdf65b89d Enable the ESLint rule accessor-pairs for Classes
Please see https://eslint.org/docs/rules/accessor-pairs#enforceforclassmembers
2019-10-11 13:28:46 +02:00
Luís Takahashi
00c3339520 Add Create React App example with TypeScript and basic usage 2019-10-10 23:25:41 +02:00
Tim van der Meij
d20ab76242
Merge pull request #11218 from Snuffleupagus/loadFont-fallback
Attempt to fallback to a default font, for non-available ones, in `PartialEvaluator.loadFont`
2019-10-10 23:15:49 +02:00
huzjakd
94171d9d72 Attempt to fallback to a default font, for non-available ones, in PartialEvaluator.loadFont
This handles the two different ways that fonts can be loaded, either by Name (which is the common case) or by Reference.
Furthermore, this also takes the `ignoreErrors` option into account when deciding whether to fallback or Error.
Finally, by creating a minimal but valid Font dictionary, there's no special-cases necessary in any of the font parsing code.

Co-authored-by: huzjakd <huzjakd@gmail.com>
Co-Authored-By: Jonas Jenwald <jonas.jenwald@gmail.com>
2019-10-10 16:49:46 +02:00
Tim van der Meij
d2959fc9c9
Merge pull request #11219 from Snuffleupagus/throw-deprecated-methods
[api-minor] Replace all `deprecated` calls with throwing of actual `Error`s
2019-10-09 23:32:22 +02:00
Tim van der Meij
1c0a93aafd
Merge pull request #11222 from Snuffleupagus/rm-unmaintained-locales
Remove locales which are unmaintained and/or not shipping in Nightly (PR 11213 follow-up)
2019-10-09 23:30:50 +02:00
Jonas Jenwald
307a85901d Remove locales which are unmaintained and/or not shipping in Nightly (PR 11213 follow-up)
With the sole exception of `meh`[1], none of the locales removed here have even been updated since the last change was made to the default `en-US` locale.

Please note that if/when these locales would start shipping in Nightly again, they will automatically be re-added in PDF.js as well with the `gulp importl10n` command.

---
[1] The current translation is also somewhat incomplete, to put it mildly.
2019-10-09 10:18:00 +02:00
Jonas Jenwald
ea729ec55c [api-minor] Replace all deprecated calls with throwing of actual Errors
All of these methods have been marked as `deprecated` in *three* releases now, and I'd thus like to (slowly) move towards complete removal.

However rather than just removing the methods right away, which would cause somewhat cryptic failures, this patch tries to implement a hopefully reasonable middle ground by throwing `Error`s with (essentially) the same information as the previous warnings.

While the previous `deprecated` messages could perhaps be seen as optional, with these changes API consumers will now be forced to actually migrate their code.
2019-10-09 09:21:15 +02:00
Tim van der Meij
5191d10dbc
Merge pull request #11209 from tamuratak/square_bracket_for_optional
Use square brackets for optional properties in the JSDoc comments of `src/display/api.js`
2019-10-08 23:25:52 +02:00
Takashi Tamura
d5ee083050 * use square brackets for optional properties in the JSDoc comments of src/display/api.js 2019-10-08 20:34:17 +09:00
Tim van der Meij
cead77ef3a
Merge pull request #11186 from Snuffleupagus/issue-9655
Improve the heuristics, in `PartialEvaluator._buildSimpleFontToUnicode`, for glyphNames of the Cdd{d}/cdd{d} format (issue 9655)
2019-10-06 19:50:43 +02:00
Tim van der Meij
a21f60415d
Merge pull request #11213 from Snuffleupagus/importl10n-fetch-langCodes
Update the `gulp importl10n` command to fetch the active language codes
2019-10-06 19:44:10 +02:00
Tim van der Meij
5fb3eb7728
Merge pull request #11212 from Snuffleupagus/MessageHandler-deleteStreamController
[MessageHandler] Some additional (small) clean-up of the code
2019-10-06 19:23:13 +02:00
Jonas Jenwald
dee3da69d4 Have gulp importl10n list locales which may be candidates for removal
Rather than having the script remove locales automatically, which seems like a heavy-handed approach at least initially, listing these for manual checking seems nice though.
2019-10-06 18:12:29 +02:00
Jonas Jenwald
8d74a9ae7f Update l10n files 2019-10-06 18:12:29 +02:00
Jonas Jenwald
ed71ec3785 Update the gulp importl10n command to fetch the active language codes
Rather than having to manually maintain a static list of language codes, it's much easier to simply fetch the active ones from `mozilla-central` instead.

As part of this the code in `external/importL10n/locales.js` was modernized slightly, by using Promises/async functions to get rid of a bunch of annoying callbacks (which shouldn't be a problem for reasonably modern Node.js versions).
2019-10-06 18:12:27 +02:00
Jonas Jenwald
eabedab38e [MessageHandler] Add a non-PRODUCTION/TESTING check to ensure that wrapReason is called with a valid reason
There shouldn't be any situation where `reason` isn't either an `Error`, or a cloned "Error" sent via `postMessage`.
2019-10-06 14:15:13 +02:00
Jonas Jenwald
9201c8dad4 [MessageHandler] Convert the deleteStreamController helper function to a "private" method instead 2019-10-06 14:15:02 +02:00