mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Enable the ESLint prefer-const
rule in the web/
directory
Please find additional details about the ESLint rule at https://eslint.org/docs/rules/prefer-const 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
9c767e3875
commit
5d14e68bec
36 changed files with 367 additions and 367 deletions
|
@ -59,7 +59,7 @@ const TempImageFactory = (function TempImageFactoryClosure() {
|
|||
tempCanvas.mozOpaque = true;
|
||||
}
|
||||
|
||||
let ctx = tempCanvas.getContext("2d", { alpha: false });
|
||||
const ctx = tempCanvas.getContext("2d", { alpha: false });
|
||||
ctx.save();
|
||||
ctx.fillStyle = "rgb(255, 255, 255)";
|
||||
ctx.fillRect(0, 0, width, height);
|
||||
|
@ -68,7 +68,7 @@ const TempImageFactory = (function TempImageFactoryClosure() {
|
|||
},
|
||||
|
||||
destroyCanvas() {
|
||||
let tempCanvas = tempCanvasCache;
|
||||
const tempCanvas = tempCanvasCache;
|
||||
if (tempCanvas) {
|
||||
// Zeroing the width and height causes Firefox to release graphics
|
||||
// resources immediately, which can greatly reduce memory consumption.
|
||||
|
@ -123,7 +123,7 @@ class PDFThumbnailView {
|
|||
|
||||
this.l10n = l10n;
|
||||
|
||||
let anchor = document.createElement("a");
|
||||
const anchor = document.createElement("a");
|
||||
anchor.href = linkService.getAnchorUrl("#page=" + id);
|
||||
this.l10n
|
||||
.get("thumb_page_title", { page: id }, "Page {{page}}")
|
||||
|
@ -136,14 +136,14 @@ class PDFThumbnailView {
|
|||
};
|
||||
this.anchor = anchor;
|
||||
|
||||
let div = document.createElement("div");
|
||||
const div = document.createElement("div");
|
||||
div.className = "thumbnail";
|
||||
div.setAttribute("data-page-number", this.id);
|
||||
this.div = div;
|
||||
|
||||
let ring = document.createElement("div");
|
||||
const ring = document.createElement("div");
|
||||
ring.className = "thumbnailSelectionRing";
|
||||
let borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
|
||||
const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
|
||||
ring.style.width = this.canvasWidth + borderAdjustment + "px";
|
||||
ring.style.height = this.canvasHeight + borderAdjustment + "px";
|
||||
this.ring = ring;
|
||||
|
@ -156,7 +156,7 @@ class PDFThumbnailView {
|
|||
setPdfPage(pdfPage) {
|
||||
this.pdfPage = pdfPage;
|
||||
this.pdfPageRotate = pdfPage.rotate;
|
||||
let totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
this.viewport = pdfPage.getViewport({ scale: 1, rotation: totalRotation });
|
||||
this.reset();
|
||||
}
|
||||
|
@ -173,12 +173,12 @@ class PDFThumbnailView {
|
|||
this.scale = this.canvasWidth / this.pageWidth;
|
||||
|
||||
this.div.removeAttribute("data-loaded");
|
||||
let ring = this.ring;
|
||||
let childNodes = ring.childNodes;
|
||||
const ring = this.ring;
|
||||
const childNodes = ring.childNodes;
|
||||
for (let i = childNodes.length - 1; i >= 0; i--) {
|
||||
ring.removeChild(childNodes[i]);
|
||||
}
|
||||
let borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
|
||||
const borderAdjustment = 2 * THUMBNAIL_CANVAS_BORDER_WIDTH;
|
||||
ring.style.width = this.canvasWidth + borderAdjustment + "px";
|
||||
ring.style.height = this.canvasHeight + borderAdjustment + "px";
|
||||
|
||||
|
@ -199,7 +199,7 @@ class PDFThumbnailView {
|
|||
if (typeof rotation !== "undefined") {
|
||||
this.rotation = rotation;
|
||||
}
|
||||
let totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
const totalRotation = (this.rotation + this.pdfPageRotate) % 360;
|
||||
this.viewport = this.viewport.clone({
|
||||
scale: 1,
|
||||
rotation: totalRotation,
|
||||
|
@ -223,7 +223,7 @@ class PDFThumbnailView {
|
|||
* @private
|
||||
*/
|
||||
_getPageDrawContext(noCtxScale = false) {
|
||||
let canvas = document.createElement("canvas");
|
||||
const canvas = document.createElement("canvas");
|
||||
// Keep the no-thumbnail outline visible, i.e. `data-loaded === false`,
|
||||
// until rendering/image conversion is complete, to avoid display issues.
|
||||
this.canvas = canvas;
|
||||
|
@ -234,8 +234,8 @@ class PDFThumbnailView {
|
|||
) {
|
||||
canvas.mozOpaque = true;
|
||||
}
|
||||
let ctx = canvas.getContext("2d", { alpha: false });
|
||||
let outputScale = getOutputScale(ctx);
|
||||
const ctx = canvas.getContext("2d", { alpha: false });
|
||||
const outputScale = getOutputScale(ctx);
|
||||
|
||||
canvas.width = (this.canvasWidth * outputScale.sx) | 0;
|
||||
canvas.height = (this.canvasHeight * outputScale.sy) | 0;
|
||||
|
@ -258,8 +258,8 @@ class PDFThumbnailView {
|
|||
if (this.renderingState !== RenderingStates.FINISHED) {
|
||||
return;
|
||||
}
|
||||
let id = this.renderingId;
|
||||
let className = "thumbnailImage";
|
||||
const id = this.renderingId;
|
||||
const className = "thumbnailImage";
|
||||
|
||||
if (this.disableCanvasToImageConversion) {
|
||||
this.canvas.id = id;
|
||||
|
@ -278,7 +278,7 @@ class PDFThumbnailView {
|
|||
this.ring.appendChild(this.canvas);
|
||||
return;
|
||||
}
|
||||
let image = document.createElement("img");
|
||||
const image = document.createElement("img");
|
||||
image.id = id;
|
||||
image.className = className;
|
||||
this.l10n
|
||||
|
@ -314,8 +314,8 @@ class PDFThumbnailView {
|
|||
}
|
||||
this.renderingState = RenderingStates.RUNNING;
|
||||
|
||||
let renderCapability = createPromiseCapability();
|
||||
let finishRenderTask = error => {
|
||||
const renderCapability = createPromiseCapability();
|
||||
const finishRenderTask = error => {
|
||||
// The renderTask may have been replaced by a new one, so only remove
|
||||
// the reference to the renderTask if it matches the one that is
|
||||
// triggering this callback.
|
||||
|
@ -338,9 +338,9 @@ class PDFThumbnailView {
|
|||
}
|
||||
};
|
||||
|
||||
let ctx = this._getPageDrawContext();
|
||||
let drawViewport = this.viewport.clone({ scale: this.scale });
|
||||
let renderContinueCallback = cont => {
|
||||
const ctx = this._getPageDrawContext();
|
||||
const drawViewport = this.viewport.clone({ scale: this.scale });
|
||||
const renderContinueCallback = cont => {
|
||||
if (!this.renderingQueue.isHighestPriority(this)) {
|
||||
this.renderingState = RenderingStates.PAUSED;
|
||||
this.resume = () => {
|
||||
|
@ -352,11 +352,11 @@ class PDFThumbnailView {
|
|||
cont();
|
||||
};
|
||||
|
||||
let renderContext = {
|
||||
const renderContext = {
|
||||
canvasContext: ctx,
|
||||
viewport: drawViewport,
|
||||
};
|
||||
let renderTask = (this.renderTask = this.pdfPage.render(renderContext));
|
||||
const renderTask = (this.renderTask = this.pdfPage.render(renderContext));
|
||||
renderTask.onContinue = renderContinueCallback;
|
||||
|
||||
renderTask.promise.then(
|
||||
|
@ -374,7 +374,7 @@ class PDFThumbnailView {
|
|||
if (this.renderingState !== RenderingStates.INITIAL) {
|
||||
return;
|
||||
}
|
||||
let img = pageView.canvas;
|
||||
const img = pageView.canvas;
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
|
@ -384,8 +384,8 @@ class PDFThumbnailView {
|
|||
|
||||
this.renderingState = RenderingStates.FINISHED;
|
||||
|
||||
let ctx = this._getPageDrawContext(true);
|
||||
let canvas = ctx.canvas;
|
||||
const ctx = this._getPageDrawContext(true);
|
||||
const canvas = ctx.canvas;
|
||||
if (img.width <= 2 * canvas.width) {
|
||||
ctx.drawImage(
|
||||
img,
|
||||
|
@ -405,8 +405,11 @@ class PDFThumbnailView {
|
|||
// drawImage does an awful job of rescaling the image, doing it gradually.
|
||||
let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
|
||||
let reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
|
||||
let reducedImage = TempImageFactory.getCanvas(reducedWidth, reducedHeight);
|
||||
let reducedImageCtx = reducedImage.getContext("2d");
|
||||
const reducedImage = TempImageFactory.getCanvas(
|
||||
reducedWidth,
|
||||
reducedHeight
|
||||
);
|
||||
const reducedImageCtx = reducedImage.getContext("2d");
|
||||
|
||||
while (reducedWidth > img.width || reducedHeight > img.height) {
|
||||
reducedWidth >>= 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue