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:
parent
cadc4d2f61
commit
9d773c1499
@ -671,14 +671,7 @@ const PDFViewerApplication = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get supportsFullscreen() {
|
get supportsFullscreen() {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
|
||||||
return shadow(this, "supportsFullscreen", document.fullscreenEnabled);
|
|
||||||
}
|
|
||||||
return shadow(
|
|
||||||
this,
|
|
||||||
"supportsFullscreen",
|
|
||||||
document.fullscreenEnabled || document.webkitFullscreenEnabled
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get supportsIntegratedFind() {
|
get supportsIntegratedFind() {
|
||||||
|
@ -63,28 +63,19 @@ class PDFPresentationMode {
|
|||||||
* @returns {boolean} Indicating if the request was successful.
|
* @returns {boolean} Indicating if the request was successful.
|
||||||
*/
|
*/
|
||||||
request() {
|
request() {
|
||||||
if (this.switchInProgress || this.active || !this.pdfViewer.pagesCount) {
|
if (
|
||||||
|
this.switchInProgress ||
|
||||||
|
this.active ||
|
||||||
|
!this.pdfViewer.pagesCount ||
|
||||||
|
!this.container.requestFullscreen
|
||||||
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.#addFullscreenChangeListeners();
|
this.#addFullscreenChangeListeners();
|
||||||
this.#setSwitchInProgress();
|
this.#setSwitchInProgress();
|
||||||
this.#notifyStateChange();
|
this.#notifyStateChange();
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
this.container.requestFullscreen();
|
||||||
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.args = {
|
this.args = {
|
||||||
pageNumber: this.pdfViewer.currentPageNumber,
|
pageNumber: this.pdfViewer.currentPageNumber,
|
||||||
@ -92,7 +83,6 @@ class PDFPresentationMode {
|
|||||||
scrollMode: this.pdfViewer.scrollMode,
|
scrollMode: this.pdfViewer.scrollMode,
|
||||||
spreadMode: this.pdfViewer.spreadMode,
|
spreadMode: this.pdfViewer.spreadMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
return true;
|
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() {
|
#notifyStateChange() {
|
||||||
let state = PresentationModeState.NORMAL;
|
let state = PresentationModeState.NORMAL;
|
||||||
if (this.switchInProgress) {
|
if (this.switchInProgress) {
|
||||||
@ -386,7 +369,7 @@ class PDFPresentationMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#fullscreenChange() {
|
#fullscreenChange() {
|
||||||
if (this.isFullscreen) {
|
if (/* isFullscreen = */ document.fullscreenElement) {
|
||||||
this.#enter();
|
this.#enter();
|
||||||
} else {
|
} else {
|
||||||
this.#exit();
|
this.#exit();
|
||||||
@ -395,25 +378,11 @@ class PDFPresentationMode {
|
|||||||
|
|
||||||
#addFullscreenChangeListeners() {
|
#addFullscreenChangeListeners() {
|
||||||
this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
|
this.fullscreenChangeBind = this.#fullscreenChange.bind(this);
|
||||||
|
|
||||||
window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
|
window.addEventListener("fullscreenchange", this.fullscreenChangeBind);
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
|
||||||
window.addEventListener(
|
|
||||||
"webkitfullscreenchange",
|
|
||||||
this.fullscreenChangeBind
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#removeFullscreenChangeListeners() {
|
#removeFullscreenChangeListeners() {
|
||||||
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
|
window.removeEventListener("fullscreenchange", this.fullscreenChangeBind);
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) {
|
|
||||||
window.removeEventListener(
|
|
||||||
"webkitfullscreenchange",
|
|
||||||
this.fullscreenChangeBind
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete this.fullscreenChangeBind;
|
delete this.fullscreenChangeBind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user