Commit Graph

10919 Commits

Author SHA1 Message Date
Jonas Jenwald
36b683ca55 Provide custom messages for the no-restricted-globals ESLint rule, and refactor the .eslintrc files (PR 9868 follow-up)
Without providing useful (custom) error messages for the `no-restricted-globals` rule, see https://eslint.org/docs/rules/no-restricted-globals, it's quite likely that the rule will be incorrectly disabled rather than the required globals being imported as intended.

To reduced duplication of the `no-restricted-globals` rule in multiple `.eslintrc` files, it's instead moved to the top-level `.eslintrc` file and disabled as needed on a folder/file basis outside of `/src` and `/web`.
2018-07-23 14:10:13 +02:00
Tim van der Meij
1aaeaf3338
Merge pull request #9904 from RonLek/master
Modified Examples to work without systemjs
2018-07-22 14:55:35 +02:00
Tim van der Meij
2ce489c16f
Merge pull request #9900 from Snuffleupagus/issue-8884
Prevent Metadata/XML parsing from breaking `PDFDocumentProxy.getMetadata` when no XML root document is found (issue 8884)
2018-07-22 14:42:30 +02:00
RonLek
8afc4ce258 Modified Examples to work without systemjs 2018-07-21 16:56:06 +05:30
Jonas Jenwald
8ec99b200c Prevent Metadata/XML parsing from breaking PDFDocumentProxy.getMetadata when no XML root document is found (issue 8884)
With the new XML parser, see PR 9573, the referenced PDF file now causes `getMetadata` to fail when incomplete XML tags are encountered. This provides a simple, and hopefully generally useful, work-around that may also help prevent future bugs.

(Without being able to reproduce nor even understand the other (non XML) errors mentioned in issue 8884, I'd say that this patch is enough to close that one as fixed.)
2018-07-18 11:37:40 +02:00
Tim van der Meij
7e13977669
Merge pull request #9898 from Snuffleupagus/rm-createPromiseCapability-waitOnEventOrTimeout
Change `waitOnEventOrTimeout`, in web/ui_utils.js, to return a regular `Promise` and remove the `createPromiseCapability` import
2018-07-16 22:55:53 +02:00
Jonas Jenwald
647fa74793 Change waitOnEventOrTimeout, in web/ui_utils.js, to return a regular Promise and remove the createPromiseCapability import
*Another small piece of clean-up of code I've previously written; follow-up to PR 8775.*

Importing `createPromiseCapability`, and then using it in just *one* spot, seems unnecessary since the `waitOnEventOrTimeout` function may just as well return a regular `Promise` directly.
2018-07-16 13:48:33 +02:00
Tim van der Meij
61db85ab64
Merge pull request #9886 from Snuffleupagus/bug-1473809
Prevent errors in `sanitizeTTProgram`, during parsing of CALL functions, when encountering invalid functions stack deltas (bug 1473809)
2018-07-15 17:23:52 +02:00
Tim van der Meij
b56081c5f8
Merge pull request #9887 from Snuffleupagus/rm-Util-inherit
Convert more code in the `/src` folder to use ES6 classes, such that `Util.inherit` can be removed
2018-07-14 23:58:38 +02:00
Tim van der Meij
1f245c247f
Merge pull request #9881 from Snuffleupagus/rm-instanceof-Array
Replace the remaining occurences of `instanceof Array` with `Array.isArray()`
2018-07-14 23:47:12 +02:00
Jonas Jenwald
8e76d26e5b Move the toRoman helper function out of the Util scope
Compared to all the other (static) methods in `Util`, the `toRoman` one looks slightly out of place. Even more so considering that `Util` is being exposed through `pdfjsLib`, where access to a Roman numerals conversion method doesn't make much sense.
2018-07-10 10:45:25 +02:00
Jonas Jenwald
c1c49badff Remove the, now unused, Util.inherit helper function 2018-07-10 10:29:47 +02:00
Jonas Jenwald
2b25deb84c Prevent errors in sanitizeTTProgram, during parsing of CALL functions, when encountering invalid functions stack deltas (bug 1473809)
*I was feeling bored; so this is a very quick, and somewhat naive, attempt at fixing the bug.*

The breaking error, i.e. `Error during font loading: invalid array length`, was thrown when attempting to re-size the `stack` to a *negative* length when parsing the CALL functions.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1473809.
2018-07-10 09:45:55 +02:00
Jonas Jenwald
bf6d45f85a Convert CMap and IdentityCMap to ES6 classes
Also changes `var` to `let`/`const` in code already touched in the patch.
2018-07-09 21:12:01 +02:00
Jonas Jenwald
b773b356af Convert NameOrNumberTree, NameTree, and NumberTree to ES6 classes
Also changes `var` to `let`/`const` in code already touched in the patch.
2018-07-09 21:12:01 +02:00
Jonas Jenwald
ba1af46709 Convert CompiledFont, TrueTypeCompiled, and Type2Compiled to ES6 classes
Also changes `var` to `let`/`const` in code already touched in the patch.
2018-07-09 21:12:01 +02:00
Jonas Jenwald
775763a091 Ensure that CompiledFont.compileGlyph always returns an Array (PR 6141 follow-up)
PR 6141 changed `CompiledFont.compileGlyph` to, in the general case, return an Array. However, that PR apparenly forgot to update the no-glyph, empty-glyph, and endchar-glyph code-path and a String was still being (incorrectly) returned.

Given the way that `FontFaceObject.getPathGenerator` (on the API side) is implemented, this shouldn't have caused any bugs despite the Worker possible returning unexpected data.
2018-07-09 21:12:01 +02:00
Tim van der Meij
646d81cd09
Merge pull request #9837 from timvandermeij/unreachable
Replace `NotImplementedException` with `unreachable`
2018-07-09 21:10:36 +02:00
Jonas Jenwald
61186698c3 Replace the remaining occurences of instanceof Array with Array.isArray()
*Follow-up to PRs 8864 and 8813.*

As explained in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray, `instanceof Array` can have inconsistent behavior. To ensure that only `Array.isArray` is used, an ESLint plugin/rule is added to enforce this.
2018-07-09 13:17:41 +02:00
Jonas Jenwald
200e3d6bd8 Update the various ESLint packages to their latest versions 2018-07-09 12:52:55 +02:00
Tim van der Meij
907c7f190b
Convert src/code/pdf_manager.js to ES6 classes/syntax 2018-07-08 16:43:46 +02:00
Tim van der Meij
31012570ea
Merge pull request #9868 from Snuffleupagus/url-polyfill
Stop exposing the `URL` polyfill in the global scope
2018-07-08 16:29:53 +02:00
Tim van der Meij
7e1f727685
Merge pull request #9877 from Snuffleupagus/scroll-spread-hide
Hide the Scroll/Spread mode buttons if the viewer is a `PDFSinglePageViewer` instance (PR 9858 follow-up)
2018-07-08 15:59:02 +02:00
Tim van der Meij
9c06338258
Merge pull request #9880 from timvandermeij/jp-JP-mac
Remove the `jp-JP-mac` locale
2018-07-08 15:47:23 +02:00
Tim van der Meij
8a6b7373a0
Remove the jp-JP-mac locale
It gives warnings when running `gulp locale`, in a previous patch it was
explicitly asked to remove it and there is quite a bit of discussion
about the validity of the locale at
https://bugzilla.mozilla.org/show_bug.cgi?id=418485. In short, let's
remove it to prevent these issues.
2018-07-08 15:40:38 +02:00
Tim van der Meij
9c613a3563
Merge pull request #9879 from timvandermeij/readme
Correct the instructions in the README file for `examples/mobile-viewer`
2018-07-08 15:37:32 +02:00
Tim van der Meij
1024615ecb
Correct the instructions in the README file for examples/mobile-viewer 2018-07-08 15:32:06 +02:00
Jonas Jenwald
d8c2bcc93a Temporarily disable the Spread mode buttons when horizontal scrolling is enabled
Given that the non-default Spread modes (currently) doesn't affect the page layout when horizontal scrolling is enabled, having the Spread buttons appear active when clicking them appears to do *nothing* is probably confusing rather than helpful to users.
2018-07-08 12:11:03 +02:00
Jonas Jenwald
36d6255866 Hide the Scroll/Spread mode buttons when the viewer is a PDFSinglePageViewer instance
If the current viewer is a `PDFSinglePageViewer` instance the Scroll/Spread modes are no-ops, hence displaying buttons that do *nothing* when clicked will probably do very little besides confuse users.
2018-07-08 12:08:48 +02:00
Jonas Jenwald
46e1d5daa4 Simplify resetting of the SecondaryToolbar Scroll/Spread mode buttons, and add a missing comment in PDFCursorTools
The names 'resetscrollmode'/'resetspreadmode' were probably *not* great choices, given that the only thing being reset are toolbar buttons and not the actual Scroll/Spread modes. Furthermore, there's really no need for two separate events here.

The patch also adds a comment that ought to have been included in PR 9040, to prevent future refactoring/removing of what may appear to be an unnecessary `Promise.resolve` call.
2018-07-08 10:55:56 +02:00
Tim van der Meij
b39a2ba57a
Merge pull request #9866 from Snuffleupagus/gulp-server-private-browsing
Prevent the development viewer, started with `gulp server`, from breaking completely in Private Browsing mode
2018-07-04 22:32:12 +02:00
Jonas Jenwald
a9ce4e8417 Stop exposing the URL polyfill in the global scope
This moves/exposes the `URL` polyfill similarily to the existing `ReadableStream` polyfill, rather than exposing it globally, to avoid interfering with any "outside" code.
Both the `URL` and `ReadableStream` polyfills are now exposed on the `pdfjsLib` object, such that they are accessible to the viewer components.
Furthermore, the `no-restricted-globals` ESLint rule is also enabled to prevent accidental usage of the native `URL`/`ReadableStream` implementations directly in the `src/` and `web/` folders; see also https://eslint.org/docs/rules/no-restricted-globals

Addresses the remaining TODO in https://github.com/mozilla/pdf.js/projects/6
2018-07-04 09:16:28 +02:00
Jonas Jenwald
8f0cc07116 Prevent the development viewer, started with gulp server, from breaking completely in Private Browsing mode
Since attempting to access `IndexedDB` in Private Browsing mode in Firefox will throw an error, see https://bugzilla.mozilla.org/show_bug.cgi?id=781982, the development viewer fails to load.
2018-07-03 13:26:01 +02:00
Tim van der Meij
42922c9ae5
Merge pull request #9861 from Snuffleupagus/PDFFindController-firstPagePromise
Refactor `PDFFindController` to use the 'pagesinit' event, dispatched on the `eventBus`, to resolve the `_firstPagePromise`
2018-07-02 23:30:37 +02:00
Jonas Jenwald
39a1fce59b Refactor PDFFindController to use the 'pagesinit' event, dispatched on the eventBus, to resolve the _firstPagePromise
Rather than having to manually call a method on `PDFFindController` instances from `BaseViewer.setDocument`, thus essentially having to resolve the private `_firstPagePromise` from the "outside", this can be done easily with the 'pagesinit' event dispatched on the `eventBus` instead.
Please note this particular `PDFFindController` code pre-dates the `eventBus` by almost three years, which should explain why the code looks the way it does.
2018-07-01 16:25:51 +02:00
Tim van der Meij
872c6e4af0
Merge pull request #9858 from Snuffleupagus/scrollMode-refactor
Additional Scroll/Spread mode clean-up (PR 9832 follow-up)
2018-06-30 22:13:42 +02:00
Tim van der Meij
4fbad9ab68
Merge pull request #9860 from timvandermeij/readme
Update the localization README to indicate that the translations are imported from the Nightly channel
2018-06-30 21:54:19 +02:00
Tim van der Meij
fa7eb95eed
Update the localization README to indicate that the translations are imported from the Nightly channel 2018-06-30 21:47:44 +02:00
Tim van der Meij
ce430bdfb5
Merge pull request #9859 from timvandermeij/updates
Update translations and packages
2018-06-30 21:38:57 +02:00
Tim van der Meij
ac401c65a0
Update packages 2018-06-30 20:41:17 +02:00
Tim van der Meij
5baec1eeb4
Update translations 2018-06-30 20:36:17 +02:00
Jonas Jenwald
ff26d419dd Ensure that Scroll/Spread mode buttons are correctly reset, when the document is closed
Since the Scroll/Spread modes are now document specific, as all other properties such as page/scale/rotation, ensure that the toolbar is always correctly reset.
2018-06-30 14:54:33 +02:00
Jonas Jenwald
bb193dc501 For consistency with other viewer state, remove and deprecate setting Scroll/Spread modes in the BaseViewer constructor
Since other viewer state, such as the current page/scale/rotation[1], are not available as `BaseViewer` constructor options, this makes the Scroll/Spread modes stand out quite a bit. Hence it probably makes sense to remove/deprecate this, to avoid inconsistent and possibly confusing state in this code.

---

[1] These properties are *purposely* not available in the constructor, since attempting to set them before a document is loaded has number of issues; please refer to https://github.com/mozilla/pdf.js/pull/8539#issuecomment-309706629 for additional details.
2018-06-30 12:36:57 +02:00
Jonas Jenwald
8b85ae4181 Re-factor updating of Scroll/Spread modes, and place all the code in BaseViewer with overrides (as necessary) in the extending classes
This structure probably makes somewhat more sense, given that `PDFSinglePageViewer` is somewhat of a special case.
2018-06-30 12:36:56 +02:00
Jonas Jenwald
a7ac27e385 Replace setScrollMode/setSpreadMode methods with getters/setters
Since all the other viewer methods use the getter/setter pattern, e.g. for setting page/scale/rotation, the way that the Scroll/Spread modes are set thus stands out. For consistency, this really ought to use the same pattern as the rest of the `BaseViewer`. (To avoid breaking third-party implementations, the old methods are kept around as aliases.)
2018-06-30 12:36:54 +02:00
Jonas Jenwald
9515f579c6 Change the scrollMode/spreadMode to "private" properties on BaseViewer instances 2018-06-30 12:19:02 +02:00
Jonas Jenwald
a9a93bd923 Allow the scrollModeOnLoad/spreadModeOnLoad Preferences to override ViewHistory settings
Note how the other "...OnLoad" preferences will allow a *non-default* value to always override a history entry. To improve overall consistency for the viewer options, and to reduce possibly confusing behaviour, this patch changes the `scrollModeOnLoad`/`spreadModeOnLoad` preferences to behave as all the other ones.
2018-06-30 12:19:02 +02:00
Jonas Jenwald
baf9c98bc7 Add scrollModeOnLoad/spreadModeOnLoad default values to AppOptions
For some reason, these weren't added to `AppOptions` despite actually being set and read from `web/app.js`. Not adding them creates inconsistencies, since all other options *are* present in `web/app_options.js`.
2018-06-30 12:19:02 +02:00
Jonas Jenwald
e522b2d87e Remove the unused PDFViewerApplication.documentFingerprint property
This property isn't accessed anywhere in the `web/app.js` file, and is also not being reset in `PDFViewerApplication.close`. Hence it seems that it can simply be removed, especially since the fingerprint is already synchronously available through `PDFViewerApplication.pdfDocument.fingerprint` (provided that a document is loaded).
2018-06-30 12:19:02 +02:00
Tim van der Meij
99f8f2c275
Merge pull request #9853 from Snuffleupagus/re-render-after-cancel
Fix re-rendering, using the same canvas, when rendering was previously cancelled (PR 8519 follow-up)
2018-06-29 23:25:43 +02:00