Bug 1313555 - Update pdf.js to version 1.6.274. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 27 Oct 2016 23:20:49 -0400
changeset 319918 4e6fc3d814dbf407d3153977b67c743fd8b420ba
parent 319917 ee0568282adc0d6cddf74c3e635568145d5a987d
child 319919 2190ea5fc2d0f31aaf1bf9f522f6a0cd67300da8
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1313555
milestone52.0a1
Bug 1313555 - Update pdf.js to version 1.6.274. r=bdahl
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.js
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,3 +1,3 @@
 This is the pdf.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 1.6.263
+Current extension version is: 1.6.274
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -19,18 +19,18 @@
   } else if (typeof exports !== 'undefined') {
     factory(exports);
   } else {
     factory(root['pdfjsDistBuildPdf'] = {});
   }
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.263';
-  var pdfjsBuild = '7e392c0';
+  var pdfjsVersion = '1.6.274';
+  var pdfjsBuild = '1c3fb17';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
     (function (root, factory) {
       factory(root.pdfjsSharedUtil = {});
     }(this, function (exports) {
       var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
       var FONT_IDENTITY_MATRIX = [
@@ -2226,17 +2226,17 @@
             addLinkAttributes(link, {
               url: this.data.url,
               target: this.data.newWindow ? LinkTarget.BLANK : undefined
             });
             if (!this.data.url) {
               if (this.data.action) {
                 this._bindNamedAction(link, this.data.action);
               } else {
-                this._bindLink(link, this.data.dest || null);
+                this._bindLink(link, this.data.dest);
               }
             }
             this.container.appendChild(link);
             return this.container;
           },
           /**
            * Bind internal links to the link element.
            *
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -19,18 +19,18 @@
   } else if (typeof exports !== 'undefined') {
     factory(exports);
   } else {
     factory(root['pdfjsDistBuildPdfWorker'] = {});
   }
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.263';
-  var pdfjsBuild = '7e392c0';
+  var pdfjsVersion = '1.6.274';
+  var pdfjsBuild = '1c3fb17';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
     (function (root, factory) {
       factory(root.pdfjsCoreArithmeticDecoder = {});
     }(this, function (exports) {
       /* This class implements the QM Coder decoding as defined in
        *   JPEG 2000 Part I Final Committee Draft Version 1.0
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -954,20 +954,22 @@ var pdfjsWebLibs;
           _bindLink: function PDFOutlineViewer_bindLink(element, item) {
             if (item.url) {
               pdfjsLib.addLinkAttributes(element, {
                 url: item.url,
                 target: item.newWindow ? PDFJS.LinkTarget.BLANK : undefined
               });
               return;
             }
-            var linkService = this.linkService;
-            element.href = linkService.getDestinationHash(item.dest);
-            element.onclick = function goToDestination(e) {
-              linkService.navigateTo(item.dest);
+            var self = this, destination = item.dest;
+            element.href = self.linkService.getDestinationHash(destination);
+            element.onclick = function () {
+              if (destination) {
+                self.linkService.navigateTo(destination);
+              }
               return false;
             };
           },
           /**
            * @private
            */
           _setStyles: function PDFOutlineViewer_setStyles(element, item) {
             var styleStr = '';
@@ -4179,56 +4181,66 @@ var pdfjsWebLibs;
           /**
            * @param dest - The PDF destination object.
            */
           navigateTo: function PDFLinkService_navigateTo(dest) {
             var destString = '';
             var self = this;
             var goToDestination = function (destRef) {
               // dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
-              var pageNumber = destRef instanceof Object ? self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : destRef + 1;
+              var pageNumber;
+              if (destRef instanceof Object) {
+                pageNumber = self._cachedPageNumber(destRef);
+              } else if ((destRef | 0) === destRef) {
+                // Integer
+                pageNumber = destRef + 1;
+              } else {
+                console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid destination reference.');
+                return;
+              }
               if (pageNumber) {
-                if (pageNumber > self.pagesCount) {
-                  console.error('PDFLinkService_navigateTo: ' + 'Trying to navigate to a non-existent page.');
+                if (pageNumber < 1 || pageNumber > self.pagesCount) {
+                  console.error('PDFLinkService_navigateTo: "' + pageNumber + '" is a non-existent page number.');
                   return;
                 }
                 self.pdfViewer.scrollPageIntoView({
                   pageNumber: pageNumber,
                   destArray: dest
                 });
                 if (self.pdfHistory) {
                   // Update the browsing history.
                   self.pdfHistory.push({
                     dest: dest,
                     hash: destString,
                     page: pageNumber
                   });
                 }
               } else {
                 self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
-                  var pageNum = pageIndex + 1;
-                  var cacheKey = destRef.num + ' ' + destRef.gen + ' R';
-                  self._pagesRefCache[cacheKey] = pageNum;
+                  self.cachePageRef(pageIndex + 1, destRef);
                   goToDestination(destRef);
+                }).catch(function () {
+                  console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid page reference.');
+                  return;
                 });
               }
             };
             var destinationPromise;
             if (typeof dest === 'string') {
               destString = dest;
               destinationPromise = this.pdfDocument.getDestination(dest);
             } else {
               destinationPromise = Promise.resolve(dest);
             }
             destinationPromise.then(function (destination) {
               dest = destination;
               if (!(destination instanceof Array)) {
+                console.error('PDFLinkService_navigateTo: "' + destination + '" is not a valid destination array.');
                 return;
               }
-              // invalid destination
               goToDestination(destination[0]);
             });
           },
           /**
            * @param dest - The PDF destination object.
            * @returns {string} The hyperlink to the PDF object.
            */
           getDestinationHash: function PDFLinkService_getDestinationHash(dest) {
@@ -4335,24 +4347,25 @@ var pdfjsWebLibs;
               }
               // simple page
               if ('pagemode' in params) {
                 this.eventBus.dispatch('pagemode', {
                   source: this,
                   mode: params.pagemode
                 });
               }
-            } else if (isPageNumber(hash)) {
-              // Page number.
-              this.page = hash | 0;
             } else {
-              // Named (or explicit) destination.
               dest = unescape(hash);
               try {
                 dest = JSON.parse(dest);
+                if (!(dest instanceof Array)) {
+                  // Avoid incorrectly rejecting a valid named destination, such as
+                  // e.g. "4.3" or "true", because `JSON.parse` converted its type.
+                  dest = dest.toString();
+                }
               } catch (ex) {
               }
               if (typeof dest === 'string' || isValidExplicitDestination(dest)) {
                 if (this.pdfHistory) {
                   this.pdfHistory.updateNextHashParam(dest);
                 }
                 this.navigateTo(dest);
                 return;
@@ -4403,16 +4416,20 @@ var pdfjsWebLibs;
           },
           /**
            * @param {number} pageNum - page number.
            * @param {Object} pageRef - reference to the page.
            */
           cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) {
             var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
             this._pagesRefCache[refStr] = pageNum;
+          },
+          _cachedPageNumber: function PDFLinkService_cachedPageNumber(pageRef) {
+            var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
+            return this._pagesRefCache && this._pagesRefCache[refStr] || null;
           }
         };
         function isValidExplicitDestination(dest) {
           if (!(dest instanceof Array)) {
             return false;
           }
           var destLength = dest.length, allowNull = true;
           if (destLength < 2) {