mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Merge pull request #15398 from Snuffleupagus/more-optional-chaining
Use more optional chaining in the code-base
This commit is contained in:
commit
af6aacfc0e
15 changed files with 51 additions and 119 deletions
|
@ -637,12 +637,9 @@ class BaseViewer {
|
|||
this._cancelRendering();
|
||||
this._resetView();
|
||||
|
||||
if (this.findController) {
|
||||
this.findController.setDocument(null);
|
||||
}
|
||||
if (this._scriptingManager) {
|
||||
this._scriptingManager.setDocument(null);
|
||||
}
|
||||
this.findController?.setDocument(null);
|
||||
this._scriptingManager?.setDocument(null);
|
||||
|
||||
if (this.#annotationEditorUIManager) {
|
||||
this.#annotationEditorUIManager.destroy();
|
||||
this.#annotationEditorUIManager = null;
|
||||
|
@ -807,12 +804,8 @@ class BaseViewer {
|
|||
// starts to create the correct size canvas. Wait until one page is
|
||||
// rendered so we don't tie up too many resources early on.
|
||||
this.#onePageRenderedOrForceFetch().then(async () => {
|
||||
if (this.findController) {
|
||||
this.findController.setDocument(pdfDocument); // Enable searching.
|
||||
}
|
||||
if (this._scriptingManager) {
|
||||
this._scriptingManager.setDocument(pdfDocument); // Enable scripting.
|
||||
}
|
||||
this.findController?.setDocument(pdfDocument); // Enable searching.
|
||||
this._scriptingManager?.setDocument(pdfDocument); // Enable scripting.
|
||||
|
||||
if (this.#annotationEditorUIManager) {
|
||||
// Ensure that the Editor buttons, in the toolbar, are updated.
|
||||
|
|
|
@ -45,9 +45,7 @@ const ChromeCom = {
|
|||
};
|
||||
if (!chrome.runtime) {
|
||||
console.error("chrome.runtime is undefined.");
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
callback?.();
|
||||
} else if (callback) {
|
||||
chrome.runtime.sendMessage(message, callback);
|
||||
} else {
|
||||
|
|
|
@ -221,9 +221,7 @@ class PDFPageView {
|
|||
|
||||
destroy() {
|
||||
this.reset();
|
||||
if (this.pdfPage) {
|
||||
this.pdfPage.cleanup();
|
||||
}
|
||||
this.pdfPage?.cleanup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -231,10 +231,7 @@ class PDFThumbnailViewer {
|
|||
// Set the first `pdfPage` immediately, since it's already loaded,
|
||||
// rather than having to repeat the `PDFDocumentProxy.getPage` call in
|
||||
// the `this.#ensurePdfPageLoaded` method before rendering can start.
|
||||
const firstThumbnailView = this._thumbnails[0];
|
||||
if (firstThumbnailView) {
|
||||
firstThumbnailView.setPdfPage(firstPdfPage);
|
||||
}
|
||||
this._thumbnails[0]?.setPdfPage(firstPdfPage);
|
||||
|
||||
// Ensure that the current thumbnail is always highlighted on load.
|
||||
const thumbnailView = this._thumbnails[this._currentPageNumber - 1];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue