Commit Graph

10080 Commits

Author SHA1 Message Date
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
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
Mukul Mishra
d16709f5e4 Adds tests for node_stream 2017-08-24 12:46:44 +05:30
Tim van der Meij
e9ba54940d Merge pull request #8800 from Snuffleupagus/issue-8798
Try to recover if we reach the end of the stream when searching for the `EI` marker of an inline image (issue 8798)
2017-08-23 23:47:51 +02:00
Brendan Dahl
23a4174163 Merge pull request #8810 from squarewave/master
Cache PdfJs's enabled setting for delayed init
2017-08-23 10:36:03 -07:00
Jonas Jenwald
6433fc8644 Merge pull request #8813 from yurydelendik/loopback-isarray
Use Array.isArray in the LoopbackPort.
2017-08-23 17:38:29 +02:00
Yury Delendik
438c0b28f2 Use Array.isArray in the LoopbackPort. 2017-08-23 09:25:25 -05:00
Mukul Mishra
18ede8c65d Adds http support to node_stream logic 2017-08-23 14:08:41 +05:30
Mukul Mishra
ed78b23ff2 Adds node.js logic for networking tasks for PDF.js 2017-08-23 14:06:43 +05:30
Jonas Jenwald
cb10c03d0a Merge pull request #8812 from yurydelendik/central-global
Moves global scope out of shared/util.
2017-08-23 09:36:13 +02:00
Yury Delendik
57bc3296f4 Moves global scope out of shared/util. 2017-08-22 18:20:52 -05:00
Tim van der Meij
07f64e064d Merge pull request #8807 from Snuffleupagus/PDFViewer-scrollPageIntoView-rm-fallback-args
Remove handling of fallback arguments from `PDFViewer.scrollPageIntoView`
2017-08-23 00:24:24 +02:00
Jonas Jenwald
ca936ee0c7 Merge pull request #8491 from janpe2/jbig2Halftone-2
JBIG2 halftone regions and pattern dictionaries
2017-08-23 00:13:43 +02:00
Doug Thayer
0f9f0f8a9b Cache PdfJs's enabled setting for delayed init
See Bug 1389443 for more information. This allows us to register
PdfJs without waiting for file IO in nsHandlerService to finish.
Once that file IO is finished, we can set everything up properly
and double-check the registration.
2017-08-22 12:20:58 -07:00
Jonas Jenwald
c523948cc7 Remove handling of fallback arguments from PDFViewer.scrollPageIntoView
The method signature was improved in PR 7440, which has now been present in a number of releases (starting with `v1.6.210`).
Hence we should be able to remove this now, and just print an error message if the old format is used.
2017-08-22 12:08:34 +02:00
Jonas Jenwald
cb55506b95 Try to recover if we reach the end of the stream when searching for the EI marker of an inline image (issue 8798) 2017-08-22 09:33:13 +02:00
Tim van der Meij
81172b571f Merge pull request #8781 from Rob--W/systemjs-__non_webpack_require__
__non_webpack_require__ -> require in SystemJS
2017-08-22 00:44:57 +02:00
Tim van der Meij
7e4c69eccf Merge pull request #8557 from Rob--W/svg-oom-streaming
pdf2svg.js: provides ReadableSVGStream class to serialize a SVG as a stream
2017-08-20 23:29:58 +02:00
Tim van der Meij
7969802739 Merge pull request #8794 from Snuffleupagus/ViewHistory-rm-migration-code
Remove the migration code for old localStorage data in `ViewHistory`
2017-08-19 15:09:17 +02:00
Jonas Jenwald
81b4761e6e Remove the migration code for old localStorage data in ViewHistory
This was added in PR 7793, which has now been present in a number of PDF.js releases (from version `v1.7.225`).
Hence we should be able to remove it now, considering that the migration code was only intended as a best effort solution to avoid wiping out all existing user data at once. Also, keep in mind that `ViewHistory` is already limited with regards to the number of documents it will simultaneous store data for.
2017-08-19 11:41:04 +02:00
Jonas Jenwald
9b26bec1d7 Merge pull request #8792 from Snuffleupagus/issue-8790
Fix caching of small inline images in `Parser.makeInlineImage` (issue 8790)
2017-08-19 09:12:55 +02:00
Jonas Jenwald
18902ec414 Add the ttest npm package to the devDependencies in package.json
I've gotten tired of having to manually re-install the `ttest` package on numerous occasions when benchmarking changes, so let's just list it in package.json to simplify things.
2017-08-18 23:17:59 +02:00
Jonas Jenwald
2112999db7 Fix caching of small inline images in Parser.makeInlineImage (issue 8790)
*Follow-up to PR 5445.*

Using the PDF file from issue 2618, i.e. http://bugzilla-attachments.gnome.org/attachment.cgi?id=226471, with the following manifest file:
```json
[
    {  "id": "issue2618",
       "file": "../web/pdfs/issue2618.pdf",
       "md5": "",
       "rounds": 50,
       "type": "eq"
    }
]
```
I get the following results when comparing `master` against this patch:
```
browser | stat         | Count | Baseline(ms) | Current(ms) |  +/- |     %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | ---- | ------ | -------------
firefox | Overall      |    50 |         4694 |        3974 | -721 | -15.35 |        faster
firefox | Page Request |    50 |            2 |           1 |    0 | -22.83 |
firefox | Rendering    |    50 |         4692 |        3972 | -720 | -15.35 |        faster
```

So, based on these results, it seems like a fairly clear win to fix this broken caching :-)
2017-08-18 23:08:55 +02:00
Tim van der Meij
8c8d8fa239 Merge pull request #8788 from Snuffleupagus/pageMode-followup
Attempt to delay disabling of the attachment view until FileAttachment annotations of the *initial* page has been parsed
2017-08-18 00:04:37 +02:00
Tim van der Meij
50e10fdafc Merge pull request #8785 from Rob--W/svg-ignore-missing-glyph
SVG: Don't render missing glyphs
2017-08-17 23:40:57 +02:00
Jonas Jenwald
9273350c6b Attempt to delay disabling of the attachment view until FileAttachment annotations of the *initial* page has been parsed
As discussed in PR 8673, we cannot solve the general issue (since that would require parsing every single page). However, we can mitigate the effect somewhat, by waiting for the FileAttachment annotations of the initially rendered page.
2017-08-17 14:30:03 +02:00
Jonas Jenwald
96fb0c0370 Call the reset() methods in the PDFAttachmentViewer and PDFOutlineViewer constructors
Rather than duplicating initialization code, we can just call `this.reset()` instead (which is also similar to other existing code, e.g. `PDFViewer`). This will also help ensure that the DOM is completely reset, before any outline items or attachments are displayed.
2017-08-17 13:04:24 +02:00
Rob Wu
f07ce2bbc2 SVG: Don't render missing glyphs
This bug is similar to the canvas bug of #6721.
I found this bug when I tried to run pdf2svg on a SVG file, and the generated
SVG could not be viewed in Chrome due to a SVG/XML parsing error:
"PCDATA invalid Char value 3"

Reduced test case:
- https://github.com/mozilla/pdf.js/files/1229507/pcdatainvalidchar.pdf
- expected: "hardware performance"
- Actual SVG source: "hardware\x03performance"
  (where "\x03" is a non-printable character, and invalid XML).

In terms of rendering, this bug is similar to #6721, where an unexpected glyph
appeared in the canvas renderer. This was fixed by #7023, which skips over
missing glyphs. This commit follows a similar logic.

The test case from #6721 can be used here too:
- https://github.com/mozilla/pdf.js/files/52205/issue6721_reduced.pdf
  expected: "Issue   6721"
  actual (before this patch): "Issue ààà6721"
2017-08-16 23:49:55 +02:00
Tim van der Meij
3a017b4317 Merge pull request #8783 from Snuffleupagus/image-decoders-Uint8ClampedArray
Use `Uint8ClampedArray` when returning image data in `src/core/jbig2.js` and `src/core/jpg.js`
2017-08-16 22:52:12 +02:00
Rob Wu
9b5086d649 pdf2svg.js: Serialize the SVG to a stream
Implement a serialization "generator" for `DOMElement` in domutils.js
that yields the serialization of the SVG element. This method is used by
a newly added `ReadableSVGStream` class, which can be used like any
other readable stream in Node.js.

This reduces the memory requirements. Now, it is not needed to require
the serialization to fully fit in memory.

Note: The implementation of the serializer is a state machine in ES5
since the rest of the file is also in ES5. Its functionality is
equivalent to:

```
function* serializeSVGElement(elem) {
  yield '<' + elem.nodeName;
  if (elem.nodeName === 'svg:svg') {
    yield ' xmlns:xlink="http://www.w3.org/1999/xlink"' +
          ' xmlns:svg="http://www.w3.org/2000/svg"';
  }
  for (let i in elem.attributes) {
    yield ' ' + i + '="' + xmlEncode(elem.attributes[i]) + '"';
  }

  yield '>';

  if (elem.nodeName === 'svg:tspan' || elem.nodeName === 'svg:style') {
    yield xmlEncode(elem.textContent);
  } else {
    for (let childNode of elem.childNodes) {
      yield* serializeSVGElement(childNode);
    }
  }
  yield '</' + elem.nodeName + '>';
}
```
2017-08-16 19:16:38 +02:00
Jonas Jenwald
563b68e74d Remove manual clamping code in src/core/jpx.js
Since we're now using `Uint8ClampedArray`, rather than `Uint8Array`, doing manual clamping shouldn't be necessary given that that is now handled natively.

This shouldn't have any measurable performance impact, but just to sanity check that I've done some quick benchmarking with the following manifest file:
```json
[
    {  "id": "S2-eq",
       "file": "pdfs/S2.pdf",
       "md5": "d0b6137846df6e0fe058f234a87fb588",
       "rounds": 100,
       "type": "eq"
    }
]
```
which gave the following results against the current `master` (repeated benchmark runs didn't result in any meaningful differences):
```
-- Grouped By browser, stat --
browser | stat         | Count | Baseline(ms) | Current(ms) | +/- |    %  | Result(P<.05)
------- | ------------ | ----- | ------------ | ----------- | --- | ----- | -------------
firefox | Overall      |   100 |          592 |         592 |   1 |  0.12 |
firefox | Page Request |   100 |            3 |           3 |   0 | -9.88 |
firefox | Rendering    |   100 |          588 |         589 |   1 |  0.18 |
```
2017-08-16 13:24:28 +02:00
Jonas Jenwald
f6636d6b19 Use Uint8ClampedArray when returning image data in src/core/jbig2.js and src/core/jpg.js 2017-08-16 13:24:28 +02:00
Jonas Jenwald
74ad90cb8f Update the mask data inversion in PDFImage.createMask to be compatible with both Uint8Array and Uint8ClampedArray 2017-08-16 13:24:21 +02:00
Rob Wu
d253889d97 __non_webpack_require__ -> require in SystemJS
When running browser tests, e.g. via `gulp unittest`, the test files are not
processed by babel, and neither by the "unittestcli" gulp target.

This commit copies the babelPluginReplaceNonWebPackRequire plugin from the
unittestcli target to the SystemJS config so that `__non_webpack_require__` is
replaced with `require` for all build targets, and adds a unit test to ensure
that this indeed works as expected.
2017-08-15 12:14:30 +02:00
Yury Delendik
ba5dbc9632 Merge pull request #8780 from yurydelendik/v1.9.426
Version 1.9.426
2017-08-14 18:41:32 -05:00
Yury Delendik
163ecf9b95 Version 1.9.426 2017-08-14 18:37:57 -05:00
Tim van der Meij
602250031e Merge pull request #8778 from Snuffleupagus/jpg-Uint8ClampedArray
Use `Uint8ClampedArray`, when returning data, and remove manual clamping in `src/core/jpg.js` (issue 4901)
2017-08-14 23:44:41 +02:00
Yury Delendik
2558a58dbb Merge pull request #8749 from yurydelendik/version-1.9
Version 1.9
2017-08-14 15:42:21 -05:00
Jonas Jenwald
d6cd5355f0 Use Uint8ClampedArray, when returning data, and remove manual clamping in src/core/jpg.js (issue 4901)
This patch removes the `clamp0to255` helper function, as well as manual clamping code in `src/core/jpg.js`.
The adjusted constants in `_convertCmykToRgb` were taken from CMYK to RGB conversion code found in `src/core/colorspace.js`.

*Please note:* There will be some very slight movement in a number of existing test-cases, since `Uint8ClampedArray` appears to use `Math.round` (or equivalent) and the old code used (basically) `Math.floor`.
2017-08-14 16:19:57 +02:00
Jonas Jenwald
be36c60e0f Polyfill Uint8ClampedArray using core-js
https://github.com/zloirock/core-js
2017-08-14 16:19:55 +02:00
Jonas Jenwald
e49dfe4ed7 Don't load compatibility.js in the viewer while in non-PRODUCTION mode
At this point, the default viewer is already not usable in older browsers in `gulp server` mode, since we only run the code through Babel as part of the build step.
Hence there shouldn't be much point in manually loading `compatibility.js` in `viewer.html` the way that we've been doing, especially considering that it's already being loaded by `src/shared/util.js`.
2017-08-14 15:57:18 +02:00
Jonas Jenwald
723bc25bc3 Update l10n files 2017-08-14 10:19:07 +02:00
Tim van der Meij
21cc2c0200 Merge pull request #8764 from Snuffleupagus/es6-DownloadManager-class
Convert `DownloadManager` to an ES6 class
2017-08-09 22:26:25 +02:00