Bug 1512884 - remove broadcasters from mailnews/. r=aceman
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sun, 09 Dec 2018 23:06:41 +0200
changeset 33193 38dbf750eea2
parent 33192 eb217bd92fbc
child 33194 9a7bbff046a2
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman
bugs1512884
Bug 1512884 - remove broadcasters from mailnews/. r=aceman
mailnews/base/prefs/content/am-copies.inc
mailnews/base/prefs/content/am-copies.js
mailnews/base/prefs/content/am-identity-edit.xul
mailnews/base/prefs/content/am-main.xul
mailnews/extensions/smime/content/certpicker.xul
--- a/mailnews/base/prefs/content/am-copies.inc
+++ b/mailnews/base/prefs/content/am-copies.inc
@@ -2,19 +2,16 @@
 # 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/.
 
   <vbox flex="1" id="copiesAndFolders">
     <stringbundleset id="stringbundleset">
     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
     </stringbundleset>
 
-    <broadcaster id="broadcaster_doFcc"/>
-    <broadcaster id="broadcaster_archiveEnabled"/>
-
     <label hidden="true" wsm_persist="true" id="identity.fccFolder"
                   pref="true" preftype="string" prefattribute="value"
                   prefstring="mail.identity.%identitykey%.fcc_folder"/>
     <label hidden="true" wsm_persist="true" id="identity.draftFolder"
                   pref="true" preftype="string" prefattribute="value"
                   prefstring="mail.identity.%identitykey%.draft_folder"/>
     <label hidden="true" wsm_persist="true" id="identity.archiveFolder"
                   pref="true" preftype="string" prefattribute="value"
@@ -49,57 +46,55 @@
         <grid class="specialFolderPickerGrid">
           <columns>
             <column/>
             <column flex="1"/>
           </columns>
           <rows>
             <row align="center">
               <radio id="fcc_selectAccount"
+                     class="depends-on-do-fcc"
                      value="0" label="&sentFolderOn.label;"
                      accesskey="&sentFolderOn.accesskey;"
-                     oncommand="setPickersState('msgFccAccountPicker', 'msgFccFolderPicker', event)"
-                     observes="broadcaster_doFcc"/>
+                     oncommand="setPickersState('msgFccAccountPicker', 'msgFccFolderPicker', event)"/>
                 <menulist id="msgFccAccountPicker"
-                          class="folderMenuItem"
-                          aria-labelledby="fcc_selectAccount"
-                          observes="broadcaster_doFcc">
+                          class="folderMenuItem depends-on-do-fcc"
+                          aria-labelledby="fcc_selectAccount">
                   <menupopup id="msgFccAccountPopup" type="folder" mode="filing"
                              expandFolders="false"
                              oncommand="noteSelectionChange('fcc', 'Account', event)"/>
                 </menulist>
             </row>
             <row align="center">
               <radio id="fcc_selectFolder"
+                     class="depends-on-do-fcc"
                      value="1" label="&sentInOtherFolder.label;"
                      accesskey="&sentInOtherFolder.accesskey;"
-                     oncommand="setPickersState('msgFccFolderPicker', 'msgFccAccountPicker', event)"
-                     observes="broadcaster_doFcc"/>
+                     oncommand="setPickersState('msgFccFolderPicker', 'msgFccAccountPicker', event)"/>
                 <menulist id="msgFccFolderPicker"
-                          class="folderMenuItem"
+                          class="folderMenuItem depends-on-do-fcc"
                           aria-labelledby="fcc_selectFolder"
-                          displayformat="verbose"
-                          observes="broadcaster_doFcc">
+                          displayformat="verbose">
                   <menupopup id="msgFccFolderPopup" type="folder" mode="filing"
                              class="menulist-menupopup"
                              showFileHereLabel="true"
                              oncommand="noteSelectionChange('fcc', 'Folder', event)"/>
                 </menulist>
             </row>
           </rows>
         </grid>
       </radiogroup>
 
       <hbox align="center" class="fccReplyFollowsParent" hidable="true" hidefor="nntp,rss">
-        <checkbox wsm_persist="true" id="identity.fccReplyFollowsParent"
-              label="&fccReplyFollowsParent.label;"
-              accesskey="&fccReplyFollowsParent.accesskey;"
-              prefattribute="value"
-              prefstring="mail.identity.%identitykey%.fcc_reply_follows_parent"
-              observes="broadcaster_doFcc"/>
+        <checkbox id="identity.fccReplyFollowsParent" wsm_persist="true"
+                  class="depends-on-do-fcc"
+                  label="&fccReplyFollowsParent.label;"
+                  accesskey="&fccReplyFollowsParent.accesskey;"
+                  prefattribute="value"
+                  prefstring="mail.identity.%identitykey%.fcc_reply_follows_parent"/>
       </hbox>
 
       <grid>
         <columns>
           <column/>
           <column flex="1"/>
         </columns>
 
@@ -140,55 +135,53 @@
         <checkbox wsm_persist="true" id="identity.archiveEnabled"
                   label="&keepArchives.label;"
                   accesskey="&keepArchives.accesskey;"
                   prefattribute="value"
                   prefstring="mail.identity.%identitykey%.archive_enabled"
                   oncommand="setupArchiveItems();"/>
         <spacer flex="1"/>
         <button id="archiveHierarchyButton"
+                class="depends-on-archive"
                 label="&archiveHierarchyButton.label;"
                 accesskey="&archiveHierarchyButton.accesskey;"
-                oncommand="ChangeArchiveHierarchy();"
-                observes="broadcaster_archiveEnabled"/>
+                oncommand="ChangeArchiveHierarchy();"/>
       </hbox>
 
       <radiogroup id="messageArchives">
         <grid class="specialFolderPickerGrid">
           <columns>
             <column/>
             <column flex="1"/>
           </columns>
           <rows>
             <row align="center">
               <radio id="archive_selectAccount"
+                     class="depends-on-archive"
                      value="0" label="&archivesFolderOn.label;"
                      accesskey="&archivesFolderOn.accesskey;"
-                     oncommand="setPickersState('msgArchivesAccountPicker', 'msgArchivesFolderPicker', event)"
-                     observes="broadcaster_archiveEnabled"/>
-                <menulist id="msgArchivesAccountPicker"
-                          class="folderMenuItem"
-                          aria-labelledby="archive_selectAccount"
-                          observes="broadcaster_archiveEnabled">
+                     oncommand="setPickersState('msgArchivesAccountPicker', 'msgArchivesFolderPicker', event)"/>
+              <menulist id="msgArchivesAccountPicker"
+                        class="folderMenuItem depends-on-archive"
+                        aria-labelledby="archive_selectAccount">
                 <menupopup id="msgArchivesAccountPopup" type="folder" mode="filing"
                            expandFolders="false"
                            oncommand="noteSelectionChange('archive', 'Account', event)"/>
               </menulist>
             </row>
             <row align="center">
               <radio id="archive_selectFolder"
+                     class="depends-on-archive"
                      value="1" label="&archiveInOtherFolder.label;"
                      accesskey="&archiveInOtherFolder.accesskey;"
-                     oncommand="setPickersState('msgArchivesFolderPicker', 'msgArchivesAccountPicker', event)"
-                     observes="broadcaster_archiveEnabled"/>
-                <menulist id="msgArchivesFolderPicker"
-                          class="folderMenuItem"
-                          aria-labelledby="archive_selectFolder"
-                          displayformat="verbose"
-                          observes="broadcaster_archiveEnabled">
+                     oncommand="setPickersState('msgArchivesFolderPicker', 'msgArchivesAccountPicker', event)"/>
+              <menulist id="msgArchivesFolderPicker"
+                        class="folderMenuItem depends-on-archive"
+                        aria-labelledby="archive_selectFolder"
+                        displayformat="verbose">
                 <menupopup id="msgArchivesFolderPopup" type="folder" mode="filing"
                            class="menulist-menupopup"
                            showFileHereLabel="true"
                            oncommand="noteSelectionChange('archive', 'Folder', event)"/>
               </menulist>
             </row>
           </rows>
         </grid>
--- a/mailnews/base/prefs/content/am-copies.js
+++ b/mailnews/base/prefs/content/am-copies.js
@@ -287,41 +287,45 @@ function SaveFolderSettings(radioElemCho
 
     formElement = document.getElementById(folderPickerModeId);
     formElement.setAttribute("value", radioElemChoice);
 }
 
 // Check the Fcc Self item and setup associated picker state
 function setupFccItems()
 {
-    var broadcaster = document.getElementById("broadcaster_doFcc");
-
-    var checked = document.getElementById("identity.doFcc").checked;
+  let checked = document.getElementById("identity.doFcc").checked;
+  document.querySelectorAll(".depends-on-do-fcc").forEach(e => {
     if (checked) {
-        broadcaster.removeAttribute("disabled");
-        switch (gFccRadioElemChoice) {
-            case "0" :
-                if (!gFccRadioElemChoiceLocked)
-                    SetPickerEnabling("msgFccAccountPicker", "msgFccFolderPicker");
-                SetRadioButtons("fcc_selectAccount", "fcc_selectFolder");
-                break;
+      e.removeAttribute("disabled");
+    } else {
+      e.setAttribute("disabled", "true");
+    }
+  });
+  if (!checked) {
+    return;
+  }
 
-            case "1" :
-                if (!gFccRadioElemChoiceLocked)
-                    SetPickerEnabling("msgFccFolderPicker", "msgFccAccountPicker");
-                SetRadioButtons("fcc_selectFolder", "fcc_selectAccount");
-                break;
+  switch (gFccRadioElemChoice) {
+    case "0" :
+      if (!gFccRadioElemChoiceLocked)
+          SetPickerEnabling("msgFccAccountPicker", "msgFccFolderPicker");
+      SetRadioButtons("fcc_selectAccount", "fcc_selectFolder");
+      break;
 
-            default :
-                dump("Error in setting Fcc elements.\n");
-                break;
-        }
-    }
-    else
-        broadcaster.setAttribute("disabled", "true");
+    case "1" :
+      if (!gFccRadioElemChoiceLocked)
+          SetPickerEnabling("msgFccFolderPicker", "msgFccAccountPicker");
+      SetRadioButtons("fcc_selectFolder", "fcc_selectAccount");
+      break;
+
+    default :
+      dump("Error in setting Fcc elements.\n");
+      break;
+  }
 }
 
 // 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");
 
@@ -421,46 +425,49 @@ function updateArchiveHierarchyButton(ar
                      .isGMailServer);
   document.getElementById("archiveHierarchyButton").disabled = isGmailImap;
 }
 
 /**
  * Enable or disable (as appropriate) the controls for setting archive options
  */
 function setupArchiveItems() {
-  let broadcaster = document.getElementById("broadcaster_archiveEnabled");
   let checked = document.getElementById("identity.archiveEnabled").checked;
-  let archiveFolder;
-
-  if (checked) {
-    broadcaster.removeAttribute("disabled");
-    switch (gArchivesRadioElemChoice) {
-      case "0":
-        if (!gArchivesRadioElemChoiceLocked)
-          SetPickerEnabling("msgArchivesAccountPicker", "msgArchivesFolderPicker");
-        SetRadioButtons("archive_selectAccount", "archive_selectFolder");
-        updateArchiveHierarchyButton(document.getElementById(
-                                     "msgArchivesAccountPicker").folder);
-        break;
+  document.querySelectorAll(".depends-on-archive").forEach(e => {
+    if (checked) {
+      e.removeAttribute("disabled");
+    } else {
+      e.setAttribute("disabled", "true");
+    }
+  });
+  if (!checked) {
+    return;
+  }
 
-      case "1":
-        if (!gArchivesRadioElemChoiceLocked)
-          SetPickerEnabling("msgArchivesFolderPicker", "msgArchivesAccountPicker");
-        SetRadioButtons("archive_selectFolder", "archive_selectAccount");
-        updateArchiveHierarchyButton(document.getElementById(
-                                     "msgArchivesFolderPicker").folder);
-        break;
+  switch (gArchivesRadioElemChoice) {
+    case "0":
+      if (!gArchivesRadioElemChoiceLocked)
+        SetPickerEnabling("msgArchivesAccountPicker", "msgArchivesFolderPicker");
+      SetRadioButtons("archive_selectAccount", "archive_selectFolder");
+      updateArchiveHierarchyButton(document.getElementById(
+                                   "msgArchivesAccountPicker").folder);
+      break;
 
-      default:
-        dump("Error in setting Archive elements.\n");
-        return;
-    }
+    case "1":
+      if (!gArchivesRadioElemChoiceLocked)
+        SetPickerEnabling("msgArchivesFolderPicker", "msgArchivesAccountPicker");
+      SetRadioButtons("archive_selectFolder", "archive_selectAccount");
+      updateArchiveHierarchyButton(document.getElementById(
+                                   "msgArchivesFolderPicker").folder);
+      break;
+
+    default:
+      dump("Error in setting Archive elements.\n");
+      return;
   }
-  else
-    broadcaster.setAttribute("disabled", "true");
 }
 
 /**
  * Open a dialog to edit the folder hierarchy used when archiving messages.
  */
 function ChangeArchiveHierarchy() {
   let identity = parent.gIdentity || parent.getCurrentAccount().defaultIdentity;
 
--- a/mailnews/base/prefs/content/am-identity-edit.xul
+++ b/mailnews/base/prefs/content/am-identity-edit.xul
@@ -47,18 +47,16 @@
   <script type="application/javascript"
           src="chrome://messenger/content/am-smime.js"/>
   <script type="application/javascript">
   <![CDATA[
     window.addEventListener("load", smimeOnLoadEditor, false);
   ]]>
   </script>
 
-  <broadcaster id="broadcaster_attachSignature"/>
-
   <description>&identityListDesc.label;</description>
   <separator class="thin"/>
 
   <tabbox flex="1" style="overflow: auto;">
     <tabs id="identitySettings">
       <tab label="&settingsTab.label;"/>
       <tab label="&copiesFoldersTab.label;"/>
       <tab label="&addressingTab.label;"/>
--- a/mailnews/base/prefs/content/am-main.xul
+++ b/mailnews/base/prefs/content/am-main.xul
@@ -16,18 +16,16 @@
     <stringbundle id="bundle_messenger" src="chrome://messenger/locale/messenger.properties"/>
 
     <script type="application/javascript" src="chrome://messenger/content/am-identity-edit.js"/>
     <script type="application/javascript" src="chrome://messenger/content/am-main.js"/>
     <script type="application/javascript" src="chrome://messenger/content/am-prefs.js"/>
     <script type="application/javascript"
             src="chrome://messenger/content/amUtils.js"/>
 
-    <broadcaster id="broadcaster_attachSignature"/>
-
     <hbox id="am-main-title" class="dialogheader">
       <label class="dialogheader-title" defaultTitle="&accountTitle.label;"/>
     </hbox>
 
     <hbox align="center">
       <label value="&accountName.label;" control="server.prettyName"
              accesskey="&accountName.accesskey;"/>
       <textbox wsm_persist="true" size="30" id="server.prettyName"
@@ -93,22 +91,20 @@
                   oncommand="setupSignatureItems();"
                   prefattribute="value"
                   prefstring="mail.identity.%identitykey%.attach_signature"/>
       </hbox>
 
       <hbox align="center" class="indent">
         <textbox wsm_persist="true" id="identity.signature" datatype="nsIFile" flex="1" name="identity.signature"
                  aria-labelledby="identity.attachSignature"
-                 observes="broadcaster_attachSignature"
                  prefstring="mail.identity.%identitykey%.sig_file" class="uri-element"/>
         <button class="push" name="browse" label="&choose.label;"
                 accesskey="&choose.accesskey;"
                 oncommand="selectFile()"
-                observes="broadcaster_attachSignature"
                 wsm_persist="true" id="identity.sigbrowsebutton"
                 prefstring="mail.identity.%identitykey%.sigbrowse.disable"/>
       </hbox>
 
       <hbox align="center">
         <checkbox wsm_persist="true" id="identity.attachVCard" label="&attachVCard.label;" flex="1"
                   accesskey="&attachVCard.accesskey;"
                   prefattribute="value"
--- a/mailnews/extensions/smime/content/certpicker.xul
+++ b/mailnews/extensions/smime/content/certpicker.xul
@@ -17,22 +17,21 @@
   ondialogaccept="return doOK();"
   ondialogcancel="return doCancel();"
   onload="onLoad();">
 
 <script type="application/javascript"
         src="chrome://messenger/content/certpicker.js"/>
 
   <hbox align="center">
-    <broadcaster id="certSelected" oncommand="onCertSelected();"/>
     <label id="pickerInfo" value="&certPicker.info;"/>
     <!-- The items in this menulist must never be sorted,
          but remain in the order filled by the application
     -->
-    <menulist id="nicknames" observes="certSelected">
+    <menulist id="nicknames" oncommand="onCertSelected();">
       <menupopup/>
     </menulist>
   </hbox>
   <separator class="thin"/>
   <label value="&certPicker.detailsLabel;"/>
   <textbox readonly="true" id="details" multiline="true"
            style="height: 12em;" flex="1"/>
 </dialog>