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() {
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);
},

View File

@ -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