Fix the remaining no-var
failures, which couldn't be handled automatically, in the src/core/evaluator.js
file
The only *slight* complication here were some of the `switch`-cases, in `getOperatorList`/`getTextContent`, where the parsing is done asynchronously. However, those cases are easy to deal with by wrapping the code within its own block; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch#block-scope_variables_within_switch_statements
This commit is contained in:
parent
f93c3b9aa7
commit
0ef9b5aafc
@ -393,7 +393,8 @@ class PartialEvaluator {
|
|||||||
} else {
|
} else {
|
||||||
bbox = null;
|
bbox = null;
|
||||||
}
|
}
|
||||||
let optionalContent = null;
|
let optionalContent = null,
|
||||||
|
groupOptions = null;
|
||||||
if (dict.has("OC")) {
|
if (dict.has("OC")) {
|
||||||
optionalContent = await this.parseMarkedContentProps(
|
optionalContent = await this.parseMarkedContentProps(
|
||||||
dict.get("OC"),
|
dict.get("OC"),
|
||||||
@ -403,7 +404,7 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
const group = dict.get("Group");
|
const group = dict.get("Group");
|
||||||
if (group) {
|
if (group) {
|
||||||
var groupOptions = {
|
groupOptions = {
|
||||||
matrix,
|
matrix,
|
||||||
bbox,
|
bbox,
|
||||||
smask,
|
smask,
|
||||||
@ -1004,8 +1005,8 @@ class PartialEvaluator {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let fontRef,
|
const xref = this.xref;
|
||||||
xref = this.xref;
|
let fontRef;
|
||||||
if (font) {
|
if (font) {
|
||||||
// Loading by ref.
|
// Loading by ref.
|
||||||
if (!isRef(font)) {
|
if (!isRef(font)) {
|
||||||
@ -1070,8 +1071,8 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
const { descriptor, hash } = preEvaluatedFont;
|
const { descriptor, hash } = preEvaluatedFont;
|
||||||
|
|
||||||
let fontRefIsRef = isRef(fontRef),
|
const fontRefIsRef = isRef(fontRef);
|
||||||
fontID;
|
let fontID;
|
||||||
if (fontRefIsRef) {
|
if (fontRefIsRef) {
|
||||||
fontID = `f${fontRef.toString()}`;
|
fontID = `f${fontRef.toString()}`;
|
||||||
}
|
}
|
||||||
@ -1464,12 +1465,9 @@ class PartialEvaluator {
|
|||||||
};
|
};
|
||||||
task.ensureNotTerminated();
|
task.ensureNotTerminated();
|
||||||
timeSlotManager.reset();
|
timeSlotManager.reset();
|
||||||
let stop,
|
|
||||||
operation = {},
|
const operation = {};
|
||||||
i,
|
let stop, i, ii, cs;
|
||||||
ii,
|
|
||||||
cs,
|
|
||||||
name;
|
|
||||||
while (!(stop = timeSlotManager.check())) {
|
while (!(stop = timeSlotManager.check())) {
|
||||||
// The arguments parsed by read() are used beyond this loop, so we
|
// The arguments parsed by read() are used beyond this loop, so we
|
||||||
// cannot reuse the same array on each iteration. Therefore we pass
|
// cannot reuse the same array on each iteration. Therefore we pass
|
||||||
@ -1483,9 +1481,9 @@ class PartialEvaluator {
|
|||||||
let fn = operation.fn;
|
let fn = operation.fn;
|
||||||
|
|
||||||
switch (fn | 0) {
|
switch (fn | 0) {
|
||||||
case OPS.paintXObject:
|
case OPS.paintXObject: {
|
||||||
// eagerly compile XForm objects
|
// eagerly compile XForm objects
|
||||||
name = args[0].name;
|
const name = args[0].name;
|
||||||
if (name) {
|
if (name) {
|
||||||
const localImage = localImageCache.getByName(name);
|
const localImage = localImageCache.getByName(name);
|
||||||
if (localImage) {
|
if (localImage) {
|
||||||
@ -1591,8 +1589,9 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
case OPS.setFont:
|
}
|
||||||
var fontSize = args[1];
|
case OPS.setFont: {
|
||||||
|
const fontSize = args[1];
|
||||||
// eagerly collect all fonts
|
// eagerly collect all fonts
|
||||||
next(
|
next(
|
||||||
self
|
self
|
||||||
@ -1611,14 +1610,15 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case OPS.beginText:
|
case OPS.beginText:
|
||||||
parsingText = true;
|
parsingText = true;
|
||||||
break;
|
break;
|
||||||
case OPS.endText:
|
case OPS.endText:
|
||||||
parsingText = false;
|
parsingText = false;
|
||||||
break;
|
break;
|
||||||
case OPS.endInlineImage:
|
case OPS.endInlineImage: {
|
||||||
var cacheKey = args[0].cacheKey;
|
const cacheKey = args[0].cacheKey;
|
||||||
if (cacheKey) {
|
if (cacheKey) {
|
||||||
const localImage = localImageCache.getByName(cacheKey);
|
const localImage = localImageCache.getByName(cacheKey);
|
||||||
if (localImage) {
|
if (localImage) {
|
||||||
@ -1639,6 +1639,7 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case OPS.showText:
|
case OPS.showText:
|
||||||
if (!stateManager.state.font) {
|
if (!stateManager.state.font) {
|
||||||
self.ensureStateFont(stateManager.state);
|
self.ensureStateFont(stateManager.state);
|
||||||
@ -1651,10 +1652,10 @@ class PartialEvaluator {
|
|||||||
self.ensureStateFont(stateManager.state);
|
self.ensureStateFont(stateManager.state);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var arr = args[0];
|
const arr = args[0],
|
||||||
var combinedGlyphs = [];
|
arrLength = arr.length,
|
||||||
var arrLength = arr.length;
|
combinedGlyphs = [],
|
||||||
var state = stateManager.state;
|
state = stateManager.state;
|
||||||
for (i = 0; i < arrLength; ++i) {
|
for (i = 0; i < arrLength; ++i) {
|
||||||
const arrItem = arr[i];
|
const arrItem = arr[i];
|
||||||
if (isString(arrItem)) {
|
if (isString(arrItem)) {
|
||||||
@ -1826,18 +1827,18 @@ class PartialEvaluator {
|
|||||||
fn = OPS.setStrokeRGBColor;
|
fn = OPS.setStrokeRGBColor;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPS.shadingFill:
|
case OPS.shadingFill: {
|
||||||
var shadingRes = resources.get("Shading");
|
const shadingRes = resources.get("Shading");
|
||||||
if (!shadingRes) {
|
if (!shadingRes) {
|
||||||
throw new FormatError("No shading resource found");
|
throw new FormatError("No shading resource found");
|
||||||
}
|
}
|
||||||
|
|
||||||
var shading = shadingRes.get(args[0].name);
|
const shading = shadingRes.get(args[0].name);
|
||||||
if (!shading) {
|
if (!shading) {
|
||||||
throw new FormatError("No shading object found");
|
throw new FormatError("No shading object found");
|
||||||
}
|
}
|
||||||
|
|
||||||
var shadingFill = Pattern.parseShading(
|
const shadingFill = Pattern.parseShading(
|
||||||
shading,
|
shading,
|
||||||
null,
|
null,
|
||||||
xref,
|
xref,
|
||||||
@ -1846,12 +1847,13 @@ class PartialEvaluator {
|
|||||||
self._pdfFunctionFactory,
|
self._pdfFunctionFactory,
|
||||||
localColorSpaceCache
|
localColorSpaceCache
|
||||||
);
|
);
|
||||||
var patternIR = shadingFill.getIR();
|
const patternIR = shadingFill.getIR();
|
||||||
args = [patternIR];
|
args = [patternIR];
|
||||||
fn = OPS.shadingFill;
|
fn = OPS.shadingFill;
|
||||||
break;
|
break;
|
||||||
case OPS.setGState:
|
}
|
||||||
name = args[0].name;
|
case OPS.setGState: {
|
||||||
|
const name = args[0].name;
|
||||||
if (name) {
|
if (name) {
|
||||||
const localGStateObj = localGStateCache.getByName(name);
|
const localGStateObj = localGStateCache.getByName(name);
|
||||||
if (localGStateObj) {
|
if (localGStateObj) {
|
||||||
@ -1911,6 +1913,7 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case OPS.moveTo:
|
case OPS.moveTo:
|
||||||
case OPS.lineTo:
|
case OPS.lineTo:
|
||||||
case OPS.curveTo:
|
case OPS.curveTo:
|
||||||
@ -2214,8 +2217,8 @@ class PartialEvaluator {
|
|||||||
// Replaces all whitespaces with standard spaces (0x20), to avoid
|
// Replaces all whitespaces with standard spaces (0x20), to avoid
|
||||||
// alignment issues between the textLayer and the canvas if the text
|
// alignment issues between the textLayer and the canvas if the text
|
||||||
// contains e.g. tabs (fixes issue6612.pdf).
|
// contains e.g. tabs (fixes issue6612.pdf).
|
||||||
|
const ii = str.length;
|
||||||
let i = 0,
|
let i = 0,
|
||||||
ii = str.length,
|
|
||||||
code;
|
code;
|
||||||
while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
|
while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
|
||||||
i++;
|
i++;
|
||||||
@ -2548,8 +2551,9 @@ class PartialEvaluator {
|
|||||||
};
|
};
|
||||||
task.ensureNotTerminated();
|
task.ensureNotTerminated();
|
||||||
timeSlotManager.reset();
|
timeSlotManager.reset();
|
||||||
|
|
||||||
|
const operation = {};
|
||||||
let stop,
|
let stop,
|
||||||
operation = {},
|
|
||||||
args = [];
|
args = [];
|
||||||
while (!(stop = timeSlotManager.check())) {
|
while (!(stop = timeSlotManager.check())) {
|
||||||
// The arguments parsed by read() are not used beyond this loop, so
|
// The arguments parsed by read() are not used beyond this loop, so
|
||||||
@ -2565,9 +2569,9 @@ class PartialEvaluator {
|
|||||||
args = operation.args;
|
args = operation.args;
|
||||||
|
|
||||||
switch (fn | 0) {
|
switch (fn | 0) {
|
||||||
case OPS.setFont:
|
case OPS.setFont: {
|
||||||
// Optimization to ignore multiple identical Tf commands.
|
// Optimization to ignore multiple identical Tf commands.
|
||||||
var fontNameArg = args[0].name,
|
const fontNameArg = args[0].name,
|
||||||
fontSizeArg = args[1];
|
fontSizeArg = args[1];
|
||||||
if (
|
if (
|
||||||
textState.font &&
|
textState.font &&
|
||||||
@ -2582,6 +2586,7 @@ class PartialEvaluator {
|
|||||||
textState.fontSize = fontSizeArg;
|
textState.fontSize = fontSizeArg;
|
||||||
next(handleSetFont(fontNameArg, null));
|
next(handleSetFont(fontNameArg, null));
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case OPS.setTextRise:
|
case OPS.setTextRise:
|
||||||
flushTextContentItem();
|
flushTextContentItem();
|
||||||
textState.textRise = args[0];
|
textState.textRise = args[0];
|
||||||
@ -2731,13 +2736,13 @@ class PartialEvaluator {
|
|||||||
isFirstChunk: true,
|
isFirstChunk: true,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case OPS.paintXObject:
|
case OPS.paintXObject: {
|
||||||
flushTextContentItem();
|
flushTextContentItem();
|
||||||
if (!xobjs) {
|
if (!xobjs) {
|
||||||
xobjs = resources.get("XObject") || Dict.empty;
|
xobjs = resources.get("XObject") || Dict.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = args[0].name;
|
const name = args[0].name;
|
||||||
if (name && emptyXObjectCache.getByName(name)) {
|
if (name && emptyXObjectCache.getByName(name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2848,8 +2853,9 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
case OPS.setGState:
|
}
|
||||||
name = args[0].name;
|
case OPS.setGState: {
|
||||||
|
const name = args[0].name;
|
||||||
if (name && emptyGStateCache.getByName(name)) {
|
if (name && emptyGStateCache.getByName(name)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2902,6 +2908,7 @@ class PartialEvaluator {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
case OPS.beginMarkedContent:
|
case OPS.beginMarkedContent:
|
||||||
if (includeMarkedContent) {
|
if (includeMarkedContent) {
|
||||||
textContent.items.push({
|
textContent.items.push({
|
||||||
@ -3557,8 +3564,9 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const descriptor = dict.get("FontDescriptor");
|
const descriptor = dict.get("FontDescriptor");
|
||||||
|
let hash;
|
||||||
if (descriptor) {
|
if (descriptor) {
|
||||||
var hash = new MurmurHash3_64();
|
hash = new MurmurHash3_64();
|
||||||
const encoding = baseDict.getRaw("Encoding");
|
const encoding = baseDict.getRaw("Encoding");
|
||||||
if (isName(encoding)) {
|
if (isName(encoding)) {
|
||||||
hash.update(encoding.name);
|
hash.update(encoding.name);
|
||||||
@ -3732,7 +3740,7 @@ class PartialEvaluator {
|
|||||||
throw new FormatError("invalid font name");
|
throw new FormatError("invalid font name");
|
||||||
}
|
}
|
||||||
|
|
||||||
let fontFile;
|
let fontFile, subtype, length1, length2, length3;
|
||||||
try {
|
try {
|
||||||
fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
|
fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
@ -3744,13 +3752,13 @@ class PartialEvaluator {
|
|||||||
}
|
}
|
||||||
if (fontFile) {
|
if (fontFile) {
|
||||||
if (fontFile.dict) {
|
if (fontFile.dict) {
|
||||||
var subtype = fontFile.dict.get("Subtype");
|
const subtypeEntry = fontFile.dict.get("Subtype");
|
||||||
if (subtype) {
|
if (subtypeEntry instanceof Name) {
|
||||||
subtype = subtype.name;
|
subtype = subtypeEntry.name;
|
||||||
}
|
}
|
||||||
var length1 = fontFile.dict.get("Length1");
|
length1 = fontFile.dict.get("Length1");
|
||||||
var length2 = fontFile.dict.get("Length2");
|
length2 = fontFile.dict.get("Length2");
|
||||||
var length3 = fontFile.dict.get("Length3");
|
length3 = fontFile.dict.get("Length3");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user