Merge pull request #14225 from Snuffleupagus/render-better-holes-check

Avoid doing unnecessary checks, when pre-rendering page layouts with "holes" (PR 14131 follow-up)
This commit is contained in:
Tim van der Meij 2021-11-03 19:48:37 +01:00 committed by GitHub
commit 2ac6c939a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,13 +115,13 @@ class PDFRenderingQueue {
* 2. if last scrolled down, the page after the visible pages, or
* if last scrolled up, the page before the visible pages
*/
const visibleViews = visible.views;
const visibleViews = visible.views,
numVisible = visibleViews.length;
const numVisible = visibleViews.length;
if (numVisible === 0) {
return null;
}
for (let i = 0; i < numVisible; ++i) {
for (let i = 0; i < numVisible; i++) {
const view = visibleViews[i].view;
if (!this.isViewFinished(view)) {
return view;
@ -132,7 +132,7 @@ class PDFRenderingQueue {
// All the visible views have rendered; try to handle any "holes" in the
// page layout (can happen e.g. with spreadModes at higher zoom levels).
if (lastId - firstId > 1) {
if (lastId - firstId + 1 > numVisible) {
for (let i = 1, ii = lastId - firstId; i < ii; i++) {
const holeId = scrolledDown ? firstId + i : lastId - i,
holeView = views[holeId - 1];