Merge pull request #13250 from Snuffleupagus/rm-_delayedFallback

Remove the `PDFViewerApplication._delayedFallback` functionality
This commit is contained in:
Tim van der Meij 2021-04-16 20:38:22 +02:00 committed by GitHub
commit 6db10d159a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -258,7 +258,6 @@ const PDFViewerApplication = {
metadata: null, metadata: null,
_contentDispositionFilename: null, _contentDispositionFilename: null,
_contentLength: null, _contentLength: null,
triggerDelayedFallback: null,
_saveInProgress: false, _saveInProgress: false,
_wheelUnusedTicks: 0, _wheelUnusedTicks: 0,
_idleCallbacks: new Set(), _idleCallbacks: new Set(),
@ -840,7 +839,6 @@ const PDFViewerApplication = {
this.metadata = null; this.metadata = null;
this._contentDispositionFilename = null; this._contentDispositionFilename = null;
this._contentLength = null; this._contentLength = null;
this.triggerDelayedFallback = null;
this._saveInProgress = false; this._saveInProgress = false;
this._cancelIdleCallbacks(); 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) { fallback(featureId) {
this.externalServices.reportTelemetry({ this.externalServices.reportTelemetry({
type: "unsupportedFeature", type: "unsupportedFeature",
@ -1496,8 +1473,8 @@ const PDFViewerApplication = {
// Don't warn/fallback for empty JavaScript actions. // Don't warn/fallback for empty JavaScript actions.
return false; return false;
} }
console.warn("Warning: JavaScript is not supported"); console.warn("Warning: JavaScript support is not enabled");
this._delayedFallback(UNSUPPORTED_FEATURES.javaScript); this.fallback(UNSUPPORTED_FEATURES.javaScript);
return true; return true;
}); });
@ -1576,13 +1553,13 @@ const PDFViewerApplication = {
!pdfDocument.isPureXfa !pdfDocument.isPureXfa
) { ) {
console.warn("Warning: XFA is not supported"); console.warn("Warning: XFA is not supported");
this._delayedFallback(UNSUPPORTED_FEATURES.forms); this.fallback(UNSUPPORTED_FEATURES.forms);
} else if ( } else if (
(info.IsAcroFormPresent || info.IsXFAPresent) && (info.IsAcroFormPresent || info.IsXFAPresent) &&
!this.pdfViewer.renderInteractiveForms !this.pdfViewer.renderInteractiveForms
) { ) {
console.warn("Warning: Interactive form support is not enabled"); console.warn("Warning: Interactive form support is not enabled");
this._delayedFallback(UNSUPPORTED_FEATURES.forms); this.fallback(UNSUPPORTED_FEATURES.forms);
} }
if (info.IsSignaturesPresent) { if (info.IsSignaturesPresent) {
@ -1989,7 +1966,6 @@ const PDFViewerApplication = {
}); });
window.addEventListener("click", webViewerClick); window.addEventListener("click", webViewerClick);
window.addEventListener("keydown", webViewerKeyDown); window.addEventListener("keydown", webViewerKeyDown);
window.addEventListener("keyup", webViewerKeyUp);
window.addEventListener("resize", _boundEvents.windowResize); window.addEventListener("resize", _boundEvents.windowResize);
window.addEventListener("hashchange", _boundEvents.windowHashChange); window.addEventListener("hashchange", _boundEvents.windowHashChange);
window.addEventListener("beforeprint", _boundEvents.windowBeforePrint); window.addEventListener("beforeprint", _boundEvents.windowBeforePrint);
@ -2067,7 +2043,6 @@ const PDFViewerApplication = {
}); });
window.removeEventListener("click", webViewerClick); window.removeEventListener("click", webViewerClick);
window.removeEventListener("keydown", webViewerKeyDown); window.removeEventListener("keydown", webViewerKeyDown);
window.removeEventListener("keyup", webViewerKeyUp);
window.removeEventListener("resize", _boundEvents.windowResize); window.removeEventListener("resize", _boundEvents.windowResize);
window.removeEventListener("hashchange", _boundEvents.windowHashChange); window.removeEventListener("hashchange", _boundEvents.windowHashChange);
window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint); window.removeEventListener("beforeprint", _boundEvents.windowBeforePrint);
@ -2796,15 +2771,6 @@ function webViewerTouchStart(evt) {
} }
function webViewerClick(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) { if (!PDFViewerApplication.secondaryToolbar.isOpen) {
return; return;
} }
@ -2818,16 +2784,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) { function webViewerKeyDown(evt) {
if (PDFViewerApplication.overlayManager.active) { if (PDFViewerApplication.overlayManager.active) {
return; return;