Change the signature of PartialEvaluator.buildPaintImageXObject to take a parameter object

This method currently requires a fair number of parameters, which creates quite	unwieldy call-sites. When invoking `buildPaintImageXObject`, you have to remember not only which arguments to supply, but also the correct order, to prevent run-time errors.
This commit is contained in:
Jonas Jenwald 2018-02-01 15:44:49 +01:00
parent 6b7e2cbcd1
commit ec85d5c625

View File

@ -349,10 +349,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}); });
}, },
buildPaintImageXObject: buildPaintImageXObject({ resources, image, isInline = false, operatorList,
function PartialEvaluator_buildPaintImageXObject(resources, image, cacheKey, imageCache, }) {
inline, operatorList,
cacheKey, imageCache) {
var dict = image.dict; var dict = image.dict;
var w = dict.get('Width', 'W'); var w = dict.get('Width', 'W');
var h = dict.get('Height', 'H'); var h = dict.get('Height', 'H');
@ -406,13 +404,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var SMALL_IMAGE_DIMENSIONS = 200; var SMALL_IMAGE_DIMENSIONS = 200;
// Inlining small images into the queue as RGB data // Inlining small images into the queue as RGB data
if (inline && !softMask && !mask && !(image instanceof JpegStream) && if (isInline && !softMask && !mask && !(image instanceof JpegStream) &&
(w + h) < SMALL_IMAGE_DIMENSIONS) { (w + h) < SMALL_IMAGE_DIMENSIONS) {
let imageObj = new PDFImage({ let imageObj = new PDFImage({
xref: this.xref, xref: this.xref,
res: resources, res: resources,
image, image,
isInline: inline, isInline,
pdfFunctionFactory: this.pdfFunctionFactory, pdfFunctionFactory: this.pdfFunctionFactory,
}); });
// We force the use of RGBA_32BPP images here, because we can't handle // We force the use of RGBA_32BPP images here, because we can't handle
@ -465,7 +463,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
xref: this.xref, xref: this.xref,
res: resources, res: resources,
image, image,
isInline: inline, isInline,
nativeDecoder: nativeImageDecoder, nativeDecoder: nativeImageDecoder,
pdfFunctionFactory: this.pdfFunctionFactory, pdfFunctionFactory: this.pdfFunctionFactory,
}).then((imageObj) => { }).then((imageObj) => {
@ -989,8 +987,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}, rejectXObject); }, rejectXObject);
return; return;
} else if (type.name === 'Image') { } else if (type.name === 'Image') {
self.buildPaintImageXObject(resources, xobj, false, self.buildPaintImageXObject({
operatorList, name, imageCache); resources,
image: xobj,
operatorList,
cacheKey: name,
imageCache,
});
} else if (type.name === 'PS') { } else if (type.name === 'PS') {
// PostScript XObjects are unused when viewing documents. // PostScript XObjects are unused when viewing documents.
// See section 4.7.1 of Adobe's PDF reference. // See section 4.7.1 of Adobe's PDF reference.
@ -1032,8 +1035,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
continue; continue;
} }
} }
self.buildPaintImageXObject(resources, args[0], true, self.buildPaintImageXObject({
operatorList, cacheKey, imageCache); resources,
image: args[0],
isInline: true,
operatorList,
cacheKey,
imageCache,
});
args = null; args = null;
continue; continue;
case OPS.showText: case OPS.showText: