From 4ef187e9032a7bbf319463fd588effb6d2a9d728 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 16 Apr 2021 10:08:13 +0200 Subject: [PATCH] Remove the `PDFViewerApplication._delayedFallback` functionality According to a decision by UX and PM, please see https://bugzilla.mozilla.org/show_bug.cgi?id=1705060#c2 (and implemented in https://bugzilla.mozilla.org/show_bug.cgi?id=1705327), we no longer show the notification-bar in Firefox; hence the special `PDFViewerApplication._delayedFallback` functionality should no longer be necessary. Furthermore, note that at this point in time *most* of the features which used the `PDFViewerApplication._delayedFallback` functionality is now enabled by default; hence that provides even less reason to keep this code around and existing calls are thus converted to "regular" `PDFViewerApplication.fallback` calls. --- web/app.js | 52 ++++------------------------------------------------ 1 file changed, 4 insertions(+), 48 deletions(-) diff --git a/web/app.js b/web/app.js index 6d74eb6c3..e9a82edd4 100644 --- a/web/app.js +++ b/web/app.js @@ -258,7 +258,6 @@ const PDFViewerApplication = { metadata: null, _contentDispositionFilename: null, _contentLength: null, - triggerDelayedFallback: null, _saveInProgress: false, _wheelUnusedTicks: 0, _idleCallbacks: new Set(), @@ -840,7 +839,6 @@ const PDFViewerApplication = { this.metadata = null; this._contentDispositionFilename = null; this._contentLength = null; - this.triggerDelayedFallback = null; this._saveInProgress = false; this._cancelIdleCallbacks(); @@ -1021,27 +1019,6 @@ const PDFViewerApplication = { } }, - /** - * For PDF documents that contain e.g. forms and javaScript, we should only - * trigger the fallback bar once the user has interacted with the page. - * @private - */ - _delayedFallback(featureId) { - // Ensure that telemetry is always reported, since it's not guaranteed - // that the fallback bar will be shown (depends on user interaction). - this.externalServices.reportTelemetry({ - type: "unsupportedFeature", - featureId, - }); - - if (!this.triggerDelayedFallback) { - this.triggerDelayedFallback = () => { - this.fallback(featureId); - this.triggerDelayedFallback = null; - }; - } - }, - fallback(featureId) { this.externalServices.reportTelemetry({ type: "unsupportedFeature", @@ -1513,8 +1490,8 @@ const PDFViewerApplication = { // Don't warn/fallback for empty JavaScript actions. return false; } - console.warn("Warning: JavaScript is not supported"); - this._delayedFallback(UNSUPPORTED_FEATURES.javaScript); + console.warn("Warning: JavaScript support is not enabled"); + this.fallback(UNSUPPORTED_FEATURES.javaScript); return true; }); @@ -1593,13 +1570,13 @@ const PDFViewerApplication = { !pdfDocument.isPureXfa ) { console.warn("Warning: XFA is not supported"); - this._delayedFallback(UNSUPPORTED_FEATURES.forms); + this.fallback(UNSUPPORTED_FEATURES.forms); } else if ( (info.IsAcroFormPresent || info.IsXFAPresent) && !this.pdfViewer.renderInteractiveForms ) { console.warn("Warning: Interactive form support is not enabled"); - this._delayedFallback(UNSUPPORTED_FEATURES.forms); + this.fallback(UNSUPPORTED_FEATURES.forms); } if (info.IsSignaturesPresent) { @@ -2006,7 +1983,6 @@ const PDFViewerApplication = { }); window.addEventListener("click", webViewerClick); window.addEventListener("keydown", webViewerKeyDown); - window.addEventListener("keyup", webViewerKeyUp); window.addEventListener("resize", _boundEvents.windowResize); window.addEventListener("hashchange", _boundEvents.windowHashChange); window.addEventListener("beforeprint", _boundEvents.windowBeforePrint); @@ -2084,7 +2060,6 @@ const PDFViewerApplication = { }); window.removeEventListener("click", webViewerClick); window.removeEventListener("keydown", webViewerKeyDown); - window.removeEventListener("keyup", webViewerKeyUp); window.removeEventListener("resize", _boundEvents.windowResize); window.removeEventListener("hashchange", _boundEvents.windowHashChange); window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint); @@ -2813,15 +2788,6 @@ function webViewerTouchStart(evt) { } function webViewerClick(evt) { - // Avoid triggering the fallback bar when the user clicks on the - // toolbar or sidebar. - if ( - PDFViewerApplication.triggerDelayedFallback && - PDFViewerApplication.pdfViewer.containsElement(evt.target) - ) { - PDFViewerApplication.triggerDelayedFallback(); - } - if (!PDFViewerApplication.secondaryToolbar.isOpen) { return; } @@ -2835,16 +2801,6 @@ function webViewerClick(evt) { } } -function webViewerKeyUp(evt) { - if (evt.keyCode === 9) { - // The user is tabbing into the viewer. Trigger the fallback bar if it has - // not already been displayed. - if (PDFViewerApplication.triggerDelayedFallback) { - PDFViewerApplication.triggerDelayedFallback(); - } - } -} - function webViewerKeyDown(evt) { if (PDFViewerApplication.overlayManager.active) { return;