Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't change options of the globally used PartialEvaluator in the "should render checkbox with fallback font for printing" unit-test #13472

Merged
merged 2 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,13 @@ class PartialEvaluator {
return shadow(this, "_pdfFunctionFactory", pdfFunctionFactory);
}

clone(newOptions = DefaultPartialEvaluatorOptions) {
clone(newOptions = null) {
const newEvaluator = Object.create(this);
newEvaluator.options = newOptions;
newEvaluator.options = Object.assign(
Object.create(null),
this.options,
newOptions
);
return newEvaluator;
}

Expand Down Expand Up @@ -3948,9 +3952,7 @@ class TranslatedFont {
// 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
// make sense to only be able to render a Type3 glyph partially.
const type3Options = Object.create(evaluator.options);
type3Options.ignoreErrors = false;
const type3Evaluator = evaluator.clone(type3Options);
const type3Evaluator = evaluator.clone({ ignoreErrors: false });
type3Evaluator.parsingType3Font = true;

const translatedFont = this.font,
Expand Down
4 changes: 2 additions & 2 deletions test/unit/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ describe("annotation", function () {
{ ref: buttonWidgetRef, data: buttonWidgetDict },
]);
const task = new WorkerTask("test print");
partialEvaluator.options = { ignoreErrors: true };
const checkboxEvaluator = partialEvaluator.clone({ ignoreErrors: true });

const annotation = await AnnotationFactory.create(
xref,
Expand All @@ -2293,7 +2293,7 @@ describe("annotation", function () {
annotationStorage.set(annotation.data.id, { value: true });

const operatorList = await annotation.getOperatorList(
partialEvaluator,
checkboxEvaluator,
task,
false,
annotationStorage
Expand Down