mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Improve how we disable PDFThumbnailView.setImage
for documents with Optional Content (PR 12170 follow-up)
Rather than always disable `PDFThumbnailView.setImage` as soon as user has changed the visibility of the Optional Content, we can utilize the new method added in the previous patch to improve thumbnail performance. Note in particular how, in the old code, even *resetting* of the Optional Content to its default state wouldn't enable `PDFThumbnailView.setImage` again. While slightly unrelated, this patch also removes the `PDFThumbnailViewer._optionalContentConfigPromise`-property since it's completely unused.
This commit is contained in:
parent
ceb4f8a6ab
commit
3446f15bf3
4 changed files with 38 additions and 25 deletions
|
@ -85,12 +85,6 @@ class PDFThumbnailViewer {
|
|||
|
||||
this.scroll = watchScroll(this.container, this._scrollUpdated.bind(this));
|
||||
this._resetView();
|
||||
|
||||
eventBus._on("optionalcontentconfigchanged", () => {
|
||||
// Ensure that the thumbnails always render with the *default* optional
|
||||
// content configuration.
|
||||
this._setImageDisabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,8 +189,6 @@ class PDFThumbnailViewer {
|
|||
this._currentPageNumber = 1;
|
||||
this._pageLabels = null;
|
||||
this._pagesRotation = 0;
|
||||
this._optionalContentConfigPromise = null;
|
||||
this._setImageDisabled = false;
|
||||
|
||||
// Remove the thumbnails from the DOM.
|
||||
this.container.textContent = "";
|
||||
|
@ -220,13 +212,8 @@ class PDFThumbnailViewer {
|
|||
|
||||
firstPagePromise
|
||||
.then(firstPdfPage => {
|
||||
this._optionalContentConfigPromise = optionalContentConfigPromise;
|
||||
|
||||
const pagesCount = pdfDocument.numPages;
|
||||
const viewport = firstPdfPage.getViewport({ scale: 1 });
|
||||
const checkSetImageDisabled = () => {
|
||||
return this._setImageDisabled;
|
||||
};
|
||||
|
||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||
const thumbnail = new PDFThumbnailView({
|
||||
|
@ -236,7 +223,6 @@ class PDFThumbnailViewer {
|
|||
optionalContentConfigPromise,
|
||||
linkService: this.linkService,
|
||||
renderingQueue: this.renderingQueue,
|
||||
checkSetImageDisabled,
|
||||
l10n: this.l10n,
|
||||
pageColors: this.pageColors,
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue