summaryrefslogtreecommitdiffstats
path: root/toolkit/components/prompts/src/CommonDialog.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:42 +0000
commitda4c7e7ed675c3bf405668739c3012d140856109 (patch)
treecdd868dba063fecba609a1d819de271f0d51b23e /toolkit/components/prompts/src/CommonDialog.sys.mjs
parentAdding upstream version 125.0.3. (diff)
downloadfirefox-da4c7e7ed675c3bf405668739c3012d140856109.tar.xz
firefox-da4c7e7ed675c3bf405668739c3012d140856109.zip
Adding upstream version 126.0.upstream/126.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/prompts/src/CommonDialog.sys.mjs')
-rw-r--r--toolkit/components/prompts/src/CommonDialog.sys.mjs62
1 files changed, 14 insertions, 48 deletions
diff --git a/toolkit/components/prompts/src/CommonDialog.sys.mjs b/toolkit/components/prompts/src/CommonDialog.sys.mjs
index a0812aa8ec..c788248442 100644
--- a/toolkit/components/prompts/src/CommonDialog.sys.mjs
+++ b/toolkit/components/prompts/src/CommonDialog.sys.mjs
@@ -30,11 +30,10 @@ CommonDialog.prototype = {
initialFocusResolver: null,
/**
- * @param [commonDialogEl] - Dialog element from commonDialog.xhtml,
- * null for TabModalPrompts.
+ * @param [commonDialogEl] - Dialog element from commonDialog.xhtml.
*/
- async onLoad(commonDialogEl = null) {
- let isEmbedded = !!commonDialogEl?.ownerGlobal.docShell.chromeEventHandler;
+ async onLoad(commonDialogEl) {
+ let isEmbedded = !!commonDialogEl.ownerGlobal.docShell.chromeEventHandler;
switch (this.args.promptType) {
case "alert":
@@ -106,36 +105,19 @@ CommonDialog.prototype = {
throw new Error("unknown dialog type");
}
- if (commonDialogEl) {
- commonDialogEl.setAttribute(
- "windowtype",
- "prompt:" + this.args.promptType
- );
- }
+ commonDialogEl.setAttribute("windowtype", "prompt:" + this.args.promptType);
// set the document title
let title = this.args.title;
let infoTitle = this.ui.infoTitle;
infoTitle.appendChild(infoTitle.ownerDocument.createTextNode(title));
- // Specific check to prevent showing the title on the old content prompts for macOS.
- // This should be removed when the old content prompts are removed.
- let contentSubDialogPromptEnabled = Services.prefs.getBoolPref(
- "prompts.contentPromptSubDialog"
- );
- let isOldContentPrompt =
- !contentSubDialogPromptEnabled &&
- this.args.modalType == Ci.nsIPrompt.MODAL_TYPE_CONTENT;
-
// After making these preventative checks, we can determine to show it if we're on
// macOS (where there is no titlebar) or if the prompt is a common dialog document
// and has been embedded (has a chromeEventHandler).
- infoTitle.hidden =
- isOldContentPrompt || !(AppConstants.platform === "macosx" || isEmbedded);
+ infoTitle.hidden = !(AppConstants.platform === "macosx" || isEmbedded);
- if (commonDialogEl) {
- commonDialogEl.ownerDocument.title = title;
- }
+ commonDialogEl.ownerDocument.title = title;
// Set button labels and visibility
//
@@ -193,7 +175,7 @@ CommonDialog.prototype = {
// set the icon
let icon = this.ui.infoIcon;
if (icon) {
- this.iconClass.forEach((el, idx, arr) => icon.classList.add(el));
+ this.iconClass.forEach(el => icon.classList.add(el));
}
// set default result to cancelled
@@ -202,15 +184,7 @@ CommonDialog.prototype = {
// Set the default button
let b = this.args.defaultButtonNum || 0;
- let button = this.ui["button" + b];
-
- if (commonDialogEl) {
- commonDialogEl.defaultButton = ["accept", "cancel", "extra1", "extra2"][
- b
- ];
- } else {
- button.setAttribute("default", "true");
- }
+ commonDialogEl.defaultButton = ["accept", "cancel", "extra1", "extra2"][b];
if (!isEmbedded && !this.ui.promptContainer?.hidden) {
// Set default focus and select textbox contents if applicable. If we're
@@ -229,7 +203,7 @@ CommonDialog.prototype = {
// Play a sound (unless we're showing a content prompt -- don't want those
// to feel like OS prompts).
try {
- if (commonDialogEl && this.soundID && !this.args.openedWithTabDialog) {
+ if (this.soundID && !this.args.openedWithTabDialog) {
Cc["@mozilla.org/sound;1"]
.getService(Ci.nsISound)
.playEventSound(this.soundID);
@@ -238,20 +212,12 @@ CommonDialog.prototype = {
console.error("Couldn't play common dialog event sound: ", e);
}
- if (commonDialogEl) {
- if (isEmbedded) {
- // If we delayed default focus above, wait for it to be ready before
- // sending the notification.
- await this.initialFocusPromise;
- }
- Services.obs.notifyObservers(this.ui.prompt, "common-dialog-loaded");
- } else {
- // ui.promptContainer is the <tabmodalprompt> element.
- Services.obs.notifyObservers(
- this.ui.promptContainer,
- "tabmodal-dialog-loaded"
- );
+ if (isEmbedded) {
+ // If we delayed default focus above, wait for it to be ready before
+ // sending the notification.
+ await this.initialFocusPromise;
}
+ Services.obs.notifyObservers(this.ui.prompt, "common-dialog-loaded");
},
setLabelForNode(aNode, aLabel) {