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

Revert "Fix the remaining no-var failures, which couldn't be handled automatically, in the src/core/evaluator.js file" (PR 13344 follow-up) #13371

Merged
Merged
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
76 changes: 34 additions & 42 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-var */

import {
AbortException,
Expand Down Expand Up @@ -393,8 +394,7 @@ class PartialEvaluator {
} else {
bbox = null;
}
let optionalContent = null,
groupOptions = null;
let optionalContent = null;
if (dict.has("OC")) {
optionalContent = await this.parseMarkedContentProps(
dict.get("OC"),
Expand All @@ -404,7 +404,7 @@ class PartialEvaluator {
}
const group = dict.get("Group");
if (group) {
groupOptions = {
var groupOptions = {
matrix,
bbox,
smask,
Expand Down Expand Up @@ -1467,7 +1467,7 @@ class PartialEvaluator {
timeSlotManager.reset();

const operation = {};
let stop, i, ii, cs;
let stop, i, ii, cs, name;
while (!(stop = timeSlotManager.check())) {
// The arguments parsed by read() are used beyond this loop, so we
// cannot reuse the same array on each iteration. Therefore we pass
Expand All @@ -1481,9 +1481,9 @@ class PartialEvaluator {
let fn = operation.fn;

switch (fn | 0) {
case OPS.paintXObject: {
case OPS.paintXObject:
// eagerly compile XForm objects
const name = args[0].name;
name = args[0].name;
if (name) {
const localImage = localImageCache.getByName(name);
if (localImage) {
Expand Down Expand Up @@ -1589,9 +1589,8 @@ class PartialEvaluator {
})
);
return;
}
case OPS.setFont: {
const fontSize = args[1];
case OPS.setFont:
var fontSize = args[1];
// eagerly collect all fonts
next(
self
Expand All @@ -1610,15 +1609,14 @@ class PartialEvaluator {
})
);
return;
}
case OPS.beginText:
parsingText = true;
break;
case OPS.endText:
parsingText = false;
break;
case OPS.endInlineImage: {
const cacheKey = args[0].cacheKey;
case OPS.endInlineImage:
var cacheKey = args[0].cacheKey;
if (cacheKey) {
const localImage = localImageCache.getByName(cacheKey);
if (localImage) {
Expand All @@ -1639,7 +1637,6 @@ class PartialEvaluator {
})
);
return;
}
case OPS.showText:
if (!stateManager.state.font) {
self.ensureStateFont(stateManager.state);
Expand All @@ -1652,10 +1649,10 @@ class PartialEvaluator {
self.ensureStateFont(stateManager.state);
continue;
}
const arr = args[0],
arrLength = arr.length,
combinedGlyphs = [],
state = stateManager.state;
var arr = args[0];
var combinedGlyphs = [];
var arrLength = arr.length;
var state = stateManager.state;
for (i = 0; i < arrLength; ++i) {
const arrItem = arr[i];
if (isString(arrItem)) {
Expand Down Expand Up @@ -1827,18 +1824,18 @@ class PartialEvaluator {
fn = OPS.setStrokeRGBColor;
break;

case OPS.shadingFill: {
const shadingRes = resources.get("Shading");
case OPS.shadingFill:
var shadingRes = resources.get("Shading");
if (!shadingRes) {
throw new FormatError("No shading resource found");
}

const shading = shadingRes.get(args[0].name);
var shading = shadingRes.get(args[0].name);
if (!shading) {
throw new FormatError("No shading object found");
}

const shadingFill = Pattern.parseShading(
var shadingFill = Pattern.parseShading(
shading,
null,
xref,
Expand All @@ -1847,13 +1844,12 @@ class PartialEvaluator {
self._pdfFunctionFactory,
localColorSpaceCache
);
const patternIR = shadingFill.getIR();
var patternIR = shadingFill.getIR();
args = [patternIR];
fn = OPS.shadingFill;
break;
}
case OPS.setGState: {
const name = args[0].name;
case OPS.setGState:
name = args[0].name;
if (name) {
const localGStateObj = localGStateCache.getByName(name);
if (localGStateObj) {
Expand Down Expand Up @@ -1913,7 +1909,6 @@ class PartialEvaluator {
})
);
return;
}
case OPS.moveTo:
case OPS.lineTo:
case OPS.curveTo:
Expand Down Expand Up @@ -2569,9 +2564,9 @@ class PartialEvaluator {
args = operation.args;

switch (fn | 0) {
case OPS.setFont: {
case OPS.setFont:
// Optimization to ignore multiple identical Tf commands.
const fontNameArg = args[0].name,
var fontNameArg = args[0].name,
fontSizeArg = args[1];
if (
textState.font &&
Expand All @@ -2586,7 +2581,6 @@ class PartialEvaluator {
textState.fontSize = fontSizeArg;
next(handleSetFont(fontNameArg, null));
return;
}
case OPS.setTextRise:
flushTextContentItem();
textState.textRise = args[0];
Expand Down Expand Up @@ -2736,13 +2730,13 @@ class PartialEvaluator {
isFirstChunk: true,
});
break;
case OPS.paintXObject: {
case OPS.paintXObject:
flushTextContentItem();
if (!xobjs) {
xobjs = resources.get("XObject") || Dict.empty;
}

const name = args[0].name;
var name = args[0].name;
if (name && emptyXObjectCache.getByName(name)) {
break;
}
Expand Down Expand Up @@ -2853,9 +2847,8 @@ class PartialEvaluator {
})
);
return;
}
case OPS.setGState: {
const name = args[0].name;
case OPS.setGState:
name = args[0].name;
if (name && emptyGStateCache.getByName(name)) {
break;
}
Expand Down Expand Up @@ -2908,7 +2901,6 @@ class PartialEvaluator {
})
);
return;
}
case OPS.beginMarkedContent:
if (includeMarkedContent) {
textContent.items.push({
Expand Down Expand Up @@ -3775,7 +3767,7 @@ class PartialEvaluator {
throw new FormatError("invalid font name");
}

let fontFile, subtype, length1, length2, length3;
let fontFile;
try {
fontFile = descriptor.get("FontFile", "FontFile2", "FontFile3");
} catch (ex) {
Expand All @@ -3787,13 +3779,13 @@ class PartialEvaluator {
}
if (fontFile) {
if (fontFile.dict) {
const subtypeEntry = fontFile.dict.get("Subtype");
if (subtypeEntry instanceof Name) {
subtype = subtypeEntry.name;
var subtype = fontFile.dict.get("Subtype");
if (subtype) {
subtype = subtype.name;
}
length1 = fontFile.dict.get("Length1");
length2 = fontFile.dict.get("Length2");
length3 = fontFile.dict.get("Length3");
var length1 = fontFile.dict.get("Length1");
var length2 = fontFile.dict.get("Length2");
var length3 = fontFile.dict.get("Length3");
}
}

Expand Down