Merge pull request #13472 from Snuffleupagus/checkbox-print-evaluator

Don't change options of the globally used `PartialEvaluator` in the "should render checkbox with fallback font for printing" unit-test
This commit is contained in:
calixteman 2021-05-31 14:06:38 +02:00 committed by GitHub
commit 706c27b9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -229,9 +229,13 @@ class PartialEvaluator {
return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory); return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory);
} }
clone(newOptions = DefaultPartialEvaluatorOptions) { clone(newOptions = null) {
const newEvaluator = Object.create(this); const newEvaluator = Object.create(this);
newEvaluator.options = newOptions; newEvaluator.options = Object.assign(
Object.create(null),
this.options,
newOptions
);
return newEvaluator; return newEvaluator;
} }
@ -3948,9 +3952,7 @@ class TranslatedFont {
// When parsing Type3 glyphs, always ignore them if there are errors. // When parsing Type3 glyphs, always ignore them if there are errors.
// Compared to the parsing of e.g. an entire page, it doesn't really // Compared to the parsing of e.g. an entire page, it doesn't really
// make sense to only be able to render a Type3 glyph partially. // make sense to only be able to render a Type3 glyph partially.
const type3Options = Object.create(evaluator.options); const type3Evaluator = evaluator.clone({ ignoreErrors: false });
type3Options.ignoreErrors = false;
const type3Evaluator = evaluator.clone(type3Options);
type3Evaluator.parsingType3Font = true; type3Evaluator.parsingType3Font = true;
const translatedFont = this.font, const translatedFont = this.font,

View File

@ -2281,7 +2281,7 @@ describe("annotation", function () {
{ ref: buttonWidgetRef, data: buttonWidgetDict }, { ref: buttonWidgetRef, data: buttonWidgetDict },
]); ]);
const task = new WorkerTask("test print"); const task = new WorkerTask("test print");
partialEvaluator.options = { ignoreErrors: true }; const checkboxEvaluator = partialEvaluator.clone({ ignoreErrors: true });
const annotation = await AnnotationFactory.create( const annotation = await AnnotationFactory.create(
xref, xref,
@ -2293,7 +2293,7 @@ describe("annotation", function () {
annotationStorage.set(annotation.data.id, { value: true }); annotationStorage.set(annotation.data.id, { value: true });
const operatorList = await annotation.getOperatorList( const operatorList = await annotation.getOperatorList(
partialEvaluator, checkboxEvaluator,
task, task,
false, false,
annotationStorage annotationStorage