Commit Graph

10069 Commits

Author SHA1 Message Date
Mukul Mishra
efad0c7a40 Set this.isCancelled in close method of streamSink. 2017-08-24 13:51:27 +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
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
Tim van der Meij
903f372e3d Merge pull request #8762 from Snuffleupagus/evaluator-coded-isType3Font
Replace the `coded` property with `isType3Font` when building the font `properties` object in `PartialEvaluator.translateFont`
2017-08-08 22:02:28 +02:00
Jonas Jenwald
11ea21265d Merge pull request #8761 from tobytailor/master
Fallback to plain object for globalScope.
2017-08-08 19:48:33 +02:00
Tobias Schneider
da44d10af1 Fallback to plain object for globalScope. 2017-08-08 09:17:48 -07:00
Jani Pehkonen
9a581ee9ed Implement JBIG2 halftone regions and pattern dictionaries 2017-08-08 15:38:29 +03:00
Jonas Jenwald
093afd1212 Replace the coded property with isType3Font when building the font properties object in PartialEvaluator.translateFont
This appears to simply have been forgotten in the re-factoring in PR 4815, where the `coded` property was renamed to the *much* more descriptive `isType3Font` property.
2017-08-08 14:03:02 +02:00
Tim van der Meij
a1d88d8e2e Merge pull request #8756 from Snuffleupagus/evaluator-paintXObject-rm-code-property
Remove leftover `args[0].code` checks from the `OPS.paintXObject` cases in evaluator.js
2017-08-07 22:34:07 +02:00
Jonas Jenwald
4729e96fb7 Remove leftover args[0].code checks from the OPS.paintXObject cases in evaluator.js
From looking at blame, it seems that these checks became obsolete with PR 692 (which landed close to six years ago). Note how, after that PR, there's no longer anything being assigned to the `code` property of an Object.
2017-08-07 10:48:37 +02:00
Jonas Jenwald
5cb8389757 Update l10n files 2017-08-07 10:10:49 +02:00
Jonas Jenwald
cbc411a2c7 Convert DownloadManager to an ES6 class 2017-08-06 14:15:18 +02:00
Tim van der Meij
f83bd721fc Merge pull request #8752 from Snuffleupagus/es6-dom_events
ES6-ify the code in `web/dom_events.js`
2017-08-05 15:32:50 +02:00
Brendan Dahl
1419b7ffe7 Merge pull request #8746 from yurydelendik/page-errors
More robust getPage() error handling.
2017-08-04 15:16:50 -07:00