Fix the remaining ESLint no-var errors in the src/display/ folder

While most of necessary changes were fixed automatically, see the previous patch, there's a number of cases that needed to be fixed manually.
This commit is contained in:
Jonas Jenwald 2020-10-02 13:54:44 +02:00
parent e557be5a17
commit 52f6016e6c
4 changed files with 48 additions and 56 deletions

View File

@ -210,11 +210,9 @@ function compileType3Glyph(imgData) {
const POINT_TO_PROCESS_LIMIT = 1000; const POINT_TO_PROCESS_LIMIT = 1000;
const width = imgData.width, const width = imgData.width,
height = imgData.height; height = imgData.height,
let i,
j,
j0,
width1 = width + 1; width1 = width + 1;
let i, ii, j, j0;
const points = new Uint8Array(width1 * (height + 1)); const points = new Uint8Array(width1 * (height + 1));
// prettier-ignore // prettier-ignore
const POINT_TYPES = const POINT_TYPES =
@ -223,12 +221,11 @@ function compileType3Glyph(imgData) {
// decodes bit-packed mask data // decodes bit-packed mask data
const lineSize = (width + 7) & ~7, const lineSize = (width + 7) & ~7,
data0 = imgData.data; data0 = imgData.data;
let data = new Uint8Array(lineSize * height), const data = new Uint8Array(lineSize * height);
pos = 0, let pos = 0;
ii;
for (i = 0, ii = data0.length; i < ii; i++) { for (i = 0, ii = data0.length; i < ii; i++) {
let mask = 128, const elem = data0[i];
elem = data0[i]; let mask = 128;
while (mask > 0) { while (mask > 0) {
data[pos++] = elem & mask ? 0 : 255; data[pos++] = elem & mask ? 0 : 255;
mask >>= 1; mask >>= 1;
@ -328,16 +325,15 @@ function compileType3Glyph(imgData) {
} }
const coords = [p % width1, i]; const coords = [p % width1, i];
var type = points[p], const p0 = p;
p0 = p, let type = points[p];
pp;
do { do {
const step = steps[type]; const step = steps[type];
do { do {
p += step; p += step;
} while (!points[p]); } while (!points[p]);
pp = points[p]; const pp = points[p];
if (pp !== 5 && pp !== 10) { if (pp !== 5 && pp !== 10) {
// set new direction // set new direction
type = pp; type = pp;
@ -705,10 +701,11 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
// inversion has already been handled. // inversion has already been handled.
let destPos = 3; // alpha component offset let destPos = 3; // alpha component offset
for (let j = 0; j < thisChunkHeight; j++) { for (let j = 0; j < thisChunkHeight; j++) {
let mask = 0; let elem,
mask = 0;
for (let k = 0; k < width; k++) { for (let k = 0; k < width; k++) {
if (!mask) { if (!mask) {
var elem = src[srcPos++]; elem = src[srcPos++];
mask = 128; mask = 128;
} }
dest[destPos] = elem & mask ? 0 : 255; dest[destPos] = elem & mask ? 0 : 255;
@ -1276,16 +1273,16 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
case OPS.rectangle: case OPS.rectangle:
x = args[j++]; x = args[j++];
y = args[j++]; y = args[j++];
var width = args[j++]; let width = args[j++];
var height = args[j++]; let height = args[j++];
if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) { if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
width = this.getSinglePixelWidth(); width = this.getSinglePixelWidth();
} }
if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) { if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
height = this.getSinglePixelWidth(); height = this.getSinglePixelWidth();
} }
var xw = x + width; const xw = x + width;
var yh = y + height; const yh = y + height;
ctx.moveTo(x, y); ctx.moveTo(x, y);
ctx.lineTo(xw, y); ctx.lineTo(xw, y);
ctx.lineTo(xw, yh); ctx.lineTo(xw, yh);
@ -1756,14 +1753,13 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
const character = glyph.fontChar; const character = glyph.fontChar;
const accent = glyph.accent; const accent = glyph.accent;
var scaledX, scaledY, scaledAccentX, scaledAccentY; let scaledX, scaledY;
let width = glyph.width; let width = glyph.width;
if (vertical) { if (vertical) {
var vmetric, vx, vy; const vmetric = glyph.vmetric || defaultVMetrics;
vmetric = glyph.vmetric || defaultVMetrics; const vx =
vx = glyph.vmetric ? vmetric[1] : width * 0.5; -(glyph.vmetric ? vmetric[1] : width * 0.5) * widthAdvanceScale;
vx = -vx * widthAdvanceScale; const vy = vmetric[2] * widthAdvanceScale;
vy = vmetric[2] * widthAdvanceScale;
width = vmetric ? -vmetric[0] : width; width = vmetric ? -vmetric[0] : width;
scaledX = vx / fontSizeScale; scaledX = vx / fontSizeScale;
@ -1801,9 +1797,9 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
} else { } else {
this.paintChar(character, scaledX, scaledY, patternTransform); this.paintChar(character, scaledX, scaledY, patternTransform);
if (accent) { if (accent) {
scaledAccentX = const scaledAccentX =
scaledX + (fontSize * accent.offset.x) / fontSizeScale; scaledX + (fontSize * accent.offset.x) / fontSizeScale;
scaledAccentY = const scaledAccentY =
scaledY - (fontSize * accent.offset.y) / fontSizeScale; scaledY - (fontSize * accent.offset.y) / fontSizeScale;
this.paintChar( this.paintChar(
accent.fontChar, accent.fontChar,
@ -1815,7 +1811,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
} }
} }
var charWidth; let charWidth;
if (vertical) { if (vertical) {
charWidth = width * widthAdvanceScale - spacing * fontDirection; charWidth = width * widthAdvanceScale - spacing * fontDirection;
} else { } else {
@ -2440,7 +2436,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
d = currentTransform[3]; d = currentTransform[3];
let heightScale = Math.max(Math.sqrt(c * c + d * d), 1); let heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
let imgToPaint, tmpCanvas; let imgToPaint, tmpCanvas, tmpCtx;
// typeof check is needed due to node.js support, see issue #8489 // typeof check is needed due to node.js support, see issue #8489
if ( if (
(typeof HTMLElement === "function" && imgData instanceof HTMLElement) || (typeof HTMLElement === "function" && imgData instanceof HTMLElement) ||
@ -2449,7 +2445,7 @@ const CanvasGraphics = (function CanvasGraphicsClosure() {
imgToPaint = imgData; imgToPaint = imgData;
} else { } else {
tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height); tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
var tmpCtx = tmpCanvas.context; tmpCtx = tmpCanvas.context;
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps); putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
imgToPaint = tmpCanvas.canvas; imgToPaint = tmpCanvas.canvas;
} }

View File

@ -178,9 +178,9 @@ const createMeshCanvas = (function createMeshCanvasClosure() {
let i, ii; let i, ii;
switch (figure.type) { switch (figure.type) {
case "lattice": case "lattice":
var verticesPerRow = figure.verticesPerRow; const verticesPerRow = figure.verticesPerRow;
var rows = Math.floor(ps.length / verticesPerRow) - 1; const rows = Math.floor(ps.length / verticesPerRow) - 1;
var cols = verticesPerRow - 1; const cols = verticesPerRow - 1;
for (i = 0; i < rows; i++) { for (i = 0; i < rows; i++) {
let q = i * verticesPerRow; let q = i * verticesPerRow;
for (let j = 0; j < cols; j++, q++) { for (let j = 0; j < cols; j++, q++) {
@ -564,14 +564,14 @@ const TilingPattern = (function TilingPatternClosure() {
current = graphics.current; current = graphics.current;
switch (paintType) { switch (paintType) {
case PaintType.COLORED: case PaintType.COLORED:
var ctx = this.ctx; const ctx = this.ctx;
context.fillStyle = ctx.fillStyle; context.fillStyle = ctx.fillStyle;
context.strokeStyle = ctx.strokeStyle; context.strokeStyle = ctx.strokeStyle;
current.fillColor = ctx.fillStyle; current.fillColor = ctx.fillStyle;
current.strokeColor = ctx.strokeStyle; current.strokeColor = ctx.strokeStyle;
break; break;
case PaintType.UNCOLORED: case PaintType.UNCOLORED:
var cssColor = Util.makeCssRgb(color[0], color[1], color[2]); const cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
context.fillStyle = cssColor; context.fillStyle = cssColor;
context.strokeStyle = cssColor; context.strokeStyle = cssColor;
// Set color needed by image masks (fixes issues 3226 and 8741). // Set color needed by image masks (fixes issues 3226 and 8741).

View File

@ -237,14 +237,14 @@ const renderTextLayer = (function renderTextLayerClosure() {
} }
// Box is rotated -- trying to find padding so rotated div will not // Box is rotated -- trying to find padding so rotated div will not
// exceed its expanded bounds. // exceed its expanded bounds.
var e = expanded[i], const e = expanded[i],
b = bounds[i]; b = bounds[i];
var m = b.m, const m = b.m,
c = m[0], c = m[0],
s = m[1]; s = m[1];
// Finding intersections with expanded box. // Finding intersections with expanded box.
const points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size]; const points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
var ts = new Float64Array(64); const ts = new Float64Array(64);
points.forEach(function (p, j) { points.forEach(function (p, j) {
const t = Util.applyTransform(p, m); const t = Util.applyTransform(p, m);
ts[j + 0] = c && (e.left - t[0]) / c; ts[j + 0] = c && (e.left - t[0]) / c;
@ -368,7 +368,7 @@ const renderTextLayer = (function renderTextLayerClosure() {
for (q = i; q <= j; q++) { for (q = i; q <= j; q++) {
horizonPart = horizon[q]; horizonPart = horizon[q];
affectedBoundary = horizonPart.boundary; affectedBoundary = horizonPart.boundary;
var xNew; let xNew;
if (affectedBoundary.x2 > boundary.x1) { if (affectedBoundary.x2 > boundary.x1) {
// In the middle of the previous element, new x shall be at the // In the middle of the previous element, new x shall be at the
// boundary start. Extending if further if the affected boundary // boundary start. Extending if further if the affected boundary
@ -415,8 +415,8 @@ const renderTextLayer = (function renderTextLayerClosure() {
} }
// Fixing the horizon. // Fixing the horizon.
let changedHorizon = [], const changedHorizon = [];
lastBoundary = null; let lastBoundary = null;
for (q = i; q <= j; q++) { for (q = i; q <= j; q++) {
horizonPart = horizon[q]; horizonPart = horizon[q];
affectedBoundary = horizonPart.boundary; affectedBoundary = horizonPart.boundary;

View File

@ -48,7 +48,7 @@ class WebGLContext {
} }
} }
var WebGLUtils = (function WebGLUtilsClosure() { const WebGLUtils = (function WebGLUtilsClosure() {
function loadShader(gl, code, shaderType) { function loadShader(gl, code, shaderType) {
const shader = gl.createShader(shaderType); const shader = gl.createShader(shaderType);
gl.shaderSource(shader, code); gl.shaderSource(shader, code);
@ -157,12 +157,10 @@ var WebGLUtils = (function WebGLUtilsClosure() {
let smaskCache = null; let smaskCache = null;
function initSmaskGL() { function initSmaskGL() {
let canvas, gl;
generateGL(); generateGL();
canvas = currentCanvas; const canvas = currentCanvas;
currentCanvas = null; currentCanvas = null;
gl = currentGL; const gl = currentGL;
currentGL = null; currentGL = null;
// setup a GLSL program // setup a GLSL program
@ -302,12 +300,10 @@ var WebGLUtils = (function WebGLUtilsClosure() {
let figuresCache = null; let figuresCache = null;
function initFiguresGL() { function initFiguresGL() {
let canvas, gl;
generateGL(); generateGL();
canvas = currentCanvas; const canvas = currentCanvas;
currentCanvas = null; currentCanvas = null;
gl = currentGL; const gl = currentGL;
currentGL = null; currentGL = null;
// setup a GLSL program // setup a GLSL program
@ -343,11 +339,11 @@ var WebGLUtils = (function WebGLUtilsClosure() {
// count triangle points // count triangle points
let count = 0; let count = 0;
let i, ii, rows; for (let i = 0, ii = figures.length; i < ii; i++) {
for (i = 0, ii = figures.length; i < ii; i++) {
switch (figures[i].type) { switch (figures[i].type) {
case "lattice": case "lattice":
rows = (figures[i].coords.length / figures[i].verticesPerRow) | 0; const rows =
(figures[i].coords.length / figures[i].verticesPerRow) | 0;
count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
break; break;
case "triangles": case "triangles":
@ -362,14 +358,14 @@ var WebGLUtils = (function WebGLUtilsClosure() {
colorsMap = context.colors; colorsMap = context.colors;
let pIndex = 0, let pIndex = 0,
cIndex = 0; cIndex = 0;
for (i = 0, ii = figures.length; i < ii; i++) { for (let i = 0, ii = figures.length; i < ii; i++) {
const figure = figures[i], const figure = figures[i],
ps = figure.coords, ps = figure.coords,
cs = figure.colors; cs = figure.colors;
switch (figure.type) { switch (figure.type) {
case "lattice": case "lattice":
var cols = figure.verticesPerRow; const cols = figure.verticesPerRow;
rows = (ps.length / cols) | 0; const rows = (ps.length / cols) | 0;
for (let row = 1; row < rows; row++) { for (let row = 1; row < rows; row++) {
let offset = row * cols + 1; let offset = row * cols + 1;
for (let col = 1; col < cols; col++, offset++) { for (let col = 1; col < cols; col++, offset++) {