Commit Graph

9591 Commits

Author SHA1 Message Date
Jonas Jenwald
a39d636eb8 [api-minor] Always allow e.g. rendering to continue even if there are errors, and add a stopAtErrors parameter to getDocument to opt-out of this behaviour (issue 6342, issue 3795, bug 1130815)
Other PDF readers, e.g. Adobe Reader and PDFium (in Chrome), will attempt to render as much of a page as possible even if there are errors present.
Currently we just bail as soon the first error is hit, which means that we'll usually not render anything in these cases and just display a blank page instead.

NOTE: This patch changes the default behaviour of the PDF.js API to always attempt to recover as much data as possible, even when encountering errors during e.g. `getOperatorList`/`getTextContent`, which thus improve our handling of corrupt PDF files and allow the default viewer to handle errors slightly more gracefully.
In the event that an API consumer wishes to use the old behaviour, where we stop parsing as soon as an error is encountered, the `stopAtErrors` parameter can be set at `getDocument`.

Fixes, inasmuch it's possible since the PDF files are corrupt, e.g. issue 6342, issue 3795, and [bug 1130815](https://bugzilla.mozilla.org/show_bug.cgi?id=1130815) (and probably others too).
2017-04-11 08:59:22 +02:00
Jonas Jenwald
10e5f766a2 Merge pull request #8266 from brendandahl/issue6652
Normalize blend mode names.
2017-04-11 08:54:42 +02:00
Brendan Dahl
4969b2ad97 Normalize blend mode names. 2017-04-10 16:18:08 -07:00
Tim van der Meij
d6dfc26d4e Merge pull request #8257 from Snuffleupagus/eslint_prefer-promise-reject-errors
Enable the `prefer-promise-reject-errors` ESLint rule
2017-04-08 22:27:04 +02:00
Jonas Jenwald
f41d80bdd3 Enable the prefer-promise-reject-errors ESLint rule
See http://eslint.org/docs/rules/prefer-promise-reject-errors, note that this is similar to the already used  `no-throw-literal` rule.
2017-04-08 11:47:22 +02:00
Brendan Dahl
55a853b667 Merge pull request #8244 from Snuffleupagus/issue-8241
Actually skip pages included in the `skipPages` array when running tests, rather than creating empty 1x1 canvases (issue 8241)
2017-04-07 10:53:54 -07:00
Jonas Jenwald
c5199d0814 Update l10n files 2017-04-07 12:31:54 +02:00
Yury Delendik
8ff1fbe7f8 Merge pull request #8249 from yurydelendik/v1.8.170
Release 1.8.170
2017-04-06 13:44:11 -05:00
Yury Delendik
a0dee94d60 Release 1.8.170 2017-04-06 13:39:45 -05:00
Yury Delendik
3ca67550ef Merge pull request #8248 from yurydelendik/version-1.8
Version 1.8
2017-04-06 13:38:03 -05:00
Yury Delendik
a7f735dbfa Version 1.8 2017-04-06 13:36:33 -05:00
Jonas Jenwald
9d62ff80ca Actually skip pages included in the skipPages array when running tests, rather than creating empty 1x1 canvases (issue 8241)
Considering how extremely simple this patch turned out to be, I'm almost worried that I completely misunderstood why the current code looks like it does...
2017-04-06 13:17:52 +02:00
Jonas Jenwald
a662d26814 Merge pull request #8243 from brendandahl/no-skip-glyph0
Don’t skip glyph 0 in cmap.
2017-04-06 10:25:55 +02:00
Brendan Dahl
cdc79a4721 Don’t skip glyph 0 in cmap. 2017-04-05 15:17:38 -07:00
Yury Delendik
c380d25407 Merge pull request #8239 from georgf/master
Stub out Firefox addon Telemetry wrapper
2017-04-05 13:29:54 -05:00
Georg Fritzsche
788fe1f810 Stub out Firefox addon Telemetry wrapper
We are planning to remove the addon histogram APIs from Firefox
Telemetry.
The easy solution here is to just stub out all calls that use them.
2017-04-05 14:17:31 +07:00
Yury Delendik
f9c07fa695 Merge pull request #8235 from Snuffleupagus/issue-7901
Disable the `NativeImageDecoder` in the `node/pdf2svg.js` example (issue 7901)
2017-04-04 10:38:22 -05:00
Yury Delendik
b665b0319a Merge pull request #8222 from tjgrathwell/ios-fake-cancel-animation-frame
ios: Patch cancelAnimationFrame whenever fakeRequestAnimationFrame is used
2017-04-04 10:29:04 -05:00
Jonas Jenwald
d76cfc0610 Disable the NativeImageDecoder in the node/pdf2svg.js example (issue 7901)
It doesn't really make sense to attempt to utilize the `NativeImageDecoder` in Node, since there's no native image support available, hence building on PR 8035 we can easily disable it in the example.

Fixes 7901.
2017-04-04 17:24:29 +02:00
Yury Delendik
31f8875614 Merge pull request #8157 from Snuffleupagus/api-RenderTask-cancel-Error
[api-minor] Reject the `RenderTask` with an actual `Error`, instead of just a `string`, when rendering is cancelled
2017-04-04 09:38:47 -05:00
Yury Delendik
a2ddf2f9ca Merge pull request #8218 from amccreight/no-sync
Split pdfjschildbootstrap.js to avoid sync IPC
2017-04-03 17:37:22 -05:00
Yury Delendik
12c1679288 Merge pull request #8232 from amccreight/lazy-net-util
Lazily load NetUtil.jsm in PdfStreamConverter.jsm.
2017-04-03 17:27:30 -05:00
Andrew McCreight
071951d787 Lazily load NetUtil.jsm in PdfStreamConverter.jsm.
This is one step towards not loading NetUtil.jsm at startup in a clean
profile.
2017-04-03 10:33:57 -07:00
Travis Grathwell
bd70a73d43 ios: Patch cancelAnimationFrame whenever fakeRequestAnimationFrame is used
The existing implementation of fakeRequestAnimationFrame
did not return a timer ID, so the frame could not be cancelled
if you wanted to cancel it. But if you do want to cancel it,
it needs to be cancelled through clearTimeout instead of
cancelAnimationFrame, because the timer IDs are different.

Signed-off-by: Jonathan Barnes <jbarnes@pivotal.io>
2017-03-31 15:31:04 -07:00
Andrew McCreight
740e1ab450 Skip PdfJs.enabled check in bootstrap-enabled.
If we only invoke the bootstrap-enabled script when PdfJs.enabled is
true, then we don't need to check it again in the script.

This avoids a sync IPC call to the parent process.

It also keeps PdfJs.jsm from importing PdfjsContentUtils.jsm in the
child process until it is actually needed, which is one steps towards
not loading it until it is really needed.
2017-03-31 13:22:39 -07:00
Andrew McCreight
d804881151 Split bootstrap script.
pdfjschildbootstrap.js will always be run, but
pdfjschildbootstrap-enabled.js will only be run if PdfJs.enabled is
true. This will let us avoid some work in the child process in the
next patch.

This will need to be landed in the mozilla-central repository at the
same time as a change to nsBrowserGlue.js. See bug 1352218.
2017-03-31 13:22:39 -07:00
Tim van der Meij
57d9a64c14 Merge pull request #8210 from Snuffleupagus/issue-8209
Refactor removing of the `zoomLayer` into a helper method, and use that in `PDFPageView.reset` to ensure that the entire `zoomLayer` is actually removed (issue 8209)
2017-03-30 23:19:08 +02:00
Tim van der Meij
8cee63df5d Merge pull request #8205 from Snuffleupagus/built-in-CMap-errors
Improve the error handling when loading of built-in CMap files fail (PR 8064 follow-up)
2017-03-30 23:01:13 +02:00
Brendan Dahl
72eeb1ccb3 Merge pull request #8207 from Snuffleupagus/cache-getPageDict
Use a simple `RefSetCache` to significantly improve the performance of `Catalog.getPageDict` for certain long documents (PR 8105 follow-up)
2017-03-30 09:28:11 -07:00
Jonas Jenwald
437104969d Improve the error handling when loading of built-in CMap files fail (PR 8064 follow-up)
I happened to notice that the error handling wasn't that great, which I missed previously since there were no unit-tests for failure to load built-in CMap files.
Hence this patch, which improves the error handling *and* adds tests.
2017-03-29 22:38:29 +02:00
Jonas Jenwald
d98a6319ec Refactor removing of the zoomLayer into a helper method, and use that in PDFPageView.reset to ensure that the entire zoomLayer is actually removed (issue 8209) 2017-03-29 16:41:38 +02:00
Jonas Jenwald
61ee0de29f Use a simple RefSetCache to significantly improve the performance of Catalog.getPageDict for certain long documents (PR 8105 follow-up)
I found that PR 8105 unfortunately causes a *very serious* performance regression in long PDF documents where the `Pages` tree only has one level; my apologies for this!

Obviously we cannot revert that PR, since that would cause more issues than it solves. Hence it seems to me that the only viable solution here, is to add a simple `RefSetCache` to reduce the amount of redundant lookups.
Previously in PR 8105 caching was thought to be unnecessary, but as it turns out I don't think that we really have a choice in the matter any more.
2017-03-28 21:39:55 +02:00
Tim van der Meij
07f7c97b2b Merge pull request #8202 from Snuffleupagus/eslint-basic-es6-rules
Add a couple of basic ES6 rules to the ESLint config
2017-03-27 22:25:00 +02:00
Jonas Jenwald
892fd84eb8 Add a couple of basic ES6 rules to the ESLint config
See http://eslint.org/docs/rules/#ecmascript-6.

To try and enforce consistent rules and to help avoid some possible errors in ES6 code from the start, this patch adds a few basic ESLint rules.

Note that a two of the rules, `no-shadow` and `object-shorthand`, are currently disabled. While it'd certainly be nice to enable both of them, it's currently impossible since that would result in close to one thousand lint errors.
2017-03-27 20:03:20 +02:00
Jonas Jenwald
ede4d3c7c5 Merge pull request #8190 from Snuffleupagus/issue-8182
Try harder to find the next valid JPEG marker when decoding Scan data (issue 8182, issue 8189)
2017-03-27 17:20:41 +02:00
Jonas Jenwald
62eee8c782 Try harder to find the next valid JPEG marker when decoding Scan data (issue 8182, issue 8189)
Tentatively fixes 8182 and fixes 8189.
2017-03-27 15:55:21 +02:00
Yury Delendik
cd5acf501e Merge pull request #8195 from yurydelendik/babel
Enable babel on sources
2017-03-27 07:48:43 -05:00
Yury Delendik
25873e92f0 Enable babel translation to enable ES module support. 2017-03-27 07:25:09 -05:00
Tim van der Meij
0423bb69e9 Merge pull request #8198 from timvandermeij/pdf-to-png
Example for converting PDF to PNG using the Node canvas library
2017-03-26 20:34:49 +02:00
Mukul Mishra
f885e98d20
Example for converting PDF to PNG using the Node canvas library 2017-03-26 20:24:00 +02:00
Tim van der Meij
b6bf1a3eb8 Merge pull request #8196 from Snuffleupagus/evaluator-rm-redundant-xref
Remove unnecessary `xref` parameters from various method signatures in `PartialEvaluator`, since `this.xref` is already available in the relevant scope
2017-03-26 19:48:23 +02:00
Jonas Jenwald
e229c21ce1 Remove unnecessary xref parameters from various method signatures in PartialEvaluator, since this.xref is already available in the relevant scope
For reasons I don't pretend to understand, we're passing around `xref` arguments to a bunch of methods despite `this.xref` being available in `PartialEvaluator`.

This patch is a small first small step towards cleaning up the, often unwieldy, signatures of methods in `PartialEvaluator`.
2017-03-26 14:12:53 +02:00
Jonas Jenwald
e40fd63bd3 In src/core/evaluator.js, convert a couple of if (!someVariable) { error(...); } instances to assert(someVariable); instead
Rather than, in a number of places, basically duplicating the logic of `assert` we can simply utilize the function directly instead.
2017-03-26 13:53:13 +02:00
Yury Delendik
b7ba44b530 Merge pull request #8194 from Snuffleupagus/getTextContent-use-proper-handler
Use a proper `MessageHandler` for `PartialEvaluator.getTextContent` to avoid errors for fonts relying on built-in CMap files (PR 8064 follow-up)
2017-03-25 17:04:03 -05:00
Jonas Jenwald
5c0c122a7d Ensure that the XMLHttpRequest is opened before attempting to set the responseType in the DOMCMapReaderFactory, since IE fails otherwise (issue 8193)
I really cannot understand why this change is necessary, since modern browsers such as Firefox and Chrome work just fine with the old code.
Hence this is patch is yet another "hack" that's needed just because IE apparently cannot just work like you'd expect.

For consistency, the Node factory used in the CMap unit-tests is changed as well.

Fixes 8193.
2017-03-25 17:44:48 +01:00
Jonas Jenwald
3705e5e459 Use a proper MessageHandler for PartialEvaluator.getTextContent to avoid errors for fonts relying on built-in CMap files (PR 8064 follow-up)
*My apologies for inadvertently breaking this in PR 8064; apparently we don't have any tests that cover this use-case :(*

Without this patch `getTextContent` will fail if called before `getOperatorList`, since loading of fonts during text-extraction may require fetching of built-in CMap files.

*Please note:* The `text` test added here, which uses an already existing PDF file, fails without this patch.
2017-03-24 17:39:33 +01:00
Yury Delendik
68f2bf3bec Update worker-loader dependency 2017-03-23 18:27:38 -05:00
Jonas Jenwald
02370f952a Merge pull request #8184 from Rob--W/rethrow-missing-data-if-needed
Rethrow MissingDataException when needed
2017-03-22 18:21:21 +01:00
Rob Wu
49af56f730 Rethrow MissingDataException when needed
In core/document.js: `PDFDocument.prototype.parse` accesses a dictionary
property, which could throw if the underlying data is not yet available.

In core/obj.js: `get Catalog.prototype.metadata` calls
`stream.getBytes`, which can throw MissingDataException too when the
stream is a ChunkedStream.
2017-03-22 14:55:59 +01:00
Rob Wu
086021b21e Merge pull request #8183 from Snuffleupagus/documentInfo-MissingDataException
Ensure that `PDFDocument.documentInfo` doesn't fail during document load, when the entire XRef table hasn't been fetched yet (issue 8180)
2017-03-22 14:46:08 +01:00