Commit Graph

9313 Commits

Author SHA1 Message Date
Jonas Jenwald
e963971244 Further adjust the heuristics used to detect OpenType font files with CFF data, to ensure that all Type0 fonts are handled the same way regardless of font Subtype (issue 7901)
Changing this particular code makes me somewhat nervous about regressions, since PR 5770 necessitated the follow-up PR 6270.
However, the patch passes all tests added in those PRs (and obviously all other tests). Furthermore, I've manually checked all the issues/bugs referenced in PRs 5770 and 6270 without finding any issues.

**Please note:** This patch fixes *only* the font bug, not the SVG conversion, present on pages two and three of the PDF file in issue 7901.
2016-12-20 17:03:51 +01:00
Yury Delendik
3b3a179486 Merge pull request #7879 from rossj/highlight-fix
Make use of textAdvanceScale consistent during combineTextItems. Fix for #7878.
2016-12-19 09:18:13 -06:00
Jonas Jenwald
33063a486e Update l10n files 2016-12-19 11:10:14 +01:00
Tim van der Meij
017e9b98d1 Merge pull request #7898 from timvandermeij/acroforms-checkbox-radiobutton
Interactive forms: render button widget annotations (checkboxes and radio buttons)
2016-12-17 21:22:15 +01:00
Tim van der Meij
a428899b3c Button widget annotations: improve unit tests, simplify code and remove labels
Modern browsers support styling radio buttons and checkboxes with CSS.
This makes the implementation much easier, and the fallback for older
browsers is still decent.
2016-12-17 20:38:48 +01:00
Tim van der Meij
77148c7880 Button widget annotations: implement radio button value fetching according to the specification 2016-12-17 20:34:32 +01:00
Tim van der Meij
0c9a06c020 Button widget annotations: implement reference testing
Moreover, ensure that the read-only state is respected and improve CSS
names.
2016-12-17 20:33:35 +01:00
benweet
ba012c7a68 Button widget annotations: implement checkboxes and radio buttons 2016-12-17 20:31:30 +01:00
Tim van der Meij
d0893b0c48 Merge pull request #7900 from Snuffleupagus/choiceWidget-Opt-indirect-objects
Ensure that we handle indirect objects in all types of `Opt` entries in `ChoiceWidget` annotation dictionaries
2016-12-17 20:29:43 +01:00
Jonas Jenwald
bd91f34513 Ensure that we handle indirect objects in all types of Opt entries in ChoiceWidget annotation dictionaries
I haven't got an example where the current code breaks, but given all the previous cases we've seen where PDF generators use indirect objects in Arrays it makes sense to fix this pro-actively.
I've modified the relevant unit-tests slightly, and they would *not* pass without the code changes in this patch.

*Note:* `Dict_getArray` only dereferences Array elements on the "top-level", to avoid recursion issues. Furthermore if you have to loop through the Array at the call-site anyway, then using `Dict_get` in combination with `XRef_fetchIfRef` is a tiny bit more efficient.
2016-12-17 13:44:20 +01:00
Tim van der Meij
a719b71e59 Merge pull request #7897 from Snuffleupagus/eslint-switch
Switch to using ESLint, instead of JSHint, for linting
2016-12-16 22:40:41 +01:00
Jonas Jenwald
c850968fa7 Remove globals that are now unnecessary thanks to the use of various ESLint environments (e.g. Node, ShellJS, Jasmine) 2016-12-16 21:09:55 +01:00
Jonas Jenwald
2f3805efbc Switch to using ESLint, instead of JSHint, for linting
*Please note that most of the necessary code adjustments were made in PR 7890.*

ESLint has a number of advantageous properties, compared to JSHint. Among those are:
 - The ability to find subtle bugs, thanks to more rules (e.g. PR 7881).
 - Much more customizable in general, and many rules allow fine-tuned behaviour rather than the just the on/off rules in JSHint.
 - Many more rules that can help developers avoid bugs, and a lot of rules that can be used to enforce a consistent coding style. The latter should be particularily useful for new contributors (and reduce the amount of stylistic review comments necessary).
 - The ability to easily specify exactly what rules to use/not to use, as opposed to JSHint which has a default set. *Note:* in future JSHint version some of the rules we depend on will be removed, according to warnings in http://jshint.com/docs/options/, so we wouldn't be able to update without losing lint coverage.
 - More easily disable one, or more, rules temporarily. In JSHint this requires using a numeric code, which isn't very user friendly, whereas in ESLint the rule name is simply used instead.

By default there's no rules enabled in ESLint, but there are some default rule sets available. However, to prevent linting failures if we update ESLint in the future, it seemed easier to just explicitly specify what rules we want.
Obviously this makes the ESLint config file somewhat bigger than the old JSHint config file, but given how rarely that one has been updated over the years I don't think that matters too much.

I've tried, to the best of my ability, to ensure that we enable the same rules for ESLint that we had for JSHint. Furthermore, I've also enabled a number of rules that seemed to make sense, both to catch possible errors *and* various style guide violations.

Despite the ESLint README claiming that it's slower that JSHint, https://github.com/eslint/eslint#how-does-eslint-performance-compare-to-jshint, locally this patch actually reduces the runtime for `gulp` lint (by approximately 20-25%).

A couple of stylistic rules that would have been nice to enable, but where our code currently differs to much to make it feasible:
 - `comma-dangle`, controls trailing commas in Objects and Arrays (among others).
 - `object-curly-spacing`, controls spacing inside of Objects.
 - `spaced-comment`, used to enforce spaces after `//` and `/*. (This is made difficult by the fact that there's still some usage of the old preprocessor left.)

Rules that I indend to look into possibly enabling in follow-ups, if it seems to make sense: `no-else-return`, `no-lonely-if`, `brace-style` with the `allowSingleLine` parameter removed.

Useful links:
 - http://eslint.org/docs/user-guide/configuring
 - http://eslint.org/docs/rules/
2016-12-16 21:06:36 +01:00
Ross Johnson
4537590033 Consitently apply textAdvanceScale during building of textContentItems for improved highlighting. Fixes #7878. 2016-12-14 21:02:19 -06:00
Jonas Jenwald
b629be05bd Merge pull request #7886 from Snuffleupagus/viewer-async-initialization
Move the `Preferences` initialization/fetching code to the top of `PDFViewerApplication.initialize`, to enable using them when initializing e.g. the viewer components
2016-12-14 17:30:40 +01:00
Jonas Jenwald
a96b0f80dd Convert the only remaining consumer (in hand_tool.js) of the 'localized' event to use the localized Promise instead, and only re-dispatch the 'localized' event on the eventBus for GENERIC builds
Ideally we'd remove the 'localized' event from the `eventBus`, but for backwards compatibility we keep it in `GENERIC` builds.
Note that while we want to ensure that the direction attribute of the HTML is updated as soon as the `localized` Promise is resolved, we purposely wait until the viewer has been initialized to ensure that the 'localized' event will always be dispatched.
2016-12-14 16:19:10 +01:00
Jonas Jenwald
648024f5d0 Don't call bindEvents() until PDFViewerApplication has been initialized, and move binding of window event listeners to a helper method, to prevent errors if an event manages to arrive too soon
With `bindEvents()` now being called after the viewer has been initialized, we no longer need to have `PDFViewerApplication.initialized` checks in the event handler functions.
Furthermore by moving the `window.addEventListener`s to a helper method, `PDFViewerApplication.initialized` checks are no longer necessary in the event handlers, hence we thus address part of issue 7797 here as well.
2016-12-14 16:17:10 +01:00
Jonas Jenwald
849f5dde9d Move the Preferences initialization/fetching code to the top of PDFViewerApplication.initialize, to enable using them when initializing e.g. the viewer components
Note that in quick testing using `console.time/timeEnd`, both locally and with the Firefox addon, the total run time of the *entire* `PDFViewerApplication.initialize` function does not seem to change with this patch.
2016-12-14 16:15:53 +01:00
Jonas Jenwald
2c1436f6cb Refactor PDFViewerApplication.initialize into two methods, one that reads the Preferences and one that initializes the various viewer components 2016-12-14 16:13:20 +01:00
Tim van der Meij
7d8fa1385d Merge pull request #7890 from Snuffleupagus/pre-eslint-fixes
Fix a number of code style issues found by various ESLint rules, to make it easier to switch from JSHint to ESLint
2016-12-14 01:16:24 +01:00
Jonas Jenwald
28e50cfa21 Fix errors reported by the space-infix-ops ESLint rule
http://eslint.org/docs/rules/space-infix-ops
2016-12-12 20:36:00 +01:00
Jonas Jenwald
68bf47d55d Fix errors reported by the space-before-function-paren ESLint rule
http://eslint.org/docs/rules/space-before-function-paren
2016-12-12 20:35:59 +01:00
Jonas Jenwald
551eb263e3 Fix errors reported by the semi-spacing ESLint rule
http://eslint.org/docs/rules/semi-spacing
2016-12-12 20:35:58 +01:00
Jonas Jenwald
aae27e76bb Fix errors reported by the no-multiple-empty-lines ESLint rule
http://eslint.org/docs/rules/no-multiple-empty-lines
2016-12-12 20:35:58 +01:00
Jonas Jenwald
efbb1e9b1c Fix errors reported by the new-cap ESLint rule
http://eslint.org/docs/rules/new-cap
2016-12-12 20:35:57 +01:00
Jonas Jenwald
c36468cbce Fix errors reported by the keyword-spacing ESLint rule
http://eslint.org/docs/rules/keyword-spacing
2016-12-12 20:35:56 +01:00
Jonas Jenwald
86ba634c97 Fix errors reported by the key-spacing ESLint rule
http://eslint.org/docs/rules/key-spacing
2016-12-12 20:35:55 +01:00
Jonas Jenwald
6606540fe4 Fix errors reported by the func-call-spacing ESLint rule
http://eslint.org/docs/rules/func-call-spacing
2016-12-12 20:35:54 +01:00
Jonas Jenwald
ad915f8af1 Fix errors reported by the comma-spacing ESLint rule
http://eslint.org/docs/rules/comma-spacing
2016-12-12 20:35:53 +01:00
Jonas Jenwald
66d2637b3f Fix errors reported by the yoda ESLint rule
http://eslint.org/docs/rules/yoda
2016-12-12 20:35:52 +01:00
Jonas Jenwald
e53ab844cc Fix errors reported by the no-useless-concat ESLint rule
http://eslint.org/docs/rules/no-useless-concat
2016-12-12 20:35:51 +01:00
Jonas Jenwald
3820946301 Fix (most) errors reported by the no-multi-spaces ESLint rule
http://eslint.org/docs/rules/no-multi-spaces
2016-12-12 20:35:51 +01:00
Jonas Jenwald
328e7397ea Fix errors reported by the no-extra-bind ESLint rule
http://eslint.org/docs/rules/no-extra-bind
2016-12-12 20:35:50 +01:00
Jonas Jenwald
25bf5db47e Fix errors reported by the no-extra-boolean-cast ESLint rule
http://eslint.org/docs/rules/no-extra-boolean-cast
2016-12-12 20:26:18 +01:00
Jonas Jenwald
fb5e756683 Fix errors reported by the no-cond-assign ESLint rule
http://eslint.org/docs/rules/no-cond-assign
2016-12-12 20:26:06 +01:00
Tim van der Meij
00a006e466 Merge pull request #7705 from Snuffleupagus/issue-2594
Move symbolic font glyphs to private use area if they don't have unicode mappings (issue 2594, bug 789074, bug 865644)
2016-12-10 21:30:28 +01:00
Tim van der Meij
47f03b619f Merge pull request #7873 from timvandermeij/mediabox-cropbox-indirect
Document: handle indirect objects in `MediaBox` and `CropBox` entries
2016-12-08 23:59:45 +01:00
Tim van der Meij
3800b5e463 Document: extract CropBox fetching and validation into a getter
This patch refactors the `CropBox` code to combine fetching and
validation code in a getter, like we already did for the `MediaBox`
property. Combined with variable name changes, this improves readability
of the code and makes the `view` getter simpler as well.
2016-12-08 22:44:53 +01:00
Jonas Jenwald
9be3aee9c9 Add a parameter to Page_getInheritedPageProp to make it possible to fetch (and dereference) Arrays, and use that for the MediaBox/CropBox getters (issue 7872) 2016-12-08 22:03:42 +01:00
Tim van der Meij
407dee390a Merge pull request #7884 from Snuffleupagus/Parser-fetch-indirect-objects-in-filter-arrays
Ensure that we resolve indirect objects in `Filter` and `DecodeParms` arrays in `parser.js`
2016-12-08 21:59:34 +01:00
Jonas Jenwald
b4ac6bd2f6 Ensure that we resolve indirect objects in Filter and DecodeParms arrays in parser.js
I've not actually, thus far, come across a PDF file that this patch fixes. However, given the string of recent patches that has fixed issues with indirect objects in arrays, I think that it makes sense to proactively avoid any issues in this code.
2016-12-08 11:55:08 +01:00
Tim van der Meij
aaec490847 Merge pull request #7881 from Snuffleupagus/fixMetadata-constant-condition
Remove a misplaced `false` from a condition in `fixMetadata`, in `metadata.js`, since it currently short circuits the entire condition
2016-12-08 00:29:42 +01:00
Jonas Jenwald
77bcc9232e Remove a misplaced false from a condition in fixMetadata, in metadata.js, since it currently short circuits the entire condition
This looks to me like a simple oversight, which has existed ever since PR 1598 all the way back in 2012.
2016-12-07 22:51:46 +01:00
Jonas Jenwald
94ddd8f61d Merge pull request #7863 from timvandermeij/colorspace
Colorspace: refactoring to prevent unnecessary creation of intermediate arrays
2016-12-06 11:18:53 +01:00
Jonas Jenwald
caf81685cb Update l10n files 2016-12-05 10:10:17 +01:00
Tim van der Meij
fa6b9b7552 Merge pull request #7868 from Snuffleupagus/pageLabels-St-unit-test
Adjust one of the Page Label unit-tests to use a PDF file where the "St" entry is both present and non-default (i.e. greater than one)
2016-12-04 20:45:52 +01:00
Jonas Jenwald
e386af7b22 Adjust one of the Page Label unit-tests to use a PDF file where the "St" entry is both present and non-default (i.e. greater than one)
I just realized that none of our current unit-tests cover this particular part of the Page Label parsing code, hence this patch adjusts an existing test PDF to include a "St" entry in the Page Label dictionary.
2016-12-04 13:03:22 +01:00
Tim van der Meij
90d94815ad Colorspace: miscellaneous improvements
- Remove an unnecessary check and assignment.
- Clean up code regarding mode setting (no need for a member variable).
- Indent two methods correctly.
2016-12-02 16:47:39 +01:00
Tim van der Meij
c5c0a00dca Colorspace: reduce duplication in AlternateCS.getRgbBuffer 2016-12-02 16:42:22 +01:00
Tim van der Meij
ef653d952b Colorspace: optimize default color initialization
This patch avoids the creation of extra arrays when initializing an
array with default (zero) values. Doing this additionally makes the code
more readable by allocating enough space for the number of color
components.
2016-12-02 16:42:22 +01:00