Commit Graph

11850 Commits

Author SHA1 Message Date
Tim van der Meij
7fc329d6e3
Merge pull request #10902 from ahuglajbclajep/tiling-pattern-support
Implement tiling patterns for the SVG back-end
2019-06-28 12:45:02 +02:00
Tim van der Meij
f1867de492
Merge pull request #10925 from Snuffleupagus/eslint_no-unsanitized
Enable the `eslint-plugin-no-unsanitized` ESLint plugin to disallow unsafe usage of e.g. `innerHTML`
2019-06-27 20:32:24 +02:00
ahuglajbclajep
77940dbd86 Implement tiling patterns for the SVG back-end 2019-06-25 16:25:25 +09:00
Tim van der Meij
2cc0bfd1b1
Merge pull request #10926 from Snuffleupagus/parser-signature
Change the signature of the `Parser` constructor to take a parameter object
2019-06-23 22:53:37 +02:00
Jonas Jenwald
f710eb56e4 Change the signature of the Parser constructor to take a parameter object
A lot of the `new Parser()` call-sites look quite unwieldy/ugly as-is, with a bunch of somewhat randomly ordered arguments, which we can avoid by changing the constructor to accept an object instead. As an added bonus, this provides better documentation without having to add inline argument comments in the code.
2019-06-23 16:01:45 +02:00
Jonas Jenwald
5bb5e7741d Enable the eslint-plugin-no-unsanitized ESLint plugin to disallow unsafe usage of e.g. innerHTML
See https://github.com/mozilla/eslint-plugin-no-unsanitized

Since we've generally never allowed e.g. `innerHTML`, which is enforced during review, there's only one linting failure with this patch. (Which is white-listed, according to the existing comment and the fact that it's test-only code.)
2019-06-23 13:50:30 +02:00
Tim van der Meij
1c9a69db82
Merge pull request #10903 from Snuffleupagus/worker-streams
Move `PDFWorkerStream` and related code to its own file
2019-06-15 22:34:05 +02:00
Tim van der Meij
0471a9961f
Merge pull request #10905 from Snuffleupagus/pin-eslint-plugin-mozilla
Pin the version of `eslint-plugin-mozilla` to prevent failures on Travis (issue 10901)
2019-06-15 21:52:35 +02:00
Jonas Jenwald
562e4ea14c Pin the version of eslint-plugin-mozilla to prevent failures on Travis (issue 10901)
It appears that the changes in `eslint-plugin-mozilla` version `1.3.0`, see https://bugzilla.mozilla.org/show_bug.cgi?id=1556013, causes dependency issues on Travis.
2019-06-15 14:02:28 +02:00
Jonas Jenwald
021e5ffb88 Move PDFWorkerStream and related code to its own file
Since all other `IPDFStream` implementations live in their own files, it seems reasonable for these to do so as well.

Furthermore, converts all of the relevant code to ES6 classes and updates the interface definitions to mark a couple of methods `async`.
2019-06-15 13:05:25 +02:00
Tim van der Meij
7348275094
Merge pull request #10898 from Snuffleupagus/firefox-print-resolution
Allow experimenting with the `printResolution` AppOption when printing with the built-in Firefox version
2019-06-11 23:42:03 +02:00
Tim van der Meij
64b520404e
Merge pull request #10897 from Snuffleupagus/rm-isPageVisible-check
Remove a superfluous `linkService.isPageVisible` check from `PDFFindController` (PR 10217 follow-up)
2019-06-11 23:40:29 +02:00
Jonas Jenwald
d6cc393cd9 Remove a superfluous linkService.isPageVisible check from PDFFindController (PR 10217 follow-up)
Unless the `PDFLinkService` instance contains all of the expected methods, a lot of things will break in various places in the default viewer. Hence there's not much value in having this check, and outright falling seems more appropriate.

Finally, this also makes the return value explicit in this case, since that's consistent with the rest of the `PDFFindController._shouldDirtyMatch` method.
2019-06-10 21:04:47 +02:00
Jonas Jenwald
5d3973ef59 Allow experimenting with the printResolution AppOption when printing with the built-in Firefox version
As have already been stated multiple times, simply increasing the printing resolution may have undesirable effects on both memory usage *and* general performance. Hence why PR 10854 did *not* add a preference, and only exposed AppOption by default in `GENERIC` builds for now.

However, considering how differently printing works in the built-in Firefox version (with `mozPrintCallback`) compared to the general default viewer, any testing done in the latter case might not be completely relevant to the first (and most important) case of the Firefox PDF Viewer.

Note that considering the implementation of `AppOptions.get`, this patch will be safe and should allow experimenting with `printResolution` in all builds of the default viewer[1]. By not, however, having `printResolution` appear in AppOptions for either the `MOZCENTRAL` or `CHROMIUM` build targets, there should be no indication of official support for now.
Furthermore, it shouldn't be a preference at this point in time (or even at all), since that makes it too easy for users to change it permanently[2] and possible "break" printing.

---

[1] By running `PDFViewerApplicationOptions.get('printResolution', /* value here */);` in the console after the viewer loads.

[2] I've seen Firefox bugs, filed in Bugzilla, where users modified e.g. preferences manually in `about:config` and then some time later (maybe months) wondered why something was suddenly broken. In those cases, trying to work out that a preference change was the culprit can take time/effort.
2019-06-10 17:45:28 +02:00
Tim van der Meij
06b253d609
Merge pull request #10890 from Snuffleupagus/outline-items-hidden
Add support for outline items, in the default viewer, which default to collapsed when the outline is built
2019-06-09 11:35:49 +02:00
Tim van der Meij
bb540e427e
Merge pull request #10879 from Snuffleupagus/print-cleanupAfterRender
[api-minor] Attempt to reduce memory usage during printing, by always running `cleanup` once rendering has finished
2019-06-09 11:32:23 +02:00
Jonas Jenwald
26bc630e19 Add support for outline items, in the default viewer, which default to collapsed when the outline is built
The PDF specification supports this feature, which is commonly used in large/long documents (such as the spec itself), and it seems reasonably straightforward to implement; see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.2095911
2019-06-07 12:26:23 +02:00
Jonas Jenwald
625af8d2ad [api-minor] Attempt to reduce memory usage during printing, by always running cleanup once rendering has finished
Given that `cleanupAfterRender` is already set for large images, when handling 'obj' messages, this patch *should* thus be safe in general (since otherwise there ought be existing bugs related to cleanup and printing).
2019-06-03 00:29:17 +02:00
Tim van der Meij
63014eb897
Merge pull request #10877 from Snuffleupagus/bug-1552113
Ignore Annotations with too large border `width`s, to prevent the `annotationLayer` from rendering it over the surrounding document (bug 1552113)
2019-06-02 12:42:15 +02:00
Jonas Jenwald
876c962235 Ignore Annotations with too large border widths, to prevent the annotationLayer from rendering it over the surrounding document (bug 1552113)
The border `width` will instead fallback to the default value of `1`, rather than ignoring it altoghether, to also ensure that e.g. `LinkAnnotation`s become clickable as intended.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1552113
2019-06-01 15:51:22 +02:00
Tim van der Meij
209e42043a
Merge pull request #10873 from Snuffleupagus/worker-terminate-clearPrimitiveCaches
Ensure that the `Cmd`/`Name`/`Ref` caches are cleared when terminating the worker (PR 10863 follow-up)
2019-05-31 12:56:53 +02:00
Tim van der Meij
3b58863d4c
Merge pull request #10872 from Snuffleupagus/api-clear-arrays
Re-use, rather than re-creating, some `Array`s when resetting them in `src/display/api.js`
2019-05-31 12:55:41 +02:00
Jonas Jenwald
a3742a9f83 Ensure that the Cmd/Name/Ref caches are cleared when terminating the worker (PR 10863 follow-up)
Usually when the worker is terminated it will also be completely destroyed/removed, which means that any global caches (such as the ones in `src/core/primitive.js`) should be automatically cleared in the process.

However, for certain ways of loading the `pdf.worker.js` file, e.g. passing in a re-usable worker to `getDocument`, using the `workerPort` functionality, or even disabling workers completely  (even though this is never a good idea), the worker file may be kept in memory and these caches will not be cleared as expected.
2019-05-30 20:57:28 +02:00
Jonas Jenwald
8857a81c8d Re-use, rather than re-creating, some Arrays when resetting them in src/display/api.js
Calling `someArray = []` will create a new Array, which seems completely unnecessary when it's sufficient to just call `someArray.length = 0` to achieve the same effect.

Even though I cannot imagine these particular cases having any noticeable performance impact, similar changes were made in `core/` code years ago since it's apparently more efficient memory wise.
2019-05-30 16:33:05 +02:00
Tim van der Meij
d0892e46e2
Merge pull request #10867 from janpe2/svg-clip-undefined
Don't clip if path is undefined in SVG back-end
2019-05-30 13:43:05 +02:00
Tim van der Meij
5adb32371e
Merge pull request #10869 from Rob--W/issue-10645-preserve-http-referer-again
Restore referrer preserving functionality in Chrome 72+
2019-05-29 23:46:52 +02:00
Rob Wu
32c1a1d329 [CRX] Preserve referrer in Chrome 72+
Fixes #10645
2019-05-29 11:28:38 +02:00
Jani Pehkonen
343b1381a2 Don't clip if path is undefined in SVG back-end 2019-05-28 18:37:15 +03:00
Tim van der Meij
f652cf8e5e
Merge pull request #10863 from Snuffleupagus/clearPrimitiveCaches
Ensure that the `Cmd`/`Name`/`Ref` caches are cleared when running other `cleanup` code
2019-05-26 15:15:00 +02:00
Jonas Jenwald
5e045bcdba Ensure that the Cmd/Name/Ref caches are cleared when running other cleanup code
The purpose of these caches is to reduce peak memory usage, by only ever having *a single* instance of a particular object.
However, as-is these caches are never cleared and they will thus remain until the worker is destroyed. This could very well have a negative effect on total memory usage, particularly for large/long documents, hence it seems to make sense to clear out these caches together with various other ones.
2019-05-26 14:29:59 +02:00
Tim van der Meij
9ab1d9f596
Merge pull request #10862 from Snuffleupagus/Ref-get
Add caching to reduce the number of `Ref` objects
2019-05-26 13:54:21 +02:00
Jonas Jenwald
2fe9f3ff8f Add caching to reduce the number of Ref objects
This is similar to the existing caching used to reduced the number of `Cmd` and `Name` objects.
With the `tracemonkey.pdf` file, this patch changes the number of `Ref` objects as follows (in the default viewer):

|          | Loading the first page | Loading *all* the pages |
|----------|------------------------|-------------------------|
| `master` | 332                    | 3265                    |
| `patch`  | 163                    | 996                     |
2019-05-26 12:23:37 +02:00
Tim van der Meij
d95145953c
Merge pull request #10859 from timvandermeij/updates
Update translations and packages
2019-05-25 16:45:26 +02:00
Tim van der Meij
18aef39b33
Update packages
This includes a major upgrade of `terser`.
2019-05-25 16:36:42 +02:00
Tim van der Meij
1f3723f54c
Update translations 2019-05-25 16:21:09 +02:00
Tim van der Meij
dcf5393270
Merge pull request #10833 from timvandermeij/annotation-fixes
[api-minor] Implement contents and creation date for the correct annotation types
2019-05-25 16:12:21 +02:00
Tim van der Meij
bc1eb49a77
Implement creation date only for markup annotations
The specification states that `CreationDate` is only available for
markup annotations instead of for all annotation types.

Moreover, popup annotations are not markup annotations according to the
specification, so the creation date inheritance from the parent
annotation is also removed there (note that only the modification date
is used in e.g., the viewer).
2019-05-25 15:31:06 +02:00
Tim van der Meij
c8c3e60b4d
Merge pull request #10854 from iquadrat-ag/print_resolution
make print resolution configurable via AppOptions
2019-05-25 14:56:17 +02:00
Stefan Klein
b85209f1fd make print resolution configurable via AppOptions 2019-05-24 14:01:26 +02:00
Tim van der Meij
cf07918ccb
Implement contents for every annotation type
The specification states that `Contents` can be available for every
annotation types instead of only for markup annotations.
2019-05-18 15:52:17 +02:00
Tim van der Meij
1421b2f205
Merge pull request #10827 from Snuffleupagus/network-streams-class
Convert the (remaining) network streams to ES6 classes
2019-05-16 22:04:29 +02:00
Tim van der Meij
0187dcfa15
Merge pull request #10826 from Snuffleupagus/rm-AnnotationFactory-ref-param
Remove unused `ref` property from the `parameters` object used when creating annotations in `AnnotationFactory._create`
2019-05-16 21:28:31 +02:00
Jonas Jenwald
f9769af365 Convert network.js to use ES6 classes 2019-05-16 10:08:51 +02:00
Jonas Jenwald
cc661a4d38 Update fetch_stream.js to use const in more places 2019-05-16 09:15:43 +02:00
Jonas Jenwald
737705264b Convert transport_stream.js to use ES6 classes 2019-05-16 09:15:39 +02:00
Jonas Jenwald
0784c98172 Remove unused ref property from the parameters object used when creating annotations in AnnotationFactory._create
The only use-cases for this property was removed in PRs 7570 and 7775, and it's been completely unused ever since the latter one.
2019-05-16 08:33:38 +02:00
Tim van der Meij
c8c937c257
Merge pull request #10794 from janpe2/cidtogidmap-zero
Fix glyph at index zero in CIDFontType2 that has a CIDToGIDMap stream
2019-05-15 00:04:39 +02:00
Tim van der Meij
fef86cc3e3
Merge pull request #10805 from Snuffleupagus/consistent-return
Enable the `consistent-return` ESLint rule
2019-05-12 14:30:30 +02:00
Jonas Jenwald
173fbef05b Enable the consistent-return ESLint rule
This rule is already enabled in mozilla-central, and helps ensure more consistent functions/methods, see https://searchfox.org/mozilla-central/rev/b9da45f63cb567244933c77b2c7e827a057d3f9b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#119-120

Please see https://eslint.org/docs/rules/consistent-return for additional information.
2019-05-11 14:27:21 +02:00
Tim van der Meij
ca2fee3d51
Merge pull request #10795 from Snuffleupagus/issue-10790
Update the `canvas` npm package to fix Travis CI builds (issue 10790)
2019-05-08 23:46:15 +02:00