Commit Graph

13692 Commits

Author SHA1 Message Date
Tim van der Meij
92d3a93897
Merge pull request #13116 from Snuffleupagus/enableScripting-true
Enable scripting by default in the viewer (PR 13053 follow-up)
2021-03-19 22:48:57 +01:00
Tim van der Meij
8a820ac151
Merge pull request #13120 from Snuffleupagus/enablePrintAutoRotate-true
Rotate landscape pages, during printing, by default in the viewer (`enablePrintAutoRotate = true`)
2021-03-19 22:45:56 +01:00
Jonas Jenwald
30c06849d8 Rotate landscape pages, during printing, by default in the viewer (enablePrintAutoRotate = true)
While this will perhaps not be perfect for *every* PDF document with mixed page orientation, based on the large number of bugs/issues seen over the years I'm however pretty convinced that it'll be an overall improvement in a majority of cases.

In order to improve things further, we'd probably need Firefox to support e.g. `@page` such that the viewer can provide better information to the print engine.
2021-03-19 12:39:37 +01:00
Jonas Jenwald
1de466896d Remove one loop from BaseViewer.getPagesOverview
Currently, with `enablePrintAutoRotate = true` set, we're forced to loop through all the pages *twice* when checking for any landscape pages.
This seems completely unnecessary now, and using only *one* loop should be marginally more efficient in general.
2021-03-19 12:38:46 +01:00
Jonas Jenwald
3ce94a9f6d Change how landscape pages are rotated, for printing, with enablePrintAutoRotate = true set
Currently landscape pages are rotated *clockwise*, which for most documents feel wrong since holding the printed pages at their *left* edge causes the landscape pages to be viewed "upside down".
In general, since most documents are LTR ones, it feels more appropriate to instead rotate landscape pages *counterclockwise* for printing.
2021-03-19 12:37:57 +01:00
Jonas Jenwald
57e7557235
Actually reset the PDFPageProxy._xfaPromise property as intended (PR 13069 follow-up) (#13119)
Similar to the existing `annotationsPromise` and `_jsActionsPromise` properties, the new `_xfaPromise` should obviously also be reset, since otherwise you might end up holding onto a lot of data for pages that are no longer active.

(That caching wasn't present in the original version of PR 13069, which is why I didn't spot it until now.)
2021-03-19 11:31:54 +01:00
calixteman
24e598a895
XFA - Add a layer to display XFA forms (#13069)
- add an option to enable XFA rendering if any;
  - for now, let the canvas layer: it could be useful to implement XFAF forms (embedded pdf in xml stream for the background and xfa form for the foreground);
  - ui elements in template DOM are pretty close to their html counterpart so we generate a fake html DOM from template one:
    - it makes easier to translate template properties to html ones;
    - it makes faster the creation of the html element in the main thread.
2021-03-19 10:11:40 +01:00
Jonas Jenwald
2d727e6e68 Enable scripting by default in the viewer (PR 13053 follow-up)
Given that https://bugzilla.mozilla.org/show_bug.cgi?id=1699219 has enabled scripting for all Firefox-channels, it seems reasonable to simply set `enableScripting = true` unconditionally in the viewer preferences/options.

For now, this patch leaves the standalone viewer-components alone (such as e.g. `BaseViewer`), and if those are used scripting will thus have to be manually enabled (see e.g. the "simpleviewer"/"singlepageviewer" examples).
2021-03-17 21:14:08 +01:00
Tim van der Meij
a164941351
Merge pull request #13106 from Snuffleupagus/LineAnnotation-empty-Rect
Support `LineAnnotation`s with empty /Rect-entries (issue 6564)
2021-03-16 19:47:21 +01:00
Jonas Jenwald
d92b77e87f
Ensure that printing, triggered from scripting, won't accidentally throw in PDFScriptingManager._updateFromSandbox (#13104)
The issue that this patch fixes is extremely unlikely, but still theoretically possible, and I really should've caught this earlier.
Note how `BaseViewer.pagesPromise` will only be defined when a document is active, see below, and that if a printing event (triggered from scripting) arrives while the document is been closed there's a small chance that the promise isn't defined.

eb92ed12f2/web/base_viewer.js (L426-L428)
2021-03-16 14:22:39 +01:00
Brendan Dahl
dd3797a325
Merge pull request #13102 from emilio/print-small-page
print: RFC: Center when printing a PDF with smaller size than the output page.
2021-03-15 18:51:42 -07:00
Jonas Jenwald
5099f1977f Support LineAnnotations with empty /Rect-entries (issue 6564)
This extends PR 13033 slightly, with a heuristic to support corrupt PDF documents where the `LineAnnotation`s have an empty /Rect-entry. Please note that while I have no idea if this is "correct", this patch at least makes us output the same /BBox as re-saving in Adobe Reader does.
2021-03-15 16:33:43 +01:00
Emilio Cobos Álvarez
1d70bfe6e6 print: RFC: Center when printing a PDF with smaller size than the output page.
This builds on top of #13100, but this changes printing behavior intentionally
so I thought it was worth discussing separately, to improve the rendering on
test-cases like the one in https://bugzil.la/1697778.

This matches what e.g.  Evince does when you print the PDF in there on an A4
printer.

We use margins to center horizontally, and flex to center vertically. The
reasoning for this is that it should have better browser support (though maybe
pdf.js no longer supports browsers without flex support?) and it's just as
simple.
2021-03-15 09:51:53 +01:00
Tim van der Meij
eb92ed12f2
Merge pull request #13100 from emilio/container-overflow
print: Ensure print containers have the right size and don't create overflow.
2021-03-14 15:53:50 +01:00
Tim van der Meij
93c062669c
Merge pull request #13101 from emilio/print-bogus-supports
print: Remove invalid @supports condition.
2021-03-14 15:29:40 +01:00
Emilio Cobos Álvarez
b932eaf6a7 print: Remove invalid @supports condition.
@supports() is not supposed to report support for page descriptors, this is
depending on a Chromium bug, which doesn't treat as invalid:

```
<div style="size: 1pt 1pt">
```

Even though it should. That is
https://bugs.chromium.org/p/chromium/issues/detail?id=1079214

There's no need to use @supports for this. If the descriptor is not accepted it
will just be ignored.

That way, when Firefox implements @page { size }, which is in progress, it will
get the right behavior.
2021-03-14 15:15:04 +01:00
Emilio Cobos Álvarez
baed09f1ff
print: Ensure print containers have the right size and don't create overflow.
First, there's just no need to do something like this, this is simpler and
closer to what the screen renderer does.

Second, this causes overflow, which Firefox tries to compensate for when
fitting to page width, and fails at it. That is tracked in:

https://bugzilla.mozilla.org/show_bug.cgi?id=1698136

But this bug works around it by not causing overflow.

For modern browsers, we could avoid the duplication setting the style attribute
by using something like width: min/max-content, but this is not a big deal I
think, let me know if you'd prefer that.

Also I had to add a max-height for Chromium not to create extra pages. This
is harmless in Firefox and workarounds the Chromium bug, so so be it.
2021-03-14 14:49:46 +01:00
Tim van der Meij
7fef896a9f
Merge pull request #13094 from timvandermeij/no-var-src
Enable the `no-var` linting rule for `src/core/{operator_list, pattern}.js`
2021-03-14 11:59:09 +01:00
Tim van der Meij
6df8f301cd
Merge pull request #13098 from Snuffleupagus/eslint-no-var-external
Enable the ESLint `no-var` rule in the `external/` folder
2021-03-14 11:53:52 +01:00
Tim van der Meij
a2f0573a64
Enable the no-var linting rule for src/core/operator_list.js
This is mostly done using `gulp lint --fix` with a few manual changes in
the following diff:

```diff
diff --git a/src/core/operator_list.js b/src/core/operator_list.js
index 66c26fe05..cbcd12d97 100644
--- a/src/core/operator_list.js
+++ b/src/core/operator_list.js
@@ -40,7 +40,8 @@ const QueueOptimizer = (function QueueOptimizerClosure() {
     // 'count' groups of (save, transform, paintImageMaskXObject, restore)+
     // have been found at iFirstSave.
     const iFirstPIMXO = iFirstSave + 2;
-    for (var i = 0; i < count; i++) {
+    let i;
+    for (i = 0; i < count; i++) {
       const arg = argsArray[iFirstPIMXO + 4 * i];
       const imageMask = arg.length === 1 && arg[0];
       if (
@@ -106,8 +107,8 @@ const QueueOptimizer = (function QueueOptimizerClosure() {
       // assuming that heights of those image is too small (~1 pixel)
       // packing as much as possible by lines
       let maxX = 0;
-      let map = [],
-        maxLineHeight = 0;
+      const map = [];
+      let maxLineHeight = 0;
       let currentX = IMAGE_PADDING,
         currentY = IMAGE_PADDING;
       let q;
@@ -326,9 +327,9 @@ const QueueOptimizer = (function QueueOptimizerClosure() {
           if (fnArray[i] !== OPS.transform) {
             return false;
           }
-          var iFirstTransform = context.iCurr - 2;
-          var firstTransformArg0 = argsArray[iFirstTransform][0];
-          var firstTransformArg3 = argsArray[iFirstTransform][3];
+          const iFirstTransform = context.iCurr - 2;
+          const firstTransformArg0 = argsArray[iFirstTransform][0];
+          const firstTransformArg3 = argsArray[iFirstTransform][3];
           if (
             argsArray[i][0] !== firstTransformArg0 ||
             argsArray[i][1] !== 0 ||
@@ -342,8 +343,8 @@ const QueueOptimizer = (function QueueOptimizerClosure() {
           if (fnArray[i] !== OPS.paintImageXObject) {
             return false;
           }
-          var iFirstPIXO = context.iCurr - 1;
-          var firstPIXOArg0 = argsArray[iFirstPIXO][0];
+          const iFirstPIXO = context.iCurr - 1;
+          const firstPIXOArg0 = argsArray[iFirstPIXO][0];
           if (argsArray[i][0] !== firstPIXOArg0) {
             return false; // images don't match
           }
@@ -423,9 +424,9 @@ const QueueOptimizer = (function QueueOptimizerClosure() {
           if (fnArray[i] !== OPS.showText) {
             return false;
           }
-          var iFirstSetFont = context.iCurr - 3;
-          var firstSetFontArg0 = argsArray[iFirstSetFont][0];
-          var firstSetFontArg1 = argsArray[iFirstSetFont][1];
+          const iFirstSetFont = context.iCurr - 3;
+          const firstSetFontArg0 = argsArray[iFirstSetFont][0];
+          const firstSetFontArg1 = argsArray[iFirstSetFont][1];
           if (
             argsArray[i][0] !== firstSetFontArg0 ||
             argsArray[i][1] !== firstSetFontArg1
```
2021-03-14 11:49:31 +01:00
Jonas Jenwald
96d2a2f795 Enable the ESLint no-var rule in the external/ folder
These changes were done automatically, by using the `gulp lint --fix` command.
2021-03-14 11:43:25 +01:00
Tim van der Meij
24ff738e7b
Enable the no-var linting rule for src/core/pattern.js
This is mostly done using `gulp lint --fix` with a few manual changes in
the following diff:

```diff
diff --git a/src/core/pattern.js b/src/core/pattern.js
index 365491ed3..eedd8b686 100644
--- a/src/core/pattern.js
+++ b/src/core/pattern.js
@@ -105,7 +105,7 @@ const Pattern = (function PatternClosure() {
   return Pattern;
 })();

-var Shadings = {};
+const Shadings = {};

 // A small number to offset the first/last color stops so we can insert ones to
 // support extend. Number.MIN_VALUE is too small and breaks the extend.
@@ -597,16 +597,15 @@ Shadings.Mesh = (function MeshClosure() {
       if (!(0 <= f && f <= 3)) {
         throw new FormatError("Unknown type6 flag");
       }
-      var i, ii;
       const pi = coords.length;
-      for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
+      for (let i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
         coords.push(reader.readCoordinate());
       }
       const ci = colors.length;
-      for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
+      for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
         colors.push(reader.readComponents());
       }
-      var tmp1, tmp2, tmp3, tmp4;
+      let tmp1, tmp2, tmp3, tmp4;
       switch (f) {
         // prettier-ignore
         case 0:
@@ -729,16 +728,15 @@ Shadings.Mesh = (function MeshClosure() {
       if (!(0 <= f && f <= 3)) {
         throw new FormatError("Unknown type7 flag");
       }
-      var i, ii;
       const pi = coords.length;
-      for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
+      for (let i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
         coords.push(reader.readCoordinate());
       }
       const ci = colors.length;
-      for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
+      for (let i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
         colors.push(reader.readComponents());
       }
-      var tmp1, tmp2, tmp3, tmp4;
+      let tmp1, tmp2, tmp3, tmp4;
       switch (f) {
         // prettier-ignore
         case 0:
@@ -897,7 +895,7 @@ Shadings.Mesh = (function MeshClosure() {
         decodeType4Shading(this, reader);
         break;
       case ShadingType.LATTICE_FORM_MESH:
-        var verticesPerRow = dict.get("VerticesPerRow") | 0;
+        const verticesPerRow = dict.get("VerticesPerRow") | 0;
         if (verticesPerRow < 2) {
           throw new FormatError("Invalid VerticesPerRow");
         }
```
2021-03-14 11:43:05 +01:00
Tim van der Meij
67b866b9ed
Merge pull request #13095 from Snuffleupagus/eslint-cmapscompress
Enable linting of the `external/cmapscompress/` folder
2021-03-14 11:40:50 +01:00
Tim van der Meij
cc59c81fe6
Merge pull request #13096 from Snuffleupagus/eslint-no-var-stats
Enable the ESLint `no-var` rule in the `test/stats/` folder
2021-03-14 11:34:06 +01:00
Tim van der Meij
0ad9265555
Merge pull request #13097 from Snuffleupagus/eslint-no-var-add_test
Enable the ESLint `no-var` rule in `test/add_test.js`
2021-03-14 11:31:55 +01:00
Jonas Jenwald
7ec2bd0f01 Enable the ESLint no-var rule in test/add_test.js
These changes were done automatically, by using the `gulp lint --fix` command.
2021-03-14 10:25:51 +01:00
Jonas Jenwald
473f0aeeb2 Enable the ESLint no-var rule in the test/stats/ folder
Note that the majority of these changes were done automatically, by using the `gulp lint --fix` command, and the manual changes were limited to the following diff:

```diff
diff --git a/test/stats/statcmp.js b/test/stats/statcmp.js
index 7c4dbf1d3..22d535a5a 100644
--- a/test/stats/statcmp.js
+++ b/test/stats/statcmp.js
@@ -1,13 +1,7 @@
 "use strict";

 const fs = require("fs");
-
-try {
-  var ttest = require("ttest");
-} catch (e) {
-  console.log('\nttest is not installed -- to intall, run "npm install ttest"');
-  console.log("Continuing without significance test...\n");
-}
+const ttest = require("ttest");

 const VALID_GROUP_BYS = ["browser", "pdf", "page", "round", "stat"];

@@ -134,9 +128,7 @@ function stat(baseline, current) {
   if (ttest) {
     labels.push("Result(P<.05)");
   }
-  let i,
-    row,
-    rows = [];
+  const rows = [];
   // collect rows and measure column widths
   const width = labels.map(function (s) {
     return s.length;
@@ -146,7 +138,7 @@ function stat(baseline, current) {
     const key = keys[k];
     const baselineMean = mean(baselineGroup[key]);
     const currentMean = mean(currentGroup[key]);
-    row = key.split(",");
+    const row = key.split(",");
     row.push(
       "" + baselineGroup[key].length,
       "" + Math.round(baselineMean),
@@ -165,7 +157,7 @@ function stat(baseline, current) {
         row.push("");
       }
     }
-    for (i = 0; i < row.length; i++) {
+    for (let i = 0; i < row.length; i++) {
       width[i] = Math.max(width[i], row[i].length);
     }
     rows.push(row);
@@ -181,8 +173,8 @@ function stat(baseline, current) {
   console.log("-- Grouped By " + options.groupBy.join(", ") + " --");
   const groupCount = options.groupBy.length;
   for (let r = 0; r < rows.length; r++) {
-    row = rows[r];
-    for (i = 0; i < row.length; i++) {
+    const row = rows[r];
+    for (let i = 0; i < row.length; i++) {
       row[i] = pad(row[i], width[i], i < groupCount ? "right" : "left");
     }
     console.log(row.join(" | "));
@@ -208,5 +200,5 @@ function main() {
   stat(baseline, current);
 }

-var options = parseOptions();
+const options = parseOptions();
 main();
```
2021-03-14 10:15:45 +01:00
Jonas Jenwald
98e658ddf0 Enable linting of the external/cmapscompress/ folder
Given that this our "own" code, there's no good reason as far as I'm concerned to not lint it.
2021-03-13 19:32:58 +01:00
Jonas Jenwald
b9f4d89254 Fix *most* linting/formatting issues in the external/cmapscompress/ folder
These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
2021-03-13 19:24:23 +01:00
Tim van der Meij
c86f44f423
Merge pull request #13093 from Snuffleupagus/eslint-no-var-builder
Enable the ESLint `no-var` rule in the `external/builder/` folder
2021-03-13 18:52:18 +01:00
Jonas Jenwald
f0f307a4b5 Enable the ESLint no-var rule in the external/builder/ folder
As part of testing this, I've diffed the output of `gulp mozcentral` with/without this patch and the *only* difference is the incremented `version`/`build` numbers.
2021-03-13 17:50:13 +01:00
Jonas Jenwald
06494ccdac Replace *most* cases of var with let/const in the external/builder/ folder
These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
2021-03-13 17:47:58 +01:00
Tim van der Meij
fb78604383
Merge pull request #13091 from Snuffleupagus/eslint-no-var
Enable the ESLint `no-var` rule globally
2021-03-13 17:39:53 +01:00
Tim van der Meij
6b97958511
Merge pull request #13092 from Snuffleupagus/eslint-no-var-importL10n
Enable the ESLint `no-var` rule in the `importL10n/` folder
2021-03-13 17:34:05 +01:00
Jonas Jenwald
2ffa428d78 Enable the ESLint no-var rule in the importL10n/ folder 2021-03-13 17:23:41 +01:00
Jonas Jenwald
5b5061afa8 Enable the ESLint no-var rule globally
A significant portion of the code-base has now been converted to use `let`/`const`, rather than `var`, hence it should be possible to simply enable the ESLint `no-var` rule globally.
This way we can ensure that new code won't accidentally use `var`, and it also removes the need to manually enable the rule in various folders.

Obviously it makes sense to continue the efforts to replace `var`, but that should probably happen on a file and/or folder basis.

Please note that this patch excludes the following code:
 - The `extensions/` folder, since that seemed easiest for now (and I don't know exactly what the support situation is for the Chromium-extension).

 - The entire `external/` folder is ignored, since most of it's currently excluded from linting.
   For the code that isn't imported from elsewhere (and should be ignored), we should probably (at some point) bring the code up to the same linting/formatting standard as the rest of the code-base.

 - Various files in the `test/` folder are ignored, as necessary, since the way that a lot of this code is loaded will require some care (or perhaps larger re-factoring) when removing `var` usage.
2021-03-13 16:12:53 +01:00
Tim van der Meij
17c0bf0473
Merge pull request #13084 from Snuffleupagus/type1-class
Enable the ESLint `no-var` rule in a few font-parsing files, and convert `src/core/type1_parser.js` to use "standard" classes
2021-03-13 13:15:53 +01:00
Tim van der Meij
1abdcbaab5
Merge pull request #13087 from Snuffleupagus/eslint-examples-no-var
Enable the ESLint `no-var` rule in the `examples/` folder
2021-03-13 13:04:00 +01:00
Tim van der Meij
ba567321da
Merge pull request #13079 from Snuffleupagus/issue-13075
Ensure that `getDocument` handles Node.js `Buffer`s more gracefully (issue 13075)
2021-03-13 12:58:29 +01:00
Tim van der Meij
6ae81255bc
Merge pull request #13090 from Snuffleupagus/eslint-no-var-gulpfile
Enable the ESLint `no-var` rule in `gulpfile.js`
2021-03-13 12:55:34 +01:00
Jonas Jenwald
22e0ed51c6 Remove unnecessary /* eslint no-var: error */ lines in the test/unit/ folder (PR 12528 follow-up)
These lines are no longer needed, since the ESLint `no-var` rule has been enabled in the entire folder.
2021-03-13 11:50:11 +01:00
Jonas Jenwald
f58fee0956 Enable the ESLint no-var rule in gulpfile.js
Given that `let`/`const` is already used here and there in this file, converting the rest of the `var` occurrences shouldn't be a problem.

Note that the majority of these changes were done automatically, by using the `gulp lint --fix` command, and the manual changes were limited to the following diff:

```diff
diff --git a/gulpfile.js b/gulpfile.js
index e2360c8ec..905420c33 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -676,8 +676,8 @@ gulp.task("default_preferences-pre", function () {
       ],
     }).code;
   }
-  var babel = require("@babel/core");
-  var ctx = {
+  const babel = require("@babel/core");
+  const ctx = {
     rootPath: __dirname,
     saveComments: false,
     defines: builder.merge(DEFINES, {
@@ -690,7 +690,7 @@ gulp.task("default_preferences-pre", function () {
       "pdfjs-lib": "../pdf",
     },
   };
-  var preprocessor2 = require("./external/builder/preprocessor2.js");
+  const preprocessor2 = require("./external/builder/preprocessor2.js");
   return merge([
     gulp.src(["web/{app_options,viewer_compatibility}.js"], {
       base: ".",
@@ -1418,14 +1418,14 @@ function buildLib(defines, dir) {
     });
     return licenseHeaderLibre + content;
   }
-  var babel = require("@babel/core");
+  const babel = require("@babel/core");
   const versionInfo = getVersionJSON();
-  var bundleDefines = builder.merge(defines, {
+  const bundleDefines = builder.merge(defines, {
     BUNDLE_VERSION: versionInfo.version,
     BUNDLE_BUILD: versionInfo.commit,
     TESTING: process.env.TESTING === "true",
   });
-  var ctx = {
+  const ctx = {
     rootPath: __dirname,
     saveComments: false,
     defines: bundleDefines,
@@ -1433,10 +1433,10 @@ function buildLib(defines, dir) {
       "pdfjs-lib": "../pdf",
     },
   };
-  var licenseHeaderLibre = fs
+  const licenseHeaderLibre = fs
     .readFileSync("./src/license_header_libre.js")
     .toString();
-  var preprocessor2 = require("./external/builder/preprocessor2.js");
+  const preprocessor2 = require("./external/builder/preprocessor2.js");
   return merge([
     gulp.src(
       [
```
2021-03-13 11:47:06 +01:00
Jonas Jenwald
50681d71c8 Ensure that getDocument handles Node.js Buffers more gracefully (issue 13075)
While the JSDocs have never advertised `getDocument` as supporting Node.js `Buffer`s, that apparently doesn't stop users from passing such data structures to `getDocument`.
In theory the existing `instanceof Uint8Array` check ought to have caught Node.js `Buffer`s, however for reasons that I don't even pretend to understand that check actually passes. Hence this patch which, *only* in Node.js environments, will special-case `Buffer`s to hopefully provide a slightly better out-of-the-box behaviour in Node.js environments[1].

---
[1] Although I'm not sure that we necessarily want to advertise this in the JSDocs, given the specialized use-case.
2021-03-13 10:52:38 +01:00
Tim van der Meij
61318c42aa
Merge pull request #13085 from Snuffleupagus/driver-rasterize-errors
Ensure that *all* errors are handled in `rasterizeTextLayer`/`rasterizeAnnotationLayer`
2021-03-12 21:16:16 +01:00
Tim van der Meij
be4a41960a
Merge pull request #13081 from Snuffleupagus/objectFromMap
Replace the `objectFromEntries` helper function with an `objectFromMap` one instead, and simplify the data lookup in the AnnotationStorage.getValue method
2021-03-12 21:12:03 +01:00
Tim van der Meij
6af9b6449e
Merge pull request #13074 from Snuffleupagus/scripting-refactor-destroy
Re-factor the `PDFScriptingManager._destroyScripting` method (PR 13042 follow-up)
2021-03-12 21:08:05 +01:00
Jonas Jenwald
d144d01afe Simplify the animationStarted handling in the mobile-viewer/ example
(This is something that I happened to notice while working on the previous patch.)

The code in the `examples/mobile-viewer/viewer.js` file is essentially copied from an older version of the default viewer, hence we can slightly simplify the `animationStarted` handling here.
2021-03-12 17:52:58 +01:00
Jonas Jenwald
5c712f2131 Enable the ESLint no-var rule in the examples/ folder
Updating the examples to use `let`/`const` should be fine, given that they are available in all browsers/platforms that the PDF.js library now supports; please note the following compatibility information:

 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const#browser_compatibility
2021-03-12 17:52:52 +01:00
Jonas Jenwald
276fa4ad8f Replace *most* cases of var with let/const in the examples/ folder
These changes were done automatically, by using the `gulp lint --fix` command, in preparation for the next patch.
2021-03-12 17:16:59 +01:00
Jonas Jenwald
39cd844243 Ensure that *all* errors are handled in rasterizeTextLayer/rasterizeAnnotationLayer
Currently errors occurring within the `src/display/{text_layer, annotation_layer}.js` files are not being handled properly by the test-suite, and the tests simply time out rather than failing as intended.
This makes it *very* easy to accidentally overlook a certain type of errors, see e.g. https://github.com/mozilla/pdf.js/pull/13055#discussion_r589005041, which this patch will thus prevent.
2021-03-12 14:05:53 +01:00