Bug 1616560 - Update pdf.js to version 2.4.375. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 19 Feb 2020 18:23:01 +0000
changeset 514651 cced129771887b9d0307e5366f018a9a3a25f00c
parent 514650 4d1cffb020950521ac61827caa78a57ac8c3886b
child 514652 bf1c7d5934e5bbbbb76bdb96cfe6578c509d147f
push id107718
push userrvandermeulen@mozilla.com
push dateWed, 19 Feb 2020 19:07:23 +0000
treeherderautoland@cced12977188 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1616560
milestone75.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 1616560 - Update pdf.js to version 2.4.375. r=bdahl Differential Revision: https://phabricator.services.mozilla.com/D63326
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.4.349
+Current extension version is: 2.4.375
 
-Taken from upstream commit: dced0a38
+Taken from upstream commit: e2b30e9e
--- 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.4.349';
-var pdfjsBuild = 'dced0a38';
+var pdfjsVersion = '2.4.375';
+var pdfjsBuild = 'e2b30e9e';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(3);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(16);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(17);
@@ -1200,17 +1200,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.4.349',
+    apiVersion: '2.4.375',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -1946,19 +1946,17 @@ class LoopbackPort {
         return cloned.get(value);
       }
 
       let buffer, result;
 
       if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) {
         const transferable = transfers && transfers.includes(buffer);
 
-        if (value === buffer) {
-          result = value;
-        } else if (transferable) {
+        if (transferable) {
           result = new value.constructor(buffer, value.byteOffset, value.byteLength);
         } else {
           result = new value.constructor(value);
         }
 
         cloned.set(value, result);
         return result;
       }
@@ -3147,19 +3145,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.4.349';
+const version = '2.4.375';
 exports.version = version;
-const build = 'dced0a38';
+const build = 'e2b30e9e';
 exports.build = build;
 
 /***/ }),
 /* 4 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -6997,25 +6995,25 @@ var _util = __w_pdfjs_require__(1);
 var _xml_parser = __w_pdfjs_require__(13);
 
 class Metadata {
   constructor(data) {
     (0, _util.assert)(typeof data === "string", "Metadata: input is not a string");
     data = this._repair(data);
     const parser = new _xml_parser.SimpleXMLParser();
     const xmlDocument = parser.parseFromString(data);
-    this._metadata = Object.create(null);
+    this._metadataMap = new Map();
 
     if (xmlDocument) {
       this._parse(xmlDocument);
     }
   }
 
   _repair(data) {
-    return data.replace(/^([^<]+)/, "").replace(/>\\376\\377([^<]+)/g, function (all, codes) {
+    return data.replace(/^[^<]+/, "").replace(/>\\376\\377([^<]+)/g, function (all, codes) {
       const bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
         return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
       }).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) {
         switch (name) {
           case "amp":
             return "&";
 
           case "apos":
@@ -7074,33 +7072,39 @@ class Metadata {
       if (desc.nodeName.toLowerCase() !== "rdf:description") {
         continue;
       }
 
       for (let j = 0, jj = desc.childNodes.length; j < jj; j++) {
         if (desc.childNodes[j].nodeName.toLowerCase() !== "#text") {
           const entry = desc.childNodes[j];
           const name = entry.nodeName.toLowerCase();
-          this._metadata[name] = entry.textContent.trim();
+
+          this._metadataMap.set(name, entry.textContent.trim());
         }
       }
     }
   }
 
   get(name) {
-    const data = this._metadata[name];
-    return typeof data !== "undefined" ? data : null;
+    return this._metadataMap.has(name) ? this._metadataMap.get(name) : null;
   }
 
   getAll() {
-    return this._metadata;
+    const obj = Object.create(null);
+
+    for (const [key, value] of this._metadataMap) {
+      obj[key] = value;
+    }
+
+    return obj;
   }
 
   has(name) {
-    return typeof this._metadata[name] !== "undefined";
+    return this._metadataMap.has(name);
   }
 
 }
 
 exports.Metadata = Metadata;
 
 /***/ }),
 /* 13 */
@@ -8945,17 +8949,16 @@ var renderTextLayer = function renderTex
         return;
       }
 
       if (this._bounds !== null) {
         expand(this);
         this._bounds = null;
       }
 
-      const NO_PADDING = "0 0 0 0";
       const transformBuf = [],
             paddingBuf = [];
 
       for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
         const div = this._textDivs[i];
 
         const divProps = this._textDivProperties.get(div);
 
@@ -8992,21 +8995,17 @@ var renderTextLayer = function renderTex
 
           if (divProps.paddingLeft > 0) {
             paddingBuf.push(`${divProps.paddingLeft / divProps.scale}px`);
             transformBuf.push(`translateX(${-divProps.paddingLeft / divProps.scale}px)`);
           } else {
             paddingBuf.push(0);
           }
 
-          const padding = paddingBuf.join(" ");
-
-          if (padding !== NO_PADDING) {
-            div.style.padding = padding;
-          }
+          div.style.padding = paddingBuf.join(" ");
 
           if (transformBuf.length) {
             div.style.transform = transformBuf.join(" ");
           }
         } else {
           div.style.padding = null;
           div.style.transform = divProps.originalTransform;
         }
--- 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.4.349';
-const pdfjsBuild = 'dced0a38';
+const pdfjsVersion = '2.4.375';
+const pdfjsBuild = 'e2b30e9e';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -218,17 +218,17 @@ var WorkerMessageHandler = {
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     const apiVersion = docParams.apiVersion;
-    const workerVersion = '2.4.349';
+    const workerVersion = '2.4.375';
 
     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";
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -372,17 +372,17 @@ class DefaultExternalServices {
     });
   }
 
 }
 
 exports.DefaultExternalServices = DefaultExternalServices;
 const PDFViewerApplication = {
   initialBookmark: document.location.hash.substring(1),
-  initialized: false,
+  _initializedCapability: (0, _pdfjsLib.createPromiseCapability)(),
   fellback: false,
   appConfig: null,
   pdfDocument: null,
   pdfLoadingTask: null,
   printService: null,
   pdfViewer: null,
   pdfThumbnailViewer: null,
   pdfRenderingQueue: null,
@@ -427,17 +427,18 @@ const PDFViewerApplication = {
     this.bindEvents();
     this.bindWindowEvents();
     const appContainer = appConfig.appContainer || document.documentElement;
     this.l10n.translate(appContainer).then(() => {
       this.eventBus.dispatch("localized", {
         source: this
       });
     });
-    this.initialized = true;
+
+    this._initializedCapability.resolve();
   },
 
   async _readPreferences() {
     if (_app_options.AppOptions.get("disablePreferences") === true) {
       return;
     }
 
     try {
@@ -634,16 +635,24 @@ const PDFViewerApplication = {
     this.pdfSidebar.onToggled = this.forceRendering.bind(this);
     this.pdfSidebarResizer = new _pdf_sidebar_resizer.PDFSidebarResizer(appConfig.sidebarResizer, eventBus, this.l10n);
   },
 
   run(config) {
     this.initialize(config).then(webViewerInitialized);
   },
 
+  get initialized() {
+    return this._initializedCapability.settled;
+  },
+
+  get initializedPromise() {
+    return this._initializedCapability.promise;
+  },
+
   zoomIn(ticks) {
     if (this.pdfViewer.isInPresentationMode) {
       return;
     }
 
     let newScale = this.pdfViewer.currentScale;
 
     do {
--- 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.4.349
+  release: version 2.4.375
 
   # 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