Only support the standard, unprefixed, Fullscreen API in the default viewer

At this point in time, after recent rounds of clean-up, the `webkit`-prefixed Fullscreen API is the only remaining *browser-specific* compatibility hack in the `web/`-folder JavaScript code.

The standard, and thus unprefixed, Fullscreen API has been supported for *over three years* in both Mozilla Firefox and Google Chrome. [According to MDN](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API#browser_compatibility), the unprefixed Fullscreen API has been available since:
 - Mozilla Firefox 64, released on 2018-12-11; see https://wiki.mozilla.org/Release_Management/Calendar#Past_branch_dates
 - Google Chrome 71, released on 2018-12-04; see https://en.wikipedia.org/wiki/Google_Chrome_version_history

Hence *only* Safari now requires using a prefixed Fullscreen API, and it's thus (significantly) lagging behind other browsers in this regard.
Considering that the default viewer is written *specifically* to be the UI for the Firefox PDF Viewer, and that we ask users to not just use it as-is[1], I think that we should only support the standard Fullscreen API now.
Furthermore, note also that the FAQ already lists Safari as "Mostly" supported; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support

---
[1] Note e.g. http://mozilla.github.io/pdf.js/getting_started/#introduction
> The viewer is built on the display layer and is the UI for PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer. *However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.*
This commit is contained in:
Jonas Jenwald 2022-02-25 15:36:45 +01:00
parent cadc4d2f61
commit 9d773c1499
2 changed files with 9 additions and 47 deletions

View File

@ -671,14 +671,7 @@ const PDFViewerApplication = {
},
get supportsFullscreen() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
}
return shadow(
this,
"supportsFullscreen",
document.fullscreenEnabled || document.webkitFullscreenEnabled
);
return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
},
get supportsIntegratedFind() {

View File

@ -63,28 +63,19 @@ class PDFPresentationMode {
* @returns {boolean} Indicating if the request was successful.
*/
request() {
if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
if (
this.switchInProgress ||
this.active ||
!this.pdfViewer.pagesCount ||
!this.container.requestFullscreen
) {
return false;
}
this.#addFullscreenChangeListeners();
this.#setSwitchInProgress();
this.#notifyStateChange();
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
if (this.container.requestFullscreen) {
this.container.requestFullscreen();
} else {
return false;
}
} else {
if (this.container.requestFullscreen) {
this.container.requestFullscreen();
} else if (this.container.webkitRequestFullscreen) {
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else {
return false;
}
}
this.container.requestFullscreen();
this.args = {
pageNumber: this.pdfViewer.currentPageNumber,
@ -92,7 +83,6 @@ class PDFPresentationMode {
scrollMode: this.pdfViewer.scrollMode,
spreadMode: this.pdfViewer.spreadMode,
};
return true;
}
@ -136,13 +126,6 @@ class PDFPresentationMode {
}
}
get isFullscreen() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
return !!document.fullscreenElement;
}
return !!(document.fullscreenElement || document.webkitIsFullScreen);
}
#notifyStateChange() {
let state = PresentationModeState.NORMAL;
if (this.switchInProgress) {
@ -386,7 +369,7 @@ class PDFPresentationMode {
}
#fullscreenChange() {
if (this.isFullscreen) {
if (/* isFullscreen = */ document.fullscreenElement) {
this.#enter();
} else {
this.#exit();
@ -395,25 +378,11 @@ class PDFPresentationMode {
#addFullscreenChangeListeners() {
this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
window.addEventListener(
"webkitfullscreenchange",
this.fullscreenChangeBind
);
}
}
#removeFullscreenChangeListeners() {
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
window.removeEventListener(
"webkitfullscreenchange",
this.fullscreenChangeBind
);
}
delete this.fullscreenChangeBind;
}
}