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.
This commit is contained in:
Jonas Jenwald 2023-07-12 17:33:20 +02:00
parent 73d650af3e
commit 7e04ca395f
2 changed files with 7 additions and 10 deletions

View file

@ -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(