Browse Source

PDF.js version 1.8.271 - See mozilla/pdf.js@7fd208479659b4ce9599bfcc7234d3928b08f567

pdfjsbot 8 years ago
parent
commit
6158fcdafd

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.254",
+  "version": "1.8.271",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 32 - 15
build/pdf.combined.js

@@ -970,7 +970,7 @@ var createObjectURL = function createObjectURLClosure() {
   return function createObjectURL(data, contentType) {
     var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 
-    if (!forceDataSchema) {
+    if (!forceDataSchema && URL.createObjectURL) {
       var blob = createBlob(data, contentType);
       return URL.createObjectURL(blob);
     }
@@ -1051,14 +1051,14 @@ function MessageHandler(sourceName, targetName, comObj) {
   comObj.addEventListener('message', this._onComObjOnMessage);
 }
 MessageHandler.prototype = {
-  on: function messageHandlerOn(actionName, handler, scope) {
+  on: function on(actionName, handler, scope) {
     var ah = this.actionHandler;
     if (ah[actionName]) {
       error('There is already an actionName called "' + actionName + '"');
     }
     ah[actionName] = [handler, scope];
   },
-  send: function messageHandlerSend(actionName, data, transfers) {
+  send: function send(actionName, data, transfers) {
     var message = {
       sourceName: this.sourceName,
       targetName: this.targetName,
@@ -1067,7 +1067,7 @@ MessageHandler.prototype = {
     };
     this.postMessage(message, transfers);
   },
-  sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
+  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
     var callbackId = this.callbackIndex++;
     var message = {
       sourceName: this.sourceName,
@@ -11651,6 +11651,7 @@ var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
         }
       }.bind(this));
     },
+
     then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
       return this.promise.then.apply(this.promise, arguments);
     }
@@ -11944,6 +11945,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
       (0, _util.deprecated)('page destroy method, use cleanup() instead');
       this.cleanup();
     },
+
     cleanup: function PDFPageProxy_cleanup() {
       this.pendingCleanup = true;
       this._tryCleanup();
@@ -12238,11 +12240,13 @@ var WorkerTransport = function WorkerTransportClosure() {
         loadingTask._capability.resolve(pdfDocument);
       }, this);
       messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
+        var _this = this;
+
         this._passwordCapability = (0, _util.createPromiseCapability)();
         if (loadingTask.onPassword) {
-          var updatePassword = function (password) {
-            this._passwordCapability.resolve({ password: password });
-          }.bind(this);
+          var updatePassword = function updatePassword(password) {
+            _this._passwordCapability.resolve({ password: password });
+          };
           loadingTask.onPassword(updatePassword, exception.code);
         } else {
           this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
@@ -12722,8 +12726,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.254';
-  exports.build = build = '366277d1';
+  exports.version = version = '1.8.271';
+  exports.build = build = '7fd20847';
 }
 exports.getDocument = getDocument;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
@@ -28016,8 +28020,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.254';
-  PDFJS.build = '366277d1';
+  PDFJS.version = '1.8.271';
+  PDFJS.build = '7fd20847';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -28031,6 +28035,7 @@ Object.defineProperty(PDFJS, 'verbosity', {
   set: function set(level) {
     (0, _util.setVerbosityLevel)(level);
   },
+
   enumerable: true,
   configurable: true
 });
@@ -28095,6 +28100,7 @@ PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
       }
       PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
     },
+
     enumerable: true,
     configurable: true
   });
@@ -42412,14 +42418,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
       this.endPath();
     },
     getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
+      var _this = this;
+
       var pattern;
       if (IR[0] === 'TilingPattern') {
         var color = IR[1];
         var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
-        var self = this;
         var canvasGraphicsFactory = {
           createCanvasGraphics: function createCanvasGraphics(ctx) {
-            return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
+            return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory);
           }
         };
         pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
@@ -42913,6 +42920,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
     },
+
     configurable: true
   });
   FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
@@ -43068,6 +43076,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
     },
+
     enumerable: true,
     configurable: true
   });
@@ -43534,8 +43543,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.254';
-var pdfjsBuild = '366277d1';
+var pdfjsVersion = '1.8.271';
+var pdfjsBuild = '7fd20847';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
 var pdfjsDisplayAPI = __w_pdfjs_require__(10);
@@ -43706,6 +43715,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -43713,6 +43723,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this.length;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -43901,6 +43912,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return dataset;
       },
+
       enumerable: true
     });
   })();
@@ -43961,6 +43973,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return classList;
       },
+
       enumerable: true
     });
   })();
@@ -44161,6 +44174,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         var scripts = document.getElementsByTagName('script');
         return scripts[scripts.length - 1];
       },
+
       enumerable: true,
       configurable: true
     });
@@ -44182,6 +44196,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         set: function set(value) {
           typeProperty.set.call(this, value === 'number' ? 'text' : value);
         },
+
         enumerable: true,
         configurable: true
       });
@@ -44204,6 +44219,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       set: function set(value) {
         readyStateProto.set.call(this, value);
       },
+
       enumerable: true,
       configurable: true
     });
@@ -44937,6 +44953,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       toString: function toString() {
         return this.href;
       },
+
       get href() {
         if (this._isInvalid) {
           return this._url;

+ 32 - 15
build/pdf.js

@@ -970,7 +970,7 @@ var createObjectURL = function createObjectURLClosure() {
   return function createObjectURL(data, contentType) {
     var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 
-    if (!forceDataSchema) {
+    if (!forceDataSchema && URL.createObjectURL) {
       var blob = createBlob(data, contentType);
       return URL.createObjectURL(blob);
     }
@@ -1051,14 +1051,14 @@ function MessageHandler(sourceName, targetName, comObj) {
   comObj.addEventListener('message', this._onComObjOnMessage);
 }
 MessageHandler.prototype = {
-  on: function messageHandlerOn(actionName, handler, scope) {
+  on: function on(actionName, handler, scope) {
     var ah = this.actionHandler;
     if (ah[actionName]) {
       error('There is already an actionName called "' + actionName + '"');
     }
     ah[actionName] = [handler, scope];
   },
-  send: function messageHandlerSend(actionName, data, transfers) {
+  send: function send(actionName, data, transfers) {
     var message = {
       sourceName: this.sourceName,
       targetName: this.targetName,
@@ -1067,7 +1067,7 @@ MessageHandler.prototype = {
     };
     this.postMessage(message, transfers);
   },
-  sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
+  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
     var callbackId = this.callbackIndex++;
     var message = {
       sourceName: this.sourceName,
@@ -2277,6 +2277,7 @@ var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
         }
       }.bind(this));
     },
+
     then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
       return this.promise.then.apply(this.promise, arguments);
     }
@@ -2570,6 +2571,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
       (0, _util.deprecated)('page destroy method, use cleanup() instead');
       this.cleanup();
     },
+
     cleanup: function PDFPageProxy_cleanup() {
       this.pendingCleanup = true;
       this._tryCleanup();
@@ -2947,11 +2949,13 @@ var WorkerTransport = function WorkerTransportClosure() {
         loadingTask._capability.resolve(pdfDocument);
       }, this);
       messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
+        var _this = this;
+
         this._passwordCapability = (0, _util.createPromiseCapability)();
         if (loadingTask.onPassword) {
-          var updatePassword = function (password) {
-            this._passwordCapability.resolve({ password: password });
-          }.bind(this);
+          var updatePassword = function updatePassword(password) {
+            _this._passwordCapability.resolve({ password: password });
+          };
           loadingTask.onPassword(updatePassword, exception.code);
         } else {
           this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
@@ -3431,8 +3435,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.254';
-  exports.build = build = '366277d1';
+  exports.version = version = '1.8.271';
+  exports.build = build = '7fd20847';
 }
 exports.getDocument = getDocument;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
@@ -5399,8 +5403,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.254';
-  PDFJS.build = '366277d1';
+  PDFJS.version = '1.8.271';
+  PDFJS.build = '7fd20847';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -5414,6 +5418,7 @@ Object.defineProperty(PDFJS, 'verbosity', {
   set: function set(level) {
     (0, _util.setVerbosityLevel)(level);
   },
+
   enumerable: true,
   configurable: true
 });
@@ -5478,6 +5483,7 @@ PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
       }
       PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
     },
+
     enumerable: true,
     configurable: true
   });
@@ -6767,14 +6773,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
       this.endPath();
     },
     getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
+      var _this = this;
+
       var pattern;
       if (IR[0] === 'TilingPattern') {
         var color = IR[1];
         var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
-        var self = this;
         var canvasGraphicsFactory = {
           createCanvasGraphics: function createCanvasGraphics(ctx) {
-            return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
+            return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory);
           }
         };
         pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
@@ -7268,6 +7275,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
     },
+
     configurable: true
   });
   FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
@@ -7423,6 +7431,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
     },
+
     enumerable: true,
     configurable: true
   });
@@ -7889,8 +7898,8 @@ exports.TilingPattern = TilingPattern;
 "use strict";
 
 
-var pdfjsVersion = '1.8.254';
-var pdfjsBuild = '366277d1';
+var pdfjsVersion = '1.8.271';
+var pdfjsBuild = '7fd20847';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);
@@ -8061,6 +8070,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -8068,6 +8078,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this.length;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -8256,6 +8267,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return dataset;
       },
+
       enumerable: true
     });
   })();
@@ -8316,6 +8328,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return classList;
       },
+
       enumerable: true
     });
   })();
@@ -8516,6 +8529,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         var scripts = document.getElementsByTagName('script');
         return scripts[scripts.length - 1];
       },
+
       enumerable: true,
       configurable: true
     });
@@ -8537,6 +8551,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         set: function set(value) {
           typeProperty.set.call(this, value === 'number' ? 'text' : value);
         },
+
         enumerable: true,
         configurable: true
       });
@@ -8559,6 +8574,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       set: function set(value) {
         readyStateProto.set.call(this, value);
       },
+
       enumerable: true,
       configurable: true
     });
@@ -9292,6 +9308,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       toString: function toString() {
         return this.href;
       },
+
       get href() {
         if (this._isInvalid) {
           return this._url;

File diff suppressed because it is too large
+ 0 - 0
build/pdf.min.js


+ 14 - 6
build/pdf.worker.js

@@ -970,7 +970,7 @@ var createObjectURL = function createObjectURLClosure() {
   return function createObjectURL(data, contentType) {
     var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 
-    if (!forceDataSchema) {
+    if (!forceDataSchema && URL.createObjectURL) {
       var blob = createBlob(data, contentType);
       return URL.createObjectURL(blob);
     }
@@ -1051,14 +1051,14 @@ function MessageHandler(sourceName, targetName, comObj) {
   comObj.addEventListener('message', this._onComObjOnMessage);
 }
 MessageHandler.prototype = {
-  on: function messageHandlerOn(actionName, handler, scope) {
+  on: function on(actionName, handler, scope) {
     var ah = this.actionHandler;
     if (ah[actionName]) {
       error('There is already an actionName called "' + actionName + '"');
     }
     ah[actionName] = [handler, scope];
   },
-  send: function messageHandlerSend(actionName, data, transfers) {
+  send: function send(actionName, data, transfers) {
     var message = {
       sourceName: this.sourceName,
       targetName: this.targetName,
@@ -1067,7 +1067,7 @@ MessageHandler.prototype = {
     };
     this.postMessage(message, transfers);
   },
-  sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
+  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
     var callbackId = this.callbackIndex++;
     var message = {
       sourceName: this.sourceName,
@@ -36956,8 +36956,8 @@ exports.Type1Parser = Type1Parser;
 "use strict";
 
 
-var pdfjsVersion = '1.8.254';
-var pdfjsBuild = '366277d1';
+var pdfjsVersion = '1.8.271';
+var pdfjsBuild = '7fd20847';
 var pdfjsCoreWorker = __w_pdfjs_require__(8);
 {
   __w_pdfjs_require__(19);
@@ -37100,6 +37100,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -37107,6 +37108,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this.length;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -37295,6 +37297,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return dataset;
       },
+
       enumerable: true
     });
   })();
@@ -37355,6 +37358,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return classList;
       },
+
       enumerable: true
     });
   })();
@@ -37555,6 +37559,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         var scripts = document.getElementsByTagName('script');
         return scripts[scripts.length - 1];
       },
+
       enumerable: true,
       configurable: true
     });
@@ -37576,6 +37581,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         set: function set(value) {
           typeProperty.set.call(this, value === 'number' ? 'text' : value);
         },
+
         enumerable: true,
         configurable: true
       });
@@ -37598,6 +37604,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       set: function set(value) {
         readyStateProto.set.call(this, value);
       },
+
       enumerable: true,
       configurable: true
     });
@@ -38331,6 +38338,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       toString: function toString() {
         return this.href;
       },
+
       get href() {
         if (this._isInvalid) {
           return this._url;

File diff suppressed because it is too large
+ 0 - 0
build/pdf.worker.min.js


+ 9 - 5
lib/display/api.js

@@ -208,6 +208,7 @@ var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
         }
       }.bind(this));
     },
+
     then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
       return this.promise.then.apply(this.promise, arguments);
     }
@@ -501,6 +502,7 @@ var PDFPageProxy = function PDFPageProxyClosure() {
       (0, _util.deprecated)('page destroy method, use cleanup() instead');
       this.cleanup();
     },
+
     cleanup: function PDFPageProxy_cleanup() {
       this.pendingCleanup = true;
       this._tryCleanup();
@@ -878,11 +880,13 @@ var WorkerTransport = function WorkerTransportClosure() {
         loadingTask._capability.resolve(pdfDocument);
       }, this);
       messageHandler.on('PasswordRequest', function transportPasswordRequest(exception) {
+        var _this = this;
+
         this._passwordCapability = (0, _util.createPromiseCapability)();
         if (loadingTask.onPassword) {
-          var updatePassword = function (password) {
-            this._passwordCapability.resolve({ password: password });
-          }.bind(this);
+          var updatePassword = function updatePassword(password) {
+            _this._passwordCapability.resolve({ password: password });
+          };
           loadingTask.onPassword(updatePassword, exception.code);
         } else {
           this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code));
@@ -1362,8 +1366,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
 }();
 var version, build;
 {
-  exports.version = version = '1.8.254';
-  exports.build = build = '366277d1';
+  exports.version = version = '1.8.271';
+  exports.build = build = '7fd20847';
 }
 exports.getDocument = getDocument;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;

+ 3 - 2
lib/display/canvas.js

@@ -1271,14 +1271,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
       this.endPath();
     },
     getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
+      var _this = this;
+
       var pattern;
       if (IR[0] === 'TilingPattern') {
         var color = IR[1];
         var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
-        var self = this;
         var canvasGraphicsFactory = {
           createCanvasGraphics: function createCanvasGraphics(ctx) {
-            return new CanvasGraphics(ctx, self.commonObjs, self.objs, self.canvasFactory);
+            return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory);
           }
         };
         pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);

+ 2 - 0
lib/display/font_loader.js

@@ -61,6 +61,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(this, 'loadTestFont', getLoadTestFont());
     },
+
     configurable: true
   });
   FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
@@ -216,6 +217,7 @@ FontLoader.prototype = {
     get: function get() {
       return (0, _util.shadow)(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
     },
+
     enumerable: true,
     configurable: true
   });

+ 4 - 2
lib/display/global.js

@@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.254';
-  PDFJS.build = '366277d1';
+  PDFJS.version = '1.8.271';
+  PDFJS.build = '7fd20847';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
@@ -54,6 +54,7 @@ Object.defineProperty(PDFJS, 'verbosity', {
   set: function set(level) {
     (0, _util.setVerbosityLevel)(level);
   },
+
   enumerable: true,
   configurable: true
 });
@@ -118,6 +119,7 @@ PDFJS.pdfjsNext = PDFJS.pdfjsNext === undefined ? false : PDFJS.pdfjsNext;
       }
       PDFJS.externalLinkTarget = value ? _dom_utils.LinkTarget.BLANK : _dom_utils.LinkTarget.NONE;
     },
+
     enumerable: true,
     configurable: true
   });

+ 2 - 2
lib/pdf.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.254';
-var pdfjsBuild = '366277d1';
+var pdfjsVersion = '1.8.271';
+var pdfjsBuild = '7fd20847';
 var pdfjsSharedUtil = require('./shared/util.js');
 var pdfjsDisplayGlobal = require('./display/global.js');
 var pdfjsDisplayAPI = require('./display/api.js');

+ 2 - 2
lib/pdf.worker.js

@@ -14,8 +14,8 @@
  */
 'use strict';
 
-var pdfjsVersion = '1.8.254';
-var pdfjsBuild = '366277d1';
+var pdfjsVersion = '1.8.271';
+var pdfjsBuild = '7fd20847';
 var pdfjsCoreWorker = require('./core/worker.js');
 {
   require('./core/network.js');

+ 8 - 0
lib/shared/compatibility.js

@@ -143,6 +143,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -150,6 +151,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this.length;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -338,6 +340,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return dataset;
       },
+
       enumerable: true
     });
   })();
@@ -398,6 +401,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return classList;
       },
+
       enumerable: true
     });
   })();
@@ -598,6 +602,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         var scripts = document.getElementsByTagName('script');
         return scripts[scripts.length - 1];
       },
+
       enumerable: true,
       configurable: true
     });
@@ -619,6 +624,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         set: function set(value) {
           typeProperty.set.call(this, value === 'number' ? 'text' : value);
         },
+
         enumerable: true,
         configurable: true
       });
@@ -641,6 +647,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       set: function set(value) {
         readyStateProto.set.call(this, value);
       },
+
       enumerable: true,
       configurable: true
     });
@@ -1374,6 +1381,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       toString: function toString() {
         return this.href;
       },
+
       get href() {
         if (this._isInvalid) {
           return this._url;

+ 4 - 4
lib/shared/util.js

@@ -886,7 +886,7 @@ var createObjectURL = function createObjectURLClosure() {
   return function createObjectURL(data, contentType) {
     var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
 
-    if (!forceDataSchema) {
+    if (!forceDataSchema && URL.createObjectURL) {
       var blob = createBlob(data, contentType);
       return URL.createObjectURL(blob);
     }
@@ -967,14 +967,14 @@ function MessageHandler(sourceName, targetName, comObj) {
   comObj.addEventListener('message', this._onComObjOnMessage);
 }
 MessageHandler.prototype = {
-  on: function messageHandlerOn(actionName, handler, scope) {
+  on: function on(actionName, handler, scope) {
     var ah = this.actionHandler;
     if (ah[actionName]) {
       error('There is already an actionName called "' + actionName + '"');
     }
     ah[actionName] = [handler, scope];
   },
-  send: function messageHandlerSend(actionName, data, transfers) {
+  send: function send(actionName, data, transfers) {
     var message = {
       sourceName: this.sourceName,
       targetName: this.targetName,
@@ -983,7 +983,7 @@ MessageHandler.prototype = {
     };
     this.postMessage(message, transfers);
   },
-  sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
+  sendWithPromise: function sendWithPromise(actionName, data, transfers) {
     var callbackId = this.callbackIndex++;
     var message = {
       sourceName: this.sourceName,

+ 4 - 0
lib/test/unit/ui_utils_spec.js

@@ -20,6 +20,7 @@ var binarySearchFirstItem = webUiUtils.binarySearchFirstItem;
 var getPDFFileNameFromURL = webUiUtils.getPDFFileNameFromURL;
 var EventBus = webUiUtils.EventBus;
 var createObjectURL = sharedUtil.createObjectURL;
+var isNodeJS = sharedUtil.isNodeJS;
 describe('ui_utils', function () {
   describe('binary search', function () {
     function isTrue(boolean) {
@@ -94,6 +95,9 @@ describe('ui_utils', function () {
       expect(getPDFFileNameFromURL('ftp://www.example.com/file4.pdf')).toEqual('file4.pdf');
     });
     it('gets PDF filename from query string appended to "blob:" URL', function () {
+      if (isNodeJS()) {
+        pending('Blob in not supported in Node.js.');
+      }
       var typedArray = new Uint8Array([1, 2, 3, 4, 5]);
       var blobUrl = createObjectURL(typedArray, 'application/pdf');
       expect(blobUrl.indexOf('blob:') === 0).toEqual(true);

+ 57 - 33
lib/web/annotation_layer_builder.js

@@ -19,14 +19,20 @@ Object.defineProperty(exports, "__esModule", {
 });
 exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
 
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
 var _pdfjs = require('./pdfjs');
 
 var _ui_utils = require('./ui_utils');
 
 var _pdf_link_service = require('./pdf_link_service');
 
-var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var AnnotationLayerBuilder = function () {
   function AnnotationLayerBuilder(options) {
+    _classCallCheck(this, AnnotationLayerBuilder);
+
     this.pageDiv = options.pageDiv;
     this.pdfPage = options.pdfPage;
     this.renderInteractiveForms = options.renderInteractiveForms;
@@ -34,57 +40,75 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
     this.downloadManager = options.downloadManager;
     this.div = null;
   }
-  AnnotationLayerBuilder.prototype = {
-    render: function AnnotationLayerBuilder_render(viewport, intent) {
-      var self = this;
-      var parameters = { intent: intent === undefined ? 'display' : intent };
-      this.pdfPage.getAnnotations(parameters).then(function (annotations) {
-        viewport = viewport.clone({ dontFlip: true });
-        parameters = {
-          viewport: viewport,
-          div: self.div,
+
+  _createClass(AnnotationLayerBuilder, [{
+    key: 'render',
+    value: function render(viewport) {
+      var _this = this;
+
+      var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
+
+      this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
+        var parameters = {
+          viewport: viewport.clone({ dontFlip: true }),
+          div: _this.div,
           annotations: annotations,
-          page: self.pdfPage,
-          renderInteractiveForms: self.renderInteractiveForms,
-          linkService: self.linkService,
-          downloadManager: self.downloadManager
+          page: _this.pdfPage,
+          renderInteractiveForms: _this.renderInteractiveForms,
+          linkService: _this.linkService,
+          downloadManager: _this.downloadManager
         };
-        if (self.div) {
+        if (_this.div) {
           _pdfjs.AnnotationLayer.update(parameters);
         } else {
           if (annotations.length === 0) {
             return;
           }
-          self.div = document.createElement('div');
-          self.div.className = 'annotationLayer';
-          self.pageDiv.appendChild(self.div);
-          parameters.div = self.div;
+          _this.div = document.createElement('div');
+          _this.div.className = 'annotationLayer';
+          _this.pageDiv.appendChild(_this.div);
+          parameters.div = _this.div;
           _pdfjs.AnnotationLayer.render(parameters);
           if (typeof _ui_utils.mozL10n !== 'undefined') {
-            _ui_utils.mozL10n.translate(self.div);
+            _ui_utils.mozL10n.translate(_this.div);
           }
         }
       });
-    },
-    hide: function AnnotationLayerBuilder_hide() {
+    }
+  }, {
+    key: 'hide',
+    value: function hide() {
       if (!this.div) {
         return;
       }
       this.div.setAttribute('hidden', 'true');
     }
-  };
+  }]);
+
   return AnnotationLayerBuilder;
 }();
-function DefaultAnnotationLayerFactory() {}
-DefaultAnnotationLayerFactory.prototype = {
-  createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage, renderInteractiveForms) {
-    return new AnnotationLayerBuilder({
-      pageDiv: pageDiv,
-      pdfPage: pdfPage,
-      renderInteractiveForms: renderInteractiveForms,
-      linkService: new _pdf_link_service.SimpleLinkService()
-    });
+
+var DefaultAnnotationLayerFactory = function () {
+  function DefaultAnnotationLayerFactory() {
+    _classCallCheck(this, DefaultAnnotationLayerFactory);
   }
-};
+
+  _createClass(DefaultAnnotationLayerFactory, [{
+    key: 'createAnnotationLayerBuilder',
+    value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
+      var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+
+      return new AnnotationLayerBuilder({
+        pageDiv: pageDiv,
+        pdfPage: pdfPage,
+        renderInteractiveForms: renderInteractiveForms,
+        linkService: new _pdf_link_service.SimpleLinkService()
+      });
+    }
+  }]);
+
+  return DefaultAnnotationLayerFactory;
+}();
+
 exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
 exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;

+ 63 - 51
lib/web/app.js

@@ -577,6 +577,8 @@ var PDFViewerApplication = {
     }
   },
   load: function pdfViewLoad(pdfDocument, scale) {
+    var _this4 = this;
+
     var self = this;
     scale = scale || _ui_utils.UNKNOWN_SCALE;
     this.pdfDocument = pdfDocument;
@@ -618,46 +620,56 @@ var PDFViewerApplication = {
         }
       }
       var initialParams = {
-        destination: self.initialDestination,
-        bookmark: self.initialBookmark,
+        destination: _this4.initialDestination,
+        bookmark: _this4.initialBookmark,
         hash: null
       };
-      store.initializedPromise.then(function resolved() {
-        var storedHash = null,
-            sidebarView = null;
-        if (self.viewerPrefs['showPreviousViewOnLoad'] && store.get('exists', false)) {
-          var pageNum = store.get('page', '1');
-          var zoom = self.viewerPrefs['defaultZoomValue'] || store.get('zoom', _ui_utils.DEFAULT_SCALE_VALUE);
-          var left = store.get('scrollLeft', '0');
-          var top = store.get('scrollTop', '0');
-          storedHash = 'page=' + pageNum + '&zoom=' + zoom + ',' + left + ',' + top;
-          sidebarView = store.get('sidebarView', _pdf_sidebar.SidebarView.NONE);
-        } else if (self.viewerPrefs['defaultZoomValue']) {
-          storedHash = 'page=1&zoom=' + self.viewerPrefs['defaultZoomValue'];
+      var storedHash = _this4.viewerPrefs['defaultZoomValue'] ? 'zoom=' + _this4.viewerPrefs['defaultZoomValue'] : null;
+      var sidebarView = _this4.viewerPrefs['sidebarViewOnLoad'];
+      new Promise(function (resolve, reject) {
+        if (!_this4.viewerPrefs['showPreviousViewOnLoad']) {
+          resolve();
+          return;
         }
-        self.setInitialView(storedHash, {
-          scale: scale,
-          sidebarView: sidebarView
+        store.getMultiple({
+          exists: false,
+          page: '1',
+          zoom: _ui_utils.DEFAULT_SCALE_VALUE,
+          scrollLeft: '0',
+          scrollTop: '0',
+          sidebarView: _pdf_sidebar.SidebarView.NONE
+        }).then(function (values) {
+          if (!values.exists) {
+            resolve();
+            return;
+          }
+          storedHash = 'page=' + values.page + '&zoom=' + (_this4.viewerPrefs['defaultZoomValue'] || values.zoom) + ',' + values.scrollLeft + ',' + values.scrollTop;
+          sidebarView = _this4.viewerPrefs['sidebarViewOnLoad'] || values.sidebarView | 0;
+          resolve();
+        }).catch(function () {
+          resolve();
+        });
+      }).then(function () {
+        _this4.setInitialView(storedHash, {
+          sidebarView: sidebarView,
+          scale: scale
         });
         initialParams.hash = storedHash;
-        if (!self.isViewerEmbedded) {
-          self.pdfViewer.focus();
+        if (!_this4.isViewerEmbedded) {
+          _this4.pdfViewer.focus();
         }
-      }, function rejected(reason) {
-        console.error(reason);
-        self.setInitialView(null, { scale: scale });
-      });
-      pagesPromise.then(function resolved() {
+        return pagesPromise;
+      }).then(function () {
         if (!initialParams.destination && !initialParams.bookmark && !initialParams.hash) {
           return;
         }
-        if (self.hasEqualPageSizes) {
+        if (_this4.hasEqualPageSizes) {
           return;
         }
-        self.initialDestination = initialParams.destination;
-        self.initialBookmark = initialParams.bookmark;
-        self.pdfViewer.currentScaleValue = self.pdfViewer.currentScaleValue;
-        self.setInitialView(initialParams.hash);
+        _this4.initialDestination = initialParams.destination;
+        _this4.initialBookmark = initialParams.bookmark;
+        _this4.pdfViewer.currentScaleValue = _this4.pdfViewer.currentScaleValue;
+        _this4.setInitialView(initialParams.hash);
       });
     });
     pdfDocument.getPageLabels().then(function (labels) {
@@ -734,11 +746,15 @@ var PDFViewerApplication = {
       }
     });
   },
-  setInitialView: function pdfViewSetInitialView(storedHash, options) {
-    var scale = options && options.scale;
-    var sidebarView = options && options.sidebarView;
+  setInitialView: function setInitialView(storedHash) {
+    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
+    var _options$scale = options.scale,
+        scale = _options$scale === undefined ? 0 : _options$scale,
+        _options$sidebarView = options.sidebarView,
+        sidebarView = _options$sidebarView === undefined ? _pdf_sidebar.SidebarView.NONE : _options$sidebarView;
+
     this.isInitialViewSet = true;
-    this.pdfSidebar.setInitialView(this.viewerPrefs['sidebarViewOnLoad'] || sidebarView | 0);
+    this.pdfSidebar.setInitialView(sidebarView);
     if (this.initialDestination) {
       this.pdfLinkService.navigateTo(this.initialDestination);
       this.initialDestination = null;
@@ -758,6 +774,7 @@ var PDFViewerApplication = {
       this.pdfViewer.currentScaleValue = _ui_utils.DEFAULT_SCALE_VALUE;
     }
   },
+
   cleanup: function pdfViewCleanup() {
     if (!this.pdfDocument) {
       return;
@@ -1114,29 +1131,24 @@ function webViewerPresentationModeChanged(e) {
   var switchInProgress = e.switchInProgress;
   PDFViewerApplication.pdfViewer.presentationModeState = switchInProgress ? _pdf_viewer.PresentationModeState.CHANGING : active ? _pdf_viewer.PresentationModeState.FULLSCREEN : _pdf_viewer.PresentationModeState.NORMAL;
 }
-function webViewerSidebarViewChanged(e) {
+function webViewerSidebarViewChanged(evt) {
   PDFViewerApplication.pdfRenderingQueue.isThumbnailViewEnabled = PDFViewerApplication.pdfSidebar.isThumbnailViewVisible;
   var store = PDFViewerApplication.store;
-  if (!store || !PDFViewerApplication.isInitialViewSet) {
-    return;
+  if (store && PDFViewerApplication.isInitialViewSet) {
+    store.set('sidebarView', evt.view).catch(function () {});
   }
-  store.initializedPromise.then(function () {
-    store.set('sidebarView', e.view).catch(function () {});
-  });
 }
-function webViewerUpdateViewarea(e) {
-  var location = e.location,
+function webViewerUpdateViewarea(evt) {
+  var location = evt.location,
       store = PDFViewerApplication.store;
-  if (store) {
-    store.initializedPromise.then(function () {
-      store.setMultiple({
-        'exists': true,
-        'page': location.pageNumber,
-        'zoom': location.scale,
-        'scrollLeft': location.left,
-        'scrollTop': location.top
-      }).catch(function () {});
-    });
+  if (store && PDFViewerApplication.isInitialViewSet) {
+    store.setMultiple({
+      'exists': true,
+      'page': location.pageNumber,
+      'zoom': location.scale,
+      'scrollLeft': location.left,
+      'scrollTop': location.top
+    }).catch(function () {});
   }
   var href = PDFViewerApplication.pdfLinkService.getAnchorUrl(location.pdfOpenParams);
   PDFViewerApplication.appConfig.toolbar.viewBookmark.href = href;

+ 19 - 4
lib/web/interfaces.js

@@ -14,6 +14,10 @@
  */
 'use strict';
 
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
 function IPDFLinkService() {}
 IPDFLinkService.prototype = {
   get page() {},
@@ -43,7 +47,18 @@ function IPDFTextLayerFactory() {}
 IPDFTextLayerFactory.prototype = {
   createTextLayerBuilder: function createTextLayerBuilder(textLayerDiv, pageIndex, viewport, enhanceTextSelection) {}
 };
-function IPDFAnnotationLayerFactory() {}
-IPDFAnnotationLayerFactory.prototype = {
-  createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage, renderInteractiveForms) {}
-};
+
+var IPDFAnnotationLayerFactory = function () {
+  function IPDFAnnotationLayerFactory() {
+    _classCallCheck(this, IPDFAnnotationLayerFactory);
+  }
+
+  _createClass(IPDFAnnotationLayerFactory, [{
+    key: 'createAnnotationLayerBuilder',
+    value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
+      var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+    }
+  }]);
+
+  return IPDFAnnotationLayerFactory;
+}();

+ 147 - 86
lib/web/pdf_presentation_mode.js

@@ -19,14 +19,27 @@ Object.defineProperty(exports, "__esModule", {
 });
 exports.PDFPresentationMode = undefined;
 
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
 var _ui_utils = require('./ui_utils');
 
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
 var DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500;
 var DELAY_BEFORE_HIDING_CONTROLS = 3000;
 var ACTIVE_SELECTOR = 'pdfPresentationMode';
 var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
-var PDFPresentationMode = function PDFPresentationModeClosure() {
+var MOUSE_SCROLL_COOLDOWN_TIME = 50;
+var PAGE_SWITCH_THRESHOLD = 0.1;
+var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
+var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
+
+var PDFPresentationMode = function () {
   function PDFPresentationMode(options) {
+    var _this = this;
+
+    _classCallCheck(this, PDFPresentationMode);
+
     this.container = options.container;
     this.viewer = options.viewer || options.container.firstElementChild;
     this.pdfViewer = options.pdfViewer;
@@ -39,26 +52,28 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
     this.mouseScrollDelta = 0;
     this.touchSwipeState = null;
     if (contextMenuItems) {
-      contextMenuItems.contextFirstPage.addEventListener('click', function PDFPresentationMode_contextFirstPageClick(e) {
-        this.contextMenuOpen = false;
-        this.eventBus.dispatch('firstpage');
-      }.bind(this));
-      contextMenuItems.contextLastPage.addEventListener('click', function PDFPresentationMode_contextLastPageClick(e) {
-        this.contextMenuOpen = false;
-        this.eventBus.dispatch('lastpage');
-      }.bind(this));
-      contextMenuItems.contextPageRotateCw.addEventListener('click', function PDFPresentationMode_contextPageRotateCwClick(e) {
-        this.contextMenuOpen = false;
-        this.eventBus.dispatch('rotatecw');
-      }.bind(this));
-      contextMenuItems.contextPageRotateCcw.addEventListener('click', function PDFPresentationMode_contextPageRotateCcwClick(e) {
-        this.contextMenuOpen = false;
-        this.eventBus.dispatch('rotateccw');
-      }.bind(this));
+      contextMenuItems.contextFirstPage.addEventListener('click', function () {
+        _this.contextMenuOpen = false;
+        _this.eventBus.dispatch('firstpage');
+      });
+      contextMenuItems.contextLastPage.addEventListener('click', function () {
+        _this.contextMenuOpen = false;
+        _this.eventBus.dispatch('lastpage');
+      });
+      contextMenuItems.contextPageRotateCw.addEventListener('click', function () {
+        _this.contextMenuOpen = false;
+        _this.eventBus.dispatch('rotatecw');
+      });
+      contextMenuItems.contextPageRotateCcw.addEventListener('click', function () {
+        _this.contextMenuOpen = false;
+        _this.eventBus.dispatch('rotateccw');
+      });
     }
   }
-  PDFPresentationMode.prototype = {
-    request: function PDFPresentationMode_request() {
+
+  _createClass(PDFPresentationMode, [{
+    key: 'request',
+    value: function request() {
       if (this.switchInProgress || this.active || !this.viewer.hasChildNodes()) {
         return false;
       }
@@ -81,15 +96,15 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
         previousScale: this.pdfViewer.currentScaleValue
       };
       return true;
-    },
-    _mouseWheel: function PDFPresentationMode_mouseWheel(evt) {
+    }
+  }, {
+    key: '_mouseWheel',
+    value: function _mouseWheel(evt) {
       if (!this.active) {
         return;
       }
       evt.preventDefault();
       var delta = (0, _ui_utils.normalizeWheelEventDelta)(evt);
-      var MOUSE_SCROLL_COOLDOWN_TIME = 50;
-      var PAGE_SWITCH_THRESHOLD = 0.1;
       var currentTime = new Date().getTime();
       var storedTime = this.mouseScrollTimeStamp;
       if (currentTime > storedTime && currentTime - storedTime < MOUSE_SCROLL_COOLDOWN_TIME) {
@@ -107,82 +122,101 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
           this.mouseScrollTimeStamp = currentTime;
         }
       }
-    },
-    get isFullscreen() {
-      return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
-    },
-    _goToPreviousPage: function PDFPresentationMode_goToPreviousPage() {
+    }
+  }, {
+    key: '_goToPreviousPage',
+    value: function _goToPreviousPage() {
       var page = this.pdfViewer.currentPageNumber;
       if (page <= 1) {
         return false;
       }
       this.pdfViewer.currentPageNumber = page - 1;
       return true;
-    },
-    _goToNextPage: function PDFPresentationMode_goToNextPage() {
+    }
+  }, {
+    key: '_goToNextPage',
+    value: function _goToNextPage() {
       var page = this.pdfViewer.currentPageNumber;
       if (page >= this.pdfViewer.pagesCount) {
         return false;
       }
       this.pdfViewer.currentPageNumber = page + 1;
       return true;
-    },
-    _notifyStateChange: function PDFPresentationMode_notifyStateChange() {
+    }
+  }, {
+    key: '_notifyStateChange',
+    value: function _notifyStateChange() {
       this.eventBus.dispatch('presentationmodechanged', {
         source: this,
         active: this.active,
         switchInProgress: !!this.switchInProgress
       });
-    },
-    _setSwitchInProgress: function PDFPresentationMode_setSwitchInProgress() {
+    }
+  }, {
+    key: '_setSwitchInProgress',
+    value: function _setSwitchInProgress() {
+      var _this2 = this;
+
       if (this.switchInProgress) {
         clearTimeout(this.switchInProgress);
       }
-      this.switchInProgress = setTimeout(function switchInProgressTimeout() {
-        this._removeFullscreenChangeListeners();
-        delete this.switchInProgress;
-        this._notifyStateChange();
-      }.bind(this), DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
-    },
-    _resetSwitchInProgress: function PDFPresentationMode_resetSwitchInProgress() {
+      this.switchInProgress = setTimeout(function () {
+        _this2._removeFullscreenChangeListeners();
+        delete _this2.switchInProgress;
+        _this2._notifyStateChange();
+      }, DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS);
+    }
+  }, {
+    key: '_resetSwitchInProgress',
+    value: function _resetSwitchInProgress() {
       if (this.switchInProgress) {
         clearTimeout(this.switchInProgress);
         delete this.switchInProgress;
       }
-    },
-    _enter: function PDFPresentationMode_enter() {
+    }
+  }, {
+    key: '_enter',
+    value: function _enter() {
+      var _this3 = this;
+
       this.active = true;
       this._resetSwitchInProgress();
       this._notifyStateChange();
       this.container.classList.add(ACTIVE_SELECTOR);
-      setTimeout(function enterPresentationModeTimeout() {
-        this.pdfViewer.currentPageNumber = this.args.page;
-        this.pdfViewer.currentScaleValue = 'page-fit';
-      }.bind(this), 0);
+      setTimeout(function () {
+        _this3.pdfViewer.currentPageNumber = _this3.args.page;
+        _this3.pdfViewer.currentScaleValue = 'page-fit';
+      }, 0);
       this._addWindowListeners();
       this._showControls();
       this.contextMenuOpen = false;
       this.container.setAttribute('contextmenu', 'viewerContextMenu');
       window.getSelection().removeAllRanges();
-    },
-    _exit: function PDFPresentationMode_exit() {
+    }
+  }, {
+    key: '_exit',
+    value: function _exit() {
+      var _this4 = this;
+
       var page = this.pdfViewer.currentPageNumber;
       this.container.classList.remove(ACTIVE_SELECTOR);
-      setTimeout(function exitPresentationModeTimeout() {
-        this.active = false;
-        this._removeFullscreenChangeListeners();
-        this._notifyStateChange();
-        this.pdfViewer.currentScaleValue = this.args.previousScale;
-        this.pdfViewer.currentPageNumber = page;
-        this.args = null;
-      }.bind(this), 0);
+      setTimeout(function () {
+        _this4.active = false;
+        _this4._removeFullscreenChangeListeners();
+        _this4._notifyStateChange();
+        _this4.pdfViewer.currentScaleValue = _this4.args.previousScale;
+        _this4.pdfViewer.currentPageNumber = page;
+        _this4.args = null;
+      }, 0);
       this._removeWindowListeners();
       this._hideControls();
       this._resetMouseScrollState();
       this.container.removeAttribute('contextmenu');
       this.contextMenuOpen = false;
-    },
-    _mouseDown: function PDFPresentationMode_mouseDown(evt) {
+    }
+  }, {
+    key: '_mouseDown',
+    value: function _mouseDown(evt) {
       if (this.contextMenuOpen) {
         this.contextMenuOpen = false;
         evt.preventDefault();
@@ -195,39 +229,49 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
           this.pdfViewer.currentPageNumber += evt.shiftKey ? -1 : 1;
         }
       }
-    },
-    _contextMenu: function PDFPresentationMode_contextMenu() {
+    }
+  }, {
+    key: '_contextMenu',
+    value: function _contextMenu() {
       this.contextMenuOpen = true;
-    },
-    _showControls: function PDFPresentationMode_showControls() {
+    }
+  }, {
+    key: '_showControls',
+    value: function _showControls() {
+      var _this5 = this;
+
       if (this.controlsTimeout) {
         clearTimeout(this.controlsTimeout);
       } else {
         this.container.classList.add(CONTROLS_SELECTOR);
       }
-      this.controlsTimeout = setTimeout(function showControlsTimeout() {
-        this.container.classList.remove(CONTROLS_SELECTOR);
-        delete this.controlsTimeout;
-      }.bind(this), DELAY_BEFORE_HIDING_CONTROLS);
-    },
-    _hideControls: function PDFPresentationMode_hideControls() {
+      this.controlsTimeout = setTimeout(function () {
+        _this5.container.classList.remove(CONTROLS_SELECTOR);
+        delete _this5.controlsTimeout;
+      }, DELAY_BEFORE_HIDING_CONTROLS);
+    }
+  }, {
+    key: '_hideControls',
+    value: function _hideControls() {
       if (!this.controlsTimeout) {
         return;
       }
       clearTimeout(this.controlsTimeout);
       this.container.classList.remove(CONTROLS_SELECTOR);
       delete this.controlsTimeout;
-    },
-    _resetMouseScrollState: function PDFPresentationMode_resetMouseScrollState() {
+    }
+  }, {
+    key: '_resetMouseScrollState',
+    value: function _resetMouseScrollState() {
       this.mouseScrollTimeStamp = 0;
       this.mouseScrollDelta = 0;
-    },
-    _touchSwipe: function PDFPresentationMode_touchSwipe(evt) {
+    }
+  }, {
+    key: '_touchSwipe',
+    value: function _touchSwipe(evt) {
       if (!this.active) {
         return;
       }
-      var SWIPE_MIN_DISTANCE_THRESHOLD = 50;
-      var SWIPE_ANGLE_THRESHOLD = Math.PI / 6;
       if (evt.touches.length > 1) {
         this.touchSwipeState = null;
         return;
@@ -269,8 +313,10 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
           }
           break;
       }
-    },
-    _addWindowListeners: function PDFPresentationMode_addWindowListeners() {
+    }
+  }, {
+    key: '_addWindowListeners',
+    value: function _addWindowListeners() {
       this.showControlsBind = this._showControls.bind(this);
       this.mouseDownBind = this._mouseDown.bind(this);
       this.mouseWheelBind = this._mouseWheel.bind(this);
@@ -285,8 +331,10 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
       window.addEventListener('touchstart', this.touchSwipeBind);
       window.addEventListener('touchmove', this.touchSwipeBind);
       window.addEventListener('touchend', this.touchSwipeBind);
-    },
-    _removeWindowListeners: function PDFPresentationMode_removeWindowListeners() {
+    }
+  }, {
+    key: '_removeWindowListeners',
+    value: function _removeWindowListeners() {
       window.removeEventListener('mousemove', this.showControlsBind);
       window.removeEventListener('mousedown', this.mouseDownBind);
       window.removeEventListener('wheel', this.mouseWheelBind);
@@ -301,29 +349,42 @@ var PDFPresentationMode = function PDFPresentationModeClosure() {
       delete this.resetMouseScrollStateBind;
       delete this.contextMenuBind;
       delete this.touchSwipeBind;
-    },
-    _fullscreenChange: function PDFPresentationMode_fullscreenChange() {
+    }
+  }, {
+    key: '_fullscreenChange',
+    value: function _fullscreenChange() {
       if (this.isFullscreen) {
         this._enter();
       } else {
         this._exit();
       }
-    },
-    _addFullscreenChangeListeners: function PDFPresentationMode_addFullscreenChangeListeners() {
+    }
+  }, {
+    key: '_addFullscreenChangeListeners',
+    value: function _addFullscreenChangeListeners() {
       this.fullscreenChangeBind = this._fullscreenChange.bind(this);
       window.addEventListener('fullscreenchange', this.fullscreenChangeBind);
       window.addEventListener('mozfullscreenchange', this.fullscreenChangeBind);
       window.addEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
       window.addEventListener('MSFullscreenChange', this.fullscreenChangeBind);
-    },
-    _removeFullscreenChangeListeners: function PDFPresentationMode_removeFullscreenChangeListeners() {
+    }
+  }, {
+    key: '_removeFullscreenChangeListeners',
+    value: function _removeFullscreenChangeListeners() {
       window.removeEventListener('fullscreenchange', this.fullscreenChangeBind);
       window.removeEventListener('mozfullscreenchange', this.fullscreenChangeBind);
       window.removeEventListener('webkitfullscreenchange', this.fullscreenChangeBind);
       window.removeEventListener('MSFullscreenChange', this.fullscreenChangeBind);
       delete this.fullscreenChangeBind;
     }
-  };
+  }, {
+    key: 'isFullscreen',
+    get: function get() {
+      return !!(document.fullscreenElement || document.mozFullScreen || document.webkitIsFullScreen || document.msFullscreenElement);
+    }
+  }]);
+
   return PDFPresentationMode;
 }();
+
 exports.PDFPresentationMode = PDFPresentationMode;

+ 46 - 21
lib/web/pdf_rendering_queue.js

@@ -17,6 +17,11 @@
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
 var CLEANUP_TIMEOUT = 30000;
 var RenderingStates = {
   INITIAL: 0,
@@ -24,8 +29,11 @@ var RenderingStates = {
   PAUSED: 2,
   FINISHED: 3
 };
-var PDFRenderingQueue = function PDFRenderingQueueClosure() {
+
+var PDFRenderingQueue = function () {
   function PDFRenderingQueue() {
+    _classCallCheck(this, PDFRenderingQueue);
+
     this.pdfViewer = null;
     this.pdfThumbnailViewer = null;
     this.onIdle = null;
@@ -34,17 +42,25 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
     this.printing = false;
     this.isThumbnailViewEnabled = false;
   }
-  PDFRenderingQueue.prototype = {
-    setViewer: function PDFRenderingQueue_setViewer(pdfViewer) {
+
+  _createClass(PDFRenderingQueue, [{
+    key: "setViewer",
+    value: function setViewer(pdfViewer) {
       this.pdfViewer = pdfViewer;
-    },
-    setThumbnailViewer: function PDFRenderingQueue_setThumbnailViewer(pdfThumbnailViewer) {
+    }
+  }, {
+    key: "setThumbnailViewer",
+    value: function setThumbnailViewer(pdfThumbnailViewer) {
       this.pdfThumbnailViewer = pdfThumbnailViewer;
-    },
-    isHighestPriority: function PDFRenderingQueue_isHighestPriority(view) {
+    }
+  }, {
+    key: "isHighestPriority",
+    value: function isHighestPriority(view) {
       return this.highestPriorityPage === view.renderingId;
-    },
-    renderHighestPriority: function PDFRenderingQueue_renderHighestPriority(currentlyVisiblePages) {
+    }
+  }, {
+    key: "renderHighestPriority",
+    value: function renderHighestPriority(currentlyVisiblePages) {
       if (this.idleTimeout) {
         clearTimeout(this.idleTimeout);
         this.idleTimeout = null;
@@ -63,8 +79,10 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
       if (this.onIdle) {
         this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
       }
-    },
-    getHighestPriority: function PDFRenderingQueue_getHighestPriority(visible, views, scrolledDown) {
+    }
+  }, {
+    key: "getHighestPriority",
+    value: function getHighestPriority(visible, views, scrolledDown) {
       var visibleViews = visible.views;
       var numVisible = visibleViews.length;
       if (numVisible === 0) {
@@ -88,13 +106,18 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
         }
       }
       return null;
-    },
-    isViewFinished: function PDFRenderingQueue_isViewFinished(view) {
+    }
+  }, {
+    key: "isViewFinished",
+    value: function isViewFinished(view) {
       return view.renderingState === RenderingStates.FINISHED;
-    },
-    renderView: function PDFRenderingQueue_renderView(view) {
-      var state = view.renderingState;
-      switch (state) {
+    }
+  }, {
+    key: "renderView",
+    value: function renderView(view) {
+      var _this = this;
+
+      switch (view.renderingState) {
         case RenderingStates.FINISHED:
           return false;
         case RenderingStates.PAUSED:
@@ -106,16 +129,18 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
           break;
         case RenderingStates.INITIAL:
           this.highestPriorityPage = view.renderingId;
-          var continueRendering = function () {
-            this.renderHighestPriority();
-          }.bind(this);
+          var continueRendering = function continueRendering() {
+            _this.renderHighestPriority();
+          };
           view.draw().then(continueRendering, continueRendering);
           break;
       }
       return true;
     }
-  };
+  }]);
+
   return PDFRenderingQueue;
 }();
+
 exports.RenderingStates = RenderingStates;
 exports.PDFRenderingQueue = PDFRenderingQueue;

+ 1 - 1
lib/web/pdfjs.js

@@ -20,7 +20,7 @@
     if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
       pdfjsLib = window['pdfjs-dist/build/pdf'];
     } else if (typeof require === 'function') {
-      pdfjsLib = require('../build/pdf.js');
+      pdfjsLib = require('../pdf.js');
     } else {
       throw new Error('Neither `require` nor `window` found');
     }

+ 2 - 2
lib/web/ui_utils.js

@@ -34,7 +34,7 @@ var RendererType = {
   CANVAS: 'canvas',
   SVG: 'svg'
 };
-var mozL10n = document.mozL10n || document.webL10n;
+var mozL10n = typeof document !== 'undefined' ? document.mozL10n || document.webL10n : undefined;
 _pdfjs.PDFJS.disableFullscreen = _pdfjs.PDFJS.disableFullscreen === undefined ? false : _pdfjs.PDFJS.disableFullscreen;
 _pdfjs.PDFJS.useOnlyCssZoom = _pdfjs.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjs.PDFJS.useOnlyCssZoom;
 _pdfjs.PDFJS.maxCanvasPixels = _pdfjs.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjs.PDFJS.maxCanvasPixels;
@@ -42,7 +42,7 @@ _pdfjs.PDFJS.disableHistory = _pdfjs.PDFJS.disableHistory === undefined ? false
 _pdfjs.PDFJS.disableTextLayer = _pdfjs.PDFJS.disableTextLayer === undefined ? false : _pdfjs.PDFJS.disableTextLayer;
 _pdfjs.PDFJS.ignoreCurrentPositionOnZoom = _pdfjs.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjs.PDFJS.ignoreCurrentPositionOnZoom;
 {
-  _pdfjs.PDFJS.locale = _pdfjs.PDFJS.locale === undefined ? navigator.language : _pdfjs.PDFJS.locale;
+  _pdfjs.PDFJS.locale = _pdfjs.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjs.PDFJS.locale;
 }
 function getOutputScale(ctx) {
   var devicePixelRatio = window.devicePixelRatio || 1;

+ 83 - 41
lib/web/view_history.js

@@ -17,45 +17,61 @@
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
 var DEFAULT_VIEW_HISTORY_CACHE_SIZE = 20;
-var ViewHistory = function ViewHistoryClosure() {
-  function ViewHistory(fingerprint, cacheSize) {
+
+var ViewHistory = function () {
+  function ViewHistory(fingerprint) {
+    var _this = this;
+
+    var cacheSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_VIEW_HISTORY_CACHE_SIZE;
+
+    _classCallCheck(this, ViewHistory);
+
     this.fingerprint = fingerprint;
-    this.cacheSize = cacheSize || DEFAULT_VIEW_HISTORY_CACHE_SIZE;
-    this.isInitializedPromiseResolved = false;
-    this.initializedPromise = this._readFromStorage().then(function (databaseStr) {
-      this.isInitializedPromiseResolved = true;
+    this.cacheSize = cacheSize;
+    this._initializedPromise = this._readFromStorage().then(function (databaseStr) {
       var database = JSON.parse(databaseStr || '{}');
       if (!('files' in database)) {
         database.files = [];
       }
-      if (database.files.length >= this.cacheSize) {
+      if (database.files.length >= _this.cacheSize) {
         database.files.shift();
       }
       var index;
       for (var i = 0, length = database.files.length; i < length; i++) {
         var branch = database.files[i];
-        if (branch.fingerprint === this.fingerprint) {
+        if (branch.fingerprint === _this.fingerprint) {
           index = i;
           break;
         }
       }
       if (typeof index !== 'number') {
-        index = database.files.push({ fingerprint: this.fingerprint }) - 1;
+        index = database.files.push({ fingerprint: _this.fingerprint }) - 1;
       }
-      this.file = database.files[index];
-      this.database = database;
-    }.bind(this));
+      _this.file = database.files[index];
+      _this.database = database;
+    });
   }
-  ViewHistory.prototype = {
-    _writeToStorage: function ViewHistory_writeToStorage() {
+
+  _createClass(ViewHistory, [{
+    key: '_writeToStorage',
+    value: function _writeToStorage() {
+      var _this2 = this;
+
       return new Promise(function (resolve) {
-        var databaseStr = JSON.stringify(this.database);
+        var databaseStr = JSON.stringify(_this2.database);
         localStorage.setItem('pdfjs.history', databaseStr);
         resolve();
-      }.bind(this));
-    },
-    _readFromStorage: function ViewHistory_readFromStorage() {
+      });
+    }
+  }, {
+    key: '_readFromStorage',
+    value: function _readFromStorage() {
       return new Promise(function (resolve) {
         var value = localStorage.getItem('pdfjs.history');
         if (!value) {
@@ -73,30 +89,56 @@ var ViewHistory = function ViewHistoryClosure() {
         }
         resolve(value);
       });
-    },
-    set: function ViewHistory_set(name, val) {
-      if (!this.isInitializedPromiseResolved) {
-        return;
-      }
-      this.file[name] = val;
-      return this._writeToStorage();
-    },
-    setMultiple: function ViewHistory_setMultiple(properties) {
-      if (!this.isInitializedPromiseResolved) {
-        return;
-      }
-      for (var name in properties) {
-        this.file[name] = properties[name];
-      }
-      return this._writeToStorage();
-    },
-    get: function ViewHistory_get(name, defaultValue) {
-      if (!this.isInitializedPromiseResolved) {
-        return defaultValue;
-      }
-      return this.file[name] || defaultValue;
     }
-  };
+  }, {
+    key: 'set',
+    value: function set(name, val) {
+      var _this3 = this;
+
+      return this._initializedPromise.then(function () {
+        _this3.file[name] = val;
+        return _this3._writeToStorage();
+      });
+    }
+  }, {
+    key: 'setMultiple',
+    value: function setMultiple(properties) {
+      var _this4 = this;
+
+      return this._initializedPromise.then(function () {
+        for (var name in properties) {
+          _this4.file[name] = properties[name];
+        }
+        return _this4._writeToStorage();
+      });
+    }
+  }, {
+    key: 'get',
+    value: function get(name, defaultValue) {
+      var _this5 = this;
+
+      return this._initializedPromise.then(function () {
+        var val = _this5.file[name];
+        return val !== undefined ? val : defaultValue;
+      });
+    }
+  }, {
+    key: 'getMultiple',
+    value: function getMultiple(properties) {
+      var _this6 = this;
+
+      return this._initializedPromise.then(function () {
+        var values = Object.create(null);
+        for (var name in properties) {
+          var val = _this6.file[name];
+          values[name] = val !== undefined ? val : properties[name];
+        }
+        return values;
+      });
+    }
+  }]);
+
   return ViewHistory;
 }();
+
 exports.ViewHistory = ViewHistory;

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.8.254",
+  "version": "1.8.271",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

+ 8 - 0
web/compatibility.js

@@ -227,6 +227,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -234,6 +235,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       get: function get() {
         return this.length;
       },
+
       enumerable: false,
       configurable: true
     });
@@ -422,6 +424,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return dataset;
       },
+
       enumerable: true
     });
   })();
@@ -482,6 +485,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         });
         return classList;
       },
+
       enumerable: true
     });
   })();
@@ -682,6 +686,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         var scripts = document.getElementsByTagName('script');
         return scripts[scripts.length - 1];
       },
+
       enumerable: true,
       configurable: true
     });
@@ -703,6 +708,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
         set: function set(value) {
           typeProperty.set.call(this, value === 'number' ? 'text' : value);
         },
+
         enumerable: true,
         configurable: true
       });
@@ -725,6 +731,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       set: function set(value) {
         readyStateProto.set.call(this, value);
       },
+
       enumerable: true,
       configurable: true
     });
@@ -1458,6 +1465,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.compatibilityChecked) {
       toString: function toString() {
         return this.href;
       },
+
       get href() {
         if (this._isInvalid) {
           return this._url;

+ 105 - 56
web/pdf_viewer.js

@@ -139,7 +139,7 @@ var RendererType = {
   CANVAS: 'canvas',
   SVG: 'svg'
 };
-var mozL10n = document.mozL10n || document.webL10n;
+var mozL10n = typeof document !== 'undefined' ? document.mozL10n || document.webL10n : undefined;
 _pdfjs.PDFJS.disableFullscreen = _pdfjs.PDFJS.disableFullscreen === undefined ? false : _pdfjs.PDFJS.disableFullscreen;
 _pdfjs.PDFJS.useOnlyCssZoom = _pdfjs.PDFJS.useOnlyCssZoom === undefined ? false : _pdfjs.PDFJS.useOnlyCssZoom;
 _pdfjs.PDFJS.maxCanvasPixels = _pdfjs.PDFJS.maxCanvasPixels === undefined ? 16777216 : _pdfjs.PDFJS.maxCanvasPixels;
@@ -147,7 +147,7 @@ _pdfjs.PDFJS.disableHistory = _pdfjs.PDFJS.disableHistory === undefined ? false
 _pdfjs.PDFJS.disableTextLayer = _pdfjs.PDFJS.disableTextLayer === undefined ? false : _pdfjs.PDFJS.disableTextLayer;
 _pdfjs.PDFJS.ignoreCurrentPositionOnZoom = _pdfjs.PDFJS.ignoreCurrentPositionOnZoom === undefined ? false : _pdfjs.PDFJS.ignoreCurrentPositionOnZoom;
 {
-  _pdfjs.PDFJS.locale = _pdfjs.PDFJS.locale === undefined ? navigator.language : _pdfjs.PDFJS.locale;
+  _pdfjs.PDFJS.locale = _pdfjs.PDFJS.locale === undefined && typeof navigator !== 'undefined' ? navigator.language : _pdfjs.PDFJS.locale;
 }
 function getOutputScale(ctx) {
   var devicePixelRatio = window.devicePixelRatio || 1;
@@ -996,14 +996,20 @@ Object.defineProperty(exports, "__esModule", {
 });
 exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = undefined;
 
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
 var _pdfjs = __w_pdfjs_require__(0);
 
 var _ui_utils = __w_pdfjs_require__(1);
 
 var _pdf_link_service = __w_pdfjs_require__(3);
 
-var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+var AnnotationLayerBuilder = function () {
   function AnnotationLayerBuilder(options) {
+    _classCallCheck(this, AnnotationLayerBuilder);
+
     this.pageDiv = options.pageDiv;
     this.pdfPage = options.pdfPage;
     this.renderInteractiveForms = options.renderInteractiveForms;
@@ -1011,58 +1017,76 @@ var AnnotationLayerBuilder = function AnnotationLayerBuilderClosure() {
     this.downloadManager = options.downloadManager;
     this.div = null;
   }
-  AnnotationLayerBuilder.prototype = {
-    render: function AnnotationLayerBuilder_render(viewport, intent) {
-      var self = this;
-      var parameters = { intent: intent === undefined ? 'display' : intent };
-      this.pdfPage.getAnnotations(parameters).then(function (annotations) {
-        viewport = viewport.clone({ dontFlip: true });
-        parameters = {
-          viewport: viewport,
-          div: self.div,
+
+  _createClass(AnnotationLayerBuilder, [{
+    key: 'render',
+    value: function render(viewport) {
+      var _this = this;
+
+      var intent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'display';
+
+      this.pdfPage.getAnnotations({ intent: intent }).then(function (annotations) {
+        var parameters = {
+          viewport: viewport.clone({ dontFlip: true }),
+          div: _this.div,
           annotations: annotations,
-          page: self.pdfPage,
-          renderInteractiveForms: self.renderInteractiveForms,
-          linkService: self.linkService,
-          downloadManager: self.downloadManager
+          page: _this.pdfPage,
+          renderInteractiveForms: _this.renderInteractiveForms,
+          linkService: _this.linkService,
+          downloadManager: _this.downloadManager
         };
-        if (self.div) {
+        if (_this.div) {
           _pdfjs.AnnotationLayer.update(parameters);
         } else {
           if (annotations.length === 0) {
             return;
           }
-          self.div = document.createElement('div');
-          self.div.className = 'annotationLayer';
-          self.pageDiv.appendChild(self.div);
-          parameters.div = self.div;
+          _this.div = document.createElement('div');
+          _this.div.className = 'annotationLayer';
+          _this.pageDiv.appendChild(_this.div);
+          parameters.div = _this.div;
           _pdfjs.AnnotationLayer.render(parameters);
           if (typeof _ui_utils.mozL10n !== 'undefined') {
-            _ui_utils.mozL10n.translate(self.div);
+            _ui_utils.mozL10n.translate(_this.div);
           }
         }
       });
-    },
-    hide: function AnnotationLayerBuilder_hide() {
+    }
+  }, {
+    key: 'hide',
+    value: function hide() {
       if (!this.div) {
         return;
       }
       this.div.setAttribute('hidden', 'true');
     }
-  };
+  }]);
+
   return AnnotationLayerBuilder;
 }();
-function DefaultAnnotationLayerFactory() {}
-DefaultAnnotationLayerFactory.prototype = {
-  createAnnotationLayerBuilder: function createAnnotationLayerBuilder(pageDiv, pdfPage, renderInteractiveForms) {
-    return new AnnotationLayerBuilder({
-      pageDiv: pageDiv,
-      pdfPage: pdfPage,
-      renderInteractiveForms: renderInteractiveForms,
-      linkService: new _pdf_link_service.SimpleLinkService()
-    });
+
+var DefaultAnnotationLayerFactory = function () {
+  function DefaultAnnotationLayerFactory() {
+    _classCallCheck(this, DefaultAnnotationLayerFactory);
   }
-};
+
+  _createClass(DefaultAnnotationLayerFactory, [{
+    key: 'createAnnotationLayerBuilder',
+    value: function createAnnotationLayerBuilder(pageDiv, pdfPage) {
+      var renderInteractiveForms = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
+
+      return new AnnotationLayerBuilder({
+        pageDiv: pageDiv,
+        pdfPage: pdfPage,
+        renderInteractiveForms: renderInteractiveForms,
+        linkService: new _pdf_link_service.SimpleLinkService()
+      });
+    }
+  }]);
+
+  return DefaultAnnotationLayerFactory;
+}();
+
 exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
 exports.DefaultAnnotationLayerFactory = DefaultAnnotationLayerFactory;
 
@@ -1846,6 +1870,11 @@ exports.DefaultTextLayerFactory = DefaultTextLayerFactory;
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+
+var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
 var CLEANUP_TIMEOUT = 30000;
 var RenderingStates = {
   INITIAL: 0,
@@ -1853,8 +1882,11 @@ var RenderingStates = {
   PAUSED: 2,
   FINISHED: 3
 };
-var PDFRenderingQueue = function PDFRenderingQueueClosure() {
+
+var PDFRenderingQueue = function () {
   function PDFRenderingQueue() {
+    _classCallCheck(this, PDFRenderingQueue);
+
     this.pdfViewer = null;
     this.pdfThumbnailViewer = null;
     this.onIdle = null;
@@ -1863,17 +1895,25 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
     this.printing = false;
     this.isThumbnailViewEnabled = false;
   }
-  PDFRenderingQueue.prototype = {
-    setViewer: function PDFRenderingQueue_setViewer(pdfViewer) {
+
+  _createClass(PDFRenderingQueue, [{
+    key: "setViewer",
+    value: function setViewer(pdfViewer) {
       this.pdfViewer = pdfViewer;
-    },
-    setThumbnailViewer: function PDFRenderingQueue_setThumbnailViewer(pdfThumbnailViewer) {
+    }
+  }, {
+    key: "setThumbnailViewer",
+    value: function setThumbnailViewer(pdfThumbnailViewer) {
       this.pdfThumbnailViewer = pdfThumbnailViewer;
-    },
-    isHighestPriority: function PDFRenderingQueue_isHighestPriority(view) {
+    }
+  }, {
+    key: "isHighestPriority",
+    value: function isHighestPriority(view) {
       return this.highestPriorityPage === view.renderingId;
-    },
-    renderHighestPriority: function PDFRenderingQueue_renderHighestPriority(currentlyVisiblePages) {
+    }
+  }, {
+    key: "renderHighestPriority",
+    value: function renderHighestPriority(currentlyVisiblePages) {
       if (this.idleTimeout) {
         clearTimeout(this.idleTimeout);
         this.idleTimeout = null;
@@ -1892,8 +1932,10 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
       if (this.onIdle) {
         this.idleTimeout = setTimeout(this.onIdle.bind(this), CLEANUP_TIMEOUT);
       }
-    },
-    getHighestPriority: function PDFRenderingQueue_getHighestPriority(visible, views, scrolledDown) {
+    }
+  }, {
+    key: "getHighestPriority",
+    value: function getHighestPriority(visible, views, scrolledDown) {
       var visibleViews = visible.views;
       var numVisible = visibleViews.length;
       if (numVisible === 0) {
@@ -1917,13 +1959,18 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
         }
       }
       return null;
-    },
-    isViewFinished: function PDFRenderingQueue_isViewFinished(view) {
+    }
+  }, {
+    key: "isViewFinished",
+    value: function isViewFinished(view) {
       return view.renderingState === RenderingStates.FINISHED;
-    },
-    renderView: function PDFRenderingQueue_renderView(view) {
-      var state = view.renderingState;
-      switch (state) {
+    }
+  }, {
+    key: "renderView",
+    value: function renderView(view) {
+      var _this = this;
+
+      switch (view.renderingState) {
         case RenderingStates.FINISHED:
           return false;
         case RenderingStates.PAUSED:
@@ -1935,17 +1982,19 @@ var PDFRenderingQueue = function PDFRenderingQueueClosure() {
           break;
         case RenderingStates.INITIAL:
           this.highestPriorityPage = view.renderingId;
-          var continueRendering = function () {
-            this.renderHighestPriority();
-          }.bind(this);
+          var continueRendering = function continueRendering() {
+            _this.renderHighestPriority();
+          };
           view.draw().then(continueRendering, continueRendering);
           break;
       }
       return true;
     }
-  };
+  }]);
+
   return PDFRenderingQueue;
 }();
+
 exports.RenderingStates = RenderingStates;
 exports.PDFRenderingQueue = PDFRenderingQueue;
 

Some files were not shown because too many files changed in this diff