Commit Graph

9625 Commits

Author SHA1 Message Date
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
Jonas Jenwald
8527d27eae Ensure that PDFDocument.documentInfo doesn't fail during document load, when the entire XRef table hasn't been fetched yet (issue 8180)
Similar to other `try-catch` statements in `/core` code, we must re-throw `MissingDataException` to prevent issues with missing data during document loading.
Note that I'm not sure if/how we can test this, which is why the patch doesn't include any test(s).

Fixes 8180.
2017-03-22 14:14:38 +01:00
Jonas Jenwald
e2e13df4a5 Merge pull request #8164 from Snuffleupagus/issue-7828
Don't read past the EOI marker for JPEG images with non-default restart interval (issue 7828)
2017-03-20 22:17:28 +01:00
Jonas Jenwald
cfc45e556c Merge pull request #8170 from Snuffleupagus/issue-8169
Try to recover when encountering JPEG markers with too short marker lengths (issue 8169)
2017-03-20 20:34:22 +01:00
Jonas Jenwald
d6d0f778aa Don't read past the EOI marker for JPEG images with non-default restart interval (issue 7828)
*After browsing through (a version of) the JPEG specification, see https://www.w3.org/Graphics/JPEG/itu-t81.pdf, I hope that this patch makes sense.*

Note that while issue 7828 became a problem after PR 7661, it isn't really a regression from than PR. The explanation is rather that we're now relying on `core/jpg.js` instead of the Native Image decoder in more situations than before, which thus exposed an *existing* issue in our JPEG decoder.
Another factor also seems to be that in many JPEG images, the DRI (Define Restart Interval) marker isn't present, in which case this bug won't manifest either.

According to https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=89 (at the bottom of the page):
"NOTE – The final restart interval may be smaller than the size specified by the DRI marker segment, as it includes only the number of MCUs remaining in the scan."
Furthermore, according to https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=39 (in the middle of the page):
"[...] If restart is enabled and the restart interval is defined to be Ri, each entropy-coded segment except the last one shall contain Ri MCUs. The last one shall contain whatever number of MCUs completes the scan."

Based on the above, it thus seem to me that we should simply ensure that we're not attempting to continue to parse Scan data once we've found all MCUs (Minimum Coded Unit) of the image.

Fixes 7828.
2017-03-20 17:16:33 +01:00
Jonas Jenwald
be1a6f294f Try to recover when encountering JPEG markers with too short marker lengths (issue 8169)
The issue with the JPEG image in question, is that the COM (Comment) marker has an incorrect length entry.

Fixes 8169.
2017-03-20 17:05:51 +01:00
Yury Delendik
b2ed788ea3 Merge pull request #8172 from Snuffleupagus/bug-1345294
Upstream the changes from bug 1345294 - nsIPrefBranch should have methods to get/set unicode strings
2017-03-20 09:38:07 -05:00
Jonas Jenwald
ebae24cacc Upstream the changes from bug 1345294 - nsIPrefBranch should have methods to get/set unicode strings
Note that in order to not break compatibility for the Firefox addon, the preprocessor is used.

Re: [bug 1345294](https://bugzilla.mozilla.org/show_bug.cgi?id=1345294) and also [this commit](https://hg.mozilla.org/mozilla-central/rev/5a8192a650e9).
2017-03-20 07:36:36 +01:00
Tim van der Meij
3ff872b796 Merge pull request #8174 from Snuffleupagus/eslint-yoda-follow-up
Adjust the `yoda` ESLint rule to apply to inequalities as well
2017-03-19 23:49:47 +01:00
Jonas Jenwald
da326a3137 Update l10n files 2017-03-19 13:46:11 +01:00
Jonas Jenwald
a7c19d9cbb Adjust the yoda ESLint rule to apply to inequalities as well
I happened to notice that some inequalities had the wrong order, and was surprised since I thought that the `yoda` rule should have caught that.
However, reading http://eslint.org/docs/rules/yoda#options a bit more closely than previously, it's quite obvious that the `onlyEquality` option does *exactly* what its name suggests. Hence I think that it makes sense to adjust the options such that only ranges are allowed instead.
2017-03-19 13:27:14 +01:00
Tim van der Meij
f0c45f0336 Merge pull request #8168 from Snuffleupagus/issue-8117
Normalize the `BBox` entry in Tiling Pattern dictionaries (issue 8117)
2017-03-16 23:29:44 +01:00
Jonas Jenwald
098a56270d Normalize the BBox entry in Tiling Pattern dictionaries (issue 8117)
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3982967, the `BBox` entry should have the form `[left, bottom, right, top]`.
Since some PDF generators apparently violates the specification, we normalize the `BBox` to ensure that the pattern is (correctly) rendered.

Fixes 8117.
2017-03-16 21:43:11 +01:00
Jonas Jenwald
e6db75b2ef Use the DOMCanvasFactory in the API unit-tests
There's still some work necessary if we want to be able to run (even a subset of) the API unit-tests on Travis.
However, this patch could be considered a small first step, since the relevant unit-tests will now rely on a `CanvasFactory` rather than using `document.createElement('canvas')` directly.
2017-03-13 18:58:26 +01:00
Jonas Jenwald
d37d271afa [api-minor] Reject the RenderTask with an actual Error, instead of just a string, when rendering is cancelled
This patch gets rid of the only case in the code-base where we're throwing a plain `string`, rather than an `Error`, which besides better/more consistent error handling also allows us to enable the [`no-throw-literal`](http://eslint.org/docs/rules/no-throw-literal) ESLint rule.
2017-03-13 18:58:21 +01:00
Jonas Jenwald
6d672c4ba6 [api-minor] Add a pdfjsNext parameter, and PDFJS_NEXT build flag, to allow backwards incompatible API changes 2017-03-13 18:43:43 +01:00
Yury Delendik
2b17188998 Merge pull request #8154 from mysterlune/pdfjslib_req_vs_window
Change to conditions that `pdfjsLib`
2017-03-13 10:47:37 -05:00
Tim van der Meij
14b91a479e Merge pull request #8156 from Snuffleupagus/findbar-missing-titles
Add (and adjust) a couple of findbar `title` attributes, in `viewer.html`, that doesn't agree with the `l10n/en-US/viewer.properties` file
2017-03-12 16:15:09 +01:00