Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the web/ folder

This patch purposely starts small, by removing IE-specific code from various JS/CSS files in the `web/` folder.

There's obviously lots of potential for additional clean-up, especially the removal of no longer necessary polyfills in `src/shared/compatibility.js`, however that will require some care considering that certain polyfills may also be necessary for e.g. Node.js or the Chromium-extension as well.
Generally speaking, once we start removing polyfills it's probably a good idea to consult the compatibility information on https://developer.mozilla.org/ and also https://caniuse.com/ first. (Deciding on the lowest supported Chromium version, for the extension, would also seem like a good idea.)
This commit is contained in:
Jonas Jenwald 2020-09-05 17:00:52 +02:00
parent 4caa14b4dc
commit 87b002c52f
9 changed files with 9 additions and 47 deletions

View File

@ -611,15 +611,13 @@ const PDFViewerApplication = {
support = !!( support = !!(
doc.requestFullscreen || doc.requestFullscreen ||
doc.mozRequestFullScreen || doc.mozRequestFullScreen ||
doc.webkitRequestFullScreen || doc.webkitRequestFullScreen
doc.msRequestFullscreen
); );
if ( if (
document.fullscreenEnabled === false || document.fullscreenEnabled === false ||
document.mozFullScreenEnabled === false || document.mozFullScreenEnabled === false ||
document.webkitFullscreenEnabled === false || document.webkitFullscreenEnabled === false
document.msFullscreenEnabled === false
) { ) {
support = false; support = false;
} }

View File

@ -35,7 +35,7 @@ function download(blobUrl, filename) {
if ("download" in a) { if ("download" in a) {
a.download = filename; a.download = filename;
} }
// <a> must be in the document for IE and recent Firefox versions, // <a> must be in the document for recent Firefox versions,
// otherwise .click() is ignored. // otherwise .click() is ignored.
(document.body || document.documentElement).appendChild(a); (document.body || document.documentElement).appendChild(a);
a.click(); a.click();
@ -51,11 +51,6 @@ class DownloadManager {
} }
downloadData(data, filename, contentType) { downloadData(data, filename, contentType) {
if (navigator.msSaveBlob) {
// IE10 and above
navigator.msSaveBlob(new Blob([data], { type: contentType }), filename);
return;
}
const blobUrl = createObjectURL( const blobUrl = createObjectURL(
data, data,
contentType, contentType,
@ -71,14 +66,6 @@ class DownloadManager {
* the "open with" dialog. * the "open with" dialog.
*/ */
download(blob, url, filename, sourceEventType = "download") { download(blob, url, filename, sourceEventType = "download") {
if (navigator.msSaveBlob) {
// IE10 / IE11
if (!navigator.msSaveBlob(blob, filename)) {
this.downloadUrl(url, filename);
}
return;
}
if (viewerCompatibilityParams.disableCreateObjectURL) { if (viewerCompatibilityParams.disableCreateObjectURL) {
// URL.createObjectURL is not supported // URL.createObjectURL is not supported
this.downloadUrl(url, filename); this.downloadUrl(url, filename);

View File

@ -180,7 +180,7 @@ GrabToPan.prototype = {
// Get the correct (vendor-prefixed) name of the matches method. // Get the correct (vendor-prefixed) name of the matches method.
let matchesSelector; let matchesSelector;
["webkitM", "mozM", "msM", "oM", "m"].some(function (prefix) { ["webkitM", "mozM", "oM", "m"].some(function (prefix) {
let name = prefix + "atches"; let name = prefix + "atches";
if (name in document.documentElement) { if (name in document.documentElement) {
matchesSelector = name; matchesSelector = name;

View File

@ -92,8 +92,6 @@ class PDFPresentationMode {
this.container.mozRequestFullScreen(); this.container.mozRequestFullScreen();
} else if (this.container.webkitRequestFullscreen) { } else if (this.container.webkitRequestFullscreen) {
this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); this.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
} else if (this.container.msRequestFullscreen) {
this.container.msRequestFullscreen();
} else { } else {
return false; return false;
} }
@ -151,8 +149,7 @@ class PDFPresentationMode {
return !!( return !!(
document.fullscreenElement || document.fullscreenElement ||
document.mozFullScreen || document.mozFullScreen ||
document.webkitIsFullScreen || document.webkitIsFullScreen
document.msFullscreenElement
); );
} }
@ -478,7 +475,6 @@ class PDFPresentationMode {
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind
); );
window.addEventListener("MSFullscreenChange", this.fullscreenChangeBind);
} }
} }
@ -496,10 +492,6 @@ class PDFPresentationMode {
"webkitfullscreenchange", "webkitfullscreenchange",
this.fullscreenChangeBind this.fullscreenChangeBind
); );
window.removeEventListener(
"MSFullscreenChange",
this.fullscreenChangeBind
);
} }
delete this.fullscreenChangeBind; delete this.fullscreenChangeBind;

View File

@ -341,7 +341,7 @@ window.addEventListener(
if ("onbeforeprint" in window) { if ("onbeforeprint" in window) {
// Do not propagate before/afterprint events when they are not triggered // Do not propagate before/afterprint events when they are not triggered
// from within this polyfill. (FF /IE / Chrome 63+). // from within this polyfill. (FF / Chrome 63+).
const stopPropagationIfNeeded = function (event) { const stopPropagationIfNeeded = function (event) {
if (event.detail !== "custom" && event.stopImmediatePropagation) { if (event.detail !== "custom" && event.stopImmediatePropagation) {
event.stopImmediatePropagation(); event.stopImmediatePropagation();

View File

@ -124,10 +124,6 @@
margin-right: auto; margin-right: auto;
} }
.pdfPresentationMode:-ms-fullscreen .pdfViewer .page {
margin-bottom: 100% !important;
}
.pdfPresentationMode:fullscreen .pdfViewer .page { .pdfPresentationMode:fullscreen .pdfViewer .page {
margin-bottom: 100%; margin-bottom: 100%;
border: 0; border: 0;

View File

@ -99,7 +99,6 @@ function getOutputScale(ctx) {
const backingStoreRatio = const backingStoreRatio =
ctx.webkitBackingStorePixelRatio || ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio || ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio || ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || ctx.backingStorePixelRatio ||
1; 1;

View File

@ -203,15 +203,6 @@ select {
cursor: not-allowed; cursor: not-allowed;
} }
#viewerContainer.pdfPresentationMode:-ms-fullscreen {
top: 0px !important;
overflow: hidden !important;
}
#viewerContainer.pdfPresentationMode:-ms-fullscreen::-ms-backdrop {
background-color: rgba(0, 0, 0, 1);
}
#viewerContainer.pdfPresentationMode:fullscreen { #viewerContainer.pdfPresentationMode:fullscreen {
top: 0px; top: 0px;
border-top: 2px solid rgba(0, 0, 0, 0); border-top: 2px solid rgba(0, 0, 0, 0);

View File

@ -23,7 +23,6 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
(typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1; (typeof navigator !== "undefined" && navigator.maxTouchPoints) || 1;
const isAndroid = /Android/.test(userAgent); const isAndroid = /Android/.test(userAgent);
const isIE = /Trident/.test(userAgent);
const isIOS = const isIOS =
/\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) || /\b(iPad|iPhone|iPod)(?=;)/.test(userAgent) ||
(platform === "MacIntel" && maxTouchPoints > 1); (platform === "MacIntel" && maxTouchPoints > 1);
@ -32,9 +31,9 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
// Checks if possible to use URL.createObjectURL() // Checks if possible to use URL.createObjectURL()
// Support: IE, Chrome on iOS // Support: IE, Chrome on iOS
(function checkOnBlobSupport() { (function checkOnBlobSupport() {
// Sometimes IE and Chrome on iOS losing the data created with // Sometimes Chrome on iOS loses data created with createObjectURL(),
// createObjectURL(), see issues #3977 and #8081. // see issue #8081.
if (isIE || isIOSChrome) { if (isIOSChrome) {
compatibilityParams.disableCreateObjectURL = true; compatibilityParams.disableCreateObjectURL = true;
} }
})(); })();