Bug 1322494 - Update pdf.js to version 1.6.372. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 08 Dec 2016 12:17:30 -0500
changeset 370400 539bdf40aacb30936dfcf25cb9d7c9f052c1f8df
parent 370399 dffe4787171445ea01f99a41514d262f7882d120
child 370401 febbbdc0273edf0cf7da1cc9de046a9c58625292
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1322494
milestone53.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 1322494 - Update pdf.js to version 1.6.372. 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
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,3 +1,3 @@
 This is the pdf.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 1.6.355
+Current extension version is: 1.6.372
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -18,18 +18,18 @@
   define('pdfjs-dist/build/pdf', ['exports'], factory);
  } else if (typeof exports !== 'undefined') {
   factory(exports);
  } else {
   factory(root['pdfjsDistBuildPdf'] = {});
  }
 }(this, function (exports) {
  'use strict';
- var pdfjsVersion = '1.6.355';
- var pdfjsBuild = '451956c';
+ var pdfjsVersion = '1.6.372';
+ var pdfjsBuild = 'aaec4908';
  var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  var pdfjsLibs = {};
  (function pdfjsWrapper() {
   (function (root, factory) {
    factory(root.pdfjsSharedUtil = {});
   }(this, function (exports) {
    var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
    var FONT_IDENTITY_MATRIX = [
@@ -1717,17 +1717,17 @@
    function fixMetadata(meta) {
     return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
      var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
       return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
      });
      var chars = '';
      for (var i = 0; i < bytes.length; i += 2) {
       var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
-      chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 && false ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
+      chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
      }
      return '>' + chars;
     });
    }
    function Metadata(meta) {
     if (typeof meta === 'string') {
      meta = fixMetadata(meta);
      var parser = new DOMParser();
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -18,18 +18,18 @@
   define('pdfjs-dist/build/pdf.worker', ['exports'], factory);
  } else if (typeof exports !== 'undefined') {
   factory(exports);
  } else {
   factory(root['pdfjsDistBuildPdfWorker'] = {});
  }
 }(this, function (exports) {
  'use strict';
- var pdfjsVersion = '1.6.355';
- var pdfjsBuild = '451956c';
+ var pdfjsVersion = '1.6.372';
+ var pdfjsBuild = 'aaec4908';
  var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  var pdfjsLibs = {};
  (function pdfjsWrapper() {
   (function (root, factory) {
    factory(root.pdfjsCoreArithmeticDecoder = {});
   }(this, function (exports) {
    var ArithmeticDecoder = function ArithmeticDecoderClosure() {
     var QeTable = [
@@ -40449,41 +40449,37 @@
       if (isDict(colorSpaces)) {
        var refcs = colorSpaces.get(cs.name);
        if (refcs) {
         cs = refcs;
        }
       }
      }
      cs = xref.fetchIfRef(cs);
-     var mode;
      if (isName(cs)) {
-      mode = cs.name;
-      this.mode = mode;
-      switch (mode) {
+      switch (cs.name) {
       case 'DeviceGray':
       case 'G':
        return 'DeviceGrayCS';
       case 'DeviceRGB':
       case 'RGB':
        return 'DeviceRgbCS';
       case 'DeviceCMYK':
       case 'CMYK':
        return 'DeviceCmykCS';
       case 'Pattern':
        return [
         'PatternCS',
         null
        ];
       default:
-       error('unrecognized colorspace ' + mode);
+       error('unrecognized colorspace ' + cs.name);
       }
      } else if (isArray(cs)) {
-      mode = xref.fetchIfRef(cs[0]).name;
-      this.mode = mode;
+      var mode = xref.fetchIfRef(cs[0]).name;
       var numComps, params, alt, whitePoint, blackPoint, gamma;
       switch (mode) {
       case 'DeviceGray':
       case 'G':
        return 'DeviceGrayCS';
       case 'DeviceRGB':
       case 'RGB':
        return 'DeviceRgbCS';
@@ -40556,22 +40552,17 @@
         'IndexedCS',
         baseIndexedCS,
         hiVal,
         lookup
        ];
       case 'Separation':
       case 'DeviceN':
        var name = xref.fetchIfRef(cs[1]);
-       numComps = 1;
-       if (isName(name)) {
-        numComps = 1;
-       } else if (isArray(name)) {
-        numComps = name.length;
-       }
+       numComps = isArray(name) ? name.length : 1;
        alt = ColorSpace.parseToIR(cs[2], xref, res);
        var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
        return [
         'AlternateCS',
         numComps,
         alt,
         tintFnIR
        ];
@@ -40649,32 +40640,26 @@
       var usesZeroToOneRange = base.usesZeroToOneRange;
       var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
       var pos = isPassthrough ? destOffset : 0;
       var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
       var numComps = this.numComps;
       var scaled = new Float32Array(numComps);
       var tinted = new Float32Array(baseNumComps);
       var i, j;
-      if (usesZeroToOneRange) {
-       for (i = 0; i < count; i++) {
-        for (j = 0; j < numComps; j++) {
-         scaled[j] = src[srcOffset++] * scale;
-        }
-        tintFn(scaled, 0, tinted, 0);
+      for (i = 0; i < count; i++) {
+       for (j = 0; j < numComps; j++) {
+        scaled[j] = src[srcOffset++] * scale;
+       }
+       tintFn(scaled, 0, tinted, 0);
+       if (usesZeroToOneRange) {
         for (j = 0; j < baseNumComps; j++) {
          baseBuf[pos++] = tinted[j] * 255;
         }
-       }
-      } else {
-       for (i = 0; i < count; i++) {
-        for (j = 0; j < numComps; j++) {
-         scaled[j] = src[srcOffset++] * scale;
-        }
-        tintFn(scaled, 0, tinted, 0);
+       } else {
         base.getRgbItem(tinted, 0, baseBuf, pos);
         pos += baseNumComps;
        }
       }
       if (!isPassthrough) {
        base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
       }
      },
@@ -40697,37 +40682,35 @@
     }
     PatternCS.prototype = {};
     return PatternCS;
    }();
    var IndexedCS = function IndexedCSClosure() {
     function IndexedCS(base, highVal, lookup) {
      this.name = 'Indexed';
      this.numComps = 1;
-     this.defaultColor = new Uint8Array([0]);
+     this.defaultColor = new Uint8Array(this.numComps);
      this.base = base;
      this.highVal = highVal;
      var baseNumComps = base.numComps;
      var length = baseNumComps * highVal;
-     var lookupArray;
      if (isStream(lookup)) {
-      lookupArray = new Uint8Array(length);
+      this.lookup = new Uint8Array(length);
       var bytes = lookup.getBytes(length);
-      lookupArray.set(bytes);
+      this.lookup.set(bytes);
      } else if (isString(lookup)) {
-      lookupArray = new Uint8Array(length);
+      this.lookup = new Uint8Array(length);
       for (var i = 0; i < length; ++i) {
-       lookupArray[i] = lookup.charCodeAt(i);
+       this.lookup[i] = lookup.charCodeAt(i);
       }
      } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
-      lookupArray = lookup;
+      this.lookup = lookup;
      } else {
       error('Unrecognized lookup table: ' + lookup);
      }
-     this.lookup = lookupArray;
     }
     IndexedCS.prototype = {
      getRgb: ColorSpace.prototype.getRgb,
      getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
       var numComps = this.base.numComps;
       var start = src[srcOffset] * numComps;
       this.base.getRgbItem(this.lookup, start, dest, destOffset);
      },
@@ -40753,17 +40736,17 @@
      usesZeroToOneRange: true
     };
     return IndexedCS;
    }();
    var DeviceGrayCS = function DeviceGrayCSClosure() {
     function DeviceGrayCS() {
      this.name = 'DeviceGray';
      this.numComps = 1;
-     this.defaultColor = new Float32Array([0]);
+     this.defaultColor = new Float32Array(this.numComps);
     }
     DeviceGrayCS.prototype = {
      getRgb: ColorSpace.prototype.getRgb,
      getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
       var c = src[srcOffset] * 255 | 0;
       c = c < 0 ? 0 : c > 255 ? 255 : c;
       dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
      },
@@ -40789,21 +40772,17 @@
      usesZeroToOneRange: true
     };
     return DeviceGrayCS;
    }();
    var DeviceRgbCS = function DeviceRgbCSClosure() {
     function DeviceRgbCS() {
      this.name = 'DeviceRGB';
      this.numComps = 3;
-     this.defaultColor = new Float32Array([
-      0,
-      0,
-      0
-     ]);
+     this.defaultColor = new Float32Array(this.numComps);
     }
     DeviceRgbCS.prototype = {
      getRgb: ColorSpace.prototype.getRgb,
      getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
       var r = src[srcOffset] * 255 | 0;
       var g = src[srcOffset + 1] * 255 | 0;
       var b = src[srcOffset + 2] * 255 | 0;
       dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
@@ -40849,22 +40828,18 @@
      var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367) + 255 | 0;
      dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
      dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
      dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
     }
     function DeviceCmykCS() {
      this.name = 'DeviceCMYK';
      this.numComps = 4;
-     this.defaultColor = new Float32Array([
-      0,
-      0,
-      0,
-      1
-     ]);
+     this.defaultColor = new Float32Array(this.numComps);
+     this.defaultColor[3] = 1;
     }
     DeviceCmykCS.prototype = {
      getRgb: ColorSpace.prototype.getRgb,
      getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
       convertToRgb(src, srcOffset, 1, dest, destOffset);
      },
      getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
       var scale = 1 / ((1 << bits) - 1);
@@ -40885,17 +40860,17 @@
      usesZeroToOneRange: true
     };
     return DeviceCmykCS;
    }();
    var CalGrayCS = function CalGrayCSClosure() {
     function CalGrayCS(whitePoint, blackPoint, gamma) {
      this.name = 'CalGray';
      this.numComps = 1;
-     this.defaultColor = new Float32Array([0]);
+     this.defaultColor = new Float32Array(this.numComps);
      if (!whitePoint) {
       error('WhitePoint missing - required for color space CalGray');
      }
      blackPoint = blackPoint || [
       0,
       0,
       0
      ];
@@ -40997,17 +40972,17 @@
     ]);
     var tempNormalizeMatrix = new Float32Array(3);
     var tempConvertMatrix1 = new Float32Array(3);
     var tempConvertMatrix2 = new Float32Array(3);
     var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
     function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
      this.name = 'CalRGB';
      this.numComps = 3;
-     this.defaultColor = new Float32Array(3);
+     this.defaultColor = new Float32Array(this.numComps);
      if (!whitePoint) {
       error('WhitePoint missing - required for color space CalRGB');
      }
      blackPoint = blackPoint || new Float32Array(3);
      gamma = gamma || new Float32Array([
       1,
       1,
       1
@@ -41197,21 +41172,17 @@
      usesZeroToOneRange: true
     };
     return CalRGBCS;
    }();
    var LabCS = function LabCSClosure() {
     function LabCS(whitePoint, blackPoint, range) {
      this.name = 'Lab';
      this.numComps = 3;
-     this.defaultColor = new Float32Array([
-      0,
-      0,
-      0
-     ]);
+     this.defaultColor = new Float32Array(this.numComps);
      if (!whitePoint) {
       error('WhitePoint missing - required for color space Lab');
      }
      blackPoint = blackPoint || [
       0,
       0,
       0
      ];
@@ -45616,73 +45587,73 @@
       var glyphsVMetrics = [];
       var defaultVMetrics;
       var i, ii, j, jj, start, code, widths;
       if (properties.composite) {
        defaultWidth = dict.get('DW') || 1000;
        widths = dict.get('W');
        if (widths) {
         for (i = 0, ii = widths.length; i < ii; i++) {
-         start = widths[i++];
+         start = xref.fetchIfRef(widths[i++]);
          code = xref.fetchIfRef(widths[i]);
          if (isArray(code)) {
           for (j = 0, jj = code.length; j < jj; j++) {
-           glyphsWidths[start++] = code[j];
+           glyphsWidths[start++] = xref.fetchIfRef(code[j]);
           }
          } else {
-          var width = widths[++i];
+          var width = xref.fetchIfRef(widths[++i]);
           for (j = start; j <= code; j++) {
            glyphsWidths[j] = width;
           }
          }
         }
        }
        if (properties.vertical) {
-        var vmetrics = dict.get('DW2') || [
+        var vmetrics = dict.getArray('DW2') || [
          880,
          -1000
         ];
         defaultVMetrics = [
          vmetrics[1],
          defaultWidth * 0.5,
          vmetrics[0]
         ];
         vmetrics = dict.get('W2');
         if (vmetrics) {
          for (i = 0, ii = vmetrics.length; i < ii; i++) {
-          start = vmetrics[i++];
+          start = xref.fetchIfRef(vmetrics[i++]);
           code = xref.fetchIfRef(vmetrics[i]);
           if (isArray(code)) {
            for (j = 0, jj = code.length; j < jj; j++) {
             glyphsVMetrics[start++] = [
-             code[j++],
-             code[j++],
-             code[j]
+             xref.fetchIfRef(code[j++]),
+             xref.fetchIfRef(code[j++]),
+             xref.fetchIfRef(code[j])
             ];
            }
           } else {
            var vmetric = [
-            vmetrics[++i],
-            vmetrics[++i],
-            vmetrics[++i]
+            xref.fetchIfRef(vmetrics[++i]),
+            xref.fetchIfRef(vmetrics[++i]),
+            xref.fetchIfRef(vmetrics[++i])
            ];
            for (j = start; j <= code; j++) {
             glyphsVMetrics[j] = vmetric;
            }
           }
          }
         }
        }
       } else {
        var firstChar = properties.firstChar;
        widths = dict.get('Widths');
        if (widths) {
         j = firstChar;
         for (i = 0, ii = widths.length; i < ii; i++) {
-         glyphsWidths[j++] = widths[i];
+         glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
         }
         defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
        } else {
         var baseFontName = dict.get('BaseFont');
         if (isName(baseFontName)) {
          var metrics = this.getBaseFontMetrics(baseFontName.name);
          glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
          defaultWidth = metrics.defaultWidth;
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -1302,17 +1302,17 @@ var pdfjsWebLibs;
     }
     return delta;
    }
    var animationStarted = new Promise(function (resolve) {
     window.requestAnimationFrame(resolve);
    });
    var localized = new Promise(function (resolve, reject) {
     if (!mozL10n) {
-     reject(new Error('mozL10n service is not available.'));
+     resolve();
      return;
     }
     if (mozL10n.getReadyState() !== 'loading') {
      resolve();
      return;
     }
     window.addEventListener('localized', function localized(evt) {
      resolve();
@@ -6712,17 +6712,17 @@ var pdfjsWebLibs;
     if (PDFViewerApplication.pdfViewer.containsElement(evt.target) || appConfig.toolbar.container.contains(evt.target) && evt.target !== appConfig.secondaryToolbar.toggleButton) {
      PDFViewerApplication.secondaryToolbar.close();
     }
    }, true);
    window.addEventListener('keydown', function keydown(evt) {
     if (OverlayManager.active) {
      return;
     }
-    var handled = false;
+    var handled = false, ensureViewerFocused = false;
     var cmd = (evt.ctrlKey ? 1 : 0) | (evt.altKey ? 2 : 0) | (evt.shiftKey ? 4 : 0) | (evt.metaKey ? 8 : 0);
     var pdfViewer = PDFViewerApplication.pdfViewer;
     var isViewerInPresentationMode = pdfViewer && pdfViewer.isInPresentationMode;
     if (cmd === 1 || cmd === 8 || cmd === 5 || cmd === 12) {
      switch (evt.keyCode) {
      case 70:
       if (!PDFViewerApplication.supportsIntegratedFind) {
        PDFViewerApplication.findBar.open();
@@ -6765,42 +6765,58 @@ var pdfjsWebLibs;
      case 96:
       if (!isViewerInPresentationMode) {
        setTimeout(function () {
         pdfViewer.currentScaleValue = DEFAULT_SCALE_VALUE;
        });
        handled = false;
       }
       break;
+     case 38:
+      if (isViewerInPresentationMode || PDFViewerApplication.page > 1) {
+       PDFViewerApplication.page = 1;
+       handled = true;
+       ensureViewerFocused = true;
+      }
+      break;
+     case 40:
+      if (isViewerInPresentationMode || PDFViewerApplication.page < PDFViewerApplication.pagesCount) {
+       PDFViewerApplication.page = PDFViewerApplication.pagesCount;
+       handled = true;
+       ensureViewerFocused = true;
+      }
+      break;
      }
     }
     if (cmd === 3 || cmd === 10) {
      switch (evt.keyCode) {
      case 80:
       PDFViewerApplication.requestPresentationMode();
       handled = true;
       break;
      case 71:
       PDFViewerApplication.appConfig.toolbar.pageNumber.select();
       handled = true;
       break;
      }
     }
     if (handled) {
+     if (ensureViewerFocused && !isViewerInPresentationMode) {
+      pdfViewer.focus();
+     }
      evt.preventDefault();
      return;
     }
     var curElement = document.activeElement || document.querySelector(':focus');
     var curElementTagName = curElement && curElement.tagName.toUpperCase();
     if (curElementTagName === 'INPUT' || curElementTagName === 'TEXTAREA' || curElementTagName === 'SELECT') {
      if (evt.keyCode !== 27) {
       return;
      }
     }
-    var ensureViewerFocused = false;
     if (cmd === 0) {
      switch (evt.keyCode) {
      case 38:
      case 33:
      case 8:
       if (!isViewerInPresentationMode && pdfViewer.currentScaleValue !== 'page-fit') {
        break;
       }