Bug 1544404 - Update pdf.js to version 2.2.145. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 15 Apr 2019 09:13:51 -0400
changeset 469598 aad2748fe8f9
parent 469597 48f7c91bbdbf
child 469599 65e46003724d
push id35875
push userccoroiu@mozilla.com
push dateTue, 16 Apr 2019 04:06:16 +0000
treeherdermozilla-central@a83cab75b00d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1544404
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 1544404 - Update pdf.js to version 2.2.145. 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.css
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.129
+Current extension version is: 2.2.145
 
-Taken from upstream commit: 725a6959
+Taken from upstream commit: 8bbae798
--- 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.129';
-var pdfjsBuild = '725a6959';
+var pdfjsVersion = '2.2.145';
+var pdfjsBuild = '8bbae798';
 
 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.129',
+    apiVersion: '2.2.145',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
@@ -2376,16 +2376,21 @@ class WorkerTransport {
       }, headersCapability.reject);
       return headersCapability.promise;
     }, this);
     messageHandler.on('GetRangeReader', function (data, sink) {
       (0, _util.assert)(this._networkStream);
 
       const rangeReader = this._networkStream.getRangeReader(data.begin, data.end);
 
+      if (!rangeReader) {
+        sink.close();
+        return;
+      }
+
       sink.onPull = () => {
         rangeReader.read().then(function ({
           value,
           done
         }) {
           if (done) {
             sink.close();
             return;
@@ -3078,19 +3083,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.2.129';
+const version = '2.2.145';
 exports.version = version;
-const build = '725a6959';
+const build = '8bbae798';
 exports.build = build;
 
 /***/ }),
 /* 7 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -7387,16 +7392,21 @@ var PDFDataTransportStream = function PD
           rangeReader._enqueue(buffer);
 
           return true;
         });
 
         (0, _util.assert)(found);
       }
     },
+
+    get _progressiveDataLength() {
+      return this._fullRequestReader ? this._fullRequestReader._loaded : 0;
+    },
+
     _onProgress: function PDFDataTransportStream_onDataProgress(evt) {
       if (evt.total === undefined && this._rangeReaders.length > 0) {
         var firstReader = this._rangeReaders[0];
 
         if (firstReader.onProgress) {
           firstReader.onProgress({
             loaded: evt.loaded
           });
@@ -7431,16 +7441,20 @@ var PDFDataTransportStream = function PD
     },
     getFullReader: function PDFDataTransportStream_getFullReader() {
       (0, _util.assert)(!this._fullRequestReader);
       var queuedChunks = this._queuedChunks;
       this._queuedChunks = null;
       return new PDFDataTransportStreamReader(this, queuedChunks, this._progressiveDone);
     },
     getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) {
+      if (end <= this._progressiveDataLength) {
+        return null;
+      }
+
       var reader = new PDFDataTransportStreamRangeReader(this, begin, end);
 
       this._pdfDataRangeTransport.requestDataRange(begin, end);
 
       this._rangeReaders.push(reader);
 
       return reader;
     },
@@ -7459,16 +7473,22 @@ var PDFDataTransportStream = function PD
     }
   };
 
   function PDFDataTransportStreamReader(stream, queuedChunks, progressiveDone = false) {
     this._stream = stream;
     this._done = progressiveDone || false;
     this._filename = null;
     this._queuedChunks = queuedChunks || [];
+    this._loaded = 0;
+
+    for (const chunk of this._queuedChunks) {
+      this._loaded += chunk.byteLength;
+    }
+
     this._requests = [];
     this._headersReady = Promise.resolve();
     stream._fullRequestReader = this;
     this.onProgress = null;
   }
 
   PDFDataTransportStreamReader.prototype = {
     _enqueue: function PDFDataTransportStreamReader_enqueue(chunk) {
@@ -7478,20 +7498,21 @@ var PDFDataTransportStream = function PD
 
       if (this._requests.length > 0) {
         var requestCapability = this._requests.shift();
 
         requestCapability.resolve({
           value: chunk,
           done: false
         });
-        return;
-      }
-
-      this._queuedChunks.push(chunk);
+      } else {
+        this._queuedChunks.push(chunk);
+      }
+
+      this._loaded += chunk.byteLength;
     },
 
     get headersReady() {
       return this._headersReady;
     },
 
     get filename() {
       return this._filename;
@@ -8820,28 +8841,34 @@ class AnnotationElementFactory {
             return new ChoiceWidgetAnnotationElement(parameters);
         }
 
         return new WidgetAnnotationElement(parameters);
 
       case _util.AnnotationType.POPUP:
         return new PopupAnnotationElement(parameters);
 
+      case _util.AnnotationType.FREETEXT:
+        return new FreeTextAnnotationElement(parameters);
+
       case _util.AnnotationType.LINE:
         return new LineAnnotationElement(parameters);
 
       case _util.AnnotationType.SQUARE:
         return new SquareAnnotationElement(parameters);
 
       case _util.AnnotationType.CIRCLE:
         return new CircleAnnotationElement(parameters);
 
       case _util.AnnotationType.POLYLINE:
         return new PolylineAnnotationElement(parameters);
 
+      case _util.AnnotationType.CARET:
+        return new CaretAnnotationElement(parameters);
+
       case _util.AnnotationType.INK:
         return new InkAnnotationElement(parameters);
 
       case _util.AnnotationType.POLYGON:
         return new PolygonAnnotationElement(parameters);
 
       case _util.AnnotationType.HIGHLIGHT:
         return new HighlightAnnotationElement(parameters);
@@ -9362,16 +9389,34 @@ class PopupElement {
     if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
       this.hideElement.setAttribute('hidden', true);
       this.container.style.zIndex -= 1;
     }
   }
 
 }
 
+class FreeTextAnnotationElement extends AnnotationElement {
+  constructor(parameters) {
+    const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
+    super(parameters, isRenderable, true);
+  }
+
+  render() {
+    this.container.className = 'freeTextAnnotation';
+
+    if (!this.data.hasPopup) {
+      this._createPopup(this.container, null, this.data);
+    }
+
+    return this.container;
+  }
+
+}
+
 class LineAnnotationElement extends AnnotationElement {
   constructor(parameters) {
     let isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
     super(parameters, isRenderable, true);
   }
 
   render() {
     this.container.className = 'lineAnnotation';
@@ -9502,16 +9547,34 @@ class PolygonAnnotationElement extends P
   constructor(parameters) {
     super(parameters);
     this.containerClassName = 'polygonAnnotation';
     this.svgElementName = 'svg:polygon';
   }
 
 }
 
+class CaretAnnotationElement extends AnnotationElement {
+  constructor(parameters) {
+    const isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
+    super(parameters, isRenderable, true);
+  }
+
+  render() {
+    this.container.className = 'caretAnnotation';
+
+    if (!this.data.hasPopup) {
+      this._createPopup(this.container, null, this.data);
+    }
+
+    return this.container;
+  }
+
+}
+
 class InkAnnotationElement extends AnnotationElement {
   constructor(parameters) {
     let isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
     super(parameters, isRenderable, true);
     this.containerClassName = 'inkAnnotation';
     this.svgElementName = 'svg:polyline';
   }
 
--- 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.129';
-const pdfjsBuild = '725a6959';
+const pdfjsVersion = '2.2.145';
+const pdfjsBuild = '8bbae798';
 
 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.129';
+    let workerVersion = '2.2.145';
 
     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';
@@ -2033,16 +2033,20 @@ class ChunkedStream {
       if (!this.loadedChunks[curChunk]) {
         this.loadedChunks[curChunk] = true;
         ++this.numChunksLoaded;
       }
     }
   }
 
   ensureByte(pos) {
+    if (pos < this.progressiveDataLength) {
+      return;
+    }
+
     const chunk = Math.floor(pos / this.chunkSize);
 
     if (chunk === this.lastSuccessfulEnsureByteChunk) {
       return;
     }
 
     if (!this.loadedChunks[chunk]) {
       throw new _core_utils.MissingDataException(pos, pos + 1);
@@ -2179,17 +2183,21 @@ class ChunkedStream {
     this.pos = this.start;
   }
 
   moveStart() {
     this.start = this.pos;
   }
 
   makeSubStream(start, length, dict) {
-    this.ensureRange(start, start + length);
+    if (length) {
+      this.ensureRange(start, start + length);
+    } else {
+      this.ensureByte(start);
+    }
 
     function ChunkedStreamSubstream() {}
 
     ChunkedStreamSubstream.prototype = Object.create(this);
 
     ChunkedStreamSubstream.prototype.getMissingChunks = function () {
       const chunkSize = this.chunkSize;
       const beginChunk = Math.floor(this.start / chunkSize);
@@ -18071,31 +18079,37 @@ class AnnotationFactory {
         }
 
         (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
         return new WidgetAnnotation(parameters);
 
       case 'Popup':
         return new PopupAnnotation(parameters);
 
+      case 'FreeText':
+        return new FreeTextAnnotation(parameters);
+
       case 'Line':
         return new LineAnnotation(parameters);
 
       case 'Square':
         return new SquareAnnotation(parameters);
 
       case 'Circle':
         return new CircleAnnotation(parameters);
 
       case 'PolyLine':
         return new PolylineAnnotation(parameters);
 
       case 'Polygon':
         return new PolygonAnnotation(parameters);
 
+      case 'Caret':
+        return new CaretAnnotation(parameters);
+
       case 'Ink':
         return new InkAnnotation(parameters);
 
       case 'Highlight':
         return new HighlightAnnotation(parameters);
 
       case 'Underline':
         return new UnderlineAnnotation(parameters);
@@ -18300,26 +18314,16 @@ class Annotation {
 
     if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
       return;
     }
 
     this.appearance = normalAppearanceState.get(as.name);
   }
 
-  _preparePopup(dict) {
-    if (!dict.has('C')) {
-      this.data.color = null;
-    }
-
-    this.data.hasPopup = dict.has('Popup');
-    this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
-    this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
-  }
-
   loadResources(keys) {
     return this.appearance.dict.getAsync('Resources').then(resources => {
       if (!resources) {
         return;
       }
 
       let objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
       return objectLoader.load().then(function () {
@@ -18448,16 +18452,32 @@ class AnnotationBorderStyle {
       this.verticalCornerRadius = radius;
     }
   }
 
 }
 
 exports.AnnotationBorderStyle = AnnotationBorderStyle;
 
+class MarkupAnnotation extends Annotation {
+  constructor(parameters) {
+    super(parameters);
+    const dict = parameters.dict;
+
+    if (!dict.has('C')) {
+      this.data.color = null;
+    }
+
+    this.data.hasPopup = dict.has('Popup');
+    this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
+    this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
+  }
+
+}
+
 class WidgetAnnotation extends Annotation {
   constructor(params) {
     super(params);
     let dict = params.dict;
     let data = this.data;
     data.annotationType = _util.AnnotationType.WIDGET;
     data.fieldName = this._constructFieldName(dict);
     data.fieldValue = (0, _core_utils.getInheritableProperty)({
@@ -18717,31 +18737,29 @@ class ChoiceWidgetAnnotation extends Wid
     }
 
     this.data.combo = this.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
     this.data.multiSelect = this.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
   }
 
 }
 
-class TextAnnotation extends Annotation {
+class TextAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     const DEFAULT_ICON_SIZE = 22;
     super(parameters);
     this.data.annotationType = _util.AnnotationType.TEXT;
 
     if (this.data.hasAppearance) {
       this.data.name = 'NoIcon';
     } else {
       this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
       this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
       this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
     }
-
-    this._preparePopup(parameters.dict);
   }
 
 }
 
 class LinkAnnotation extends Annotation {
   constructor(params) {
     super(params);
     this.data.annotationType = _util.AnnotationType.LINK;
@@ -18786,77 +18804,85 @@ class PopupAnnotation extends Annotation
       if (this._isViewable(parentFlags)) {
         this.setFlags(parentFlags);
       }
     }
   }
 
 }
 
-class LineAnnotation extends Annotation {
+class FreeTextAnnotation extends MarkupAnnotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.FREETEXT;
+  }
+
+}
+
+class LineAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.LINE;
     let dict = parameters.dict;
     this.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
-
-    this._preparePopup(dict);
-  }
-
-}
-
-class SquareAnnotation extends Annotation {
+  }
+
+}
+
+class SquareAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.SQUARE;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class CircleAnnotation extends Annotation {
+  }
+
+}
+
+class CircleAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.CIRCLE;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class PolylineAnnotation extends Annotation {
+  }
+
+}
+
+class PolylineAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.POLYLINE;
     let dict = parameters.dict;
     let rawVertices = dict.getArray('Vertices');
     this.data.vertices = [];
 
     for (let i = 0, ii = rawVertices.length; i < ii; i += 2) {
       this.data.vertices.push({
         x: rawVertices[i],
         y: rawVertices[i + 1]
       });
     }
-
-    this._preparePopup(dict);
   }
 
 }
 
 class PolygonAnnotation extends PolylineAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.POLYGON;
   }
 
 }
 
-class InkAnnotation extends Annotation {
+class CaretAnnotation extends MarkupAnnotation {
+  constructor(parameters) {
+    super(parameters);
+    this.data.annotationType = _util.AnnotationType.CARET;
+  }
+
+}
+
+class InkAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.INK;
     let dict = parameters.dict;
     const xref = parameters.xref;
     let originalInkLists = dict.getArray('InkList');
     this.data.inkLists = [];
 
@@ -18865,80 +18891,66 @@ class InkAnnotation extends Annotation {
 
       for (let j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
         this.data.inkLists[i].push({
           x: xref.fetchIfRef(originalInkLists[i][j]),
           y: xref.fetchIfRef(originalInkLists[i][j + 1])
         });
       }
     }
-
-    this._preparePopup(dict);
-  }
-
-}
-
-class HighlightAnnotation extends Annotation {
+  }
+
+}
+
+class HighlightAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.HIGHLIGHT;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class UnderlineAnnotation extends Annotation {
+  }
+
+}
+
+class UnderlineAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.UNDERLINE;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class SquigglyAnnotation extends Annotation {
+  }
+
+}
+
+class SquigglyAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.SQUIGGLY;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class StrikeOutAnnotation extends Annotation {
+  }
+
+}
+
+class StrikeOutAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.STRIKEOUT;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class StampAnnotation extends Annotation {
+  }
+
+}
+
+class StampAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     this.data.annotationType = _util.AnnotationType.STAMP;
-
-    this._preparePopup(parameters.dict);
-  }
-
-}
-
-class FileAttachmentAnnotation extends Annotation {
+  }
+
+}
+
+class FileAttachmentAnnotation extends MarkupAnnotation {
   constructor(parameters) {
     super(parameters);
     let file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
     this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
     this.data.file = file.serializable;
-
-    this._preparePopup(parameters.dict);
   }
 
 }
 
 /***/ }),
 /* 27 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
--- a/browser/extensions/pdfjs/content/web/viewer.css
+++ b/browser/extensions/pdfjs/content/web/viewer.css
@@ -242,21 +242,23 @@
   margin: 0;
   padding-top: 0.2em;
 }
 
 .annotationLayer .highlightAnnotation,
 .annotationLayer .underlineAnnotation,
 .annotationLayer .squigglyAnnotation,
 .annotationLayer .strikeoutAnnotation,
+.annotationLayer .freeTextAnnotation,
 .annotationLayer .lineAnnotation svg line,
 .annotationLayer .squareAnnotation svg rect,
 .annotationLayer .circleAnnotation svg ellipse,
 .annotationLayer .polylineAnnotation svg polyline,
 .annotationLayer .polygonAnnotation svg polygon,
+.annotationLayer .caretAnnotation,
 .annotationLayer .inkAnnotation svg polyline,
 .annotationLayer .stampAnnotation,
 .annotationLayer .fileAttachmentAnnotation {
   cursor: pointer;
 }
 
 .pdfViewer .canvasWrapper {
   overflow: hidden;
--- 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.129
+  release: version 2.2.145
 
   # 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