From b7eef925acd69bd8b60cd04b9ba6aca5f581bc39 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 15 Mar 2025 13:19:34 +0100 Subject: [PATCH] Shorten the `PDFThumbnailView.prototype.#getReducedImageDims` method (PR 19635 follow-up) This method is slightly more verbose than necessary, hence we can shorten the code a little bit. --- web/pdf_thumbnail_view.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/web/pdf_thumbnail_view.js b/web/pdf_thumbnail_view.js index 59e171bb3..c512aca5f 100644 --- a/web/pdf_thumbnail_view.js +++ b/web/pdf_thumbnail_view.js @@ -366,8 +366,8 @@ class PDFThumbnailView { } #getReducedImageDims(canvas) { - let reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS, - reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS; + const width = canvas.width << MAX_NUM_SCALING_STEPS, + height = canvas.height << MAX_NUM_SCALING_STEPS; const outputScale = new OutputScale(); // Here we're not actually "rendering" to the canvas and the `OutputScale` @@ -375,15 +375,12 @@ class PDFThumbnailView { outputScale.sx = outputScale.sy = 1; outputScale.limitCanvas( - reducedWidth, - reducedHeight, + width, + height, this.maxCanvasPixels, this.maxCanvasDim ); - reducedWidth = (reducedWidth * outputScale.sx) | 0; - reducedHeight = (reducedHeight * outputScale.sy) | 0; - - return [reducedWidth, reducedHeight]; + return [(width * outputScale.sx) | 0, (height * outputScale.sy) | 0]; } #reduceImage(img) {