Bug 1616514 - backed out changeset a070c087756d for test failures. r=backout DONTBUILD
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 14 May 2021 18:10:43 +0300
changeset 42435 a6ff085b9e6fd762dd9b318ecc339888ff0862a5
parent 42434 a070c087756d6d09e6d41d79b89a83f3807936de
child 42436 d71c00626b9c398cf7b7d2651c7297e30ea994a3
push id3121
push usertbbld-merge
push dateMon, 31 May 2021 21:07:04 +0000
treeherdercomm-beta@a02c59e58d79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1616514
Bug 1616514 - backed out changeset a070c087756d for test failures. r=backout DONTBUILD
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/addressingWidgetOverlay.js
mail/locales/en-US/messenger/preferences/am-copies.ftl
mailnews/base/prefs/content/am-copies.inc.xhtml
mailnews/base/prefs/content/am-copies.js
mailnews/base/prefs/content/am-copies.xhtml
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -7748,48 +7748,16 @@ function LoadIdentity(startup) {
             x => !toCcBccAddrs.has(...msgCompFields.splitRecipients(x, true))
           )
           .join(", ");
         awAddRecipients(msgCompFields, "addr_bcc", newBcc);
       }
       changedRecipients = true;
     }
 
-    // Handle showing/hiding of empty CC/BCC row after changing identity.
-    // Whenever "Cc/Bcc these email addresses" aka mail.identity.id#.doCc/doBcc
-    // is checked in Account Settings, show the address row, even if empty.
-    // This is a feature especially for ux-efficiency of enterprise workflows.
-    let addressRowCc = document.getElementById("addressRowCc");
-    if (gCurrentIdentity.doCc) {
-      // Per identity's doCc pref, show CC row, even if empty.
-      showAddressRow(document.getElementById("addr_cc"), "addressRowCc");
-    } else if (
-      prevIdentity.doCc &&
-      !addressRowCc.querySelector("mail-address-pill")
-    ) {
-      // Current identity doesn't need CC row shown, but previous identity did.
-      // Hide CC row if it's empty.
-      addressRowCc.classList.add("hidden");
-      document.getElementById("addr_cc").removeAttribute("collapsed");
-    }
-
-    let addressRowBcc = document.getElementById("addressRowBcc");
-    if (gCurrentIdentity.doBcc) {
-      // Per identity's doBcc pref, show BCC row, even if empty.
-      showAddressRow(document.getElementById("addr_bcc"), "addressRowBcc");
-    } else if (
-      prevIdentity.doBcc &&
-      !addressRowBcc.querySelector("mail-address-pill")
-    ) {
-      // Current identity doesn't need BCC row shown, but previous identity did.
-      // Hide BCC row if it's empty.
-      addressRowBcc.classList.add("hidden");
-      document.getElementById("addr_bcc").removeAttribute("collapsed");
-    }
-
     adjustSignEncryptAfterIdentityChanged(prevIdentity);
 
     try {
       gMsgCompose.identity = gCurrentIdentity;
     } catch (ex) {
       dump("### Cannot change the identity: " + ex + "\n");
     }
 
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -106,92 +106,93 @@ function Recipients2CompFields(msgCompFi
  * Convert all the recipients coming from a message header into pills.
  *
  * @param {Object} msgCompFields - An object containing all the recipients. If
  *                                 any property is not a string, it is ignored.
  */
 function CompFields2Recipients(msgCompFields) {
   if (msgCompFields) {
     // Populate all the recipients with the proper values.
+    // We need to force the focus() on each input to trigger the attachment
+    // of the autocomplete mController.
     if (typeof msgCompFields.replyTo == "string") {
       let input = document.getElementById("replyAddrInput");
       recipientClearPills(input);
 
       let msgReplyTo = MailServices.headerParser.parseEncodedHeaderW(
         msgCompFields.replyTo
       );
       if (msgReplyTo.length) {
         showAddressRow(
           document.getElementById("addr_reply"),
           "addressRowReply"
         );
+        input.focus();
         input.value = msgReplyTo.join(", ");
         recipientAddPills(input, true);
       }
     }
 
     if (typeof msgCompFields.to == "string") {
       let input = document.getElementById("toAddrInput");
       recipientClearPills(input);
 
       let msgTo = MailServices.headerParser.parseEncodedHeaderW(
         msgCompFields.to
       );
       if (msgTo.length) {
         if (input.closest(".address-row").classList.contains("hidden")) {
           showAddressRow(document.getElementById("addr_to"), "addressRowTo");
         }
+        input.focus();
         input.value = msgTo.join(", ");
         recipientAddPills(input, true);
       }
     }
 
     if (typeof msgCompFields.cc == "string") {
       let input = document.getElementById("ccAddrInput");
       recipientClearPills(input);
 
       let msgCC = MailServices.headerParser.parseEncodedHeaderW(
         msgCompFields.cc
       );
-      // Show Cc field if we have Cc recipients or if doCc pref is checked.
-      if (msgCC.length || gCurrentIdentity.doCc) {
+      if (msgCC.length) {
         showAddressRow(document.getElementById("addr_cc"), "addressRowCc");
-      }
-      if (msgCC.length) {
+        input.focus();
         input.value = msgCC.join(", ");
         recipientAddPills(input, true);
       }
     }
 
     if (typeof msgCompFields.bcc == "string") {
       let input = document.getElementById("bccAddrInput");
       recipientClearPills(input);
 
       let msgBCC = MailServices.headerParser.parseEncodedHeaderW(
         msgCompFields.bcc
       );
-      // Show Bcc field if we have Bcc recipients or if doBcc pref is checked.
-      if (msgBCC.length || gCurrentIdentity.doBcc) {
+      if (msgBCC.length) {
         showAddressRow(document.getElementById("addr_bcc"), "addressRowBcc");
-      }
-      if (msgBCC.length) {
+        input.focus();
         input.value = msgBCC.join(", ");
         recipientAddPills(input, true);
       }
     }
 
     if (typeof msgCompFields.newsgroups == "string") {
       let input = document.getElementById("newsgroupsAddrInput");
       recipientClearPills(input);
 
       if (msgCompFields.newsgroups) {
         showAddressRow(
           document.getElementById("addr_newsgroups"),
           "addressRowNewsgroups"
         );
+        input.focus();
         input.value = msgCompFields.newsgroups;
         recipientAddPills(input, true);
       }
     }
 
     if (typeof msgCompFields.followupTo == "string") {
       let input = document.getElementById("followupAddrInput");
       recipientClearPills(input);
@@ -199,16 +200,17 @@ function CompFields2Recipients(msgCompFi
       let msgFollowupTo = MailServices.headerParser.parseEncodedHeaderW(
         msgCompFields.followupTo
       );
       if (msgFollowupTo.length) {
         showAddressRow(
           document.getElementById("addr_followup"),
           "addressRowFollowup"
         );
+        input.focus();
         input.value = msgFollowupTo.join(", ");
         recipientAddPills(input, true);
       }
     }
 
     // Add the sender to our spell check ignore list.
     if (gCurrentIdentity) {
       addRecipientsToIgnoreList(gCurrentIdentity.fullAddress);
deleted file mode 100644
--- a/mail/locales/en-US/messenger/preferences/am-copies.ftl
+++ /dev/null
@@ -1,5 +0,0 @@
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-account-prefs-show-address-row-description = Leave the address field blank to always show the address row when starting a new message.
--- a/mailnews/base/prefs/content/am-copies.inc.xhtml
+++ b/mailnews/base/prefs/content/am-copies.inc.xhtml
@@ -94,52 +94,44 @@
       <separator class="thin"/>
 
       <hbox>
         <vbox>
           <hbox flex="1" align="center">
             <checkbox id="identity.doCc" wsm_persist="true" label="&ccAddress.label;"
                       accesskey="&ccAddress.accesskey;"
                       control="identity.doCcList"
-                      oncommand="identityDoCcBccOnCommand(event);"
+                      oncommand="setupCcTextbox();"
                       prefattribute="value"
                       prefstring="mail.identity.%identitykey%.doCc"/>
           </hbox>
           <hbox flex="1" align="center">
             <checkbox id="identity.doBcc" wsm_persist="true" label="&bccAddress.label;"
                       accesskey="&bccAddress.accesskey;"
                       control="identity.doBccList"
-                      oncommand="identityDoCcBccOnCommand(event);"
+                      oncommand="setupBccTextbox();"
                       prefattribute="value"
                       prefstring="mail.identity.%identitykey%.doBcc"/>
           </hbox>
         </vbox>
         <vbox flex="1">
-          <hbox flex="1" class="input-container" align="center">
-            <html:input id="identity.doCcList" wsm_persist="true"
-                        type="text"
-                        aria-labelledby="identity.doCc"
-                        prefstring="mail.identity.%identitykey%.doCcList"
-                        class="uri-element input-inline"
-                        placeholder="&ccAddressList.placeholder;"
-                        onblur="identityDoCcBccOnBlur(event);"/>
-          </hbox>
-          <hbox flex="1" class="input-container" align="center">
-            <html:input id="identity.doBccList" wsm_persist="true"
-                        type="text"
-                        aria-labelledby="identity.doBcc"
-                        prefstring="mail.identity.%identitykey%.doBccList"
-                        class="uri-element input-inline"
-                        placeholder="&bccAddressList.placeholder;"
-                        onblur="identityDoCcBccOnBlur(event);"/>
-          </hbox>
+          <html:input id="identity.doCcList" wsm_persist="true"
+                      type="text"
+                      aria-labelledby="identity.doCc"
+                      prefstring="mail.identity.%identitykey%.doCcList"
+                      class="uri-element input-inline"
+                      placeholder="&ccAddressList.placeholder;"/>
+          <html:input id="identity.doBccList" wsm_persist="true"
+                      type="text"
+                      aria-labelledby="identity.doBcc"
+                      prefstring="mail.identity.%identitykey%.doBccList"
+                      class="uri-element input-inline"
+                      placeholder="&bccAddressList.placeholder;"/>
         </vbox>
       </hbox>
-      <description class="indent tip-caption"
-                   data-l10n-id="account-prefs-show-address-row-description"/>
     </html:fieldset>
     </html:div>
 
     <html:div>
     <html:fieldset id="archivesGroup">
       <html:legend>&archivesTitle.label;</html:legend>
 
       <hbox pack="start">
--- a/mailnews/base/prefs/content/am-copies.js
+++ b/mailnews/base/prefs/content/am-copies.js
@@ -81,18 +81,18 @@ function onInitCopiesAndFolders() {
     gTmplRadioElemChoice,
     gTmplRadioElemChoiceLocked,
     "tmpl",
     "msgStationeryAccountPicker",
     "identity.stationeryFolder",
     "msgStationeryFolderPicker"
   );
 
-  setupDoCcBccItems("identity.doCc", "identity.doCcList");
-  setupDoCcBccItems("identity.doBcc", "identity.doBccList");
+  setupCcTextbox(true);
+  setupBccTextbox(true);
   setupFccItems();
   setupArchiveItems();
 
   SetSpecialFolderNamesWithDelims();
 }
 
 // Initialize the picker mode choices (account/folder picker) into global vars
 function SetGlobalRadioElemChoices() {
@@ -367,72 +367,58 @@ function setupFccItems() {
       break;
 
     default:
       dump("Error in setting Fcc elements.\n");
       break;
   }
 }
 
-/**
- * Handle the initial status and value of the Auto-Cc/Bcc text input fields.
- *
- * @param {string} checkboxId - The ID of an Auto-Cc/Bcc checkbox.
- * @param {string} inputId - The ID of an Auto-Cc/Bcc text input element.
- */
-function setupDoCcBccItems(checkboxId, inputId) {
-  // Enable address input according to the status of the checkbox.
-  let input = document.getElementById(inputId);
-  input.disabled = !document.getElementById(checkboxId).checked;
-  // Safeguard against space-padded address list to ensure list visibility.
-  input.value = input.value.trim();
-}
+// Disable CC textbox if CC checkbox is not checked
+function setupCcTextbox(init) {
+  var ccChecked = document.getElementById("identity.doCc").checked;
+  var ccTextbox = document.getElementById("identity.doCcList");
+
+  ccTextbox.disabled = !ccChecked;
 
-/**
- * Handle the command event of the Auto-Cc/Bcc checkboxes.
- * Disable the respective text input element if the checkbox is not checked, and
- * handle the default value of the input when the checkbox is toggled.
- *
- * @param {Event} event - The command event of the checkbox.
- */
-function identityDoCcBccOnCommand(event) {
-  let checkbox = event.target;
-  let checked = checkbox.checked;
-  // For checkboxes #identity.doCc and #identity.doBcc, get the corresponding
-  // inputs: #identity.doCcList and #identity.doBccList.
-  let input = document.getElementById(`${checkbox.id}List`);
-  input.disabled = !checked;
-
-  // User toggled checkbox.
-  let identityEmailAddress = document.getElementById("identity.email").value;
-  if (checked) {
-    // If user checks the checkbox and there's no address, default to identity's
-    // email address.
-    if (!input.value) {
-      input.value = identityEmailAddress;
+  if (ccChecked) {
+    if (ccTextbox.value == "") {
+      ccTextbox.value = document.getElementById("identity.email").value;
+      if (!init) {
+        ccTextbox.select();
+      }
     }
-    input.select();
-    return;
-  }
-
-  if (input.value == identityEmailAddress) {
-    // If user unchecks checkbox and the input has default address, clear input.
-    input.value = "";
+  } else if (
+    ccTextbox.value == document.getElementById("identity.email").value ||
+    (init && ccTextbox.getAttribute("value") == "")
+  ) {
+    ccTextbox.value = "";
   }
 }
 
-/**
- * Handle the blur event of the Auto-Cc/Bcc checkboxes.
- *
- * @param {Event} event - The blur event of the checkbox.
- */
-function identityDoCcBccOnBlur(event) {
-  let input = event.target;
-  // Safeguard against space-padded address list to ensure list visibility.
-  input.value = input.value.trim();
+// Disable BCC textbox if BCC checkbox is not checked
+function setupBccTextbox(init) {
+  var bccChecked = document.getElementById("identity.doBcc").checked;
+  var bccTextbox = document.getElementById("identity.doBccList");
+
+  bccTextbox.disabled = !bccChecked;
+
+  if (bccChecked) {
+    if (bccTextbox.value == "") {
+      bccTextbox.value = document.getElementById("identity.email").value;
+      if (!init) {
+        bccTextbox.select();
+      }
+    }
+  } else if (
+    bccTextbox.value == document.getElementById("identity.email").value ||
+    (init && bccTextbox.getAttribute("value") == "")
+  ) {
+    bccTextbox.value = "";
+  }
 }
 
 // Enable and disable pickers based on the radio element clicked
 function SetPickerEnabling(enablePickerId, disablePickerId) {
   var activePicker = document.getElementById(enablePickerId);
   activePicker.removeAttribute("disabled");
 
   var inactivePicker = document.getElementById(disablePickerId);
--- a/mailnews/base/prefs/content/am-copies.xhtml
+++ b/mailnews/base/prefs/content/am-copies.xhtml
@@ -8,20 +8,16 @@
 
 <!DOCTYPE window SYSTEM "chrome://messenger/locale/am-copies.dtd">
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         xmlns:html="http://www.w3.org/1999/xhtml"
         title="&copyAndFolderTitle.label;"
         onload="parent.onPanelLoaded('am-copies.xhtml');">
 
-  <linkset>
-    <html:link rel="localization" href="messenger/preferences/am-copies.ftl"/>
-  </linkset>
-
   <script src="chrome://global/content/globalOverlay.js"/>
   <script src="chrome://global/content/editMenuOverlay.js"/>
 
   <vbox flex="1" style="overflow: auto;"><vbox id="containerBox" flex="1">
     <script src="chrome://messenger/content/am-copies.js"/>
     <script src="chrome://messenger/content/am-prefs.js"/>
     <script src="chrome://messenger/content/amUtils.js"/>