Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle the <dialog> polyfill-CSS in the GENERIC legacy/-viewer (PR 14710 follow-up) #14984

Merged
merged 1 commit into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ 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")
Expand Down Expand Up @@ -736,6 +738,12 @@ 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/";

Expand Down Expand Up @@ -1519,6 +1527,8 @@ 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([
Expand Down
9 changes: 9 additions & 0 deletions web/overlay_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ 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.insertBefore(style, document.head.firstElementChild);
}
}

dialog.addEventListener("cancel", evt => {
Expand Down