From bbdabc55aa286e1368bd6813212392a479aeeac4 Mon Sep 17 00:00:00 2001 From: Emma Malysz Date: Mon, 1 Jun 2020 10:28:30 -0700 Subject: [PATCH] For #11838: trigger fallback bar after user clicks in pdf --- web/app.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/web/app.js b/web/app.js index 1d442f0a189aa7..4bb56e2f2e0916 100644 --- a/web/app.js +++ b/web/app.js @@ -189,6 +189,8 @@ const PDFViewerApplication = { externalServices: DefaultExternalServices, _boundEvents: {}, contentDispositionFilename: null, + _hasInteracted: false, + _isAcroFormPresent: false, // Called once when the document is loaded. async initialize(appConfig) { @@ -868,10 +870,16 @@ const PDFViewerApplication = { PDFJSDev.test("MOZCENTRAL || GENERIC") ) { // Only trigger the fallback once so we don't spam the user with messages - // for one PDF. + // for one PDF. For forms, it should only be triggered once the user has + // clicked within the PDF. if (this.fellback) { return; } + + if (featureId === UNSUPPORTED_FEATURES.forms && !this._hasInteracted) { + return; + } + this.fellback = true; this.externalServices.fallback( { @@ -1317,7 +1325,7 @@ const PDFViewerApplication = { if (info.IsAcroFormPresent) { console.warn("Warning: AcroForm/XFA is not supported"); - this.fallback(UNSUPPORTED_FEATURES.forms); + this._isAcroFormPresent = true; } if ( @@ -2473,6 +2481,11 @@ function webViewerWheel(evt) { } function webViewerClick(evt) { + PDFViewerApplication._hasInteracted = true; + if (PDFViewerApplication._isAcroFormPresent) { + PDFViewerApplication.fallback(UNSUPPORTED_FEATURES.forms); + } + if (!PDFViewerApplication.secondaryToolbar.isOpen) { return; }