Remove prefixed fullscreen properties/methods from the MOZCENTRAL builds

The unprefixed version of the fullscreen API has been enabled for quite some time in Firefox, see below, hence we can (slightly) clean-up the relevant code.

 - https://developer.mozilla.org/en-us/docs/Web/API/Document/fullscreenEnabled#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen#browser_compatibility
This commit is contained in:
Jonas Jenwald 2021-01-31 13:45:14 +01:00
parent 59f938d073
commit 1c802e0e6c
2 changed files with 37 additions and 30 deletions

View File

@ -657,26 +657,22 @@ const PDFViewerApplication = {
}, },
get supportsFullscreen() { get supportsFullscreen() {
let support;
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
support = return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
document.fullscreenEnabled === true || }
document.mozFullScreenEnabled === true; const doc = document.documentElement;
} else { let support = !!(
const doc = document.documentElement; doc.requestFullscreen ||
support = !!( doc.mozRequestFullScreen ||
doc.requestFullscreen || doc.webkitRequestFullScreen
doc.mozRequestFullScreen || );
doc.webkitRequestFullScreen
);
if ( if (
document.fullscreenEnabled === false || document.fullscreenEnabled === false ||
document.mozFullScreenEnabled === false || document.mozFullScreenEnabled === false ||
document.webkitFullscreenEnabled === false document.webkitFullscreenEnabled === false
) { ) {
support = false; support = false;
}
} }
return shadow(this, "supportsFullscreen", support); return shadow(this, "supportsFullscreen", support);
}, },

View File

@ -86,14 +86,22 @@ class PDFPresentationMode {
this._setSwitchInProgress(); this._setSwitchInProgress();
this._notifyStateChange(); this._notifyStateChange();
if (this.container.requestFullscreen) { if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
this.container.requestFullscreen(); if (this.container.requestFullscreen) {
} else if (this.container.mozRequestFullScreen) { this.container.requestFullscreen();
this.container.mozRequestFullScreen(); } else {
} else if (this.container.webkitRequestFullscreen) { return false;
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); }
} else { } 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 = { this.args = {
@ -148,6 +156,9 @@ class PDFPresentationMode {
} }
get isFullscreen() { get isFullscreen() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
return !!document.fullscreenElement;
}
return !!( return !!(
document.fullscreenElement || document.fullscreenElement ||
document.mozFullScreen || document.mozFullScreen ||
@ -468,8 +479,8 @@ class PDFPresentationMode {
this.fullscreenChangeBind = this._fullscreenChange.bind(this); this.fullscreenChangeBind = this._fullscreenChange.bind(this);
window.addEventListener("fullscreenchange", this.fullscreenChangeBind); window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
window.addEventListener("mozfullscreenchange", this.fullscreenChangeBind);
window.addEventListener( window.addEventListener(
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind
@ -482,11 +493,11 @@ class PDFPresentationMode {
*/ */
_removeFullscreenChangeListeners() { _removeFullscreenChangeListeners() {
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind); window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
window.removeEventListener(
"mozfullscreenchange",
this.fullscreenChangeBind
);
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) { if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
window.removeEventListener(
"mozfullscreenchange",
this.fullscreenChangeBind
);
window.removeEventListener( window.removeEventListener(
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind