Bug 1595519 - Update pdf.js to version 2.4.127. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 14 Nov 2019 16:37:46 +0000
changeset 502067 4c2fbb90bbe3fc214014a89fb9061fce677c3040
parent 502066 f6aa348ba29ac0d8310d5ea7a447828dc22f0543
child 502068 06e855bfa7cebf2912446718eabd4eec6e82238c
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1595519
milestone72.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 1595519 - Update pdf.js to version 2.4.127. r=bdahl Differential Revision: https://phabricator.services.mozilla.com/D52545
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.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.107
+Current extension version is: 2.4.127
 
-Taken from upstream commit: de77d668
+Taken from upstream commit: 21895aa7
--- 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.107';
-var pdfjsBuild = 'de77d668';
+var pdfjsVersion = '2.4.127';
+var pdfjsBuild = '21895aa7';
 
 var pdfjsSharedUtil = __w_pdfjs_require__(1);
 
 var pdfjsDisplayAPI = __w_pdfjs_require__(5);
 
 var pdfjsDisplayTextLayer = __w_pdfjs_require__(17);
 
 var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(18);
@@ -907,16 +907,20 @@ const PDFStringTranslateTable = [0, 0, 0
 function stringToPDFString(str) {
   const length = str.length,
         strBuf = [];
 
   if (str[0] === '\xFE' && str[1] === '\xFF') {
     for (let i = 2; i < length; i += 2) {
       strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
     }
+  } else if (str[0] === '\xFF' && str[1] === '\xFE') {
+    for (let i = 2; i < length; i += 2) {
+      strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
+    }
   } else {
     for (let i = 0; i < length; ++i) {
       const code = PDFStringTranslateTable[str.charCodeAt(i)];
       strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
     }
   }
 
   return strBuf.join('');
@@ -1022,28 +1026,35 @@ exports.createObjectURL = createObjectUR
 
 /***/ }),
 /* 2 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-const globalScope = __w_pdfjs_require__(3);
+const {
+  globalScope
+} = __w_pdfjs_require__(3);
 
 ;
 
 /***/ }),
 /* 3 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.globalScope = void 0;
+const globalScope = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
+exports.globalScope = globalScope;
 
 /***/ }),
 /* 4 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
@@ -1074,30 +1085,28 @@ var _util = __w_pdfjs_require__(1);
 var _display_utils = __w_pdfjs_require__(6);
 
 var _font_loader = __w_pdfjs_require__(7);
 
 var _api_compatibility = __w_pdfjs_require__(8);
 
 var _canvas = __w_pdfjs_require__(9);
 
-var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
+var _global_scope = __w_pdfjs_require__(3);
 
 var _worker_options = __w_pdfjs_require__(11);
 
 var _message_handler = __w_pdfjs_require__(12);
 
 var _metadata = __w_pdfjs_require__(13);
 
 var _transport_stream = __w_pdfjs_require__(15);
 
 var _webgl = __w_pdfjs_require__(16);
 
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
 const DEFAULT_RANGE_CHUNK_SIZE = 65536;
 const RENDERING_CANCELLED_TIMEOUT = 100;
 let isWorkerDisabled = false;
 let fallbackWorkerSrc;
 let fakeWorkerFilesLoader = null;
 ;
 let createPDFNetworkStream;
 
@@ -1266,17 +1275,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.107',
+    apiVersion: '2.4.127',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -1939,17 +1948,17 @@ class PDFPageProxy {
     pump();
   }
 
   _abortOperatorList({
     intentState,
     reason,
     force = false
   }) {
-    (0, _util.assert)(reason instanceof Error, 'PDFPageProxy._abortOperatorList: Expected "reason" argument.');
+    (0, _util.assert)(reason instanceof Error || typeof reason === 'object' && reason !== null, 'PDFPageProxy._abortOperatorList: Expected "reason" argument.');
 
     if (!intentState.streamReader) {
       return;
     }
 
     if (!force) {
       if (intentState.renderTasks.length !== 0) {
         return;
@@ -2619,20 +2628,20 @@ class WorkerTransport {
             const exportedError = exportedData.error;
             (0, _util.warn)(`Error during font loading: ${exportedError}`);
             this.commonObjs.resolve(id, exportedError);
             break;
           }
 
           let fontRegistry = null;
 
-          if (params.pdfBug && _global_scope.default.FontInspector && _global_scope.default.FontInspector.enabled) {
+          if (params.pdfBug && _global_scope.globalScope.FontInspector && _global_scope.globalScope.FontInspector.enabled) {
             fontRegistry = {
               registerFont(font, url) {
-                _global_scope.default['FontInspector'].fontAdded(font, url);
+                _global_scope.globalScope['FontInspector'].fontAdded(font, url);
               }
 
             };
           }
 
           const font = new _font_loader.FontFaceObject(exportedData, {
             isEvalSupported: params.isEvalSupported,
             disableFontFace: params.disableFontFace,
@@ -3086,18 +3095,18 @@ const InternalRenderTask = function Inte
       if (this._canvas) {
         if (canvasInRendering.has(this._canvas)) {
           throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.');
         }
 
         canvasInRendering.add(this._canvas);
       }
 
-      if (this._pdfBug && _global_scope.default.StepperManager && _global_scope.default.StepperManager.enabled) {
-        this.stepper = _global_scope.default.StepperManager.create(this.pageNumber - 1);
+      if (this._pdfBug && _global_scope.globalScope.StepperManager && _global_scope.globalScope.StepperManager.enabled) {
+        this.stepper = _global_scope.globalScope.StepperManager.create(this.pageNumber - 1);
         this.stepper.init(this.operatorList);
         this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
       }
 
       const {
         canvasContext,
         viewport,
         transform,
@@ -3200,19 +3209,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.4.107';
+const version = '2.4.127';
 exports.version = version;
-const build = 'de77d668';
+const build = '21895aa7';
 exports.build = build;
 
 /***/ }),
 /* 6 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -8352,19 +8361,17 @@ var WebGLUtils = function WebGLUtilsClos
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.renderTextLayer = void 0;
 
 var _util = __w_pdfjs_require__(1);
 
-var _global_scope = _interopRequireDefault(__w_pdfjs_require__(3));
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+var _global_scope = __w_pdfjs_require__(3);
 
 var renderTextLayer = function renderTextLayerClosure() {
   var MAX_TEXT_DIVS_TO_RENDER = 100000;
   var NonWhitespaceRegexp = /\S/;
 
   function isAllWhitespace(str) {
     return !NonWhitespaceRegexp.test(str);
   }
@@ -8782,17 +8789,17 @@ var renderTextLayer = function renderTex
   }) {
     this._textContent = textContent;
     this._textContentStream = textContentStream;
     this._container = container;
     this._viewport = viewport;
     this._textDivs = textDivs || [];
     this._textContentItemsStr = textContentItemsStr || [];
     this._enhanceTextSelection = !!enhanceTextSelection;
-    this._fontInspectorEnabled = !!(_global_scope.default.FontInspector && _global_scope.default.FontInspector.enabled);
+    this._fontInspectorEnabled = !!(_global_scope.globalScope.FontInspector && _global_scope.globalScope.FontInspector.enabled);
     this._reader = null;
     this._layoutTextLastFontSize = null;
     this._layoutTextLastFontFamily = null;
     this._layoutTextCtx = null;
     this._textDivProperties = new WeakMap();
     this._renderingDone = false;
     this._canceled = false;
     this._capability = (0, _util.createPromiseCapability)();
@@ -9681,17 +9688,17 @@ class LineAnnotationElement extends Anno
     const width = data.rect[2] - data.rect[0];
     const height = data.rect[3] - data.rect[1];
     const svg = this.svgFactory.create(width, height);
     const line = this.svgFactory.createElement('svg:line');
     line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);
     line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);
     line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);
     line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);
-    line.setAttribute('stroke-width', data.borderStyle.width);
+    line.setAttribute('stroke-width', data.borderStyle.width || 1);
     line.setAttribute('stroke', 'transparent');
     svg.appendChild(line);
     this.container.append(svg);
 
     this._createPopup(this.container, line, data);
 
     return this.container;
   }
@@ -9711,17 +9718,17 @@ class SquareAnnotationElement extends An
     const height = data.rect[3] - data.rect[1];
     const svg = this.svgFactory.create(width, height);
     const borderWidth = data.borderStyle.width;
     const square = this.svgFactory.createElement('svg:rect');
     square.setAttribute('x', borderWidth / 2);
     square.setAttribute('y', borderWidth / 2);
     square.setAttribute('width', width - borderWidth);
     square.setAttribute('height', height - borderWidth);
-    square.setAttribute('stroke-width', borderWidth);
+    square.setAttribute('stroke-width', borderWidth || 1);
     square.setAttribute('stroke', 'transparent');
     square.setAttribute('fill', 'none');
     svg.appendChild(square);
     this.container.append(svg);
 
     this._createPopup(this.container, square, data);
 
     return this.container;
@@ -9742,17 +9749,17 @@ class CircleAnnotationElement extends An
     const height = data.rect[3] - data.rect[1];
     const svg = this.svgFactory.create(width, height);
     const borderWidth = data.borderStyle.width;
     const circle = this.svgFactory.createElement('svg:ellipse');
     circle.setAttribute('cx', width / 2);
     circle.setAttribute('cy', height / 2);
     circle.setAttribute('rx', width / 2 - borderWidth / 2);
     circle.setAttribute('ry', height / 2 - borderWidth / 2);
-    circle.setAttribute('stroke-width', borderWidth);
+    circle.setAttribute('stroke-width', borderWidth || 1);
     circle.setAttribute('stroke', 'transparent');
     circle.setAttribute('fill', 'none');
     svg.appendChild(circle);
     this.container.append(svg);
 
     this._createPopup(this.container, circle, data);
 
     return this.container;
@@ -9780,17 +9787,17 @@ class PolylineAnnotationElement extends 
       const x = coordinate.x - data.rect[0];
       const y = data.rect[3] - coordinate.y;
       points.push(x + ',' + y);
     }
 
     points = points.join(' ');
     const polyline = this.svgFactory.createElement(this.svgElementName);
     polyline.setAttribute('points', points);
-    polyline.setAttribute('stroke-width', data.borderStyle.width);
+    polyline.setAttribute('stroke-width', data.borderStyle.width || 1);
     polyline.setAttribute('stroke', 'transparent');
     polyline.setAttribute('fill', 'none');
     svg.appendChild(polyline);
     this.container.append(svg);
 
     this._createPopup(this.container, polyline, data);
 
     return this.container;
@@ -9847,17 +9854,17 @@ class InkAnnotationElement extends Annot
         const x = coordinate.x - data.rect[0];
         const y = data.rect[3] - coordinate.y;
         points.push(`${x},${y}`);
       }
 
       points = points.join(' ');
       const polyline = this.svgFactory.createElement(this.svgElementName);
       polyline.setAttribute('points', points);
-      polyline.setAttribute('stroke-width', data.borderStyle.width);
+      polyline.setAttribute('stroke-width', data.borderStyle.width || 1);
       polyline.setAttribute('stroke', 'transparent');
       polyline.setAttribute('fill', 'none');
 
       this._createPopup(this.container, polyline, data);
 
       svg.appendChild(polyline);
     }
 
@@ -10055,33 +10062,34 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.SVGGraphics = void 0;
 
 var _util = __w_pdfjs_require__(1);
 
 var _display_utils = __w_pdfjs_require__(6);
 
-var _is_node = _interopRequireDefault(__w_pdfjs_require__(20));
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+var _is_node = __w_pdfjs_require__(20);
 
 let SVGGraphics = function () {
   throw new Error('Not implemented: SVGGraphics');
 };
 
 exports.SVGGraphics = SVGGraphics;
 ;
 
 /***/ }),
 /* 20 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-module.exports = function isNodeJS() {
-  return typeof process === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
-};
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.isNodeJS = void 0;
+const isNodeJS = typeof process === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
+exports.isNodeJS = isNodeJS;
 
 /***/ })
 /******/ ]);
 });
\ No newline at end of file
--- 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.107';
-const pdfjsBuild = 'de77d668';
+const pdfjsVersion = '2.4.127';
+const pdfjsBuild = '21895aa7';
 
 const pdfjsCoreWorker = __w_pdfjs_require__(1);
 
 exports.WorkerMessageHandler = pdfjsCoreWorker.WorkerMessageHandler;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -143,26 +143,24 @@ Object.defineProperty(exports, "__esModu
 exports.WorkerMessageHandler = exports.WorkerTask = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
 var _primitives = __w_pdfjs_require__(6);
 
 var _pdf_manager = __w_pdfjs_require__(7);
 
-var _is_node = _interopRequireDefault(__w_pdfjs_require__(46));
+var _is_node = __w_pdfjs_require__(46);
 
 var _message_handler = __w_pdfjs_require__(47);
 
 var _worker_stream = __w_pdfjs_require__(48);
 
 var _core_utils = __w_pdfjs_require__(9);
 
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
 var WorkerTask = function WorkerTaskClosure() {
   function WorkerTask(name) {
     this.name = name;
     this.terminated = false;
     this._capability = (0, _util.createPromiseCapability)();
   }
 
   WorkerTask.prototype = {
@@ -220,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.107';
+    const workerVersion = '2.4.127';
 
     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';
@@ -646,17 +644,17 @@ var WorkerMessageHandler = {
 
 };
 exports.WorkerMessageHandler = WorkerMessageHandler;
 
 function isMessagePort(maybePort) {
   return typeof maybePort.postMessage === 'function' && 'onmessage' in maybePort;
 }
 
-if (typeof window === 'undefined' && !(0, _is_node.default)() && typeof self !== 'undefined' && isMessagePort(self)) {
+if (typeof window === 'undefined' && !_is_node.isNodeJS && typeof self !== 'undefined' && isMessagePort(self)) {
   WorkerMessageHandler.initializeFromPort(self);
 }
 
 /***/ }),
 /* 2 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
@@ -1384,16 +1382,20 @@ const PDFStringTranslateTable = [0, 0, 0
 function stringToPDFString(str) {
   const length = str.length,
         strBuf = [];
 
   if (str[0] === '\xFE' && str[1] === '\xFF') {
     for (let i = 2; i < length; i += 2) {
       strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
     }
+  } else if (str[0] === '\xFF' && str[1] === '\xFE') {
+    for (let i = 2; i < length; i += 2) {
+      strBuf.push(String.fromCharCode(str.charCodeAt(i + 1) << 8 | str.charCodeAt(i)));
+    }
   } else {
     for (let i = 0; i < length; ++i) {
       const code = PDFStringTranslateTable[str.charCodeAt(i)];
       strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
     }
   }
 
   return strBuf.join('');
@@ -1499,28 +1501,35 @@ exports.createObjectURL = createObjectUR
 
 /***/ }),
 /* 3 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-const globalScope = __w_pdfjs_require__(4);
+const {
+  globalScope
+} = __w_pdfjs_require__(4);
 
 ;
 
 /***/ }),
 /* 4 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.globalScope = void 0;
+const globalScope = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {};
+exports.globalScope = globalScope;
 
 /***/ }),
 /* 5 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
@@ -44734,19 +44743,22 @@ exports.PDFImage = PDFImage;
 
 /***/ }),
 /* 46 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
-module.exports = function isNodeJS() {
-  return typeof process === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
-};
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.isNodeJS = void 0;
+const isNodeJS = typeof process === 'object' && process + '' === '[object process]' && !process.versions['nw'] && !process.versions['electron'];
+exports.isNodeJS = isNodeJS;
 
 /***/ }),
 /* 47 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
--- 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.107
+  release: version 2.4.127
 
   # 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