diff options
author | Ryan VanderMeulen <ryanvm@gmail.com> | 2018-04-13 10:46:47 -0400 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-04-19 12:03:19 +0200 |
commit | e2403192f5088d3733762ba6ed4fd74fd0ab4a2d (patch) | |
tree | 1318f8b761a68374b87f961471329faa4a94d63e /browser/extensions/pdfjs/content/build | |
parent | 9472136272f01b858412f2d9d7854d2daa82496f (diff) | |
download | UXP-e2403192f5088d3733762ba6ed4fd74fd0ab4a2d.tar UXP-e2403192f5088d3733762ba6ed4fd74fd0ab4a2d.tar.gz UXP-e2403192f5088d3733762ba6ed4fd74fd0ab4a2d.tar.lz UXP-e2403192f5088d3733762ba6ed4fd74fd0ab4a2d.tar.xz UXP-e2403192f5088d3733762ba6ed4fd74fd0ab4a2d.zip |
Bug 1452075 - Backport some upstream pdf.js fixes.
Diffstat (limited to 'browser/extensions/pdfjs/content/build')
-rw-r--r-- | browser/extensions/pdfjs/content/build/pdf.worker.js | 67 |
1 files changed, 38 insertions, 29 deletions
diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index 4c35bd401..6ce519940 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -41653,6 +41653,22 @@ var isStream = corePrimitives.isStream; var PostScriptLexer = corePsParser.PostScriptLexer; var PostScriptParser = corePsParser.PostScriptParser; + function toNumberArray(arr) { + if (!Array.isArray(arr)) { + return null; + } + var length = arr.length; + for (var i = 0; i < length; i++) { + if (typeof arr[i] !== 'number') { + var result = new Array(length); + for (var j = 0; j < length; j++) { + result[j] = +arr[j]; + } + return result; + } + } + return arr; + } var PDFFunction = function PDFFunctionClosure() { var CONSTRUCT_SAMPLED = 0; var CONSTRUCT_INTERPOLATED = 2; @@ -41752,8 +41768,8 @@ } return out; } - var domain = dict.getArray('Domain'); - var range = dict.getArray('Range'); + var domain = toNumberArray(dict.getArray('Domain')); + var range = toNumberArray(dict.getArray('Range')); if (!domain || !range) { error('No domain or range'); } @@ -41761,7 +41777,7 @@ var outputSize = range.length / 2; domain = toMultiArray(domain); range = toMultiArray(range); - var size = dict.get('Size'); + var size = toNumberArray(dict.get('Size')); var bps = dict.get('BitsPerSample'); var order = dict.get('Order') || 1; if (order !== 1) { @@ -41769,16 +41785,16 @@ // As in poppler, ignoring order, linear interpolation may work as good info('No support for cubic spline interpolation: ' + order); } - var encode = dict.getArray('Encode'); + var encode = toNumberArray(dict.getArray('Encode')); if (!encode) { encode = []; for (var i = 0; i < inputSize; ++i) { - encode.push(0); - encode.push(size[i] - 1); + encode.push([0, size[i] - 1]); } + } else { + encode = toMultiArray(encode); } - encode = toMultiArray(encode); - var decode = dict.getArray('Decode'); + var decode = toNumberArray(dict.getArray('Decode')); if (!decode) { decode = range; } else { @@ -41873,12 +41889,9 @@ }; }, constructInterpolated: function PDFFunction_constructInterpolated(str, dict) { - var c0 = dict.getArray('C0') || [0]; - var c1 = dict.getArray('C1') || [1]; + var c0 = toNumberArray(dict.getArray('C0')) || [0]; + var c1 = toNumberArray(dict.getArray('C1')) || [1]; var n = dict.get('N'); - if (!isArray(c0) || !isArray(c1)) { - error('Illegal dictionary for interpolated function'); - } var length = c0.length; var diff = []; for (var i = 0; i < length; ++i) { @@ -41904,7 +41917,7 @@ }; }, constructStiched: function PDFFunction_constructStiched(fn, dict, xref) { - var domain = dict.getArray('Domain'); + var domain = toNumberArray(dict.getArray('Domain')); if (!domain) { error('No domain'); } @@ -41915,10 +41928,10 @@ var fnRefs = dict.get('Functions'); var fns = []; for (var i = 0, ii = fnRefs.length; i < ii; ++i) { - fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i]))); + fns.push(PDFFunction.parse(xref, xref.fetchIfRef(fnRefs[i]))); } - var bounds = dict.getArray('Bounds'); - var encode = dict.getArray('Encode'); + var bounds = toNumberArray(dict.getArray('Bounds')); + var encode = toNumberArray(dict.getArray('Encode')); return [ CONSTRUCT_STICHED, domain, @@ -41931,12 +41944,8 @@ var domain = IR[1]; var bounds = IR[2]; var encode = IR[3]; - var fnsIR = IR[4]; - var fns = []; + var fns = IR[4]; var tmpBuf = new Float32Array(1); - for (var i = 0, ii = fnsIR.length; i < ii; i++) { - fns.push(PDFFunction.fromIR(fnsIR[i])); - } return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) { var clip = function constructStichedFromIRClip(v, min, max) { if (v > max) { @@ -41973,8 +41982,8 @@ }; }, constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) { - var domain = dict.getArray('Domain'); - var range = dict.getArray('Range'); + var domain = toNumberArray(dict.getArray('Domain')); + var range = toNumberArray(dict.getArray('Range')); if (!domain) { error('No domain.'); } @@ -42933,8 +42942,8 @@ case 'AlternateCS': var numComps = IR[1]; var alt = IR[2]; - var tintFnIR = IR[3]; - return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR)); + var tintFn = IR[3]; + return new AlternateCS(numComps, ColorSpace.fromIR(alt), tintFn); case 'LabCS': whitePoint = IR[1]; blackPoint = IR[2]; @@ -43072,12 +43081,12 @@ numComps = name.length; } alt = ColorSpace.parseToIR(cs[2], xref, res); - var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3])); + var tintFn = PDFFunction.parse(xref, xref.fetchIfRef(cs[3])); return [ 'AlternateCS', numComps, alt, - tintFnIR + tintFn ]; case 'Lab': params = xref.fetchIfRef(cs[1]); @@ -52488,4 +52497,4 @@ })); }.call(pdfjsLibs)); exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler; -}));
\ No newline at end of file +})); |