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
|
@ -37,7 +37,6 @@ const THUMBNAIL_WIDTH = 98; // px
|
|||
* The default value is `null`.
|
||||
* @property {IPDFLinkService} linkService - The navigation/linking service.
|
||||
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object.
|
||||
* @property {function} checkSetImageDisabled
|
||||
* @property {IL10n} l10n - Localization service.
|
||||
* @property {Object} [pageColors] - Overwrites background and foreground colors
|
||||
* with user defined ones in order to improve readability in high contrast
|
||||
|
@ -88,7 +87,6 @@ class PDFThumbnailView {
|
|||
optionalContentConfigPromise,
|
||||
linkService,
|
||||
renderingQueue,
|
||||
checkSetImageDisabled,
|
||||
l10n,
|
||||
pageColors,
|
||||
}) {
|
||||
|
@ -109,11 +107,6 @@ class PDFThumbnailView {
|
|||
this.renderTask = null;
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
this.resume = null;
|
||||
this._checkSetImageDisabled =
|
||||
checkSetImageDisabled ||
|
||||
function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
const pageWidth = this.viewport.width,
|
||||
pageHeight = this.viewport.height,
|
||||
|
@ -356,13 +349,10 @@ class PDFThumbnailView {
|
|||
}
|
||||
|
||||
setImage(pageView) {
|
||||
if (this._checkSetImageDisabled()) {
|
||||
return;
|
||||
}
|
||||
if (this.renderingState !== RenderingStates.INITIAL) {
|
||||
return;
|
||||
}
|
||||
const { canvas, pdfPage } = pageView;
|
||||
const { thumbnailCanvas: canvas, pdfPage } = pageView;
|
||||
if (!canvas) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue