Commit Graph

9404 Commits

Author SHA1 Message Date
Rob Wu
775441b7c6 Refactor: configurable page rotation in print job
Determine the page rotation at the same place as where the page size is
determined. This allows us to implement custom print page rotation logic
in one place, in the future.
2017-02-07 23:42:36 +01:00
Tim van der Meij
6f0cf8c4cb Merge pull request #7972 from Snuffleupagus/eslint_no-unused-vars
Enable the `no-unused-vars` ESLint rule
2017-02-01 23:50:23 +01:00
Tim van der Meij
fe3b64d4ab Merge pull request #8016 from Snuffleupagus/remove-isStream-property
Remove the unused `isStream` property on various `Stream`s
2017-02-01 23:07:40 +01:00
Tim van der Meij
37ecb8e620 Merge pull request #7959 from Snuffleupagus/PDFSidebar-notifications
Display a notification on the `sidebarToggle` button for PDF documents with outline/attachments
2017-02-01 22:59:31 +01:00
Jonas Jenwald
f7d99ccc26 Remove the unused isStream property on various Streams
This property was added all the way back in PR 542, but hasn't actually been relied upon ever since PR 692.
Note that there's a `isStream()` utility function which replaced the property years ago, hence the `isStream` property is now dead code.
2017-02-01 11:38:11 +01:00
Jonas Jenwald
c102232275 Append the contents of FileAttachment annotations to the attachments view of the sidebar, for easier access to the embedded files
Other PDF viewers, e.g. Adobe Reader, seem to append `FileAttachment`s to their attachments views.
One obvious difference in PDF.js is that we cannot append all the annotations on document load, since that would require parsing *every* page. Despite that, it still seems like a good idea to add `FileAttachment`s, since it's thus possible to access all the various types of attachments from a single place.

*Note:* With the previous patch we display a notification when a `FileAttachment` is added to the sidebar, which thus makes appending the contents of these annotations to the sidebar slightly more visible/useful.
2017-01-31 22:26:16 +01:00
Jonas Jenwald
616e5fadff Display a notification on the sidebarToggle button for PDF documents with outline/attachments
A longstanding issue with the viewer is that you cannot tell if a PDF document includes an outline and/or attachments without actually opening the sidebar.
This patch contains a suggested solution for that, by displaying an hide-on-interaction notification on the `sidebarToggle` button (and the relevant sidebar view buttons). Note that this was inspired by e.g. the update notification that is displayed on the menu button in Firefox.

For an initial implementation, I've tried to do this in such a way that the notification isn't too distracting. Without being an UX expert, I don't think that we'd want something too in-your-face, in order to keep the viewer toolbars reasonable clean. (We probably do *not* want e.g. an entire notification bar in these situations, since that would take up unnecessary screen space and require actions from the user to close.)

However it's certainly possible that the current notification might simply be *too* inconspicuous to be truly helpful to users, but we could probably iterate on that if the feature itself is deemed useful.
2017-01-30 15:39:04 +01:00
Jonas Jenwald
3f320f0b11 Merge pull request #8006 from timvandermeij/mozFillRule
Remove usage of `mozFillRule`
2017-01-30 10:35:29 +01:00
Tim van der Meij
95732279b6 Remove usage of mozFillRule
The non-standard `mozFillRule` has been removed in Firefox 51 [1, 2].
Instead, a parameter of the standard methods should be used. Note that
this is supported in all major browsers for a long time now, so there
should be no need keeping this Firefox-specific code around.

[1] https://developer.mozilla.org/en-US/Firefox/Releases/51
[2] https://bugzilla.mozilla.org/show_bug.cgi?id=826619
2017-01-29 23:24:44 +01:00
Jonas Jenwald
52e0f51917 Enable the no-unused-vars ESLint rule
Please see http://eslint.org/docs/rules/no-unused-vars; note that this patch purposely uses the same rule options as in `mozilla-central`, such that it fixes part of issue 7957.

It wasn't, in my opinion, entirely straightforward to enable this rule compared to the already existing rules. In many cases a `var descriptiveName = ...` format was used (more or less) to document the code, and I choose to place the old variable name in a trailing comment to not lose that information.

I welcome feedback on these changes, since it wasn't always entirely easy to know what changes made the most sense in every situation.
2017-01-29 23:23:17 +01:00
Tim van der Meij
8d684b5b3f Merge pull request #8003 from Snuffleupagus/move-EOF-isEOF
Move `EOF`/`isEOF` from core/parser.js to core/primitives.js
2017-01-29 22:16:25 +01:00
Jonas Jenwald
2b84fb79b4 Merge pull request #7995 from Snuffleupagus/addon-eslint_consistent-return
[Firefox addon] Enable the `consistent-return` ESLint rule (issue 7957)
2017-01-27 19:11:43 +01:00
Jonas Jenwald
7e1d92461a [Firefox addon] Enable the consistent-return ESLint rule (issue 7957)
See http://eslint.org/docs/rules/consistent-return; it appears that I overlooked this rule in PR 7982.

Also adds the http://eslint.org/docs/rules/no-nested-ternary rule, which didn't require any code changes, since that rule is being enforced in mozilla-central.

Re: issue 7957.
2017-01-27 19:04:08 +01:00
Jonas Jenwald
8823f6f5eb Merge pull request #7991 from Snuffleupagus/addon-eslint-quotes-double
[Firefox addon] Enforce double quotes, using ESLint, to avoid linting errors in mozilla-central (issue 7957)
2017-01-27 17:54:26 +01:00
Jonas Jenwald
50c2856097 Move EOF/isEOF from core/parser.js to core/primitives.js
Given the nature of `EOF` and `isEOF`, it seems to me that they really ought to be placed in `core/primitives.js` instead.

In general, it doesn't seem great to have to depend on the entire `core/parser.js` file for such simple primitives/helper functions.
In particular, while `core/ps_parser.js` is completely separate from `core/parser.js` with regards to its function, it still depends on the latter for just *one* primitive.

Note that compared to e.g. PR 7389, this will not reduce the number of dependencies for `core/ps_parser`, however the new dependency IMHO makes more sense.
2017-01-27 13:37:48 +01:00
Yury Delendik
e132fa976e Merge pull request #8001 from yurydelendik/v1.7.225
Release of 1.7.225
2017-01-26 14:55:22 -06:00
Yury Delendik
ad4960ab09 Release of 1.7.225 2017-01-26 14:54:47 -06:00
Yury Delendik
17d135fcfc Merge pull request #8000 from yurydelendik/version1.7
Version 1.7
2017-01-26 14:48:49 -06:00
Yury Delendik
5fdec9257a Version 1.7 2017-01-26 14:47:23 -06:00
Jonas Jenwald
e835774d9c Update l10n files 2017-01-26 21:24:30 +01:00
Jonas Jenwald
af42c266e7 Merge pull request #7987 from yurydelendik/noopener
[api-minor] Adds noopener and nofollow to rel attribute of hyperlinks.
2017-01-26 20:54:09 +01:00
Jonas Jenwald
a5d5b970af [Firefox addon] Enforce double quotes, using ESLint, to avoid linting errors in mozilla-central (issue 7957)
Given that this patch causes a lot of churn in the addon code, I wouldn't really mind if we ultimately decide against doing this and just add a rule exception in mozilla-central instead.[1]

---
[1] Note that I used the ESLint `--fix` option, hence writing this commit message actually took longer time than the creation of the patch :-)
2017-01-25 01:14:06 +01:00
Yury Delendik
e0a92a7f48 Merge pull request #7990 from Snuffleupagus/addon-remove-network.js
[Firefox addon] Stop bundling `src/core/network.js` into the `FIREFOX`/`MOZCENTRAL` builds (PR 7322 follow-up)
2017-01-24 09:54:14 -06:00
Tim van der Meij
2170eda9df Merge pull request #7971 from davehouse/remove_viewer_page_div_id
remove viewer page div id
2017-01-23 22:27:26 +01:00
Jonas Jenwald
f000417ce0 [Firefox addon] Stop bundling src/core/network.js into the FIREFOX/MOZCENTRAL builds (PR 7322 follow-up)
PR 7322 added the `PdfJsNetwork.jsm` file, instead of the general `src/core/network.js` file for the Firefox addon. However, `make.js` wasn't updated to actually stop including the now obsolete network file.
2017-01-23 22:23:17 +01:00
Yury Delendik
ca74e15a46 Merge pull request #7988 from Snuffleupagus/eslint-more-rules-2
Enable the `no-empty-pattern`/`no-floating-decimal`/`no-self-compare`/`no-delete-var`/`no-new-object` ESLint rules
2017-01-23 14:28:12 -06:00
Jonas Jenwald
f77c52291e Enable the no-empty-pattern/no-floating-decimal/no-self-compare/no-delete-var/no-new-object ESLint rules
The following rules required no code changes:
http://eslint.org/docs/rules/no-empty-pattern
http://eslint.org/docs/rules/no-floating-decimal
http://eslint.org/docs/rules/no-delete-var
http://eslint.org/docs/rules/no-new-object

There was just one change needed in order to enable:
http://eslint.org/docs/rules/no-self-compare; which I think helps readability a lot, since that comparison makes no sense until you realize that we push `NaN` onto the `stack` in some cases *and* furthermore that `NaN !== NaN`.
2017-01-23 20:30:50 +01:00
Yury Delendik
fc2d8c15e8 Adds noopener and nofollow to rel attribute of hyperlinks. 2017-01-23 10:34:27 -06:00
Yury Delendik
fd1affa78a Merge pull request #7982 from Snuffleupagus/addon-es6
[Firefox addon] Convert the code to be ES6 friendly, in order to better agree with mozilla-central coding conventions (issue 7957)
2017-01-23 09:53:37 -06:00
Yury Delendik
857e360a42 Merge pull request #7977 from Snuffleupagus/paintedViewport-regression
Ensure that we use the *correct* `paintedViewport` in `PDFPageView.cssTransform`, to avoid visual glitches on quick rotations (PR 7738 follow-up)
2017-01-23 09:41:35 -06:00
Jonas Jenwald
a47fc2f8f3 Merge pull request #7985 from yurydelendik/ie9-doc-ready
Fixes IE9 document.readyState and input.type=number issues.
2017-01-23 16:37:23 +01:00
Yury Delendik
a9cf281723 Fixes IE9 document.readyState and input.type=number issues. 2017-01-23 09:23:13 -06:00
Dave House
52360694b0
Remove ids from viewer page and thumbnail divs
The id, and parsing it for the page number, is replaced by the
data-page-number attribute (added here for thumbnails).
2017-01-23 07:46:39 -07:00
Jonas Jenwald
9eb9065c79 Ensure that we use the *correct* paintedViewport in PDFPageView.cssTransform, to avoid visual glitches on quick rotations (PR 7738 follow-up)
*This fixes a regression from commit c9a0955c9c, i.e. PR 7738.*

Currently if you quickly rotate a document at least *twice*,[1] such that rendering of a page hasn't finished for the first rotation before the last rotation is triggered, the `cssTransform` method can fail to update the page correctly leading to it looking temporarily distorted.

The reason why things break is that previously we stored the `viewport` on the canvas DOM element, meaning that when it was accessed in `cssTransform` is was guaranteed to point to the `viewport` of the `zoomLayer` canvas.
Generally you want to avoid storing data on DOM elements this way, and during the `PDFPageView` refactoring needed to support SVG rendering, the previous `viewport` was instead stored directly on `PDFPageView`.
However, the problem is first of all that the `paintedViewport` only stores the *last* `viewport` computed, and second of all that there're no guarantees that it actually applies to the current `zoomLayer` canvas.
If a document is rotated slowly enough that rendering finishes *before* the next rotation then this problem doesn't exist, but for sufficiently quick rotations rendering will be cancelled at least once and the `paintedViewport` could thus be bogus.

The solution for the above problems is to ensure that we track the correct `viewport` for each DOM element (canvas or svg),[2] which seemed easist to do with a `WeakMap`.[3]

---
[1] I'm able to reproduce this using the `tracemonkey` file, but please note that for pages with few operations, i.e. that render very quickly, the effect may be hard to spot.

[2] One other possible solution that I briefly considered, was to wait until rendering finished before storing the current `viewport`. However, that would have caused issues with rotating a page before the *first* rendering operation had finished.

[3] This regression took me way longer to both figure out, and fix, than I'd like to admit :-)
2017-01-23 12:13:53 +01:00
Jonas Jenwald
3ec99f0e12 [Firefox addon] Convert the code to be ES6 friendly, in order to better agree with mozilla-central coding conventions (issue 7957)
*Please note: ignoring whitespace changes is most likely necessary for the diff to be readable.*

This patch addresses all the current, in `mozilla-central`, linting failures in the addon. It should thus be possible to change the `.eslintignore` entry for PDF.js in `mozilla-central` from `browser/extensions/pdfjs/**` to `browser/extensions/pdfjs/build/**` and `browser/extensions/pdfjs/web/**` instead.
Note that we cannot, for backwards compatibility reason of the general PDF.js library, at this time make similar changes for files residing in the `build` and `web` directories in `mozilla-central`.

The main changes in this patch are that we now use [classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes) instead of our previous "class-like" functions, and also use the more compact [object shorthand notation](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Object_initializer#New_notations_in_ECMAScript_2015).
A couple of functions were also converted to [arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions), to reduced usages of `bind(this)` and `var self = this`.

One caveat with ES6 classes is that it's not (yet) possible to define private constants/helper functions within them, which is why the `NetworkManagerClosure` was kept to not change the visibility of those constant/functions.

Besides testing in Firefox Nightly 53, this patch has also been tested in Firefox ESR 45 and SeaMonkey 2.46.
However, I'd gladly welcome help with testing the patch more, to ensure that nothing has gone wrong during the refactoring.

Fixes the first bullet point of issue 7957.
2017-01-22 23:14:58 +01:00
Tim van der Meij
1948a53ebb Merge pull request #7973 from Snuffleupagus/eslint_spaced-comment
Enable the `spaced-comment` ESLint rule
2017-01-22 21:58:42 +01:00
Tim van der Meij
17dd2e6b20 Merge pull request #7979 from Snuffleupagus/eslint-more-rules
Enable the `no-unsafe-finally`/`no-octal`/`no-useless-call` ESLint rules
2017-01-22 20:53:26 +01:00
Jonas Jenwald
54d55e8b7a Merge pull request #7980 from mukulmishra18/lint-errors
Fix #7978: Fixes ESLint yoda rule for the URL polyfill.
2017-01-22 00:49:20 +01:00
Mukul Mishra
4e38200030 Fix #7978: Fixes ESLint yoda rule for the URL polyfill. 2017-01-21 22:47:28 +05:30
Jonas Jenwald
82ea7e6e6e Enable the no-unsafe-finally/no-octal/no-useless-call ESLint rules
http://eslint.org/docs/rules/no-unsafe-finally, there's just one violation which in this case can actually be ignored since there's nothing `return`ed there.
http://eslint.org/docs/rules/no-octal, there're no violations in the code-base.
http://eslint.org/docs/rules/no-useless-call, there's just one violation that needs to be fixed.
2017-01-21 17:15:57 +01:00
Tim van der Meij
f8e793f8c2 Merge pull request #7974 from Snuffleupagus/eslint_no-lone-blocks
Enable the `no-lone-blocks` ESLint rule
2017-01-19 22:35:38 +01:00
Jonas Jenwald
31684e6918 Enable the no-lone-blocks ESLint rule
http://eslint.org/docs/rules/no-lone-blocks

Note that we currently have no code that violates this rule in the source files, but it seems that the built files are possibly affected (see issue 7957).
2017-01-19 19:56:23 +01:00
Jonas Jenwald
4626fc8342 Enable the spaced-comment ESLint rule
Please see http://eslint.org/docs/rules/spaced-comment.

Note that the exceptions added for `line` comments are intended to still allow use of the old preprocessor without linting errors.
Also, I took the opportunity to improve the grammar slightly (w.r.t. capitalization and punctuation) for comments touched in the patch.
2017-01-19 16:41:59 +01:00
Tim van der Meij
a917443ae6 Merge pull request #7965 from Snuffleupagus/bug-1331081
[Bug 1331081] omit addEventListener/removeEventListener's third parameter when it's false
2017-01-17 22:26:26 +01:00
Jonas Jenwald
70c1a6b120 [Bug 1331081] omit addEventListener/removeEventListener's third parameter when it's false
Upstream changes from https://bugzilla.mozilla.org/show_bug.cgi?id=1331081; this patch also covers one file, `pdf_print_service.js`, that's not present in mozilla-central.

Fixes 7962.
2017-01-17 17:50:21 +01:00
Tim van der Meij
c1703e977d Merge pull request #7960 from Snuffleupagus/eslint_space-unary-ops
Adjust the `space-unary-ops` ESLint rule to comply with mozilla-central lint rules
2017-01-16 22:18:39 +01:00
Jonas Jenwald
0dff8f3600 Adjust the space-unary-ops ESLint rule to comply with mozilla-central lint rules
See http://eslint.org/docs/rules/space-unary-ops; a *very* small part of issue 7957.
2017-01-16 17:19:25 +01:00
Jonas Jenwald
c0a47fddcc Update l10n files 2017-01-16 09:54:50 +01:00
Yury Delendik
9b111c9157 Merge pull request #7956 from Snuffleupagus/bug-1330147
[Bug 1330147] removeObserver calls should not supply a third parameter
2017-01-13 08:06:18 -06:00
Jonas Jenwald
54a64863e2 [Bug 1330147] removeObserver calls should not supply a third parameter
*This is yet another very recent change that we were not notified about.*

Upstream changes from https://bugzilla.mozilla.org/show_bug.cgi?id=1330147, specifically https://hg.mozilla.org/mozilla-central/rev/8e0b7bc5fd71.
2017-01-13 11:34:26 +01:00