diff --git a/web/app.js b/web/app.js index e483d1797..9987f9bfe 100644 --- a/web/app.js +++ b/web/app.js @@ -657,26 +657,22 @@ const PDFViewerApplication = { }, get supportsFullscreen() { - let support; if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { - support = - document.fullscreenEnabled === true || - document.mozFullScreenEnabled === true; - } else { - const doc = document.documentElement; - support = !!( - doc.requestFullscreen || - doc.mozRequestFullScreen || - doc.webkitRequestFullScreen - ); + return shadow(this, "supportsFullscreen", document.fullscreenEnabled); + } + const doc = document.documentElement; + let support = !!( + doc.requestFullscreen || + doc.mozRequestFullScreen || + doc.webkitRequestFullScreen + ); - if ( - document.fullscreenEnabled === false || - document.mozFullScreenEnabled === false || - document.webkitFullscreenEnabled === false - ) { - support = false; - } + if ( + document.fullscreenEnabled === false || + document.mozFullScreenEnabled === false || + document.webkitFullscreenEnabled === false + ) { + support = false; } return shadow(this, "supportsFullscreen", support); }, diff --git a/web/pdf_presentation_mode.js b/web/pdf_presentation_mode.js index f9ad45280..cf0c119de 100644 --- a/web/pdf_presentation_mode.js +++ b/web/pdf_presentation_mode.js @@ -86,14 +86,22 @@ class PDFPresentationMode { this._setSwitchInProgress(); this._notifyStateChange(); - if (this.container.requestFullscreen) { - this.container.requestFullscreen(); - } else if (this.container.mozRequestFullScreen) { - this.container.mozRequestFullScreen(); - } else if (this.container.webkitRequestFullscreen) { - this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { + if (this.container.requestFullscreen) { + this.container.requestFullscreen(); + } else { + return false; + } } else { - return false; + if (this.container.requestFullscreen) { + this.container.requestFullscreen(); + } else if (this.container.mozRequestFullScreen) { + this.container.mozRequestFullScreen(); + } else if (this.container.webkitRequestFullscreen) { + this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); + } else { + return false; + } } this.args = { @@ -148,6 +156,9 @@ class PDFPresentationMode { } get isFullscreen() { + if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { + return !!document.fullscreenElement; + } return !!( document.fullscreenElement || document.mozFullScreen || @@ -468,8 +479,8 @@ class PDFPresentationMode { this.fullscreenChangeBind = this._fullscreenChange.bind(this); window.addEventListener("fullscreenchange", this.fullscreenChangeBind); - window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind); if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { + window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind); window.addEventListener( "webkitfullscreenchange", this.fullscreenChangeBind @@ -482,11 +493,11 @@ class PDFPresentationMode { */ _removeFullscreenChangeListeners() { window.removeEventListener("fullscreenchange", this.fullscreenChangeBind); - window.removeEventListener( - "mozfullscreenchange", - this.fullscreenChangeBind - ); if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { + window.removeEventListener( + "mozfullscreenchange", + this.fullscreenChangeBind + ); window.removeEventListener( "webkitfullscreenchange", this.fullscreenChangeBind