Commit Graph

11961 Commits

Author SHA1 Message Date
Nisar Hassan Naqvi
b21a341332 Simplifies code contributions by automating the dev setup with gitpod.io 2019-11-06 04:12:19 +00:00
Tim van der Meij
30ef05c161
Merge pull request #11290 from Snuffleupagus/MessageHandler-rm-in
[MessageHandler] Re-factor and convert the code to a proper `class`
2019-10-31 23:57:52 +01:00
Tim van der Meij
c807637f40
Merge pull request #11294 from Snuffleupagus/rm-non-PRODUCTION-require
Remove some unused `require` statements, used when loading fake workers, in non-`PRODUCTION` mode
2019-10-31 23:47:55 +01:00
Jonas Jenwald
eedd449cb4 Remove some unused require statements, used when loading fake workers, in non-PRODUCTION mode
The code in question is *only* relevant in non-`PRODUCTION` mode, i.e. the *development* version of the viewer run with `gulp server`, and has been completely unused at least since SystemJS was added.
I really cannot see any reason to keep this, since it's code which first of all isn't shipping and secondly isn't even being used in the development viewer.
2019-10-31 12:08:07 +01:00
Jonas Jenwald
0293222b96 [MessageHandler] Convert the code to a proper class 2019-10-30 23:22:59 +01:00
Jonas Jenwald
5d5733c0a7 [MessageHandler] Convert all instances of var to const in the code 2019-10-30 23:22:59 +01:00
Jonas Jenwald
f61fb3e0f9 [MessageHandler] Re-factor the _onComObjOnMessage function to use early returns
When `ReadableStream` support was added to the `MessageHandler`, the `_onComObjOnMessage` function became more complex than previously.
All of the nested `if`/`else if`/`else` branches are now, at least in my opinion, making some of this code a bit difficult to follow. Hence this patch, which attempts to help readability by making use of early `return`s and `Error`s.

The patch also changes a couple of `var`/`let` occurences to `const`.
2019-10-30 23:22:59 +01:00
Jonas Jenwald
62f28e11a3 [MessageHandler] Remove unnecessary usage of in from the code
Note that using `in` leads to unnecessary stringification of the properties, which seems completely unnecessary here. To avoid future problems from these changes the `MessageHandler.on` method will now assert, in non-`PRODUCTION`/`TESTING` builds, that it's always called with a function as expected.

This patch also renames `callbacksCapabilities` to `callbackCapabilities`, note the removed "s", since using a double plural format looks a bit strange.
2019-10-30 23:22:59 +01:00
Jonas Jenwald
3e46e800a0 [MessageHandler] Replace the internal isReply property, as sent when Promise callbacks are used, with enumeration values
Given that the `isReply` property is an internal implementation detail, changing its type shouldn't be a problem. Note that by directly indicating if either data or an Error is sent, it's no longer necessary to use `in` when handling the callback.
2019-10-30 23:22:59 +01:00
Tim van der Meij
72bd8e8bdb
Merge pull request #11284 from Snuffleupagus/ObjectLoader-allChunksLoaded
Make the `ObjectLoader` use more efficient methods when determining if data needs to be loaded
2019-10-30 22:48:48 +01:00
Jonas Jenwald
2d35a49dd8 Inline a couple of isRef/isDict checks in the ObjectLoader code
As we've seen in numerous other cases, avoiding unnecessary function calls is never a bad thing (even if the effect is probably tiny here).
2019-10-29 23:20:10 +01:00
Jonas Jenwald
1133dbac33 Make the ObjectLoader use more efficient methods when determining if data needs to be loaded
Currently, for data in `ChunkedStream` instances, the `getMissingChunks` method is used in a couple of places to determine if data is already available or if it needs to be loaded.

When looking at how `ChunkedStream.getMissingChunks` is being used in the `ObjectLoader` you'll notice that we don't actually care about which *specific* chunks are missing, but rather only want essentially a yes/no answer to the "Is the data available?" question.
Furthermore, when looking at how `ChunkedStream.getMissingChunks` itself is implemented you'll notice that it (somewhat expectedly) always iterates over *all* chunks.

All in all, using `ChunkedStream.getMissingChunks` in the `ObjectLoader` seems like an unnecessary "heavy" and roundabout way to obtain a boolean value. However, it turns out there already exists a `ChunkedStream.allChunksLoaded` method, consisting of a *single* simple check, which seems like a perfect fit for the `ObjectLoader` use cases.
In particular, once the *entire* PDF document has been loaded (which is usually fairly quick with streaming enabled), you'd really want the `ObjectLoader` to be as simple/quick as possible (similar to e.g. loading a local files) which this patch should help with.

Note that I wouldn't expect this patch to have a huge effect on performance, but it will nonetheless save some CPU/memory resources when the `ObjectLoader` is used. (As usual this should help larger PDF documents, w.r.t. both file size and number of pages, the most.)
2019-10-29 23:20:09 +01:00
Tim van der Meij
16fb5437c7
Merge pull request #11283 from Snuffleupagus/hasBlendModes-Array
Ensure that `PartialEvaluator.hasBlendModes` handles Blend Modes in Arrays (PR 11281 follow-up)
2019-10-28 23:14:04 +01:00
Jonas Jenwald
0496ea61f5 Ensure that PartialEvaluator.hasBlendModes handles Blend Modes in Arrays (PR 11281 follow-up)
I completely overlooked this in PR 11281, but you obviously need to make similar changes in `PartialEvaluator.hasBlendModes` since it will otherwise ignore valid Blend Modes.
2019-10-28 11:37:05 +01:00
Tim van der Meij
31737565d5
Merge pull request #11281 from Snuffleupagus/issue-11279
Support Blend Modes which are specified in an Array of Names (issue 11279)
2019-10-27 19:09:54 +01:00
Tim van der Meij
b8d129eeea
Merge pull request #11282 from Snuffleupagus/EXCLUDE_LANG_CODES
Update l10n files
2019-10-26 14:26:25 +02:00
Jonas Jenwald
5c266f0e8c Support Blend Modes which are specified in an Array of Names (issue 11279)
According to the specification, the first *supported* Blend Mode should be choosen in this case; please see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G10.4848607
2019-10-26 14:24:31 +02:00
Jonas Jenwald
d08ecdb9fa Update l10n files 2019-10-26 13:56:37 +02:00
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