Commit Graph

42 Commits

Author SHA1 Message Date
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
e95c11a7f0 Remove the undocumented PDFJS.enableStats option
In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now instead used to enabled general debugging *and* page request/rendering stats.
Considering that in the default viewer the `stats` was only used when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
2018-02-13 16:56:57 +01:00
Jonas Jenwald
1cf116ab88 Enable the mozilla/use-includes-instead-of-indexOf ESLint rule globally
This rule is available from https://www.npmjs.com/package/eslint-plugin-mozilla, and is enforced in mozilla-central. Note that we have the necessary `Array`/`String` polyfills and that most cases have already been fixed, see PRs 9032 and 9434.
2018-02-10 23:24:50 +01:00
Jonas Jenwald
d70263ced8 Enable the no-var ESLint rule in the /web folder
https://eslint.org/docs/rules/no-var

Please note that two files were excluded:
 1. `web/debugger.js`, since there's code in other files that currently depend on the global availability of code in `web/debugger.js`. Furthermore, since that file isn't used in production, doing a ES6 conversion probably isn't a priority.

 2. `web/grab_to_pan.js`, since that file could be considered to be "external" code. We have made smaller changes to that file over the years, however doing a full ES6 `class` conversion might be a step too far!?
2017-11-05 16:53:47 +01:00
Jonas Jenwald
223c429357 Fix inconsistent spacing and trailing commas in objects in web/ files, so we can enable the comma-dangle and object-curly-spacing ESLint rules later on
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing

Given that we currently have quite inconsistent object formatting, fixing this in in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.

*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.

```diff
diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js
index 002dbf29..1de4e530 100644
--- a/web/pdf_thumbnail_view.js
+++ b/web/pdf_thumbnail_view.js
@@ -420,8 +420,8 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
     setPageLabel: function PDFThumbnailView_setPageLabel(label) {
       this.pageLabel = (typeof label === 'string' ? label : null);

-      this.l10n.get('thumb_page_title', { page: this.pageId, }, 'Page {{page}}').
-          then((msg) => {
+      this.l10n.get('thumb_page_title', { page: this.pageId, },
+                    'Page {{page}}').then((msg) => {
         this.anchor.title = msg;
       });

diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js
index 160e0410..6495fc5e 100644
--- a/web/secondary_toolbar.js
+++ b/web/secondary_toolbar.js
@@ -65,7 +65,8 @@ class SecondaryToolbar {
       { element: options.printButton, eventName: 'print', close: true, },
       { element: options.downloadButton, eventName: 'download', close: true, },
       { element: options.viewBookmarkButton, eventName: null, close: true, },
-      { element: options.firstPageButton, eventName: 'firstpage', close: true, },
+      { element: options.firstPageButton, eventName: 'firstpage',
+        close: true, },
       { element: options.lastPageButton, eventName: 'lastpage', close: true, },
       { element: options.pageRotateCwButton, eventName: 'rotatecw',
         close: false, },
@@ -76,7 +77,7 @@ class SecondaryToolbar {
       { element: options.cursorHandToolButton, eventName: 'switchcursortool',
         eventDetails: { tool: CursorTool.HAND, }, close: true, },
       { element: options.documentPropertiesButton,
-        eventName: 'documentproperties', close: true, }
+        eventName: 'documentproperties', close: true, },
     ];
     this.items = {
       firstPage: options.firstPageButton,
```
2017-06-01 12:47:47 +02: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
Jonas Jenwald
2a0207ccaf Enable the object-shorthand ESLint rule in web
Please see http://eslint.org/docs/rules/object-shorthand.

For the most part, these changes are of the search-and-replace kind, and the previously enabled `no-undef` rule should complement the tests in helping ensure that no stupid errors crept into to the patch.
2017-04-29 20:29:04 +02:00
Yury Delendik
25873e92f0 Enable babel translation to enable ES module support. 2017-03-27 07:25:09 -05:00
Jonas Jenwald
bc736fdc7d Adjust the brace-style ESLint rule to disallow single lines (and also enable no-iterator)
See http://eslint.org/docs/rules/brace-style.
Having the opening/closing braces on the same line can often make the code slightly more difficult to read, in particular for `if`/`else if` statements, compared to using new lines.

This patch also, for consistency with `mozilla-central`, enables the [`no-iterator`](http://eslint.org/docs/rules/no-iterator) rule. Note that this rule didn't require a single code change.
2017-02-04 15:53:08 +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
klemens
6f03f62327 trivial spelling fixes 2016-07-17 14:33:41 +02:00
Yury Delendik
a4c81c203b Enables debugger only when needed. 2016-05-09 18:18:43 -05:00
Yury Delendik
b6c74f2056 Moves all document.getElementById lookups into viewer.js 2016-04-21 11:39:11 -05:00
Yury Delendik
4165cedc9f Replace pdfjsLib with module that represents pdf.js. 2016-04-13 10:11:34 -05:00
Yury Delendik
1e3e14e6b2 Exposes all functional members via lib exports and use them in viewer. 2016-04-07 13:46:07 -05:00
Yury Delendik
2edf2792dc Replaces literal {} created lookup tables with Object.create 2016-01-28 12:18:38 -06:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Jonas Jenwald
4ed3074011 Fix regression that prevents downloading of font files in the debugger
This is a regression from PR 5366.
2014-10-28 19:56:55 +01:00
Rob Wu
d0845df971 Use Font Loading API if available
http://dev.w3.org/csswg/css-font-loading/
2014-09-30 22:18:53 +02:00
Jonas Jenwald
7af46b433d Fix a regression preventing page change in the Stepper in the debugger
This is a regression from ddd3c8fc2f, which prevents changing pages in the Stepper.

(Apart from fixing the bug, for the sake of consistency, I also removed one instance of `parseInt`.)
2014-09-24 10:38:27 +02:00
Tim van der Meij
ddd3c8fc2f Use strict equalities in web/debugger.js 2014-08-01 19:21:32 +02:00
Yury Delendik
d53dc2e7d6 Refactors showText: split type3, remove showSpacedText 2014-05-23 13:36:54 -05:00
Jonas Jenwald
8edb5cc804 Fix regression preventing the setting of breakpoints in the Stepper (PDFBug) 2014-04-20 01:05:38 +02:00
Rob Wu
d7dfa447cd Remove unused (local) variables in web/ 2014-04-15 17:10:23 +02:00
Tim van der Meij
b348243866 Fixes lint warning W004 in /web 2014-04-11 00:02:33 +02:00
Yury Delendik
ed8ecfd00a Cleaning up the viewer and pdfbug; fixes repeats in Stepper 2014-03-26 15:18:53 -05:00
Jonas Jenwald
e9cfae84a0 Fix coding style in web/debugger.js 2014-03-09 11:51:15 +01:00
Brendan Dahl
f4942b11f8 Reduce the memory usage of the operator list. 2013-11-13 11:43:38 -08:00
Brendan Dahl
2bd9901d62 Show sensible output for showText commands in the stepper. 2013-08-14 15:34:55 -07:00
Brendan Dahl
bf72bc94e2 Incrementally render by sending the operator list by chunks as they're ready. 2013-07-31 11:17:36 -07:00
Rob Wu
b46c375126 Compatibility with XHTML documents
Previously, when the XHTML doctype + header is active, checks
would fail because a <div>'s tag name is "div" instead of "DIV".

document.activeElement does not exist in Chrome for XHTML documents

== -> ===
2013-04-04 12:35:50 +02:00
Yury Delendik
81f8f92696 Adds web/* and test/* for jshint target 2013-02-04 12:01:19 -06:00
Brendan Dahl
332ae4ce41 Change to the Apache v2 license. 2012-08-31 15:48:21 -07:00
gigaherz
eaffcfa920 Fix some typos in comments and variable names.
Fix some nits in debugger.js.
2012-08-08 20:26:24 +02:00
Brendan Dahl
fe0d7d24bc Update pdfbug style. 2012-04-26 12:35:52 -07:00
Yury Delendik
494fd1ccf9 Fixes make files, removes stats from backend, stepper 2012-04-12 14:02:47 -07:00
Brendan Dahl
41557d62c0 Merge branch 'master' of https://github.com/mozilla/pdf.js into stats 2012-03-12 13:23:33 -07:00
Brendan Dahl
4b887fe1c2 Remove unused variable. 2012-02-21 13:39:04 -08:00
Brendan Dahl
3a824f69d4 Fix the stepper beyond page 1. 2012-02-21 13:37:22 -08:00
Brendan Dahl
e07505ff8d Update stats to use the new pdfBug panel. 2012-02-21 09:52:09 -08:00
Brendan Dahl
0f4730c825 Address review comments. 2012-02-16 09:55:09 -08:00
Brendan Dahl
f17a1679eb Move debugger to the web folder. 2012-02-15 14:55:16 -08:00