Skip to content

Commit

Permalink
Remove variable shadowing from the JavaScript files in the `src/core/…
Browse files Browse the repository at this point in the history
…` folder

*This is part of a series of patches that will try to split PR 11566 into smaller chunks, to make reviewing more feasible.*

Once all the code has been fixed, we'll be able to eventually enable the ESLint no-shadow rule; see https://eslint.org/docs/rules/no-shadow
  • Loading branch information
Snuffleupagus committed Mar 23, 2020
1 parent b86df97 commit 216cbca
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 140 deletions.
10 changes: 5 additions & 5 deletions src/core/chunked_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,15 @@ class ChunkedStreamManager {
}

const loadedRequests = [];
for (let chunk = beginChunk; chunk < endChunk; ++chunk) {
for (let curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
// The server might return more chunks than requested.
const requestIds = this.requestsByChunk[chunk] || [];
delete this.requestsByChunk[chunk];
const requestIds = this.requestsByChunk[curChunk] || [];
delete this.requestsByChunk[curChunk];

for (const requestId of requestIds) {
const chunksNeeded = this.chunksNeededByRequest[requestId];
if (chunk in chunksNeeded) {
delete chunksNeeded[chunk];
if (curChunk in chunksNeeded) {
delete chunksNeeded[curChunk];
}

if (!isEmptyObj(chunksNeeded)) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class Page {
// Fetching the individual streams from the array.
const xref = this.xref;
const streams = [];
for (const stream of content) {
streams.push(xref.fetchIfRef(stream));
for (const subStream of content) {
streams.push(xref.fetchIfRef(subStream));
}
stream = new StreamsSequenceStream(streams);
} else if (isStream(content)) {
Expand Down
34 changes: 17 additions & 17 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
pdfFunctionFactory: this.pdfFunctionFactory,
})
.then(imageObj => {
var imgData = imageObj.createImageData(/* forceRGBA = */ false);
imgData = imageObj.createImageData(/* forceRGBA = */ false);

if (this.parsingType3Font) {
return this.handler.sendWithPromise(
Expand Down Expand Up @@ -2479,16 +2479,16 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
properties.hasEncoding = !!baseEncodingName || differences.length > 0;
properties.dict = dict;
return toUnicodePromise
.then(toUnicode => {
properties.toUnicode = toUnicode;
.then(readToUnicode => {
properties.toUnicode = readToUnicode;
return this.buildToUnicode(properties);
})
.then(toUnicode => {
properties.toUnicode = toUnicode;
.then(builtToUnicode => {
properties.toUnicode = builtToUnicode;
if (cidToGidBytes) {
properties.cidToGidMap = this.readCidToGidMap(
cidToGidBytes,
toUnicode
builtToUnicode
);
}
return properties;
Expand Down Expand Up @@ -3092,21 +3092,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
};
const widths = dict.get("Widths");
return this.extractDataStructures(dict, dict, properties).then(
properties => {
newProperties => {
if (widths) {
const glyphWidths = [];
let j = firstChar;
for (let i = 0, ii = widths.length; i < ii; i++) {
glyphWidths[j++] = this.xref.fetchIfRef(widths[i]);
}
properties.widths = glyphWidths;
newProperties.widths = glyphWidths;
} else {
properties.widths = this.buildCharCodeToWidth(
newProperties.widths = this.buildCharCodeToWidth(
metrics.widths,
properties
newProperties
);
}
return new Font(baseFontName, null, properties);
return new Font(baseFontName, null, newProperties);
}
);
}
Expand Down Expand Up @@ -3212,13 +3212,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
.then(() => {
return this.extractDataStructures(dict, baseDict, properties);
})
.then(properties => {
this.extractWidths(dict, descriptor, properties);
.then(newProperties => {
this.extractWidths(dict, descriptor, newProperties);

if (type === "Type3") {
properties.isType3Font = true;
newProperties.isType3Font = true;
}
return new Font(fontName.name, fontFile, properties);
return new Font(fontName.name, fontFile, newProperties);
});
},
};
Expand Down Expand Up @@ -3352,8 +3352,8 @@ var TranslatedFont = (function TranslatedFontClosure() {
})
.catch(function(reason) {
warn(`Type3 font resource "${key}" is not available.`);
var operatorList = new OperatorList();
charProcOperatorList[key] = operatorList.getIR();
const dummyOperatorList = new OperatorList();
charProcOperatorList[key] = dummyOperatorList.getIR();
});
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/font_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}

function compileCharString(code, cmds, font, glyphId) {
var stack = [];
var x = 0,
y = 0;
var stems = 0;

function compileCharString(charStringCode, cmds, font, glyphId) {
function moveTo(x, y) {
cmds.push({ cmd: "moveTo", args: [x, y] });
}
Expand All @@ -361,6 +356,11 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
cmds.push({ cmd: "bezierCurveTo", args: [x1, y1, x2, y2, x, y] });
}

var stack = [];
var x = 0,
y = 0;
var stems = 0;

function parse(code) {
var i = 0;
while (i < code.length) {
Expand Down Expand Up @@ -719,7 +719,7 @@ var FontRendererFactory = (function FontRendererFactoryClosure() {
}
}
}
parse(code);
parse(charStringCode);
}

const NOOP = [];
Expand Down
Loading

0 comments on commit 216cbca

Please sign in to comment.