Commit Graph

10825 Commits

Author SHA1 Message Date
Tim van der Meij
3e5ec41045
Remove dead code in the gh-pages-prepare task in the Gulpfile 2018-06-04 22:54:28 +02:00
Brendan Dahl
3c51f2fc1a
Merge pull request #9741 from timvandermeij/webpack
Build improvements
2018-06-04 13:21:50 -07:00
Jonas Jenwald
89caaf4071 Use LoopbackPort in the "message_handler" unit-tests
There's no good reason, as far as I can tell, to duplicate the functionality of the `LoopbackPort` in the unit-tests. The only difference between the implementations is that `LoopbackPort` mimics the (native) structured cloning, however that shouldn't matter here since the tests are only sending "simple" data (strings respectively arrays with numbers).

Furthermore the patch also changes `LoopbackPort` to default to using "structured cloning" and deferred invocation of the listeners, since native typed array support is now a requirement for using the PDF.js library.
2018-06-04 12:53:08 +02:00
Jonas Jenwald
44d8afd46b Move MessageHandler into a separate src/shared/message_handler.js file
The `MessageHandler` itself, and its assorted helper functions, are currently the single largest[1] piece of code in the `src/shared/util.js` file. By moving this code into its own file, `src/shared/util.js` thus becomes smaller and more manageable.
2018-06-04 12:53:08 +02:00
Jonas Jenwald
69f2a77543 Update the signature of the PageViewport constructor, and improve the JSDoc comments for the class
This changes the constructor to take a parameter object, rather than a string of parameters.
2018-06-04 12:53:07 +02:00
Jonas Jenwald
51673dbc5a Convert the PageViewport to a proper ES6 class
Also converts all `var` to `let` for good measure.
2018-06-04 12:53:07 +02:00
Jonas Jenwald
5917b21702 Remove completely unused fontScale property from PageViewport
The `fontScale` property was added in PR 1531, see commit b312719d7e in particular, apparently for the sole purpose of supporting the "acroforms" example.

However, the `fontScale` property was never used anywhere else in the code-base, and after the modernization of the "acroforms" example in PR 8030 it's been completely unused.

Finally, note that there's also a (more suitably named) `scale` property on `PageViewport` instances, which contains the exact same information as the property being removed here.
2018-06-04 12:53:07 +02:00
Jonas Jenwald
08c8f8733d Move PageViewport from src/shared/util.js to src/display/dom_utils.js
Since the `PageViewport` is not used in the worker, duplicating this code on both the main and worker sides seems completely unnecessary.
2018-06-04 12:53:07 +02:00
Jonas Jenwald
f486051d77 Explicitly list the ignored files in the src/shared/ folder, for the gulp lib build target
To avoid having to manually update the "shared files" list in `gulpfile.js`, whenever any changes are made to the file structure in the `src/shared/` folder, let's simply list the files we do *not* want instead.
Given that the excluded files have been consistent ever since the `lib` build target was added, this patch should help avoid unnecessary churn in `gulpfile.js` in the future.
2018-06-04 12:53:07 +02:00
Tim van der Meij
5053d02ba4
Merge pull request #9774 from timvandermeij/unlink
Use `fs.unlinkSync` instead of `fs.unlink` when removing files in the font tests
2018-06-03 22:27:47 +02:00
Tim van der Meij
90750d624b
Use fs.unlinkSync instead of fs.unlink when removing files in the font tests 2018-06-03 22:17:05 +02:00
Tim van der Meij
8ce24744f2
Merge pull request #9769 from Snuffleupagus/node-unittest-rm-console-errors
Reduce the amount of errors logged, primarily in Node.js/Travis, when running the unit-tests
2018-06-03 19:50:42 +02:00
Tim van der Meij
3859c63780
Merge pull request #9773 from Rob--W/content-disposition-textdecode-utf8
Fix multibyte decoding in content_disposition.js
2018-06-03 19:38:35 +02:00
Rob Wu
0e4e79169b Fall back to ISO-8859-1 in content_disposition.js
Updates content_disposition.js to include
9b789d9b3b
2018-06-03 16:17:28 +02:00
Rob Wu
e992480baa Fix multibyte decoding in content_disposition.js
I made some mistakes when trying to make the content_disposition.js
compatible with non-modern browsers (IE/Edge).
Notably, text decoding was usually skipped because of the inverted
logical check at the top of `textdecode`.

I verified that this new version works as expected, as follows:

1. Visit 55c71eb44e/test/
   and get  test-content-disposition.js
   also get test-content-disposition.node.js if using Node.js,
     or get test-content-disposition.html if you use a browser.
2. Modify `test-content-disposition.node.js` (or the HTML file) and
   change `../extension/content-disposition.js` to `PDFJS-content_disposition.js`
3. Copy the `getFilenameFromContentDispositionHeader` function from
   `content_disposition.js` (i.e. the file without the trailing exports)
   and save it as `PDFJS-content_disposition.js`.
4. Run the tests (`node test-content-disposition.node.js` or by opening
   `test-content-disposition.html` in a browser).
5. Confirm that there are no failures: "Finished all tests (0 failures)"

The code has a best-efforts fallback for Microsoft Edge, which lacks the
TextDecoder API. The fallback only supports the common UTF-8 encoding.
To simulate this in a test, modify `PDFJS-content_disposition.js` and
deliberately throw an error before `new TextDecoder`. There will be two
failures because we don't want to include too much code to support text
decoding for non-UTF-8 encodings in Edge

```
test-content-disposition.js:265 Assertion failed: Input: attachment; filename*=ISO-8859-1''%c3%a4
Expected: "ä"
Actual  : "ä"
test-content-disposition.js:268 Assertion failed: Input: attachment; filename*=ISO-8859-1''%e2%82%ac
Expected: "€"
Actual  : "€"
```
2018-06-03 15:28:22 +02:00
Jonas Jenwald
11b4613e20 Reduce the amount of console "spam", by ignoring info/warn calls, when running the unit-tests in Node.js/Travis
Compared to running the unit-tests in "regular" browsers, where any console output won't get mixed up with test output, in Node.js/Travis the test output looks quite noisy.
By ignoring `info`/`warn` calls, when running unit-tests in Node.js/Travis, the test output is a lot smaller not to mention that any *actual* failures are more easily spotted.
2018-06-03 00:28:40 +02:00
Jonas Jenwald
ef081a0531 Ensure that the WorkerTransport._passwordCapability is always rejected, even when errors are thrown in PDFDocumentLoadingTask.onPassword callback
Please note that while the current code works, both in the viewer and the unit-tests, it can leave the `WorkerTransport._passwordCapability` Promise in a pending state.
In the `PasswordRequest` handler, in src/display/api.js, we're returning the Promise from a `capability` object (rather than just a "plain" Promise). While an error thrown anywhere within this handler was fortunately enough to propagate it to the Worker side, it won't cause the Promise (in `WorkerTransport._passwordCapability`) to actually be rejected.
Finally note that while we're now catching errors in the `PasswordRequest` handler, those errors are still propagated to the Worker side via the (now) rejected Promise and the existing `return this._passwordCapability.promise;` line.

This prevents warnings about uncaught Promises, with messages such as "Error: Worker was destroyed during onPassword callback", when running the unit-tests both in browsers *and* in Node.js/Travis.
2018-06-03 00:28:40 +02:00
Jonas Jenwald
0ecc22cb04 Attempt to provide better default values for the disableFontFace/nativeImageDecoderSupport API options in Node.js
This should provide a better out-of-the-box experience when using PDF.js in a Node.js environment, since it's missing native support for both `@font-face` and `Image`.
Please note that this change *only* affects the default values, hence it's still possible for an API consumer to override those values when calling `getDocument`.

Also, prevents "ReferenceError: document is not defined" errors, when running the unit-tests in Node.js/Travis.
2018-06-03 00:28:37 +02:00
Jonas Jenwald
dcc7f33ee7 Prevent "ReferenceError: window is not defined" errors, from web/ui_utils.js, when running the unit-tests in Node.js/Travis 2018-06-03 00:23:07 +02:00
Tim van der Meij
a71886ffe0
Include package-lock.json for reproducible builds 2018-06-02 20:29:47 +02:00
Tim van der Meij
a816ee5c25
Upgrade to Webpack 4 2018-06-02 20:28:36 +02:00
Tim van der Meij
e3f635ce01
Update packages 2018-06-02 20:28:36 +02:00
Tim van der Meij
2921cc0eba
Merge pull request #9771 from timvandermeij/extension
Remove the `gulp extension` build target
2018-06-02 20:03:20 +02:00
Tim van der Meij
32de419a88
Remove the gulp extension build target 2018-06-02 19:56:09 +02:00
Tim van der Meij
36af85db92
Merge pull request #9740 from pedrotp/replace-get-getArray
Use Dict.getArray, instead of Dict.get, when getting the 'Size' in constructSampled in src/core/function.js
2018-06-02 19:50:09 +02:00
pedrotp
a190d21dd7 Use Dict.getArray, instead of Dict.get, when getting the 'Size' in constructSampled in src/core/function.js (PR 7295 follow-up) 2018-06-02 11:16:05 -04:00
Tim van der Meij
e39541ac18
Merge pull request #9730 from Snuffleupagus/jpeg-EOI-decodeScan
Ignore the rest of the image when encountering an EOI (End of Image) marker while parsing Scan data (issue 9679)
2018-06-01 00:10:43 +02:00
Jonas Jenwald
83ff7d9de9 Simplify the DNL (Define Number of Lines) marker warning in JpegImage.parse 2018-05-30 22:40:11 +02:00
Jonas Jenwald
620f65488b Ignore the rest of the image when encountering an EOI (End of Image) marker while parsing Scan data (issue 9679) 2018-05-30 22:40:11 +02:00
Tim van der Meij
c2cbeaa34d
Merge pull request #9759 from brendandahl/win-exclude-path
Fix webpack exclude path on windows.
2018-05-30 22:21:26 +02:00
Brendan Dahl
548b4ca208 Fix webpack exclude path on windows. 2018-05-29 17:43:02 -07:00
Tim van der Meij
7cd6c0fbf2
Merge pull request #9758 from timvandermeij/unlink
Use `fs.unlinkSync` instead of `fs.unlink` when removing `eq.log`
2018-05-28 23:52:47 +02:00
Tim van der Meij
4f8dae683e
Use fs.unlinkSync instead of fs.unlink when removing eq.log
This is necessary because Node.js crashes when `fs.unlink` is called
without a callback function.
2018-05-28 23:48:20 +02:00
Tim van der Meij
c5d5d29b03
Merge pull request #9756 from Snuffleupagus/Type1Parser-rm-makeSubStream
Remove usage of `makeSubStream` from `Type1Parser.extractFontProgram` in src/core/type1_parser.js (issue 9735)
2018-05-28 23:34:57 +02:00
Tim van der Meij
c8b4e6ec9d
Merge pull request #9757 from timvandermeij/backout
Backout of pull request #9345
2018-05-28 23:05:50 +02:00
Tim van der Meij
057994d781
Backout of pull request #9345 2018-05-28 22:54:09 +02:00
Jonas Jenwald
f68f60099e Remove usage of makeSubStream from Type1Parser.extractFontProgram in src/core/type1_parser.js (issue 9735)
This avoids the initialization of, potentially thousands of, unnecessary `Stream` objects, by getting the required number of bytes directly instead.
Given the special behaviour, when `length === 0`, of the `getBytes`/`skip` methods, it's also necessary to handle that particular case to prevent errors when encountering empty CharStrings.
2018-05-28 14:32:20 +02:00
Tim van der Meij
70cad2f053
Merge pull request #9754 from timvandermeij/tests
Fix broken links to Bugzilla PDF attachments and convert all PDF links from HTTP to HTTPS
2018-05-27 16:26:47 +02:00
Tim van der Meij
2f3b05fd5a
Convert all PDF links from HTTP to HTTPS 2018-05-27 16:02:04 +02:00
Tim van der Meij
4958b59369
Fix broken links to Bugzilla PDF attachments 2018-05-27 15:40:33 +02:00
Rob Wu
28360a0142
Merge pull request #9701 from mukulmishra18/fetch-abort
Add abort functionality in fetch stream
2018-05-22 15:11:49 +02:00
Mukul Mishra
949c3e9417 Add abort functionality in fetch stream 2018-05-22 12:46:59 +05:30
Tim van der Meij
b7a3a5e7e4
Merge pull request #9742 from AbhimanyuVashisht/remove-new-buffer
Replace deprecated new Buffer(string) constructor with Buffer.from(string)
2018-05-20 17:21:04 +02:00
Abhimanyu Vashisht
58612f869a Replace deprecated new Buffer(string) constructor with Buffer.from(string) 2018-05-20 20:42:50 +05:30
Tim van der Meij
4948129dc4
Merge pull request #9743 from timvandermeij/translations
Import translations
2018-05-20 16:57:21 +02:00
Tim van der Meij
321681d867
Import translations 2018-05-20 16:53:20 +02:00
Rob Wu
7ba50448fd
Merge pull request #9208 from rhendric/scrolling-modes
Add scrolling and spread modes to web viewer
2018-05-15 11:41:47 +02:00
Ryan Hendrickson
d7c051e807 Add preferences for default scroll/spread modes
This commit adds `scrollModeOnLoad` and `spreadModeOnLoad` preferences
that control the default viewer state when opening a new document for
the first time.

This commit also contains a minor refactoring of some of the option UI
rendering code in extensions/chromium/options/options.js, as I couldn't
bear creating two more functions nearly identical to the four that
already existed.
2018-05-14 23:10:33 -04:00
Ryan Hendrickson
c24bc29757 Remember last used scroll and spread modes 2018-05-14 23:10:33 -04:00
Ryan Hendrickson
eaf14e5d47 Modify key events for horizontal scrolling
Specifically, when there is no vertical scrollbar, let up, down, page
up, and page down all trigger moving to the next or previous page.
2018-05-14 23:10:32 -04:00