Commit Graph

9943 Commits

Author SHA1 Message Date
Honza Bambas :mayhemer
20aa8d74e9 Upstream changes from: Bug 1319111 - Expose result principal URL ("final channel URL") on LoadInfo, convert current consumers of LOAD_REPLACE
This is a downstream change introduced in [1]. That mozilla bug is adding a new property to channel's loadinfo object (nsILoadInfo) that protocol handlers has to set on channels when originalURI on the result channel is set to a different URI than the channel has been created for.

Existence of the new property on nsILoadInfo depends on landing [1].

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1319111
2017-05-07 21:38:10 +02:00
Tim van der Meij
bc49524ac7
Convert the hand tool to ES6 syntax 2017-05-07 21:30:07 +02:00
Yury Delendik
7015c88ce9 Merge pull request #8387 from evadne/issue-8386-webkit-subtle-crypto
amends Babel cache (#8364) implementation to also work on Safari
2017-05-07 13:13:20 -05:00
Evadne Wu
50af2284aa
amends Babel cache (#8364) implementation to disable caching on Safari
- the viewer was not loading in development mode on Safari, due to Safari
  having crypto.webkitSubtle instead of crypto.subtle.

- the isCachingPossible check was amended to check for crypro.subtle
  which is currently not in Safari but in Firefox and Chrome. This
  essentially works around the issue by disabling caching for Safari
  in development mode.

- maintainer sentiment: people who develop on Safari can get this speedup
  once Safari drops prefix for SubtleCrypto.

- note: at time of writing Safari Version 10.1 (12603.1.30.0.34) has an
  issue where caching can be enabled for PDF.js but must to be disabled for
  worker, otherwise the two sides do not communicate.

- https://github.com/mozilla/pdf.js/pull/8387#issuecomment-299709961
- https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
2017-05-07 18:00:30 +01:00
Tim van der Meij
b3e4361d7b Merge pull request #8381 from Snuffleupagus/document-properties-reset
Re-factor `PDFDocumentProperties` such that it's properly reset when a new PDF file is opened (issue 8371)
2017-05-07 17:43:23 +02:00
Jonas Jenwald
0c2ebda31c Cache JPEG images, just as we do for other image formats, in evaluator.js (issue 8380)
For some reason, we're putting all kind of images *except* JPEG into the `imageCache` in `evaluator.js`.[1]
This means that in the PDF file in issue 8380, we'll keep sending the *same* two small images[2] to the main-thread and decoding them over and over. This is obviously hugely inefficient!

As can be seen from the discussion in the issue, the performance becomes *extremely* bad if the user has the addon "Adblock Plus" installed. However, even in a clean Firefox profile, the performance isn't that great.

This patch not only addresses the performance implications of the "Adblock Plus" addon together with that particular PDF file, but it *also* improves the rendering times considerably for *all* users.
Locally, with a clean profile, the rendering times are reduced from `~2000 ms` to `~500 ms` for my setup!

Obviously, the general structure of the PDF file and its operator sequence is still hugely inefficient, however I'd say that the performance with this patch is good enough to consider the issue (as it stands) resolved.[3]

Fixes 8380.

---
[1] Not technically true, since inline images are cached from `parser.js`, but whatever :-)

[2] The two JPEG images have dimensions 1x2, respectively 4x2.

[3] To make this even more efficient, a new state would have to be added to the `QueueOptimizer`. Given that PDF files this stupid fortunately aren't too common, I'm not convinced that it's worth doing.
2017-05-07 13:07:41 +02:00
Jonas Jenwald
7780fd5b98 Re-factor PDFDocumentProperties such that it's properly reset when a new PDF file is opened (issue 8371)
This patch contains the following improvements:
 - Only fetch the various document properties *once* per PDF file opened, and cache the result (in a frozen object).
 - Always update the *entire* dialog at once, to prevent inconsistent UI state (issue 8371).
 - Ensure that the dialog, and all its internal properties, are reset when `PDFViewerApplication.close` is called.
 - Inline, and re-factor, the `getProperties` method in `open`, since that's the only call-site.
 - Always overwrite the fileSize with the value obtained from `pdfDocument.getDownloadInfo`, to ensure that it's correct.
 - ES6-ify the code that's touched in this patch.

Fixes 8371.
2017-05-07 10:16:03 +02:00
Jonas Jenwald
50d026fbda Merge pull request #8385 from tobytailor/master
Fix typo in LoopbackPort export
2017-05-06 10:35:49 +02:00
Tobias Schneider
e1a3e46cba Fix typo 2017-05-05 19:10:00 -07:00
Yury Delendik
deae2d8cb8 Merge pull request #8368 from yurydelendik/sourcemap
Enables source maps for webpack generated files.
2017-05-05 09:32:27 -05:00
Yury Delendik
996805f953 Produces source maps for built files. 2017-05-05 08:15:21 -05:00
Yury Delendik
c3cfcbe72f Merge pull request #8340 from ydfzgyj/fix-svg-spacing
Fix char spacing bug in SVG mode
2017-05-05 07:41:25 -05:00
巴里切罗
d58040aa29 fix(svg) char spacing bug 2017-05-05 12:11:20 +08:00
Yury Delendik
206ad8d8b2 Merge pull request #8378 from Snuffleupagus/es6-modules-src-shared
Convert the files in the `/src/shared` folder to ES6 modules
2017-05-04 14:35:09 -05:00
Jonas Jenwald
60b14f526e Convert the files in the /src/shared folder to ES6 modules 2017-05-04 21:07:59 +02:00
Yury Delendik
b0a796ced3 Merge pull request #8377 from Snuffleupagus/web-rm-bind
Replace unnecessary `bind(this)` statements with arrow functions in `web/` files
2017-05-04 12:08:05 -05:00
Jonas Jenwald
f27b5013e2 Replace unnecessary bind(this) statements with arrow functions in web/ files
By using `let`, which is block-scoped, instead of `var` in a couple of places we're able to get rid of additional `bind` calls.
2017-05-04 17:13:09 +02:00
Yury Delendik
c9d3c20e2c Fix esprima tests. 2017-05-04 08:24:44 -05:00
Yury Delendik
3adda80f97 Merge pull request #8358 from Snuffleupagus/PartialEvaluator-method-signatures
Change the signatures of the `PartialEvaluator` "constructor" and its `getOperatorList`/`getTextContent` methods to take parameter objects
2017-05-04 08:10:30 -05:00
Yury Delendik
e81c067de2 Merge pull request #8370 from Snuffleupagus/src-rm-bind
Replace unnecessary `bind(this)` and `var self = this` statements with arrow functions in remaining `src/` files
2017-05-03 18:00:34 -05:00
Jonas Jenwald
6c81b8e6dd Replace unnecessary bind(this) and var self = this statements with arrow functions in remaining src/ files 2017-05-03 23:12:35 +02:00
Yury Delendik
e42fc546a0 Merge pull request #8369 from mozilla/brendandahl-patch-1
Add no-default-browser-check to chrome runner.
2017-05-03 13:44:19 -05:00
Brendan Dahl
b06022895e Add no-default-browser-check to chrome runner. 2017-05-03 11:22:08 -07:00
Yury Delendik
74ba3033e8 Merge pull request #8359 from Snuffleupagus/Lexer-getNumber-ignore-line-breaks
Ignore line-breaks between operator and digit in `Lexer.getNumber`
2017-05-03 09:43:59 -05:00
Yury Delendik
2ac410625b Fixes shell parameters quoting after #8349 2017-05-03 08:17:31 -05:00
Jonas Jenwald
b4787f0d38 Merge pull request #8364 from yurydelendik/babel-cache
Adds babel caching for system.js.
2017-05-03 13:05:39 +02:00
Jonas Jenwald
3e20d30afc Change the signatures of the PartialEvaluator "constructor" and its getOperatorList/getTextContent methods to take parameter objects
Currently these methods accept a large number of parameters, which creates quite unwieldy call-sites. When invoking them, you have to remember not only what arguments to supply, but also the correct order, to avoid runtime errors.
Furthermore, since some of the parameters are optional, you also have to remember to pass e.g. `null` or `undefined` for those ones.
Also, adding new parameters to these methods (which happens occasionally), often becomes unnecessarily tedious (based on personal experience).

Please note that I do *not* think that we need/should convert *every* single method in `evaluator.js` (or elsewhere in `/core` files) to take parameter objects. However, in my opinion, once a method starts relying on approximately five parameter (or even more), passing them in individually becomes quite cumbersome.

With these changes, I obviously needed to update the `evaluator_spec.js` unit-tests. The main change there, except the new method signatures[1], is that it's now re-using *one* `PartialEvalutor` instance, since I couldn't see any compelling reason for creating a new one in every single test.

*Note:* If this patch is accepted, my intention is to (time permitting) see if it makes sense to convert additional methods in `evaluator.js` (and other `/core` files) in a similar fashion, but I figured that it'd be a good idea to limit the initial scope somewhat.

---

[1] A fun fact here, note how the `PartialEvaluator` signature used in `evaluator_spec.js` wasn't even correct in the current `master`.
2017-05-03 12:10:20 +02:00
Yury Delendik
bbb2cc000e Adds babel caching for system.js. 2017-05-02 19:28:03 -05:00
Yury Delendik
84f174bb2f Merge pull request #8363 from yurydelendik/worker-fromport
Adds initializeFromPort to the WorkerMessageHandler.
2017-05-02 19:22:20 -05:00
Yury Delendik
008aa56ac6 Adds initializeFromPort to the WorkerMessageHandler. 2017-05-02 16:11:54 -05:00
Jonas Jenwald
40feca12c1 Ignore line-breaks between operator and digit in Lexer.getNumber
This is consistent with the behaviour in Adobe Reader (and PDFium), and it fixes the display of page 30 in https://bug1354114.bmoattachments.org/attachment.cgi?id=8855457 (taken from https://bugzilla.mozilla.org/show_bug.cgi?id=1354114).

The patch also makes the `error` message for invalid numbers slightly more useful, by including the charCode as well. (Having that information available would have reduced the time spent on debugging the PDF file above.)
2017-05-02 20:59:42 +02:00
Yury Delendik
aea3eccd0f Merge pull request #8361 from tobytailor/master
Export LoopbackPort
2017-05-02 13:51:57 -05:00
Tobias Schneider
a80c405941 Rename FakeWorkerPort to LoopbackPort and export it 2017-05-02 11:33:19 -07:00
Yury Delendik
de7002dc6c Merge pull request #8357 from Snuffleupagus/core-rm-bind
Replace unnecessary `bind(this)` and `var self = this` statements with arrow functions in remaining `src/core/` files
2017-05-02 10:11:02 -05:00
Jonas Jenwald
ebaa22478c Replace unnecessary bind(this) and var self = this statements with arrow functions in remaining src/core/ files 2017-05-02 15:47:43 +02:00
Tim van der Meij
0c99429291 Merge pull request #8349 from timvandermeij/remove-make
Migrate `make.js` to `gulpfile.js`
2017-05-02 01:12:56 +02:00
Tim van der Meij
f748407b26
Remove make.js and the target fetching in gulpfile.js
Note that we have to use `fs.writeFileSync` since `.to()` is not
available anymore. Moreover, introduce `safeSpawnSync` to make sure that
we check the return codes of the spawned processes properly.
2017-05-02 01:00:52 +02:00
Tim van der Meij
145c0cea39
Remove unused Gulp target for testing
To run the regression tests, developers use `gulp browsertest` and the
bot uses `gulp bottest`. We're not passing the `noreftest` option
anywhere in the code (probably because the `bottest` command takes care
of this already), so we should remove this.
2017-05-02 00:47:53 +02:00
Tim van der Meij
19cc9bcded
Port the mozcentraldiff target to Gulp 2017-05-02 00:47:51 +02:00
Tim van der Meij
74854fb4cc
Port the mozcentralbaseline target to Gulp
The baseline fix is dead code since three years, so we can safely remove
it.
2017-05-02 00:45:52 +02:00
Tim van der Meij
e18a08ffeb Merge pull request #8355 from Snuffleupagus/evaluator-rm-bind
Replace unnecessary `bind(this)` and `var self = this` statements with arrow functions in `src/core/evaluator.js`
2017-05-01 23:41:06 +02:00
Jonas Jenwald
95bbc8101c Replace unnecessary bind(this) and var self = this statements with arrow functions in src/core/evaluator.js
Note that by using `let` instead of `var` in `PartialEvaluator.setGState` and `TranslatedFont.loadType3Data`, we can get rid of further `bind` usages since `let` is block-scoped.
Also, the fact that `bind` wasn't used in the `Font` case inside of `setGState` is actually a bug which has been present ever since PR 5205, where a closure was replaced by a standard loop.[1]

---
[1] I'm not aware of any bugs caused by this, but that is probably more a happy accident than anything else, since e.g. just removing the `bind` from the `SMask` case without using block-scoped variables causes test failures.
2017-05-01 20:29:44 +02:00
Tim van der Meij
60c232bc8c Merge pull request #8353 from Snuffleupagus/eslint_object-shorthand
Enable the `object-shorthand` ESLint rule
2017-04-30 21:23:57 +02:00
Tim van der Meij
456b1566cb Merge pull request #8354 from Snuffleupagus/PdfStreamConverter-remove-bind
[Firefox addon] Replace a `bind(this)` statement with an arrow function in `PdfStreamConverter.jsm` (issue 8343)
2017-04-30 21:10:53 +02:00
Jonas Jenwald
8e976d7110 [Firefox addon] Replace a bind(this) statement with an arrow function in PdfStreamConverter.jsm (issue 8343)
Please note that I used the addon debugger to set a breakpoint in the `unload` function, in order to ensure that `this` still correctly refers to the `FindEventManager` scope.
2017-04-30 13:26:34 +02:00
Jonas Jenwald
7560f12a17 Enable the object-shorthand ESLint rule
Please see http://eslint.org/docs/rules/object-shorthand.

Unfortunately, based on commit 9276d1dcd9, it seems that we still need to maintain compatibility with old Node.js versions, hence certain files/directories that are executed in Node.js are currently exempt from this rule.

Furthermore, since the files specific to the Chromium extension are not run through Babel, the `/extensions/chromium/` directory is also exempt from this rule.
2017-04-30 11:13:34 +02:00
Jonas Jenwald
00d67371ec Merge pull request #8298 from timvandermeij/es6-modules-test
Convert the files in the `/test/unit` folder to ES6 modules
2017-04-30 10:34:48 +02:00
Tim van der Meij
35730148a7
Convert the files in the /test/unit folder to ES6 modules 2017-04-30 00:34:02 +02:00
Tim van der Meij
06c93d8fbd Merge pull request #8342 from Snuffleupagus/eslint_object-shorthand-src-core
Enable the `object-shorthand` ESLint rule in `src/core`
2017-04-29 23:59:20 +02:00
Tim van der Meij
5fb779d26f Merge pull request #8351 from Snuffleupagus/eslint_object-shorthand-web
Enable the `object-shorthand` ESLint rule in `web`
2017-04-29 23:49:33 +02:00