From cfa15bbf59aed5a34dc321a94f462368e44c0ccd Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 29 Apr 2023 08:48:06 +0200 Subject: [PATCH 1/4] Revert "Compatible with ResizeObserver borderBoxSize in legacy safari" This reverts commit 6ca702d6804097514ecf4f5ded84efa87771182a now that Safari-compatibility is updated. --- web/pdf_viewer.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index ddc869fe4..143f6bd6d 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -2180,14 +2180,7 @@ class PDFViewer { for (const entry of entries) { if (entry.target === this.container) { this.#updateContainerHeightCss( - // Safari doesn't support `borderBoxSize` until version 15.4. - Math.floor( - typeof PDFJSDev !== "undefined" && - !PDFJSDev.test("SKIP_BABEL") && - !entry.borderBoxSize?.length - ? entry.contentRect.height - : entry.borderBoxSize[0].blockSize - ) + Math.floor(entry.borderBoxSize[0].blockSize) ); this.#containerTopLeft = null; break; From c5eb79577ae9926111e68382aa6f47fe8086166a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 29 Apr 2023 08:51:39 +0200 Subject: [PATCH 2/4] Revert "Bundle the `` polyfill-CSS in the GENERIC `legacy/`-viewer (PR 14710 follow-up)" This reverts commit bb8f5ec20bf6a2fed1f962178b06bc4d99d1e2ef now that Safari-compatibility is updated. --- gulpfile.js | 10 ---------- web/overlay_manager.js | 9 --------- 2 files changed, 19 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a25dd399c..71bd903a4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -192,8 +192,6 @@ function createWebpackConfig( DEFAULT_PREFERENCES: defaultPreferencesDir ? getDefaultPreferences(defaultPreferencesDir) : {}, - DIALOG_POLYFILL_CSS: - defines.GENERIC && !defines.SKIP_BABEL ? getDialogPolyfillCSS() : "", }); const licenseHeaderLibre = fs .readFileSync("./src/license_header_libre.js") @@ -821,12 +819,6 @@ function getDefaultPreferences(dir) { return AppOptions.getAll(OptionKind.PREFERENCE); } -function getDialogPolyfillCSS() { - return fs - .readFileSync("node_modules/dialog-polyfill/dist/dialog-polyfill.css") - .toString(); -} - gulp.task("locale", function () { const VIEWER_LOCALE_OUTPUT = "web/locale/"; @@ -1585,8 +1577,6 @@ function buildLib(defines, dir) { DEFAULT_PREFERENCES: getDefaultPreferences( defines.SKIP_BABEL ? "lib/" : "lib-legacy/" ), - DIALOG_POLYFILL_CSS: - defines.GENERIC && !defines.SKIP_BABEL ? getDialogPolyfillCSS() : "", }); const inputStream = merge([ diff --git a/web/overlay_manager.js b/web/overlay_manager.js index 885066106..e4d7378e1 100644 --- a/web/overlay_manager.js +++ b/web/overlay_manager.js @@ -44,15 +44,6 @@ class OverlayManager { ) { const dialogPolyfill = require("dialog-polyfill/dist/dialog-polyfill.js"); dialogPolyfill.registerDialog(dialog); - - if (!this._dialogPolyfillCSS) { - this._dialogPolyfillCSS = true; - - const style = document.createElement("style"); - style.textContent = PDFJSDev.eval("DIALOG_POLYFILL_CSS"); - - document.head.prepend(style); - } } dialog.addEventListener("cancel", evt => { From 2c2acdfd1c402d7b51b55264c05e4e2777e77739 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 29 Apr 2023 08:55:08 +0200 Subject: [PATCH 3/4] Revert "Add a `` polyfill for the `generic-legacy` build" This reverts commit c9f262c480e0d22fdcc6991700f9ce92b72812b2 now that Safari-compatibility is updated. --- package-lock.json | 37 ++++++++++++------------------------- package.json | 1 - web/overlay_manager.js | 9 --------- 3 files changed, 12 insertions(+), 35 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1c5469733..62073005e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "canvas": "^2.11.2", "core-js": "^3.30.1", "cross-env": "^7.0.3", - "dialog-polyfill": "^0.5.6", "es-module-shims": "1.4.7", "eslint": "^8.39.0", "eslint-config-prettier": "^8.8.0", @@ -5030,12 +5029,6 @@ "kuler": "1.0.x" } }, - "node_modules/dialog-polyfill": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/dialog-polyfill/-/dialog-polyfill-0.5.6.tgz", - "integrity": "sha512-ZbVDJI9uvxPAKze6z146rmfUZjBqNEwcnFTVamQzXH+svluiV7swmVIGr7miwADgfgt1G2JQIytypM9fbyhX4w==", - "dev": true - }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -12506,7 +12499,7 @@ }, "node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -12522,19 +12515,19 @@ }, "node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -12549,7 +12542,7 @@ }, "node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -12567,7 +12560,7 @@ }, "node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", - "dev": true, + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -23031,12 +23024,6 @@ "kuler": "1.0.x" } }, - "dialog-polyfill": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/dialog-polyfill/-/dialog-polyfill-0.5.6.tgz", - "integrity": "sha512-ZbVDJI9uvxPAKze6z146rmfUZjBqNEwcnFTVamQzXH+svluiV7swmVIGr7miwADgfgt1G2JQIytypM9fbyhX4w==", - "dev": true - }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -28769,7 +28756,7 @@ "lodash._baseindexof": { "version": "3.1.0", "bundled": true, - "dev": true + "extraneous": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -28783,17 +28770,17 @@ "lodash._bindcallback": { "version": "3.0.1", "bundled": true, - "dev": true + "extraneous": true }, "lodash._cacheindexof": { "version": "3.0.2", "bundled": true, - "dev": true + "extraneous": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, - "dev": true, + "extraneous": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -28806,7 +28793,7 @@ "lodash._getnative": { "version": "3.9.1", "bundled": true, - "dev": true + "extraneous": true }, "lodash._root": { "version": "3.0.1", @@ -28821,7 +28808,7 @@ "lodash.restparam": { "version": "3.6.1", "bundled": true, - "dev": true + "extraneous": true }, "lodash.union": { "version": "4.6.0", diff --git a/package.json b/package.json index c3fd6999d..5586f8308 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ "canvas": "^2.11.2", "core-js": "^3.30.1", "cross-env": "^7.0.3", - "dialog-polyfill": "^0.5.6", "es-module-shims": "1.4.7", "eslint": "^8.39.0", "eslint-config-prettier": "^8.8.0", diff --git a/web/overlay_manager.js b/web/overlay_manager.js index e4d7378e1..233c9f594 100644 --- a/web/overlay_manager.js +++ b/web/overlay_manager.js @@ -37,15 +37,6 @@ class OverlayManager { } this.#overlays.set(dialog, { canForceClose }); - if ( - typeof PDFJSDev !== "undefined" && - PDFJSDev.test("GENERIC && !SKIP_BABEL") && - !dialog.showModal - ) { - const dialogPolyfill = require("dialog-polyfill/dist/dialog-polyfill.js"); - dialogPolyfill.registerDialog(dialog); - } - dialog.addEventListener("cancel", evt => { this.#active = null; }); From d1adab8c7b9724ffd4e3111e7e64ac9df7ed5802 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 29 Apr 2023 08:58:44 +0200 Subject: [PATCH 4/4] [api-minor] Update the minimum supported Safari version to 15.4 This patch updates the minimum supported browsers as follows: - Safari 15.4, which was released on 2022-03-15; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_15 Nowadays we usually we try, where feasible and possible, to support browsers that are about two years old. The reasons for limiting support to a *somewhat* more recent Safari version include: - Throughout the history of the PDF.js project, Safari has always been the worst browser to attempt to support. Compared to other browsers there's a disproportionate number of bugs affecting Safari, especially on iOS, and in most cases those are browser-specific issues that we simply cannot address.[1] - Safari has often been a lot slower, compared to other browsers, at implementing new web-platform features. Historically this has sometimes blocked usage of new features, for the benefit of the Firefox PDF Viewer, and it's very often meant having to include and maintain polyfills *only* for Safari. - The current (minimum) supported Safari version lack enough functionality that polyfills placed in the `src/shared/compatibility.js` file are unfortunately not sufficient, but it also requires a bunch of special-cases in both the `gulpfile` and in the `web/`-code. - Given that the *built-in* Firefox PDF Viewer is the primary development target for the PDF.js library, and the general development pace these days, we need to limit the maintenance "overhead" caused by other browsers. --- [1] In a few cases a work-around might be possible, however it'd negatively affect e.g. performance, readability, and/or maintainability of the code. --- gulpfile.js | 2 +- src/shared/compatibility.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 71bd903a4..c49839163 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -79,7 +79,7 @@ const ENV_TARGETS = [ "last 2 versions", "Chrome >= 88", "Firefox ESR", - "Safari >= 14.1", + "Safari >= 15.4", "Node >= 18", "> 1%", "not IE > 0", diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index cf623e0c5..641cc431e 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -36,7 +36,7 @@ import { isNodeJS } from "./is_node.js"; polyfillPath2D(globalThis); })(); -// Support: Chrome<92, Safari<15.4 +// Support: Chrome<92 (function checkArrayAt() { if (Array.prototype.at) { return; @@ -44,7 +44,7 @@ import { isNodeJS } from "./is_node.js"; require("core-js/es/array/at.js"); })(); -// Support: Chrome<92, Safari<15.4 +// Support: Chrome<92 (function checkTypedArrayAt() { if (Uint8Array.prototype.at) { return; @@ -52,7 +52,7 @@ import { isNodeJS } from "./is_node.js"; require("core-js/es/typed-array/at.js"); })(); -// Support: Chrome<98, Safari<15.4 +// Support: Chrome<98 (function checkStructuredClone() { if (globalThis.structuredClone) { return;