Bug 1389211 - Update pdf.js to version 1.8.618. r=bdahl, a=gchang
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 10 Aug 2017 15:13:44 -0400
changeset 423543 5fbb7413a6d4ec3aba41acf456d3efaeed02ce24
parent 423542 d6f0fac3ee72018bd9049bc9c663225fde62d2fe
child 423544 5ee15d0b8f882d0f34d4aebd88fdc8bc9fd1316d
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl, gchang
bugs1389211
milestone56.0
Bug 1389211 - Update pdf.js to version 1.8.618. r=bdahl, a=gchang
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,5 +1,5 @@
 This is the PDF.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 1.8.605
+Current extension version is: 1.8.618
 
-Taken from upstream commit: ace9de6f
+Taken from upstream commit: 21cc2c02
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -3821,18 +3821,18 @@ var _UnsupportedManager = function Unsup
       for (var i = 0, ii = listeners.length; i < ii; i++) {
         listeners[i](featureId);
       }
     }
   };
 }();
 var version, build;
 {
-  exports.version = version = '1.8.605';
-  exports.build = build = 'ace9de6f';
+  exports.version = version = '1.8.618';
+  exports.build = build = '21cc2c02';
 }
 exports.getDocument = getDocument;
 exports.LoopbackPort = LoopbackPort;
 exports.PDFDataRangeTransport = PDFDataRangeTransport;
 exports.PDFWorker = PDFWorker;
 exports.PDFDocumentProxy = PDFDocumentProxy;
 exports.PDFPageProxy = PDFPageProxy;
 exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
@@ -4872,18 +4872,18 @@ var _text_layer = __w_pdfjs_require__(5)
 var _svg = __w_pdfjs_require__(4);
 
 var isWorker = typeof window === 'undefined';
 if (!_util.globalScope.PDFJS) {
   _util.globalScope.PDFJS = {};
 }
 var PDFJS = _util.globalScope.PDFJS;
 {
-  PDFJS.version = '1.8.605';
-  PDFJS.build = 'ace9de6f';
+  PDFJS.version = '1.8.618';
+  PDFJS.build = '21cc2c02';
 }
 PDFJS.pdfBug = false;
 if (PDFJS.verbosity !== undefined) {
   (0, _util.setVerbosityLevel)(PDFJS.verbosity);
 }
 delete PDFJS.verbosity;
 Object.defineProperty(PDFJS, 'verbosity', {
   get() {
@@ -10439,18 +10439,18 @@ exports.PDFDataTransportStream = PDFData
 
 /***/ }),
 /* 14 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '1.8.605';
-var pdfjsBuild = 'ace9de6f';
+var pdfjsVersion = '1.8.618';
+var pdfjsBuild = '21cc2c02';
 var pdfjsSharedUtil = __w_pdfjs_require__(0);
 var pdfjsDisplayGlobal = __w_pdfjs_require__(8);
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(5);
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(2);
 var pdfjsDisplayDOMUtils = __w_pdfjs_require__(1);
 var pdfjsDisplaySVG = __w_pdfjs_require__(4);
 ;
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -17315,19 +17315,16 @@ var PartialEvaluator = function PartialE
           operation.args = null;
           if (!preprocessor.read(operation)) {
             break;
           }
           var args = operation.args;
           var fn = operation.fn;
           switch (fn | 0) {
             case _util.OPS.paintXObject:
-              if (args[0].code) {
-                break;
-              }
               var name = args[0].name;
               if (!name) {
                 (0, _util.warn)('XObject must be referred to by name.');
                 continue;
               }
               if (imageCache[name] !== undefined) {
                 operatorList.addOp(imageCache[name].fn, imageCache[name].args);
                 args = null;
@@ -17899,19 +17896,16 @@ var PartialEvaluator = function PartialE
               flushTextContentItem();
               textState.wordSpacing = args[0];
               textState.charSpacing = args[1];
               textState.carriageReturn();
               buildTextContentItem(args[2]);
               break;
             case _util.OPS.paintXObject:
               flushTextContentItem();
-              if (args[0].code) {
-                break;
-              }
               if (!xobjs) {
                 xobjs = resources.get('XObject') || _primitives.Dict.empty;
               }
               var name = args[0].name;
               if (name in skipEmptyXObjs) {
                 break;
               }
               var xobj = xobjs.get(name);
@@ -18535,17 +18529,17 @@ var PartialEvaluator = function PartialE
         lastChar: lastChar || maxCharIndex,
         bbox: descriptor.getArray('FontBBox'),
         ascent: descriptor.get('Ascent'),
         descent: descriptor.get('Descent'),
         xHeight: descriptor.get('XHeight'),
         capHeight: descriptor.get('CapHeight'),
         flags: descriptor.get('Flags'),
         italicAngle: descriptor.get('ItalicAngle'),
-        coded: false
+        isType3Font: false
       };
       var cMapPromise;
       if (composite) {
         var cidEncoding = baseDict.get('Encoding');
         if ((0, _primitives.isName)(cidEncoding)) {
           properties.cidEncoding = cidEncoding.name;
         }
         cMapPromise = _cmap.CMapFactory.create({
@@ -39884,18 +39878,18 @@ exports.Type1Parser = Type1Parser;
 
 /***/ }),
 /* 35 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '1.8.605';
-var pdfjsBuild = 'ace9de6f';
+var pdfjsVersion = '1.8.618';
+var pdfjsBuild = '21cc2c02';
 var pdfjsCoreWorker = __w_pdfjs_require__(17);
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 36 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -532,111 +532,111 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.getGlobalEventBus = exports.attachDOMEventsToEventBus = undefined;
 
 var _ui_utils = __webpack_require__(0);
 
 function attachDOMEventsToEventBus(eventBus) {
   eventBus.on('documentload', function () {
-    var event = document.createEvent('CustomEvent');
+    let event = document.createEvent('CustomEvent');
     event.initCustomEvent('documentload', true, true, {});
     window.dispatchEvent(event);
   });
-  eventBus.on('pagerendered', function (e) {
-    var event = document.createEvent('CustomEvent');
+  eventBus.on('pagerendered', function (evt) {
+    let event = document.createEvent('CustomEvent');
     event.initCustomEvent('pagerendered', true, true, {
-      pageNumber: e.pageNumber,
-      cssTransform: e.cssTransform
-    });
-    e.source.div.dispatchEvent(event);
+      pageNumber: evt.pageNumber,
+      cssTransform: evt.cssTransform
+    });
+    evt.source.div.dispatchEvent(event);
   });
-  eventBus.on('textlayerrendered', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('textlayerrendered', true, true, { pageNumber: e.pageNumber });
-    e.source.textLayerDiv.dispatchEvent(event);
+  eventBus.on('textlayerrendered', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('textlayerrendered', true, true, { pageNumber: evt.pageNumber });
+    evt.source.textLayerDiv.dispatchEvent(event);
   });
-  eventBus.on('pagechange', function (e) {
-    var event = document.createEvent('UIEvents');
+  eventBus.on('pagechange', function (evt) {
+    let event = document.createEvent('UIEvents');
     event.initUIEvent('pagechange', true, true, window, 0);
-    event.pageNumber = e.pageNumber;
-    e.source.container.dispatchEvent(event);
+    event.pageNumber = evt.pageNumber;
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('pagesinit', function (e) {
-    var event = document.createEvent('CustomEvent');
+  eventBus.on('pagesinit', function (evt) {
+    let event = document.createEvent('CustomEvent');
     event.initCustomEvent('pagesinit', true, true, null);
-    e.source.container.dispatchEvent(event);
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('pagesloaded', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('pagesloaded', true, true, { pagesCount: e.pagesCount });
-    e.source.container.dispatchEvent(event);
+  eventBus.on('pagesloaded', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('pagesloaded', true, true, { pagesCount: evt.pagesCount });
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('scalechange', function (e) {
-    var event = document.createEvent('UIEvents');
+  eventBus.on('scalechange', function (evt) {
+    let event = document.createEvent('UIEvents');
     event.initUIEvent('scalechange', true, true, window, 0);
-    event.scale = e.scale;
-    event.presetValue = e.presetValue;
-    e.source.container.dispatchEvent(event);
+    event.scale = evt.scale;
+    event.presetValue = evt.presetValue;
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('updateviewarea', function (e) {
-    var event = document.createEvent('UIEvents');
+  eventBus.on('updateviewarea', function (evt) {
+    let event = document.createEvent('UIEvents');
     event.initUIEvent('updateviewarea', true, true, window, 0);
-    event.location = e.location;
-    e.source.container.dispatchEvent(event);
+    event.location = evt.location;
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('find', function (e) {
-    if (e.source === window) {
+  eventBus.on('find', function (evt) {
+    if (evt.source === window) {
       return;
     }
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('find' + e.type, true, true, {
-      query: e.query,
-      phraseSearch: e.phraseSearch,
-      caseSensitive: e.caseSensitive,
-      highlightAll: e.highlightAll,
-      findPrevious: e.findPrevious
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('find' + evt.type, true, true, {
+      query: evt.query,
+      phraseSearch: evt.phraseSearch,
+      caseSensitive: evt.caseSensitive,
+      highlightAll: evt.highlightAll,
+      findPrevious: evt.findPrevious
     });
     window.dispatchEvent(event);
   });
-  eventBus.on('attachmentsloaded', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: e.attachmentsCount });
-    e.source.container.dispatchEvent(event);
+  eventBus.on('attachmentsloaded', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('attachmentsloaded', true, true, { attachmentsCount: evt.attachmentsCount });
+    evt.source.container.dispatchEvent(event);
   });
-  eventBus.on('sidebarviewchanged', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('sidebarviewchanged', true, true, { view: e.view });
-    e.source.outerContainer.dispatchEvent(event);
+  eventBus.on('sidebarviewchanged', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('sidebarviewchanged', true, true, { view: evt.view });
+    evt.source.outerContainer.dispatchEvent(event);
   });
-  eventBus.on('pagemode', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('pagemode', true, true, { mode: e.mode });
-    e.source.pdfViewer.container.dispatchEvent(event);
+  eventBus.on('pagemode', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('pagemode', true, true, { mode: evt.mode });
+    evt.source.pdfViewer.container.dispatchEvent(event);
   });
-  eventBus.on('namedaction', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('namedaction', true, true, { action: e.action });
-    e.source.pdfViewer.container.dispatchEvent(event);
+  eventBus.on('namedaction', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('namedaction', true, true, { action: evt.action });
+    evt.source.pdfViewer.container.dispatchEvent(event);
   });
-  eventBus.on('presentationmodechanged', function (e) {
-    var event = document.createEvent('CustomEvent');
+  eventBus.on('presentationmodechanged', function (evt) {
+    let event = document.createEvent('CustomEvent');
     event.initCustomEvent('presentationmodechanged', true, true, {
-      active: e.active,
-      switchInProgress: e.switchInProgress
+      active: evt.active,
+      switchInProgress: evt.switchInProgress
     });
     window.dispatchEvent(event);
   });
-  eventBus.on('outlineloaded', function (e) {
-    var event = document.createEvent('CustomEvent');
-    event.initCustomEvent('outlineloaded', true, true, { outlineCount: e.outlineCount });
-    e.source.container.dispatchEvent(event);
+  eventBus.on('outlineloaded', function (evt) {
+    let event = document.createEvent('CustomEvent');
+    event.initCustomEvent('outlineloaded', true, true, { outlineCount: evt.outlineCount });
+    evt.source.container.dispatchEvent(event);
   });
 }
-var globalEventBus = null;
+let globalEventBus = null;
 function getGlobalEventBus() {
   if (globalEventBus) {
     return globalEventBus;
   }
   globalEventBus = new _ui_utils.EventBus();
   attachDOMEventsToEventBus(globalEventBus);
   return globalEventBus;
 }
@@ -2978,16 +2978,20 @@ class PDFFindController {
         return this.pdfViewer.getPageTextContent(i).then(textContent => {
           let textItems = textContent.items;
           let strBuf = [];
           for (let j = 0, jj = textItems.length; j < jj; j++) {
             strBuf.push(textItems[j].str);
           }
           this.pageContents[i] = strBuf.join('');
           extractTextCapability.resolve(i);
+        }, reason => {
+          console.error(`Unable to get page ${i + 1} text content`, reason);
+          this.pageContents[i] = '';
+          extractTextCapability.resolve(i);
         });
       });
     }
   }
   executeCommand(cmd, state) {
     if (this.state === null || cmd !== 'findagain') {
       this.dirtyMatch = true;
     }
@@ -4876,16 +4880,17 @@ var _dom_events = __webpack_require__(2)
 var _pdf_rendering_queue = __webpack_require__(3);
 
 class PDFPageView {
   constructor(options) {
     let container = options.container;
     let defaultViewport = options.defaultViewport;
     this.id = options.id;
     this.renderingId = 'page' + this.id;
+    this.pdfPage = null;
     this.pageLabel = null;
     this.rotation = 0;
     this.scale = options.scale || _ui_utils.DEFAULT_SCALE;
     this.viewport = defaultViewport;
     this.pdfPageRotate = defaultViewport.rotation;
     this.hasRestrictedScaling = false;
     this.enhanceTextSelection = options.enhanceTextSelection || false;
     this.renderInteractiveForms = options.renderInteractiveForms || false;
@@ -4920,16 +4925,17 @@ class PDFPageView {
     this.viewport = pdfPage.getViewport(this.scale * _ui_utils.CSS_UNITS, totalRotation);
     this.stats = pdfPage.stats;
     this.reset();
   }
   destroy() {
     this.reset();
     if (this.pdfPage) {
       this.pdfPage.cleanup();
+      this.pdfPage = null;
     }
   }
   _resetZoomLayer(removeFromDOM = false) {
     if (!this.zoomLayer) {
       return;
     }
     let zoomLayerCanvas = this.zoomLayer.firstChild;
     this.paintedViewportMap.delete(zoomLayerCanvas);
@@ -5098,16 +5104,20 @@ class PDFPageView {
   getPagePoint(x, y) {
     return this.viewport.convertToPdfPoint(x, y);
   }
   draw() {
     if (this.renderingState !== _pdf_rendering_queue.RenderingStates.INITIAL) {
       console.error('Must be in new state before drawing');
       this.reset();
     }
+    if (!this.pdfPage) {
+      this.renderingState = _pdf_rendering_queue.RenderingStates.FINISHED;
+      return Promise.reject(new Error('Page is not loaded'));
+    }
     this.renderingState = _pdf_rendering_queue.RenderingStates.RUNNING;
     let pdfPage = this.pdfPage;
     let div = this.div;
     let canvasWrapper = document.createElement('div');
     canvasWrapper.style.width = div.style.width;
     canvasWrapper.style.height = div.style.height;
     canvasWrapper.classList.add('canvasWrapper');
     if (this.annotationLayer && this.annotationLayer.div) {
@@ -6297,33 +6307,35 @@ class PDFThumbnailViewer {
   }
   setDocument(pdfDocument) {
     if (this.pdfDocument) {
       this._cancelRendering();
       this._resetView();
     }
     this.pdfDocument = pdfDocument;
     if (!pdfDocument) {
-      return Promise.resolve();
-    }
-    return pdfDocument.getPage(1).then(firstPage => {
+      return;
+    }
+    pdfDocument.getPage(1).then(firstPage => {
       let pagesCount = pdfDocument.numPages;
       let viewport = firstPage.getViewport(1.0);
       for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
         let thumbnail = new _pdf_thumbnail_view.PDFThumbnailView({
           container: this.container,
           id: pageNum,
           defaultViewport: viewport.clone(),
           linkService: this.linkService,
           renderingQueue: this.renderingQueue,
           disableCanvasToImageConversion: false,
           l10n: this.l10n
         });
         this._thumbnails.push(thumbnail);
       }
+    }).catch(reason => {
+      console.error('Unable to initialize thumbnail viewer', reason);
     });
   }
   _cancelRendering() {
     for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
       if (this._thumbnails[i]) {
         this._thumbnails[i].cancelRendering();
       }
     }
@@ -6352,16 +6364,19 @@ class PDFThumbnailViewer {
     let pageNumber = thumbView.id;
     if (this._pagesRequests[pageNumber]) {
       return this._pagesRequests[pageNumber];
     }
     let promise = this.pdfDocument.getPage(pageNumber).then(pdfPage => {
       thumbView.setPdfPage(pdfPage);
       this._pagesRequests[pageNumber] = null;
       return pdfPage;
+    }).catch(reason => {
+      console.error('Unable to get page for thumb view', reason);
+      this._pagesRequests[pageNumber] = null;
     });
     this._pagesRequests[pageNumber] = promise;
     return promise;
   }
   forceRendering() {
     let visibleThumbs = this._getVisibleThumbs();
     let thumbView = this.renderingQueue.getHighestPriority(visibleThumbs, this._thumbnails, this.scroll.down);
     if (thumbView) {
@@ -6596,17 +6611,17 @@ class PDFViewer {
         if (!isOnePageRenderedResolved) {
           isOnePageRenderedResolved = true;
           onePageRenderedCapability.resolve();
         }
       };
     };
     let firstPagePromise = pdfDocument.getPage(1);
     this.firstPagePromise = firstPagePromise;
-    return firstPagePromise.then(pdfPage => {
+    firstPagePromise.then(pdfPage => {
       let scale = this.currentScale;
       let viewport = pdfPage.getViewport(scale * _ui_utils.CSS_UNITS);
       for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
         let textLayerFactory = null;
         if (!_pdfjsLib.PDFJS.disableTextLayer) {
           textLayerFactory = this;
         }
         let pageView = new _pdf_page_view.PDFPageView({
@@ -6637,26 +6652,33 @@ class PDFViewer {
             let pageView = this._pages[pageNum - 1];
             if (!pageView.pdfPage) {
               pageView.setPdfPage(pdfPage);
             }
             this.linkService.cachePageRef(pageNum, pdfPage.ref);
             if (--getPagesLeft === 0) {
               pagesCapability.resolve();
             }
+          }, reason => {
+            console.error(`Unable to get page ${pageNum} to initialize viewer`, reason);
+            if (--getPagesLeft === 0) {
+              pagesCapability.resolve();
+            }
           });
         }
       });
       this.eventBus.dispatch('pagesinit', { source: this });
       if (this.defaultRenderingQueue) {
         this.update();
       }
       if (this.findController) {
         this.findController.resolveFirstPage();
       }
+    }).catch(reason => {
+      console.error('Unable to initialize viewer', reason);
     });
   }
   setPageLabels(labels) {
     if (!this.pdfDocument) {
       return;
     }
     if (!labels) {
       this._pageLabels = null;
@@ -6974,16 +6996,19 @@ class PDFViewer {
       return this._pagesRequests[pageNumber];
     }
     let promise = this.pdfDocument.getPage(pageNumber).then(pdfPage => {
       if (!pageView.pdfPage) {
         pageView.setPdfPage(pdfPage);
       }
       this._pagesRequests[pageNumber] = null;
       return pdfPage;
+    }).catch(reason => {
+      console.error('Unable to get page for page view', reason);
+      this._pagesRequests[pageNumber] = null;
     });
     this._pagesRequests[pageNumber] = promise;
     return promise;
   }
   forceRendering(currentlyVisiblePages) {
     let visiblePages = currentlyVisiblePages || this._getVisiblePages();
     let pageView = this.renderingQueue.getHighestPriority(visiblePages, this._pages, this.scroll.down);
     if (pageView) {