Skip to content

Commit

Permalink
Merge pull request #16683 from Snuffleupagus/app-isOffscreenCanvasSup…
Browse files Browse the repository at this point in the history
…ported

Access the `isOffscreenCanvasSupported` option *once* in `PDFViewerApplication._initializeViewerComponents`
  • Loading branch information
Snuffleupagus authored Jul 12, 2023
2 parents b449da3 + 7e04ca3 commit 762d86a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@
<div class="verticalToolbarSeparator hiddenMediumView"></div>

<div id="editorModeButtons" class="splitToolbarButton toggled" role="radiogroup">
<button id="editorStamp" class="toolbarButton" hidden="true" disabled="disabled" title="Image" role="radio" aria-checked="false" tabindex="34" data-l10n-id="editor_stamp">
<button id="editorStamp" class="toolbarButton hidden" disabled="disabled" title="Image" role="radio" aria-checked="false" tabindex="34" data-l10n-id="editor_stamp">
<span data-l10n-id="editor_stamp_label">Image</span>
</button>
<button id="editorFreeText" class="toolbarButton" disabled="disabled" title="Text" role="radio" aria-checked="false" aria-controls="editorFreeTextParamsToolbar" tabindex="35" data-l10n-id="editor_free_text2">
Expand Down

0 comments on commit 762d86a

Please sign in to comment.