Bug 516387: nsPromptService dialogs should not have '&' shortcuts in labels, r=gavin
authorMark Finkle <mfinkle@mozilla.com>
Wed, 23 Sep 2009 00:58:34 -0400
changeset 65600 252522388fb10e39c93ae28d017e4b3d3e8e27a1
parent 65599 3d229247ecda3ada45a123e6c77f1e39b18a877f
child 65601 a1c1853640b14d869dd082d1eeb18d9177cfde3f
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs516387
Bug 516387: nsPromptService dialogs should not have '&' shortcuts in labels, r=gavin
mobile/chrome/content/prompt/alert.xul
mobile/chrome/content/prompt/confirm.xul
mobile/chrome/content/prompt/prompt.xul
mobile/components/promptService.js
--- a/mobile/chrome/content/prompt/alert.xul
+++ b/mobile/chrome/content/prompt/alert.xul
@@ -6,15 +6,15 @@
       script="chrome://browser/content/prompt/prompt.js">
   
   <label id="prompt-alert-title" crop="center"/>
   <scrollbox orient="vertical">
     <description id="prompt-alert-message"/>
   </scrollbox>
   <hbox id="prompt-alert-checkbox-box" collapsed="true" align="center">
     <checkbox class="toggle-dark" id="prompt-alert-checkbox"/>
-    <label id="prompt-alert-checkbox-msg"/>
+    <description id="prompt-alert-checkbox-msg"/>
   </hbox>
   <hbox pack="center">
     <button class="button-dark" label="&ok.label;"
             oncommand="document.getElementById('prompt-alert-dialog').close()"/>
   </hbox>
 </dialog>
--- a/mobile/chrome/content/prompt/confirm.xul
+++ b/mobile/chrome/content/prompt/confirm.xul
@@ -5,17 +5,17 @@
       onclose="this.PromptHelper.onCloseConfirm(this)"
       script="chrome://browser/content/prompt/prompt.js">
   <label id="prompt-confirm-title"/>
   <scrollbox orient="vertical">
     <description id="prompt-confirm-message"/>
   </scrollbox>
   <hbox id="prompt-confirm-checkbox-box" collapsed="true" align="center">
     <checkbox class="toggle-dark" id="prompt-confirm-checkbox"/>
-    <label id="prompt-confirm-checkbox-msg"/>
+    <description id="prompt-confirm-checkbox-msg"/>
   </hbox>
   <hbox pack="center" id="prompt-confirm-button-box">
     <button class="button-dark" label="&ok.label;"
             oncommand="document.getElementById('prompt-confirm-dialog').PromptHelper.closeConfirm(true);"/>
     <button class="button-dark" label="&cancel.label;"
             oncommand="document.getElementById('prompt-confirm-dialog').PromptHelper.closeConfirm(false);"/>
   </hbox>
 </dialog>
--- a/mobile/chrome/content/prompt/prompt.xul
+++ b/mobile/chrome/content/prompt/prompt.xul
@@ -7,17 +7,17 @@
       script="chrome://browser/content/prompt/prompt.js">
   <label id="prompt-prompt-title"/>
   <scrollbox orient="vertical">
     <description id="prompt-prompt-message"/>
   </scrollbox>
   <textbox id="prompt-prompt-textbox"/>
   <hbox id="prompt-prompt-checkbox-box" collapsed="true" align="center">
     <checkbox class="toggle-dark" id="prompt-prompt-checkbox"/>
-    <label id="prompt-prompt-checkbox-msg"/>
+    <description id="prompt-prompt-checkbox-msg"/>
   </hbox>
   <hbox pack="center" id="prompt-prompt-button-box">
     <button class="button-dark" label="&ok.label;"
             oncommand="document.getElementById('prompt-prompt-dialog').PromptHelper.closePrompt(true)"/>
     <button class="button-dark" label="&cancel.label;"
             oncommand="document.getElementById('prompt-prompt-dialog').PromptHelper.closePrompt(false)"/>
   </hbox>
 </dialog>
--- a/mobile/components/promptService.js
+++ b/mobile/components/promptService.js
@@ -96,17 +96,17 @@ promptService.prototype = {
     let dialog = this.openDialog("chrome://browser/content/prompt/alert.xul", aCheckState);
     let doc = this.getDocument();
     doc.getElementById("prompt-alert-title").value = aTitle;
     doc.getElementById("prompt-alert-message").appendChild(doc.createTextNode(aText));
     this.sizeElement("prompt-alert-message", 80);
     this.sizeScrollableMsg("prompt-alert-message", 25);
     
     doc.getElementById("prompt-alert-checkbox").checked = aCheckState.value;
-    doc.getElementById("prompt-alert-checkbox-msg").value = aCheckMsg;
+    this.setLabelForNode(doc.getElementById("prompt-alert-checkbox-msg"), aCheckMsg);
     this.sizeElement("prompt-alert-checkbox-msg", 50);
     doc.getElementById("prompt-alert-checkbox-box").removeAttribute("collapsed");
     
     dialog.waitForClose();
   },
   
   confirm: function(aParent, aTitle, aText) {
     var params = new Object();
@@ -129,32 +129,32 @@ promptService.prototype = {
     let doc = this.getDocument();
     let dialog = this.openDialog("chrome://browser/content/prompt/confirm.xul", params);
     doc.getElementById("prompt-confirm-title").value = aTitle;
     doc.getElementById("prompt-confirm-message").appendChild(doc.createTextNode(aText));
     this.sizeElement("prompt-confirm-message", 80);
     this.sizeScrollableMsg("prompt-confirm-message", 25);
 
     doc.getElementById("prompt-confirm-checkbox").checked = aCheckState.value;
-    doc.getElementById("prompt-confirm-checkbox-msg").value = aCheckMsg;
+    this.setLabelForNode(doc.getElementById("prompt-confirm-checkbox-msg"), aCheckMsg);
     this.sizeElement("prompt-confirm-checkbox-msg", 50);
     doc.getElementById("prompt-confirm-checkbox-box").removeAttribute("collapsed");
     
     dialog.waitForClose();
     return params.result;
   },
   
   getLocaleString: function(key) {
     return this._bundle.GetStringFromName(key);
   },
   
   //
   // Copied from chrome://global/content/commonDialog.js
   //
-  setLabelForNode: function(aNode, aLabel, aIsLabelFlag) {
+  setLabelForNode: function(aNode, aLabel) {
     // This is for labels which may contain embedded access keys.
     // If we end in (&X) where X represents the access key, optionally preceded
     // by spaces and/or followed by the ':' character, store the access key and
     // remove the access key placeholder + leading spaces from the label.
     // Otherwise a character preceded by one but not two &s is the access key.
     // Store it and remove the &.
   
     // Note that if you change the following code, see the comment of
@@ -167,18 +167,21 @@ promptService.prototype = {
       accessKey = RegExp.$1;
     } else if (/^(.*[^&])?\&(([^&]).*$)/.test(aLabel)) {
       aLabel = RegExp.$1 + RegExp.$2;
       accessKey = RegExp.$3;
     }
   
     // && is the magic sequence to embed an & in your label.
     aLabel = aLabel.replace(/\&\&/g, "&");
-    if (aIsLabelFlag) {    // Set text for <label> element
+    if (aNode instanceof Ci.nsIDOMXULLabelElement) {
       aNode.setAttribute("value", aLabel);
+    } else if (aNode instanceof Ci.nsIDOMXULDescriptionElement) {
+      text = aNode.ownerDocument.createTextNode(aLabel);
+      aNode.appendChild(text);
     } else {    // Set text for other xul elements
       aNode.setAttribute("label", aLabel);
     }
     
     // XXXjag bug 325251
     // Need to set this after aNode.setAttribute("value", aLabel);
     if (accessKey)
       aNode.setAttribute("accesskey", accessKey);
@@ -195,17 +198,17 @@ promptService.prototype = {
     let doc = this.getDocument();
     let dialog = this.openDialog("chrome://browser/content/prompt/confirm.xul", params);
     doc.getElementById("prompt-confirm-title").value = aTitle;
     doc.getElementById("prompt-confirm-message").appendChild(doc.createTextNode(aText));
     this.sizeElement("prompt-confirm-message", 80);
     this.sizeScrollableMsg("prompt-confirm-message", 25);
 
     doc.getElementById("prompt-confirm-checkbox").checked = aCheckState.value;
-    doc.getElementById("prompt-confirm-checkbox-msg").value = aCheckMsg;
+    this.setLabelForNode(doc.getElementById("prompt-confirm-checkbox-msg"), aCheckMsg);
     this.sizeElement("prompt-confirm-checkbox-msg", 50);
     if (aCheckMsg) {
       doc.getElementById("prompt-confirm-checkbox-box").removeAttribute("collapsed");
     }
     
     let bbox = doc.getElementById("prompt-confirm-button-box");
     while (bbox.lastChild) {
       bbox.removeChild(bbox.lastChild);
@@ -237,17 +240,17 @@ promptService.prototype = {
         break;
         case Ci.nsIPromptService.BUTTON_TITLE_IS_STRING :
           bTitle = titles[i];
         break;
       }
       
       if (bTitle) {
         let button = doc.createElement("button");
-        this.setLabelForNode(button, bTitle, false);
+        this.setLabelForNode(button, bTitle);
         button.setAttribute("class", "button-dark");
         button.setAttribute("oncommand",
           "document.getElementById('prompt-confirm-dialog').PromptHelper.closeConfirm(" + i + ")");
         bbox.appendChild(button);
       }
       
       aButtonFlags >>= 8;
     }
@@ -264,17 +267,17 @@ promptService.prototype = {
     let dialog = this.openDialog("chrome://browser/content/prompt/prompt.xul", params);
     let doc = this.getDocument();
     doc.getElementById("prompt-prompt-title").value = aTitle;
     doc.getElementById("prompt-prompt-message").appendChild(doc.createTextNode(aText));
     this.sizeElement("prompt-prompt-message", 80);
     this.sizeScrollableMsg("prompt-prompt-message", 25);
 
     doc.getElementById("prompt-prompt-checkbox").checked = aCheckState.value;
-    doc.getElementById("prompt-prompt-checkbox-msg").value = aCheckMsg;
+    this.setLabelForNode(doc.getElementById("prompt-prompt-checkbox-msg"), aCheckMsg);
     this.sizeElement("prompt-prompt-checkbox-msg", 50);
     doc.getElementById("prompt-prompt-textbox").value = aValue.value;
     if (aCheckMsg) {
       doc.getElementById("prompt-prompt-checkbox-box").removeAttribute("collapsed");
     }
     if (isPassword) {
       doc.getElementById("prompt-prompt-textbox").type = "password";
     }
@@ -304,17 +307,17 @@ promptService.prototype = {
     this.sizeElement("prompt-password-message", 80);
     this.sizeScrollableMsg("prompt-password-message", 25);
     doc.getElementById("prompt-password-checkbox").checked = aCheckState.value;
     
     doc.getElementById("prompt-password-user").value = aUsername.value;
     doc.getElementById("prompt-password-password").value = aPassword.value;
     if (aCheckMsg) {
       doc.getElementById("prompt-password-checkbox-box").removeAttribute("collapsed");
-      doc.getElementById("prompt-password-checkbox-msg").appendChild(doc.createTextNode(aCheckMsg));
+      this.setLabelForNode(doc.getElementById("prompt-password-checkbox-msg"), aCheckMsg);
       this.sizeElement("prompt-password-checkbox-msg", 50);
       this.sizeElement("prompt-password-checkbox-box", 50);
     }
     
     dialog.waitForClose();
     return params.result;
   },