From 7e04ca395fb12ee261dd0611d17c89ca1774ee6c Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 12 Jul 2023 17:33:20 +0200 Subject: [PATCH] Access the `isOffscreenCanvasSupported` option *once* in `PDFViewerApplication._initializeViewerComponents` There's no good reason for getting this option multiple times in the same method. Also, we can slightly re-factor how the `editorStampButton` is made visible. --- web/app.js | 15 ++++++--------- web/viewer.html | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/web/app.js b/web/app.js index b7c245b6d4ba3..baf06fb5dd247 100644 --- a/web/app.js +++ b/web/app.js @@ -495,6 +495,9 @@ const PDFViewerApplication = { const container = appConfig.mainContainer, viewer = appConfig.viewerContainer; const annotationEditorMode = AppOptions.get("annotationEditorMode"); + const isOffscreenCanvasSupported = + AppOptions.get("isOffscreenCanvasSupported") && + FeatureTest.isOffscreenCanvasSupported; const pageColors = AppOptions.get("forcePageColors") || window.matchMedia("(forced-colors: active)").matches @@ -521,7 +524,7 @@ const PDFViewerApplication = { imageResourcesPath: AppOptions.get("imageResourcesPath"), enablePrintAutoRotate: AppOptions.get("enablePrintAutoRotate"), useOnlyCssZoom: AppOptions.get("useOnlyCssZoom"), - isOffscreenCanvasSupported: AppOptions.get("isOffscreenCanvasSupported"), + isOffscreenCanvasSupported, maxCanvasPixels: AppOptions.get("maxCanvasPixels"), enablePermissions: AppOptions.get("enablePermissions"), pageColors, @@ -560,14 +563,8 @@ const PDFViewerApplication = { if (appConfig.annotationEditorParams) { if (annotationEditorMode !== AnnotationEditorType.DISABLE) { - const editorStampButton = appConfig.toolbar?.editorStampButton; - if ( - editorStampButton && - AppOptions.get("enableStampEditor") && - AppOptions.get("isOffscreenCanvasSupported") && - FeatureTest.isOffscreenCanvasSupported - ) { - editorStampButton.hidden = false; + if (AppOptions.get("enableStampEditor") && isOffscreenCanvasSupported) { + appConfig.toolbar?.editorStampButton?.classList.remove("hidden"); } this.annotationEditorParams = new AnnotationEditorParams( diff --git a/web/viewer.html b/web/viewer.html index 7bb89b73a550d..b94f1d8e23c56 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -330,7 +330,7 @@
-