Introduce some logical assignment in the src/core/ folder

This commit is contained in:
Jonas Jenwald 2022-07-17 11:24:05 +02:00
parent 317abd6d07
commit d950b91c4e
20 changed files with 62 additions and 103 deletions

View file

@ -519,7 +519,7 @@ class PartialEvaluator {
}
if (smask && smask.backdrop) {
colorSpace = colorSpace || ColorSpace.singletons.rgb;
colorSpace ||= ColorSpace.singletons.rgb;
smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
}
@ -1272,10 +1272,7 @@ class PartialEvaluator {
}
if (hash && descriptor instanceof Dict) {
if (!descriptor.fontAliases) {
descriptor.fontAliases = Object.create(null);
}
const fontAliases = descriptor.fontAliases;
const fontAliases = (descriptor.fontAliases ||= Object.create(null));
if (fontAliases[hash]) {
const aliasFontRef = fontAliases[hash].aliasRef;
@ -1668,8 +1665,8 @@ class PartialEvaluator {
}) {
// Ensure that `resources`/`initialState` is correctly initialized,
// even if the provided parameter is e.g. `null`.
resources = resources || Dict.empty;
initialState = initialState || new EvalState();
resources ||= Dict.empty;
initialState ||= new EvalState();
if (!operatorList) {
throw new Error('getOperatorList: missing "operatorList" parameter');
@ -2276,11 +2273,11 @@ class PartialEvaluator {
}) {
// Ensure that `resources`/`stateManager` is correctly initialized,
// even if the provided parameter is e.g. `null`.
resources = resources || Dict.empty;
stateManager = stateManager || new StateManager(new TextState());
resources ||= Dict.empty;
stateManager ||= new StateManager(new TextState());
if (includeMarkedContent) {
markedContentData = markedContentData || { level: 0 };
markedContentData ||= { level: 0 };
}
const textContent = {
@ -4255,7 +4252,7 @@ class PartialEvaluator {
}
}
}
fontName = fontName || baseFont;
fontName ||= baseFont;
if (!(fontName instanceof Name)) {
throw new FormatError("invalid font name");