Commit Graph

10185 Commits

Author SHA1 Message Date
Mukul Mishra
568b0b6a42 Adds ready capability rejection logic for stream sink. 2017-07-25 02:07:38 +05:30
Jonas Jenwald
794b099385 Add a reduced test-case for issue 7696
Issue 7696 was one of the issues fixed by PR 8580. The other ones were all cases of missing glyphs, however in this particular one glyphs did render but every single one was incorrect.
Hence it probably cannot hurt to have a small, reduced, reference test for that PDF file as well.
2017-07-24 09:55:16 +02:00
Jonas Jenwald
38d566f1e5 Update l10n files 2017-07-24 09:37:07 +02:00
Tim van der Meij
53cd2f9d0a Merge pull request #8689 from tiagmoraismorgado/patch-1
Update README.md
2017-07-23 19:30:46 +02:00
Tiago Morais Morgado
60fc8c932a Update README.md 2017-07-23 17:57:19 +01:00
Tim van der Meij
af71ea7a7d Merge pull request #8673 from Snuffleupagus/api-pageMode
[api-minor] Add support for PageMode in the API and viewer (issue 8657)
2017-07-23 13:17:07 +02:00
Tim van der Meij
e7cddcce28 Merge pull request #8684 from Snuffleupagus/rm-assert
Remove most `assert()` calls (issue 8506)
2017-07-22 19:42:24 +02:00
Tim van der Meij
7ded895d0c Merge pull request #8638 from Snuffleupagus/issue-4926-built-in-jpg
In `src/core/jpg.js`, ensure that the Adobe JPEG marker always takes precedence, even when the color transform code is zero
2017-07-22 17:25:09 +02:00
Jonas Jenwald
814fa1dee3 Remove most assert() calls (issue 8506)
This replaces `assert` calls with `throw new FormatError()`/`throw new Error()`.
In a few places, throwing an `Error` (which is what `assert` meant) isn't correct since the enclosing function is supposed to return a `Promise`, hence some cases were changed to `Promise.reject(...)` and similarily for `createPromiseCapability` instances.
2017-07-21 18:51:02 +02:00
Tim van der Meij
09f04eccda Merge pull request #8678 from Snuffleupagus/fix-Catalog-numPages-shadow
Fix a typo, in the `Catalog.numPages` getter, than prevents shadowing from working correctly
2017-07-20 23:08:50 +02:00
Apoorv Mishra
d14956d4b8 Fix TypeError that occurs in colorspace.js on accidentally passing an 'Array' instead of 'TypedArray'
Fix TypeError that occurs in colorspace.js on accidentally passing an 'Array' instead of 'TypedArray'

Changed getRgbItem(...) to getRgbBuffer(...) since this.lookup has values in range[0, 255] whereas getRgbItem(...) expects those to be in range [0, 1]

Revert changes for IE9 compatibility
2017-07-21 01:15:05 +05:30
Jonas Jenwald
15f0963f51 Fix a typo, in the Catalog.numPages getter, than prevents shadowing from working correctly
Looking at the blame, it seems that this typo was present even before PR 700 (almost six years ago).
The result of using `'num'`, rather than the *correct* `'numPages'` string, is that the `Catalog.numPages` getter isn't actually being shadowed.
2017-07-20 12:35:09 +02:00
Jonas Jenwald
20d6286cce Add support for, the API property, PageMode in the viewer (issue 8657)
Note that the PageMode, as specified in the API, will only be honoured when either: the user hasn't set the `sidebarViewOnLoad` preference to a non-default value, or a non-default `sidebarView` entry doesn't exist in the view history, or the "pagemode" hash parameter is included in the URL.

Since this is new functionality, the patch also includes a preference (`disablePageMode`), to make it easy to opt-out of this functionality if the user/implementor so wishes.
2017-07-19 16:58:25 +02:00
Jonas Jenwald
f7c4ed4bc3 Refactor reading from the ViewHistory in PDFViewerApplication.load 2017-07-19 16:40:47 +02:00
Jonas Jenwald
16c5d41c5b [api-minor] Add support for PageMode in the API (issue 8657)
Please refer to https://wwwimages2.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=82.
2017-07-19 16:40:03 +02:00
Tim van der Meij
4a74cc418c Merge pull request #8653 from Rob--W/crx-migrate-pref-enableHandToolOnLoad-to-cursorToolOnLoad
Add UI for the cursorToolOnLoad pref in the Chrome extension + migration logic
2017-07-16 22:40:37 +02:00
Jonas Jenwald
5187f0fcbb Merge pull request #8636 from Snuffleupagus/es6-PDFViewer-class
Convert `PDFViewer` to an ES6 class
2017-07-16 15:57:22 +02:00
Tim van der Meij
947b2f59fc Merge pull request #8651 from Rob--W/issue-8620-follow-up-fix-tests
Fix display_svg_spec tests.
2017-07-16 15:17:06 +02:00
Rob Wu
18566091aa Fix display_svg_spec tests.
- Mark the test as async, and don't swallow exceptions.
- Fix the DOMElement polyfill to behave closer to the actual getAttributeNS
  method, which excludes the namespace prefix.
2017-07-16 11:01:52 +02:00
Jonas Jenwald
e1536251d5 Convert PDFViewer to an ES6 class 2017-07-16 10:20:35 +02:00
Jonas Jenwald
49333ddd44 Move the hasEqualPageSizes getter from PDFViewerApplication and into PDFViewer instead
Since the method needs to access properties that are directly available inside of `PDFViewer`, it seems simpler to just have it live there.
2017-07-16 10:17:38 +02:00
Rob Wu
19549bb7d6 [CRX] Integrate cursorToolOnLoad pref + migration logic
Add UI for the cursorToolOnLoad pref in the UI of the Chrome extension.

Add logic to migrate the enableHandToolOnLoad pref to cursorToolOnLoad.
For past values in the mutable extension storage area:
1. If enableHandToolOnLoad=true, save cursorToolOnLoad=1.
2. Remove enableHandToolOnLoad.

For the managed extension storage, which is immutable since it is based
on administrative policies, use the following logic:
1. If enableHandToolOnLoad=true and cursorToolOnLoad=0 (default).
   set cursorToolOnLoad=0 and assume enableHandToolOnLoad=false.
2. As usual, managed preferences can (and will) be overridden by the user.

The first migration logic is in extensions/chromium/options/migration.js
and can be removed after a few months / less than many years.

The second migration logic is in web/chromecom.js, and should be kept
around for a long while (many years).

The need for this migration logic arises from the change by:
https://github.com/mozilla/pdf.js/pull/7635
2017-07-15 01:50:15 +02:00
Tim van der Meij
afb1cd7377 Merge pull request #8649 from Snuffleupagus/es6-PDFLinkService-class
Convert `PDFLinkService` to an ES6 class
2017-07-15 01:22:02 +02:00
Jonas Jenwald
8ba8072937 Convert PDFLinkService to an ES6 class 2017-07-14 16:30:25 +02:00
Yury Delendik
ca3c08f12b Merge pull request #8620 from Rob--W/issue-8560-improve-png-compression
Improve compression of PNG images embedded in generated SVG files
2017-07-14 07:23:38 -05:00
Tim van der Meij
26be1df5f7 Merge pull request #8641 from Snuffleupagus/eslint-version-4-upgrade
Update ESLint (and eslint-plugin-mozilla) to the latest version
2017-07-14 14:17:42 +02:00
Tim van der Meij
d95022328c Merge pull request #8618 from Snuffleupagus/webViewerResize-rm-hack
Remove the scale-not-initialized hack from `webViewerResize` (in app.js)
2017-07-14 14:14:12 +02:00
Tim van der Meij
3e472f1798 Merge pull request #8634 from nish17/master
Update inconsistent names
2017-07-14 13:53:36 +02:00
Tim van der Meij
d7367f102e Merge pull request #8609 from Snuffleupagus/findbar-more-adjustWidth
Ensure that `PDFFindBar._adjustWidth` is called in all situations where the width of the findbar might have changed
2017-07-14 13:34:17 +02:00
Christian Myksvoll
95093a5276 Check for undefined url (#8640)
* Check for undefined

new URL(file, window.location.href) throws the following error in IE11 + iPad Safari:
Unable to get property 'replace' of undefined or null reference

* Adapting previous change to pdf.js code standards

Added curly braces

* Moved check for undefined above try/catch
2017-07-13 13:48:04 -07:00
Yury Delendik
c673b6fee1 Merge pull request #8646 from yurydelendik/issue-8645
Fixes pdf.js library source detection.
2017-07-13 15:20:17 -05:00
Yury Delendik
52460687ca Fixes pdf.js library source detection. 2017-07-13 14:57:39 -05:00
Jonas Jenwald
a63015a9a2 Merge pull request #8643 from Snuffleupagus/polyfill-Number-isNaN
Add `Number.isNaN` and `Number.isInteger` polyfills in compatibility.js, since the Streams polyfill relies on them
2017-07-13 18:25:46 +02:00
Jonas Jenwald
f2270252c7 Add Number.isNaN and Number.isInteger polyfills in compatibility.js, since the Streams polyfill relies on them
Without this, the Streams polyfill will fail in Internet Explorer when the code-paths containing these methods are used.
2017-07-13 12:02:14 +02:00
Jonas Jenwald
6f3565e638 Update ESLint (and eslint-plugin-mozilla) to the latest version 2017-07-12 13:14:25 +02:00
Jonas Jenwald
e2ea9b693c In src/core/jpg.js, ensure that the Adobe JPEG marker always takes precedence, even when the color transform code is zero
According to the PDF specification, please see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2394361, if an Adobe JPEG marker is present it should always take precedence. This even seem to be consistent with the existing comment that is present in the code.
Hence it seems reasonable to interpret `transformCode === 0` as no color conversion being necessary.

Fixes the rendering of page 1 in `issue-4926` (from the test-suite), when the built-in `src/core/jpg.js` image decoder is used.
2017-07-11 17:08:30 +02:00
Jonas Jenwald
11e95712d4 Add support for the nativeImageDecoderSupport parameter, to force JPEG image decoding using src/core/jpg.js, when running the reference tests 2017-07-11 16:38:49 +02:00
Nimesh Solanki
e004b3cfab update inconsistent names 2017-07-11 00:57:39 +05:30
Rob Wu
01f03fe393 Optimize PNG compression in SVG backend on Node.js
Use the environment's zlib implementation if available to get
reasonably-sized SVG files when an XObject image is converted to PNG.
The generated PNG is not optimal because we do not use a PNG predictor.
Futher, when our SVG backend is run in a browser, the generated PNG
images will still be unnecessarily large (though the use of blob:-URLs
when available should reduce the impact on memory usage). If we want to
optimize PNG images in browsers too, we can either try to use a DEFLATE
library such as pako, or re-use our XObject image painting logic in
src/display/canvas.js. This potential improvement is not implemented by
this commit

Tested with:

- Node.js 8.1.3 (uses zlib)
- Node.js 0.11.12 (uses zlib)
- Node.js 0.10.48 (falls back to inferior existing implementation).
- Chrome 59.0.3071.86
- Firefox 54.0

Tests:

Unit test on Node.js:

```
$ gulp lib
$ JASMINE_CONFIG_PATH=test/unit/clitests.json node ./node_modules/.bin/jasmine --filter=SVG
```

Unit test in browser: Run `gulp server` and open
http://localhost:8888/test/unit/unit_test.html?spec=SVGGraphics

To verify that the patch works as desired,

```
$ node examples/node/pdf2svg.js test/pdfs/xobject-image.pdf
$ du -b svgdump/xobject-image-1.svg
 # ^ Calculates the file size. Confirm that the size is small
 #   (784 instead of 80664 bytes).
```
2017-07-10 18:56:57 +02:00
Rob Wu
3479a19bf0 Remove btoa from domstubs.js
btoa is already defined by src/shared/compatibility.js,
which is unconditionally imported by src/shared/util.js.
2017-07-10 18:45:47 +02:00
Rob Wu
a488ff4f70 Put every test file on a separate lint in jasmine-boot.js 2017-07-10 18:45:47 +02:00
Rob Wu
9caaaf3a91 Add setStubs/unsetStubs to domstubs to support testing
Do not directly export to global. Instead, export all stubs in domstubs.js and
add a method setStubs to assign all exported stubs to a namespace. Then replace
the import domstubs with an explicit call to this setStubs method.  Also added
unsetStubs for undoing the changes. This is done to allow unit testing of the
SVG backend without namespace pollution.
2017-07-10 18:45:47 +02:00
Rob Wu
94f1dde07d Move DEFLATE logic in convertImgDataToPng
Move the DEFLATE logic in convertImgDataToPng to a separate function.
A later commit will introduce a more efficient deflate algorithm,
and fall back to the existing, naive algorithm if needed.
2017-07-10 18:45:47 +02:00
Yury Delendik
2cef24a2ad Merge pull request #8630 from Rob--W/issue-8622-remove-__pdfjsdev_webpack__
Remove __pdfjsdev_webpack__, use webpack options
2017-07-10 11:31:45 -05:00
Jonas Jenwald
85161fa6dc Update l10n files 2017-07-10 12:20:25 +02:00
Rob Wu
742ed3d1c9 Remove __pdfjsdev_webpack__, use webpack options
`__pdfjsdev_webpack__` was used to skip evaluating part of an AST,
in order to not mangle some `require` symbols.
This commit removes `__pdfjsdev_webpack__`, and:

- Uses `__non_webpack_require__` when one wants the output to
  contain `require` instead of `__webpack_require__`.
- Adds options to the webpack config to prevent "polyfills" for
  some Node.js-specific APIs to be added.
- Use `// eslint-disable-next-line no-undef` instead of `/* globals ... */`
  for variables that are not meant to be used globally.
2017-07-09 16:35:48 +02:00
Yury Delendik
7b4887dd21 Merge pull request #8581 from yurydelendik/rm-error
Removes error()
2017-07-07 09:43:30 -05:00
Yury Delendik
d028c26210 Removes error() 2017-07-07 09:40:24 -05:00
Jonas Jenwald
ac9802809c Merge pull request #8621 from Rob--W/eslint-version-update
Bump minimum eslint version to 3.19.0
2017-07-06 15:58:06 +02:00
Rob Wu
06887b6b62 Bump minimum eslint version to 3.19.0
The previously referenced eslint version is not compatible with our code base.
For example, rule "prefer-promise-reject-errors" requires 3.14.0.
2017-07-06 15:40:08 +02:00