Merge pull request #14828 from Snuffleupagus/viewer-more-for-of

Use more `for...of` loops in the viewer
This commit is contained in:
Tim van der Meij 2022-04-23 13:09:32 +02:00 committed by GitHub
commit 1921c4612d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 22 deletions

View File

@ -1467,12 +1467,9 @@ class BaseViewer {
}
cleanup() {
for (let i = 0, ii = this._pages.length; i < ii; i++) {
if (
this._pages[i] &&
this._pages[i].renderingState !== RenderingStates.FINISHED
) {
this._pages[i].reset();
for (const pageView of this._pages) {
if (pageView.renderingState !== RenderingStates.FINISHED) {
pageView.reset();
}
}
}
@ -1481,10 +1478,8 @@ class BaseViewer {
* @private
*/
_cancelRendering() {
for (let i = 0, ii = this._pages.length; i < ii; i++) {
if (this._pages[i]) {
this._pages[i].cancelRendering();
}
for (const pageView of this._pages) {
pageView.cancelRendering();
}
}
@ -1873,8 +1868,8 @@ class BaseViewer {
viewer.textContent = "";
if (this._spreadMode === SpreadMode.NONE) {
for (let i = 0, ii = pages.length; i < ii; ++i) {
viewer.appendChild(pages[i].div);
for (const pageView of this._pages) {
viewer.appendChild(pageView.div);
}
} else {
const parity = this._spreadMode - 1;

View File

@ -151,12 +151,9 @@ class PDFThumbnailViewer {
}
cleanup() {
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
if (
this._thumbnails[i] &&
this._thumbnails[i].renderingState !== RenderingStates.FINISHED
) {
this._thumbnails[i].reset();
for (const thumbnail of this._thumbnails) {
if (thumbnail.renderingState !== RenderingStates.FINISHED) {
thumbnail.reset();
}
}
TempImageFactory.destroyCanvas();
@ -237,10 +234,8 @@ class PDFThumbnailViewer {
* @private
*/
_cancelRendering() {
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
if (this._thumbnails[i]) {
this._thumbnails[i].cancelRendering();
}
for (const thumbnail of this._thumbnails) {
thumbnail.cancelRendering();
}
}