Remove variable shadowing from the JavaScript files in the src/display/
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
This commit is contained in:
parent
3cebb430c2
commit
3539a17d2a
@ -2343,7 +2343,7 @@ class WorkerTransport {
|
|||||||
this._onUnsupportedFeature.bind(this)
|
this._onUnsupportedFeature.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
messageHandler.on("JpegDecode", data => {
|
messageHandler.on("JpegDecode", ([imageUrl, components]) => {
|
||||||
if (this.destroyed) {
|
if (this.destroyed) {
|
||||||
return Promise.reject(new Error("Worker was destroyed"));
|
return Promise.reject(new Error("Worker was destroyed"));
|
||||||
}
|
}
|
||||||
@ -2354,7 +2354,6 @@ class WorkerTransport {
|
|||||||
return Promise.reject(new Error('"document" is not defined.'));
|
return Promise.reject(new Error('"document" is not defined.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const [imageUrl, components] = data;
|
|
||||||
if (components !== 3 && components !== 1) {
|
if (components !== 3 && components !== 1) {
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
new Error("Only 3 components or 1 component can be returned")
|
new Error("Only 3 components or 1 component can be returned")
|
||||||
|
@ -367,11 +367,11 @@ function compileType3Glyph(imgData) {
|
|||||||
c.scale(1 / width, -1 / height);
|
c.scale(1 / width, -1 / height);
|
||||||
c.translate(0, -height);
|
c.translate(0, -height);
|
||||||
c.beginPath();
|
c.beginPath();
|
||||||
for (var i = 0, ii = outlines.length; i < ii; i++) {
|
for (let k = 0, kk = outlines.length; k < kk; k++) {
|
||||||
var o = outlines[i];
|
var o = outlines[k];
|
||||||
c.moveTo(o[0], o[1]);
|
c.moveTo(o[0], o[1]);
|
||||||
for (var j = 2, jj = o.length; j < jj; j += 2) {
|
for (let l = 2, ll = o.length; l < ll; l += 2) {
|
||||||
c.lineTo(o[j], o[j + 1]);
|
c.lineTo(o[l], o[l + 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.fill();
|
c.fill();
|
||||||
|
@ -115,13 +115,13 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function rfc2231getparam(contentDisposition) {
|
function rfc2231getparam(contentDispositionStr) {
|
||||||
const matches = [];
|
const matches = [];
|
||||||
let match;
|
let match;
|
||||||
// Iterate over all filename*n= and filename*n*= with n being an integer
|
// Iterate over all filename*n= and filename*n*= with n being an integer
|
||||||
// of at least zero. Any non-zero number must not start with '0'.
|
// of at least zero. Any non-zero number must not start with '0'.
|
||||||
const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
|
const iter = toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)", "ig");
|
||||||
while ((match = iter.exec(contentDisposition)) !== null) {
|
while ((match = iter.exec(contentDispositionStr)) !== null) {
|
||||||
let [, n, quot, part] = match; // eslint-disable-line prefer-const
|
let [, n, quot, part] = match; // eslint-disable-line prefer-const
|
||||||
n = parseInt(n, 10);
|
n = parseInt(n, 10);
|
||||||
if (n in matches) {
|
if (n in matches) {
|
||||||
@ -205,11 +205,11 @@ function getFilenameFromContentDispositionHeader(contentDisposition) {
|
|||||||
// ... but Firefox permits ? and space.
|
// ... but Firefox permits ? and space.
|
||||||
return value.replace(
|
return value.replace(
|
||||||
/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,
|
/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,
|
||||||
function(_, charset, encoding, text) {
|
function(matches, charset, encoding, text) {
|
||||||
if (encoding === "q" || encoding === "Q") {
|
if (encoding === "q" || encoding === "Q") {
|
||||||
// RFC 2047 section 4.2.
|
// RFC 2047 section 4.2.
|
||||||
text = text.replace(/_/g, " ");
|
text = text.replace(/_/g, " ");
|
||||||
text = text.replace(/=([0-9a-fA-F]{2})/g, function(_, hex) {
|
text = text.replace(/=([0-9a-fA-F]{2})/g, function(match, hex) {
|
||||||
return String.fromCharCode(parseInt(hex, 16));
|
return String.fromCharCode(parseInt(hex, 16));
|
||||||
});
|
});
|
||||||
return textdecode(charset, text);
|
return textdecode(charset, text);
|
||||||
|
@ -292,13 +292,13 @@ class BaseRangeReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRequestOptions(url, headers) {
|
function createRequestOptions(parsedUrl, headers) {
|
||||||
return {
|
return {
|
||||||
protocol: url.protocol,
|
protocol: parsedUrl.protocol,
|
||||||
auth: url.auth,
|
auth: parsedUrl.auth,
|
||||||
host: url.hostname,
|
host: parsedUrl.hostname,
|
||||||
port: url.port,
|
port: parsedUrl.port,
|
||||||
path: url.path,
|
path: parsedUrl.path,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers,
|
headers,
|
||||||
};
|
};
|
||||||
|
@ -158,7 +158,7 @@ var createMeshCanvas = (function createMeshCanvasClosure() {
|
|||||||
var x2_ = Math.round(Math.max(xa, xb));
|
var x2_ = Math.round(Math.max(xa, xb));
|
||||||
var j = rowSize * y + x1_ * 4;
|
var j = rowSize * y + x1_ * 4;
|
||||||
for (var x = x1_; x <= x2_; x++) {
|
for (var x = x1_; x <= x2_; x++) {
|
||||||
let k = (xa - x) / (xa - xb);
|
k = (xa - x) / (xa - xb);
|
||||||
if (k < 0) {
|
if (k < 0) {
|
||||||
k = 0;
|
k = 0;
|
||||||
} else if (k > 1) {
|
} else if (k > 1) {
|
||||||
|
@ -182,6 +182,17 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
capability.resolve();
|
capability.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findPositiveMin(ts, offset, count) {
|
||||||
|
let result = 0;
|
||||||
|
for (let i = 0; i < count; i++) {
|
||||||
|
const t = ts[offset++];
|
||||||
|
if (t > 0) {
|
||||||
|
result = result ? Math.min(t, result) : t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function expand(task) {
|
function expand(task) {
|
||||||
var bounds = task._bounds;
|
var bounds = task._bounds;
|
||||||
var viewport = task._viewport;
|
var viewport = task._viewport;
|
||||||
@ -208,38 +219,28 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
// Finding intersections with expanded box.
|
// Finding intersections with expanded box.
|
||||||
var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
|
var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size];
|
||||||
var ts = new Float64Array(64);
|
var ts = new Float64Array(64);
|
||||||
points.forEach(function(p, i) {
|
points.forEach(function(p, j) {
|
||||||
var t = Util.applyTransform(p, m);
|
var t = Util.applyTransform(p, m);
|
||||||
ts[i + 0] = c && (e.left - t[0]) / c;
|
ts[j + 0] = c && (e.left - t[0]) / c;
|
||||||
ts[i + 4] = s && (e.top - t[1]) / s;
|
ts[j + 4] = s && (e.top - t[1]) / s;
|
||||||
ts[i + 8] = c && (e.right - t[0]) / c;
|
ts[j + 8] = c && (e.right - t[0]) / c;
|
||||||
ts[i + 12] = s && (e.bottom - t[1]) / s;
|
ts[j + 12] = s && (e.bottom - t[1]) / s;
|
||||||
|
|
||||||
ts[i + 16] = s && (e.left - t[0]) / -s;
|
ts[j + 16] = s && (e.left - t[0]) / -s;
|
||||||
ts[i + 20] = c && (e.top - t[1]) / c;
|
ts[j + 20] = c && (e.top - t[1]) / c;
|
||||||
ts[i + 24] = s && (e.right - t[0]) / -s;
|
ts[j + 24] = s && (e.right - t[0]) / -s;
|
||||||
ts[i + 28] = c && (e.bottom - t[1]) / c;
|
ts[j + 28] = c && (e.bottom - t[1]) / c;
|
||||||
|
|
||||||
ts[i + 32] = c && (e.left - t[0]) / -c;
|
ts[j + 32] = c && (e.left - t[0]) / -c;
|
||||||
ts[i + 36] = s && (e.top - t[1]) / -s;
|
ts[j + 36] = s && (e.top - t[1]) / -s;
|
||||||
ts[i + 40] = c && (e.right - t[0]) / -c;
|
ts[j + 40] = c && (e.right - t[0]) / -c;
|
||||||
ts[i + 44] = s && (e.bottom - t[1]) / -s;
|
ts[j + 44] = s && (e.bottom - t[1]) / -s;
|
||||||
|
|
||||||
ts[i + 48] = s && (e.left - t[0]) / s;
|
ts[j + 48] = s && (e.left - t[0]) / s;
|
||||||
ts[i + 52] = c && (e.top - t[1]) / -c;
|
ts[j + 52] = c && (e.top - t[1]) / -c;
|
||||||
ts[i + 56] = s && (e.right - t[0]) / s;
|
ts[j + 56] = s && (e.right - t[0]) / s;
|
||||||
ts[i + 60] = c && (e.bottom - t[1]) / -c;
|
ts[j + 60] = c && (e.bottom - t[1]) / -c;
|
||||||
});
|
});
|
||||||
var findPositiveMin = function(ts, offset, count) {
|
|
||||||
var result = 0;
|
|
||||||
for (var i = 0; i < count; i++) {
|
|
||||||
var t = ts[offset++];
|
|
||||||
if (t > 0) {
|
|
||||||
result = result ? Math.min(t, result) : t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
// Not based on math, but to simplify calculations, using cos and sin
|
// Not based on math, but to simplify calculations, using cos and sin
|
||||||
// absolute values to not exceed the box (it can but insignificantly).
|
// absolute values to not exceed the box (it can but insignificantly).
|
||||||
var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
|
var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user