mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 02:05:37 +02:00
Enable the ESLint prefer-const
rule globally (PR 11450 follow-up)
Please find additional details about the ESLint rule at https://eslint.org/docs/rules/prefer-const With the recent introduction of Prettier this sort of mass enabling of ESLint rules becomes a lot easier, since the code will be automatically reformatted as necessary to account for e.g. changed line lengths. Note that this patch is generated automatically, by using the ESLint `--fix` argument, and will thus require some additional clean-up (which is done separately).
This commit is contained in:
parent
d2d9441373
commit
9e262ae7fa
54 changed files with 676 additions and 661 deletions
|
@ -271,17 +271,17 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
);
|
||||
}
|
||||
function spliceString(s, offset, remove, insert) {
|
||||
let chunk1 = s.substring(0, offset);
|
||||
let chunk2 = s.substring(offset + remove);
|
||||
const chunk1 = s.substring(0, offset);
|
||||
const chunk2 = s.substring(offset + remove);
|
||||
return chunk1 + insert + chunk2;
|
||||
}
|
||||
let i, ii;
|
||||
|
||||
// The temporary canvas is used to determine if fonts are loaded.
|
||||
let canvas = document.createElement("canvas");
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 1;
|
||||
canvas.height = 1;
|
||||
let ctx = canvas.getContext("2d");
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
let called = 0;
|
||||
function isFontReady(name, callback) {
|
||||
|
@ -294,7 +294,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
}
|
||||
ctx.font = "30px " + name;
|
||||
ctx.fillText(".", 0, 20);
|
||||
let imageData = ctx.getImageData(0, 0, 1, 1);
|
||||
const imageData = ctx.getImageData(0, 0, 1, 1);
|
||||
if (imageData.data[3] > 0) {
|
||||
callback();
|
||||
return;
|
||||
|
@ -309,7 +309,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
// TODO: This could maybe be made faster by avoiding the btoa of the full
|
||||
// font by splitting it in chunks before hand and padding the font id.
|
||||
let data = this._loadTestFont;
|
||||
let COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)
|
||||
const COMMENT_OFFSET = 976; // has to be on 4 byte boundary (for checksum)
|
||||
data = spliceString(
|
||||
data,
|
||||
COMMENT_OFFSET,
|
||||
|
@ -317,8 +317,8 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
loadTestFontId
|
||||
);
|
||||
// CFF checksum is important for IE, adjusting it
|
||||
let CFF_CHECKSUM_OFFSET = 16;
|
||||
let XXXX_VALUE = 0x58585858; // the "comment" filled with 'X'
|
||||
const CFF_CHECKSUM_OFFSET = 16;
|
||||
const XXXX_VALUE = 0x58585858; // the "comment" filled with 'X'
|
||||
let checksum = int32(data, CFF_CHECKSUM_OFFSET);
|
||||
for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
|
||||
checksum = (checksum - XXXX_VALUE + int32(loadTestFontId, i)) | 0;
|
||||
|
@ -334,13 +334,13 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
const rule = `@font-face {font-family:"${loadTestFontId}";src:${url}}`;
|
||||
this.insertRule(rule);
|
||||
|
||||
let names = [];
|
||||
const names = [];
|
||||
for (i = 0, ii = fonts.length; i < ii; i++) {
|
||||
names.push(fonts[i].loadedName);
|
||||
}
|
||||
names.push(loadTestFontId);
|
||||
|
||||
let div = document.createElement("div");
|
||||
const div = document.createElement("div");
|
||||
div.setAttribute(
|
||||
"style",
|
||||
"visibility: hidden;" +
|
||||
|
@ -348,7 +348,7 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
|||
"position: absolute; top: 0px; left: 0px;"
|
||||
);
|
||||
for (i = 0, ii = names.length; i < ii; ++i) {
|
||||
let span = document.createElement("span");
|
||||
const span = document.createElement("span");
|
||||
span.textContent = "Hi";
|
||||
span.style.fontFamily = names[i];
|
||||
div.appendChild(span);
|
||||
|
@ -383,7 +383,7 @@ class FontFaceObject {
|
|||
) {
|
||||
this.compiledGlyphs = Object.create(null);
|
||||
// importing translated data
|
||||
for (let i in translatedData) {
|
||||
for (const i in translatedData) {
|
||||
this[i] = translatedData[i];
|
||||
}
|
||||
this.isEvalSupported = isEvalSupported !== false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue