From 1c809c87af7e027b8f15e2f638562069d157725a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 23 Jul 2020 18:06:02 +0200 Subject: [PATCH] Remove a couple of unnecessary `PDFJSDev` checks from the viewer - Given the `DefaultExternalServices` implementation, the `PDFViewerApplication.supportsDocumentFonts` getter is guaranteed to be defined and we can thus remove some (now) unnecessary `PDFJSDev` checks from the `webViewerInitialized` function. - By slightly tweaking the "pdfBugEnabled" definition in `web/app_options`, similar to the existing ones for "workerSrc" and "cMapUrl", we can remove some `PDFJSDev` checks from the `PDFViewerApplication._parseHashParameters` method. --- web/app.js | 12 ++---------- web/app_options.js | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/web/app.js b/web/app.js index 774fbf7d05ea2..e84a2af22b78a 100644 --- a/web/app.js +++ b/web/app.js @@ -299,11 +299,7 @@ const PDFViewerApplication = { * @private */ async _parseHashParameters() { - if ( - typeof PDFJSDev !== "undefined" && - PDFJSDev.test("PRODUCTION") && - !AppOptions.get("pdfBugEnabled") - ) { + if (!AppOptions.get("pdfBugEnabled")) { return undefined; } const hash = document.location.hash.substring(1); @@ -1931,11 +1927,7 @@ function webViewerInitialized() { appConfig.secondaryToolbar.openFileButton.setAttribute("hidden", "true"); } - if ( - (typeof PDFJSDev === "undefined" || - PDFJSDev.test("MOZCENTRAL || GENERIC")) && - !PDFViewerApplication.supportsDocumentFonts - ) { + if (!PDFViewerApplication.supportsDocumentFonts) { AppOptions.set("disableFontFace", true); PDFViewerApplication.l10n .get( diff --git a/web/app_options.js b/web/app_options.js index 8b68d7525c530..a3854264939e6 100644 --- a/web/app_options.js +++ b/web/app_options.js @@ -112,7 +112,7 @@ const defaultOptions = { }, pdfBugEnabled: { /** @type {boolean} */ - value: false, + value: typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION"), kind: OptionKind.VIEWER + OptionKind.PREFERENCE, }, printResolution: {