Change PartialEvaluator.handleColorN
to throw when no valid pattern is found
Currently `handleColorN` will fallback to add a completely unparsed/unvalidated operator when no valid pattern was found. This is unfortunate, since it could very easily lead to a couple of different errors: - `DataCloneError`s when attempting to send the data to the main-thread, e.g. when `args` is `Dict`/`Stream`. - Errors in `getShadingPatternFromIR` on the main-thread, unless `args` just happens to have the expected format. - Errors when actually attempting to render the pattern on the main-thread, since the `args` will most likely not have the expected format. Hence it probably makes sense to error in `PartialEvaluator.handleColorN`, and having invalid patterns fail gracefully via the existing `ignoreErrors` code-paths instead.
This commit is contained in:
parent
155304a0c1
commit
007fab6ab5
@ -853,9 +853,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
}
|
||||
},
|
||||
|
||||
handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args,
|
||||
cs, patterns,
|
||||
resources, task) {
|
||||
async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
|
||||
// compile tiling patterns
|
||||
var patternName = args[args.length - 1];
|
||||
// SCN/scn applies patterns along with normal colors
|
||||
@ -875,13 +873,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
pattern = Pattern.parseShading(shading, matrix, this.xref, resources,
|
||||
this.handler, this.pdfFunctionFactory);
|
||||
operatorList.addOp(fn, pattern.getIR());
|
||||
return Promise.resolve();
|
||||
return undefined;
|
||||
}
|
||||
return Promise.reject(new Error('Unknown PatternType: ' + typeNum));
|
||||
throw new FormatError(`Unknown PatternType: ${typeNum}`);
|
||||
}
|
||||
// TODO shall we fail here?
|
||||
operatorList.addOp(fn, args);
|
||||
return Promise.resolve();
|
||||
throw new FormatError(`Unknown PatternName: ${patternName}`);
|
||||
},
|
||||
|
||||
getOperatorList({ stream, task, resources, operatorList,
|
||||
|
Loading…
x
Reference in New Issue
Block a user