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

View File

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