mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-12 18:15:48 +02:00
Use for...of even more in the code-base
This replaces a couple of "standard" `for` loops with the shorter `for...of` format instead.
This commit is contained in:
parent
c4574a5470
commit
c46720d893
@ -4792,19 +4792,19 @@ class InkAnnotation extends MarkupAnnotation {
|
||||
if (!Array.isArray(rawInkLists)) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0, ii = rawInkLists.length; i < ii; ++i) {
|
||||
for (const rawInkList of rawInkLists) {
|
||||
// The raw ink lists array contains arrays of numbers representing
|
||||
// the alternating horizontal and vertical coordinates, respectively,
|
||||
// of each vertex. Convert this to an array of objects with x and y
|
||||
// coordinates.
|
||||
if (!Array.isArray(rawInkLists[i])) {
|
||||
if (!Array.isArray(rawInkList)) {
|
||||
continue;
|
||||
}
|
||||
const inkList = new Float32Array(rawInkLists[i].length);
|
||||
const inkList = new Float32Array(rawInkList.length);
|
||||
this.data.inkLists.push(inkList);
|
||||
for (let j = 0, jj = rawInkLists[i].length; j < jj; j += 2) {
|
||||
const x = xref.fetchIfRef(rawInkLists[i][j]),
|
||||
y = xref.fetchIfRef(rawInkLists[i][j + 1]);
|
||||
for (let j = 0, jj = rawInkList.length; j < jj; j += 2) {
|
||||
const x = xref.fetchIfRef(rawInkList[j]),
|
||||
y = xref.fetchIfRef(rawInkList[j + 1]);
|
||||
if (typeof x === "number" && typeof y === "number") {
|
||||
inkList[j] = x;
|
||||
inkList[j + 1] = y;
|
||||
|
||||
@ -200,8 +200,7 @@ async function createImage(bitmap, xref, { closeBitmap = false } = {}) {
|
||||
const colorCounter = new Set();
|
||||
let hasAlpha = false;
|
||||
let useFlate = true;
|
||||
for (let i = 0, ii = buf32.length; i < ii; i++) {
|
||||
const v = buf32[i];
|
||||
for (const v of buf32) {
|
||||
if ((isLE ? v >>> 24 : v & 0xff) !== 0xff) {
|
||||
hasAlpha = true;
|
||||
break;
|
||||
|
||||
@ -3273,9 +3273,7 @@ class PartialEvaluator {
|
||||
|
||||
const spaceFactor =
|
||||
((textState.font.vertical ? 1 : -1) * textState.fontSize) / 1000;
|
||||
const elements = args[0];
|
||||
for (let i = 0, ii = elements.length; i < ii; i++) {
|
||||
const item = elements[i];
|
||||
for (const item of args[0]) {
|
||||
if (typeof item === "string") {
|
||||
showSpacedTextBuffer.push(item);
|
||||
} else if (typeof item === "number" && item !== 0) {
|
||||
|
||||
@ -1525,9 +1525,9 @@ class Font {
|
||||
}
|
||||
const [nameTable] = readNameTable(potentialTables.name);
|
||||
|
||||
for (let j = 0, jj = nameTable.length; j < jj; j++) {
|
||||
for (let k = 0, kk = nameTable[j].length; k < kk; k++) {
|
||||
const nameEntry = nameTable[j][k]?.replaceAll(/\s/g, "");
|
||||
for (const nameArr of nameTable) {
|
||||
for (const entry of nameArr) {
|
||||
const nameEntry = entry?.replaceAll(/\s/g, "");
|
||||
if (!nameEntry) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3517,10 +3517,10 @@ class InkAnnotationElement extends AnnotationElement {
|
||||
g.setAttribute("fill", "transparent");
|
||||
g.setAttribute("transform", transform);
|
||||
|
||||
for (let i = 0, ii = inkLists.length; i < ii; i++) {
|
||||
for (const inkList of inkLists) {
|
||||
const polyline = this.svgFactory.createElement(this.svgElementName);
|
||||
this.#polylines.push(polyline);
|
||||
polyline.setAttribute("points", inkLists[i].join(","));
|
||||
polyline.setAttribute("points", inkList.join(","));
|
||||
g.append(polyline);
|
||||
}
|
||||
|
||||
|
||||
@ -517,8 +517,7 @@ class Stepper {
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (let i = 0; i < operatorsGroupsByZindex.length; i++) {
|
||||
const group = operatorsGroupsByZindex[i];
|
||||
for (const group of operatorsGroupsByZindex) {
|
||||
if (group.minX !== null) {
|
||||
const el = this.#c("div");
|
||||
el.style.left = `${group.minX * 100}%`;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user