Bug 1542737 - Update pdf.js to version 2.2.129. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 08 Apr 2019 08:51:19 -0400
changeset 468348 0ffc8e3349d70b567d709517d589e035b64ea1c8
parent 468347 4a995c35eff47f4d6e5cc50329d0f450d1aa2320
child 468349 0e564383758ab26265058ae635dba9e80eb63a27
child 468479 5b174e2193469708b66773f4139018db44d4cdf7
push id35834
push userdvarga@mozilla.com
push dateMon, 08 Apr 2019 16:17:50 +0000
treeherdermozilla-central@0e564383758a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1542737
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542737 - Update pdf.js to version 2.2.129. 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
browser/extensions/pdfjs/moz.yaml
--- 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: 2.2.117
+Current extension version is: 2.2.129
 
-Taken from upstream commit: 57abddc9
+Taken from upstream commit: 725a6959
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-var pdfjsVersion = '2.2.117';
-var pdfjsBuild = '57abddc9';
+var pdfjsVersion = '2.2.129';
+var pdfjsBuild = '725a6959';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(6);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(18);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(19);
@@ -1298,17 +1298,17 @@ function _fetchDocument(worker, source, 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
     source.progressiveDone = pdfDataRangeTransport.progressiveDone;
   }
 
   return worker.messageHandler.sendWithPromise('GetDocRequest', {
     docId,
-    apiVersion: '2.2.117',
+    apiVersion: '2.2.129',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -1401,20 +1401,20 @@ class PDFDataRangeTransport {
   }
 
   onDataRange(begin, chunk) {
     for (const listener of this._rangeListeners) {
       listener(begin, chunk);
     }
   }
 
-  onDataProgress(loaded) {
+  onDataProgress(loaded, total) {
     this._readyCapability.promise.then(() => {
       for (const listener of this._progressListeners) {
-        listener(loaded);
+        listener(loaded, total);
       }
     });
   }
 
   onDataProgressiveRead(chunk) {
     this._readyCapability.promise.then(() => {
       for (const listener of this._progressiveReadListeners) {
         listener(chunk);
@@ -1473,16 +1473,20 @@ class PDFDocumentProxy {
   getDestination(id) {
     return this._transport.getDestination(id);
   }
 
   getPageLabels() {
     return this._transport.getPageLabels();
   }
 
+  getPageLayout() {
+    return this._transport.getPageLayout();
+  }
+
   getPageMode() {
     return this._transport.getPageMode();
   }
 
   getOpenActionDestination() {
     return this._transport.getOpenActionDestination();
   }
 
@@ -2756,16 +2760,20 @@ class WorkerTransport {
       id
     });
   }
 
   getPageLabels() {
     return this.messageHandler.sendWithPromise('GetPageLabels', null);
   }
 
+  getPageLayout() {
+    return this.messageHandler.sendWithPromise('GetPageLayout', null);
+  }
+
   getPageMode() {
     return this.messageHandler.sendWithPromise('GetPageMode', null);
   }
 
   getOpenActionDestination() {
     return this.messageHandler.sendWithPromise('getOpenActionDestination', null);
   }
 
@@ -3070,19 +3078,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.2.117';
+const version = '2.2.129';
 exports.version = version;
-const build = '57abddc9';
+const build = '725a6959';
 exports.build = build;
 
 /***/ }),
 /* 7 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -4586,18 +4594,21 @@ var CanvasGraphics = function CanvasGrap
     setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
       var ctx = this.ctx;
 
       if (ctx.setLineDash !== undefined) {
         ctx.setLineDash(dashArray);
         ctx.lineDashOffset = dashPhase;
       }
     },
-    setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
-    setFlatness: function CanvasGraphics_setFlatness(flatness) {},
+
+    setRenderingIntent(intent) {},
+
+    setFlatness(flatness) {},
+
     setGState: function CanvasGraphics_setGState(states) {
       for (var i = 0, ii = states.length; i < ii; i++) {
         var state = states[i];
         var key = state[0];
         var value = state[1];
 
         switch (key) {
           case 'LW':
@@ -7332,19 +7343,20 @@ var PDFDataTransportStream = function PD
 
     this._pdfDataRangeTransport.addRangeListener((begin, chunk) => {
       this._onReceiveData({
         begin,
         chunk
       });
     });
 
-    this._pdfDataRangeTransport.addProgressListener(loaded => {
+    this._pdfDataRangeTransport.addProgressListener((loaded, total) => {
       this._onProgress({
-        loaded
+        loaded,
+        total
       });
     });
 
     this._pdfDataRangeTransport.addProgressiveReadListener(chunk => {
       this._onReceiveData({
         chunk
       });
     });
@@ -7376,25 +7388,35 @@ var PDFDataTransportStream = function PD
 
           return true;
         });
 
         (0, _util.assert)(found);
       }
     },
     _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
-      if (this._rangeReaders.length > 0) {
+      if (evt.total === undefined && this._rangeReaders.length > 0) {
         var firstReader = this._rangeReaders[0];
 
         if (firstReader.onProgress) {
           firstReader.onProgress({
             loaded: evt.loaded
           });
+          return;
         }
       }
+
+      let fullReader = this._fullRequestReader;
+
+      if (fullReader && fullReader.onProgress) {
+        fullReader.onProgress({
+          loaded: evt.loaded,
+          total: evt.total
+        });
+      }
     },
 
     _onProgressiveDone() {
       if (this._fullRequestReader) {
         this._fullRequestReader.progressiveDone();
       }
 
       this._progressiveDone = true;
@@ -9725,17 +9747,17 @@ exports.SVGGraphics = void 0;
 var _util = __w_pdfjs_require__(1);
 
 var _display_utils = __w_pdfjs_require__(7);
 
 var _is_node = _interopRequireDefault(__w_pdfjs_require__(21));
 
 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
-var SVGGraphics = function () {
+let SVGGraphics = function () {
   throw new Error('Not implemented: SVGGraphics');
 };
 
 exports.SVGGraphics = SVGGraphics;
 ;
 
 /***/ }),
 /* 21 */
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -118,18 +118,18 @@ return /******/ (function(modules) { // 
 /************************************************************************/
 /******/ ([
 /* 0 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-const pdfjsVersion = '2.2.117';
-const pdfjsBuild = '57abddc9';
+const pdfjsVersion = '2.2.129';
+const pdfjsBuild = '725a6959';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -373,17 +373,17 @@ var WorkerMessageHandler = {
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     let apiVersion = docParams.apiVersion;
-    let workerVersion = '2.2.117';
+    let workerVersion = '2.2.129';
 
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
     }
 
     var docId = docParams.docId;
     var docBaseUrl = docParams.docBaseUrl;
     var workerHandlerName = docParams.docId + '_worker';
@@ -639,16 +639,19 @@ var WorkerMessageHandler = {
       return pdfManager.ensureCatalog('destinations');
     });
     handler.on('GetDestination', function wphSetupGetDestination(data) {
       return pdfManager.ensureCatalog('getDestination', [data.id]);
     });
     handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
       return pdfManager.ensureCatalog('pageLabels');
     });
+    handler.on('GetPageLayout', function wphSetupGetPageLayout(data) {
+      return pdfManager.ensureCatalog('pageLayout');
+    });
     handler.on('GetPageMode', function wphSetupGetPageMode(data) {
       return pdfManager.ensureCatalog('pageMode');
     });
     handler.on('getOpenActionDestination', function (data) {
       return pdfManager.ensureCatalog('openActionDestination');
     });
     handler.on('GetAttachments', function wphSetupGetAttachments(data) {
       return pdfManager.ensureCatalog('attachments');
@@ -3742,16 +3745,35 @@ class Catalog {
 
       pageLabels[i] = prefix + currentLabel;
       currentIndex++;
     }
 
     return pageLabels;
   }
 
+  get pageLayout() {
+    const obj = this.catDict.get('PageLayout');
+    let pageLayout = '';
+
+    if ((0, _primitives.isName)(obj)) {
+      switch (obj.name) {
+        case 'SinglePage':
+        case 'OneColumn':
+        case 'TwoColumnLeft':
+        case 'TwoColumnRight':
+        case 'TwoPageLeft':
+        case 'TwoPageRight':
+          pageLayout = obj.name;
+      }
+    }
+
+    return (0, _util.shadow)(this, 'pageLayout', pageLayout);
+  }
+
   get pageMode() {
     const obj = this.catDict.get('PageMode');
     let pageMode = 'UseNone';
 
     if ((0, _primitives.isName)(obj)) {
       switch (obj.name) {
         case 'UseNone':
         case 'UseOutlines':
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -1012,16 +1012,17 @@ let PDFViewerApplication = {
       this.downloadComplete = true;
       this.loadingBar.hide();
       firstPagePromise.then(() => {
         this.eventBus.dispatch('documentloaded', {
           source: this
         });
       });
     });
+    const pageLayoutPromise = pdfDocument.getPageLayout().catch(function () {});
     const pageModePromise = pdfDocument.getPageMode().catch(function () {});
     const openActionDestPromise = pdfDocument.getOpenActionDestination().catch(function () {});
     this.toolbar.setPagesCount(pdfDocument.numPages, false);
     this.secondaryToolbar.setPagesCount(pdfDocument.numPages);
     const store = this.store = new _view_history.ViewHistory(pdfDocument.fingerprint);
     let baseDocumentUrl;
     baseDocumentUrl = this.baseUrl;
     this.pdfLinkService.setDocument(pdfDocument, baseDocumentUrl);
@@ -1040,17 +1041,17 @@ let PDFViewerApplication = {
         zoom: _ui_utils.DEFAULT_SCALE_VALUE,
         scrollLeft: '0',
         scrollTop: '0',
         rotation: null,
         sidebarView: _pdf_sidebar.SidebarView.UNKNOWN,
         scrollMode: _ui_utils.ScrollMode.UNKNOWN,
         spreadMode: _ui_utils.SpreadMode.UNKNOWN
       }).catch(() => {});
-      Promise.all([storePromise, pageModePromise, openActionDestPromise]).then(async ([values = {}, pageMode, openActionDest]) => {
+      Promise.all([storePromise, pageLayoutPromise, pageModePromise, openActionDestPromise]).then(async ([values = {}, pageLayout, pageMode, openActionDest]) => {
         const viewOnLoad = _app_options.AppOptions.get('viewOnLoad');
 
         this._initializePdfHistory({
           fingerprint: pdfDocument.fingerprint,
           viewOnLoad,
           initialDest: openActionDest
         });
 
@@ -1083,16 +1084,20 @@ let PDFViewerApplication = {
             spreadMode = values.spreadMode | 0;
           }
         }
 
         if (pageMode && sidebarView === _pdf_sidebar.SidebarView.UNKNOWN) {
           sidebarView = apiPageModeToSidebarView(pageMode);
         }
 
+        if (pageLayout && spreadMode === _ui_utils.SpreadMode.UNKNOWN) {
+          spreadMode = apiPageLayoutToSpreadMode(pageLayout);
+        }
+
         this.setInitialView(hash, {
           rotation,
           sidebarView,
           scrollMode,
           spreadMode
         });
         this.eventBus.dispatch('documentinit', {
           source: this
@@ -2335,16 +2340,34 @@ function webViewerKeyDown(evt) {
     pdfViewer.focus();
   }
 
   if (handled) {
     evt.preventDefault();
   }
 }
 
+function apiPageLayoutToSpreadMode(layout) {
+  switch (layout) {
+    case 'SinglePage':
+    case 'OneColumn':
+      return _ui_utils.SpreadMode.NONE;
+
+    case 'TwoColumnLeft':
+    case 'TwoPageLeft':
+      return _ui_utils.SpreadMode.ODD;
+
+    case 'TwoColumnRight':
+    case 'TwoPageRight':
+      return _ui_utils.SpreadMode.EVEN;
+  }
+
+  return _ui_utils.SpreadMode.NONE;
+}
+
 function apiPageModeToSidebarView(mode) {
   switch (mode) {
     case 'UseNone':
       return _pdf_sidebar.SidebarView.NONE;
 
     case 'UseThumbs':
       return _pdf_sidebar.SidebarView.THUMBS;
 
@@ -11400,16 +11423,17 @@ class FirefoxComDataRangeTransport exten
           break;
 
         case 'rangeProgress':
           pdfDataRangeTransport.onDataProgress(args.loaded);
           break;
 
         case 'progressiveRead':
           pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
+          pdfDataRangeTransport.onDataProgress(args.loaded, args.total);
           break;
 
         case 'progressiveDone':
           if (pdfDataRangeTransport) {
             pdfDataRangeTransport.onDataProgressiveDone();
           }
 
           break;
--- a/browser/extensions/pdfjs/moz.yaml
+++ b/browser/extensions/pdfjs/moz.yaml
@@ -15,15 +15,15 @@ origin:
   description: Portable Document Format (PDF) viewer that is built with HTML5
 
   # Full URL for the package's homepage/etc
   # Usually different from repository url
   url: https://github.com/mozilla/pdf.js
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.2.117
+  release: version 2.2.129
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
   # Multiple licenses can be specified (as a YAML list)
   # A "LICENSE" file must exist containing the full license text
   license: Apache-2.0