Commit Graph

10122 Commits

Author SHA1 Message Date
Tim van der Meij
336d26dd13 Merge pull request #8864 from Snuffleupagus/rm-isArray
Replace the `isArray` helper function with the native `Array.isArray` function
2017-09-01 23:08:44 +02:00
Jonas Jenwald
cfb4955a92 Replace the isArray helper function with the native Array.isArray function
*Follow-up to PR 8813.*
2017-09-01 20:27:13 +02:00
Jonas Jenwald
22ade754cc Merge pull request #8862 from Snuffleupagus/rm-isInt
Replace the `isInt` helper function with the native `Number.isInteger` function
2017-09-01 19:56:48 +02:00
Jonas Jenwald
11408da340 Replace the isInt helper function with the native Number.isInteger function
*Follow-up to PR 8643.*
2017-09-01 16:52:50 +02:00
Jonas Jenwald
066fea9c8b Merge pull request #8859 from yurydelendik/issue-8858
Revert PDFPageView.pdfPage reset.
2017-09-01 00:05:37 +02:00
Yury Delendik
47c28643d6 Revert PDFPageView.pdfPage reset. 2017-08-31 16:49:01 -05:00
Tim van der Meij
d332f62d60 Merge pull request #8857 from Snuffleupagus/fetchUncompressed-type-checks
Avoid some redundant type checks in `XRef.fetchUncompressed`
2017-08-31 23:33:02 +02:00
Tim van der Meij
51be27853f Merge pull request #8847 from Snuffleupagus/AnnotationElement-isRenderable-regression
Correct the default value for `isRenderable` in the `AnnotationElement` constructor, to fix breaking errors when rendering unsupported annotations
2017-08-31 22:08:10 +02:00
Jonas Jenwald
772a5412a4 Avoid some redundant type checks in XRef.fetchUncompressed
When looking briefly at using `Number.isInteger`/`Number.isNan` rather than `isInt`/`isNaN`, I noticed that there's a couple of not entirely straightforward cases to consider.

At first I really couldn't understand why `parseInt` is being used like it is in `XRef.fetchUncompressed`, since the `num` and `gen` properties of an object reference should *always* be integers.
However, doing a bit of code archaeology pointed to PR 4348, and it thus seem that this was a very deliberate change. Since I didn't want to inadvertently introduce any regressions, I've kept the `parseInt` calls intact but moved them to occur *only* when actually necessary.[1]

Secondly, I noticed that there's a redundant `isCmd` check for an edge-case of broken operators. Since we're throwing a `FormatError` if `obj3` isn't a command, we don't need to repeat that check.

In practice, this patch could perhaps be considered as a micro-optimization, but considering that `XRef.fetchUncompressed` can be called *many* thousand times when loading larger PDF documents these changes at least cannot hurt.

---
[1] I even ran all tests locally, with an added `assert(Number.isInteger(obj1) && Number.isInteger(obj2));` check, and everything passed with flying colours.
However, since it appears that this was in fact necessary at one point, one possible explanation is that the failing test-case(s) have now been replaced by reduced ones.
2017-08-31 16:49:04 +02:00
Yury Delendik
47789b51c3 Merge pull request #8855 from Rob--W/fetch-withCredentials-fix-default
Add test for withCredentials option
2017-08-31 08:45:22 -05:00
Rob Wu
73273ccbe9 Add test for withCredentials option 2017-08-31 14:30:00 +02:00
Rob Wu
0430e99d16 Merge pull request #8848 from Snuffleupagus/fetch-credentials
Correctly set the `credentials` of a fetch request, when the `withCredentials` parameter was passed to `getDocument`
2017-08-31 14:12:06 +02:00
Jonas Jenwald
84fe442b35 Correctly set the credentials of a fetch request, when the withCredentials parameter was passed to getDocument
Skimming through https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Sending_a_request_with_credentials_included, it looks to me like the `credentials` option was accidentally inverted.
2017-08-31 09:20:05 +02:00
Jonas Jenwald
87fc9bafea Correct the default value for isRenderable in the AnnotationElement constructor, to fix breaking errors when rendering unsupported annotations
*This regressed in PR 8828.*

When attempting to open e.g. http://mirrors.ctan.org/macros/latex/contrib/pdfcomment/doc/example.pdf, the annotation layers are now missing since `Error: Abstract method `AnnotationElement.render` called` is thrown multiple times.
2017-08-31 08:47:36 +02:00
Tim van der Meij
a4cc85fc5f Merge pull request #8828 from timvandermeij/es6-annotations
Improve the annotation code by converting to ES6 syntax and removing duplicate code
2017-08-31 00:02:07 +02:00
Yury Delendik
2656825432 Merge pull request #8845 from yurydelendik/fix-autofetch
Fixes autofetch and firefox nightly fetch streams
2017-08-30 11:28:42 -05:00
Yury Delendik
bad3203fda Merge pull request #8768 from mukulmishra18/fetch_stream
Adds fetch stream logic for networking part of PDF.js
2017-08-30 11:27:48 -05:00
Yury Delendik
cd95b426c7 Disables fetch when ReadableStream is not available. 2017-08-30 10:53:59 -05:00
Yury Delendik
3cff7da0e7 Fixes fetch and node behavior when disableAutoFetch adn disableStream is used. 2017-08-30 10:53:38 -05:00
Mukul Mishra
3516a59384 Adds fetch stream logic for networking part of PDF.js 2017-08-29 22:56:48 +05:30
Tim van der Meij
d734b3d1d6 Merge pull request #8835 from Snuffleupagus/viewer-firefox-error-message
Ensure that `PDFViewerApplication.error` outputs proper messages in FIREFOX/MOZCENTRAL builds
2017-08-28 22:51:29 +02:00
Jonas Jenwald
b7fcaff07c Update l10n files 2017-08-28 14:30:27 +02:00
Jonas Jenwald
028d7c0950 Ensure that PDFViewerApplication.error outputs proper messages in FIREFOX/MOZCENTRAL builds
*It appears that this accidentally broke with PR 8394.*

Currently, the following will be printed in the console:
```
An error occurred while loading the PDF.
[object Promise],[object Promise]
```

With this patch we'll again get proper output, e.g. something with this format:
```
An error occurred while loading the PDF.
PDF.js v? (build: ?)
Message: unknown encryption method
```
2017-08-28 13:49:40 +02:00
Tim van der Meij
f54dfc63dc Merge pull request #8831 from Snuffleupagus/uglify-es
Update the `gulp minified` command to use uglify-es
2017-08-27 19:09:22 +02:00
Tim van der Meij
7c7ba9a2ad Merge pull request #8829 from Snuffleupagus/issue-8823
Attempt to improve the `EI` detection heuristics, for inline images, in streams containing `NUL` bytes (issue 8823)
2017-08-27 17:18:23 +02:00
Jonas Jenwald
70e80322da Update the gulp minified command to use uglify-es
By updating to uglify-es, rather than uglify-js, the minifier *itself* now supports ES6 code. This means that it's now possible to minify code built with `PDFJS_NEXT = true` set, i.e. with Babel transpilation disabled, which wasn't the case previously.

Note that uglify-es is based on the API of uglify-js v3, which differs from the one that we previously used.
Of particular importance is the fact that it's no longer possible to provide a path to a file for minification, but one must instead directly provide the source of the file.

For more information, please see https://github.com/mishoo/UglifyJS2/tree/harmony
2017-08-27 15:31:04 +02:00
Jonas Jenwald
49b8cd5a6a Attempt to improve the EI detection heuristics, for inline images, in streams containing NUL bytes (issue 8823)
Since this patch will now treat (some) `NUL` bytes as "ASCII", the number of `followingBytes` checked are thus increased to (hopefully) reduce the risk of introducing new false positives.

Fixes 8823.
2017-08-27 12:48:28 +02:00
Tim van der Meij
7787987a4b
Update webpack and webpack-stream to the latest version
Aside from being up-to-date, this may improve build time/size.
2017-08-27 01:07:51 +02:00
Tim van der Meij
2512eccbf0
Implement getOperatorList method in the WidgetAnnotation class to
avoid duplication in subclasses
2017-08-27 01:02:41 +02:00
Tim van der Meij
4f02857394
Let the two annotation factories use static methods
This corresponds to how other factories are implemented.
2017-08-27 01:02:40 +02:00
Tim van der Meij
af10f8b586
Convert src/display/annotation_layer.js to ES6 syntax 2017-08-27 01:02:40 +02:00
Tim van der Meij
24d741d045
Convert src/core/annotation.js to ES6 syntax 2017-08-27 00:53:45 +02:00
Rob Wu
7cc7260634 Merge pull request #8796 from timvandermeij/svg-text-rise
Implement text rise for the SVG back-end
2017-08-26 19:02:51 +02:00
Rob Wu
a0eed974a3 Merge pull request #8825 from Snuffleupagus/simpleDest-dictionary
Account for broken outlines/annotations, where the destination dictionary contains an invalid `/Dest` entry
2017-08-26 18:40:45 +02:00
Jonas Jenwald
42f2d36d1f Account for broken outlines/annotations, where the destination dictionary contains an invalid /Dest entry
According to the specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=377, a `Dest` entry in an outline item should *not* contain a dictionary.
Unsurprisingly there's PDF generators that completely ignore this, treating is an `A` entry instead.

The patch also adds a little bit more validation code in `Catalog.parseDestDictionary`.
2017-08-26 17:38:15 +02:00
Tim van der Meij
bd85bda0a6 Merge pull request #8826 from Snuffleupagus/eslint_for-direction
Enable the `for-direction` ESLint rule
2017-08-26 15:26:01 +02:00
Jonas Jenwald
0e2618fdbc Enable the for-direction ESLint rule
See https://eslint.org/docs/rules/for-direction; helps avoid typos that would cause infinite `for` loops.

Also, updates `eslint` and `eslint-plugin-mozilla` to the latest available versions.
2017-08-26 11:31:07 +02:00
Tim van der Meij
798e46da97 Merge pull request #8821 from Snuffleupagus/issue-8798-reduced-test
Replace the test-case for issue 8798 with a reduced one (PR 8800 follow-up)
2017-08-26 00:00:45 +02:00
Tim van der Meij
26c4536964 Merge pull request #8820 from Snuffleupagus/viewer-open-rm-scale
Remove the ability to pass a `scale` parameter in the (optional) `args` object parameter of `PDFViewerApplication.open(file, args)`
2017-08-25 00:45:35 +02:00
Tim van der Meij
d368a5baed Merge pull request #8817 from mukulmishra18/intermittent-error
Set this.isCancelled in close method of streamSink.
2017-08-25 00:31:44 +02:00
Tim van der Meij
5f372cdae3 Merge pull request #8819 from Snuffleupagus/getting_started-rm-compatibility
Remove any mention of `compatibility.js` from the "Getting Started" docs (issue 8818)
2017-08-24 22:50:43 +02:00
Jonas Jenwald
88167b5e38 Merge pull request #8824 from Snuffleupagus/bug-1393476
Prevent an infinite loop in `XRef.readXRef` by keeping track of already parsed tables (bug 1393476)
2017-08-24 22:13:48 +02:00
Jonas Jenwald
4660cf8238 Prevent an infinite loop in XRef.readXRef by keeping track of already parsed tables (bug 1393476)
With this patch, not only is the infinite loop prevented, but we're also able to actually render the file (which e.g. Adobe Reader isn't able to).

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1393476.
2017-08-24 19:18:08 +02:00
Yury Delendik
f1819f4d36 Merge pull request #8822 from yurydelendik/disable-fs-in-dist
Disable node libs in pdfjs-dist package.json
2017-08-24 11:36:00 -05:00
Yury Delendik
e82811adb4 Merge pull request #8712 from mukulmishra18/node_stream
Adds node.js logic for networking tasks for PDF.js
2017-08-24 11:35:29 -05:00
Yury Delendik
4e6ae18f19 Disable node libs in pdfjs-dist package.json 2017-08-24 10:57:18 -05:00
Jonas Jenwald
4891b9c7e0 Replace the test-case for issue 8798 with a reduced one (PR 8800 follow-up)
*Re: issue 8798 and PR 8800.*

Big thanks to @THausherr for providing the test-case.
2017-08-24 17:43:05 +02:00
Jonas Jenwald
870a8f6c35 Remove the ability to pass a scale parameter in the (optional) args object parameter of PDFViewerApplication.open(file, args)
Since the very early days of the viewer, it's been possible to pass in a `scale` when opening a PDF file. However, most of the time it was/is actually being ignored, which limits its usefulness considerably.

In older versions of the viewer, if a document hash was present (i.e. `PDFViewerApplication.initialBookmark` being set) or if the document existed in the `ViewHistory`, the `scale` passed to `PDFViewerApplication.open` would thus always be ignored.
In addition to the above, in the current viewer there's even more cases where the `scale` parameter will be ignored: if a (valid) browser history entry exists on document load, or if the `defaultZoomValue` preference is set to a non-default value.
Hence the result is that in most situation, a `scale` passed to `PDFViewerApplication.open` will be completely ignored.

A much better, not to mention supported, way of setting the initial scale is by using the `defaultZoomLevel` preference. In comparision, this also has the advantage of being used in situations where the `scale` would be ignored.

All in all this leads to the current situation where we have code which is essentially dead, since no part of the viewer (by default) relies on it.
To clean up this code, and to avoid having to pass (basically) unused parameters around, I'd thus like to remove the ability to pass a `scale` to `PDFViewerApplication.open`.
2017-08-24 13:14:00 +02:00
Jonas Jenwald
b048b65e7b Remove any mention of compatibility.js from the "Getting Started" docs (issue 8818)
*With PR 8102, `compatibility.js` is now bundled directly into `pdf.js` and `pdf.worker.js`.*

Fixes 8818.
2017-08-24 13:08:55 +02:00
Mukul Mishra
efad0c7a40 Set this.isCancelled in close method of streamSink. 2017-08-24 13:51:27 +05:30