diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index e6fba5232092..4ba2267f4e45 100644 --- 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 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index 4f7994827836..e0e53c5a56bb 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -23,8 +23,8 @@ } }(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() { @@ -1722,7 +1722,7 @@ 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; }); diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index ce85d7555e9a..1e696cc3db8c 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -23,8 +23,8 @@ } }(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() { @@ -40454,11 +40454,8 @@ } } 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'; @@ -40474,11 +40471,10 @@ 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': @@ -40561,12 +40557,7 @@ 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 [ @@ -40654,22 +40645,16 @@ 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; } @@ -40702,27 +40687,25 @@ 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, @@ -40758,7 +40741,7 @@ 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, @@ -40794,11 +40777,7 @@ 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, @@ -40854,12 +40833,8 @@ 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, @@ -40890,7 +40865,7 @@ 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'); } @@ -41002,7 +40977,7 @@ 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'); } @@ -41202,11 +41177,7 @@ 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'); } @@ -45621,14 +45592,14 @@ 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; } @@ -45636,7 +45607,7 @@ } } if (properties.vertical) { - var vmetrics = dict.get('DW2') || [ + var vmetrics = dict.getArray('DW2') || [ 880, -1000 ]; @@ -45648,21 +45619,21 @@ 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; @@ -45677,7 +45648,7 @@ 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 { diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 18c1e19661a3..b471a4e55d5b 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -1307,7 +1307,7 @@ var pdfjsWebLibs; }); var localized = new Promise(function (resolve, reject) { if (!mozL10n) { - reject(new Error('mozL10n service is not available.')); + resolve(); return; } if (mozL10n.getReadyState() !== 'loading') { @@ -6717,7 +6717,7 @@ var pdfjsWebLibs; 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; @@ -6770,6 +6770,20 @@ var pdfjsWebLibs; 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) { @@ -6785,6 +6799,9 @@ var pdfjsWebLibs; } } if (handled) { + if (ensureViewerFocused && !isViewerInPresentationMode) { + pdfViewer.focus(); + } evt.preventDefault(); return; } @@ -6795,7 +6812,6 @@ var pdfjsWebLibs; return; } } - var ensureViewerFocused = false; if (cmd === 0) { switch (evt.keyCode) { case 38: