Bug 1459184 - Port bug 1456611: Replace use of insertItemAt and removeItemAt methods (mail part). r=jorgk, ui-r=Paenglab
authoraceman <acelists@atlas.sk>
Sat, 05 May 2018 09:49:00 +0200
changeset 31026 02e4c2f6655fd398a52d76e2a9445d2bd373ddf3
parent 31025 f223187047f5fd9cf256fd929bf71ebcc250fce5
child 31027 c870df0b09fad7662a9426de64762407257ed2d0
push id2198
push userclokep@gmail.com
push dateMon, 07 May 2018 22:01:28 +0000
treeherdercomm-beta@c31c128cd17a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk, Paenglab
bugs1459184, 1456611
Bug 1459184 - Port bug 1456611: Replace use of insertItemAt and removeItemAt methods (mail part). r=jorgk, ui-r=Paenglab
editor/ui/dialogs/content/EdDictionary.js
editor/ui/dialogs/content/EdSpellCheck.js
editor/ui/dialogs/content/EditorPublishSettings.js
mail/base/content/ABSearchDialog.js
mail/base/content/ABSearchDialog.xul
mail/base/content/FilterListDialog.js
mail/components/accountcreation/content/emailWizard.js
mail/components/addrbook/content/abCommon.js
mail/components/addrbook/content/abContactsPanel.xul
mail/components/cloudfile/content/addAccountDialog.js
mail/components/compose/content/MsgComposeCommands.js
mail/components/preferences/applicationManager.js
mail/components/preferences/applications.js
mail/components/preferences/attachmentReminder.js
mail/components/preferences/display.inc.xul
mail/components/preferences/display.js
mailnews/addrbook/content/addrbookWidgets.xml
mailnews/base/prefs/content/am-junk.js
suite/common/pref/pref-spelling.js
--- a/editor/ui/dialogs/content/EdDictionary.js
+++ b/editor/ui/dialogs/content/EdDictionary.js
@@ -112,17 +112,17 @@ function ReplaceWord()
 function RemoveWord()
 {
   var selIndex = gDialog.DictionaryList.selectedIndex;
   if (selIndex >= 0)
   {
     var word = gDialog.DictionaryList.selectedItem.label;
 
     // Remove word from list
-    gDialog.DictionaryList.removeItemAt(selIndex);
+    gDialog.DictionaryList.selectedItem.remove();
 
     // Remove from dictionary
     try {
       //Not working: BUG 43348
       gSpellChecker.RemoveWordFromDictionary(word);
     }
     catch (e)
     {
--- a/editor/ui/dialogs/content/EdSpellCheck.js
+++ b/editor/ui/dialogs/content/EdSpellCheck.js
@@ -142,25 +142,30 @@ function InitLanguageMenu(aCurLang)
 
   // Store current dictionary count.
   gDictCount = count;
 
   var inlineSpellChecker = new InlineSpellChecker();
   var sortedList = inlineSpellChecker.sortDictionaryList(dictList);
 
   // Remove any languages from the list.
-  var languageMenuPopup = gDialog.LanguageMenulist.firstChild;
+  var languageMenuPopup = gDialog.LanguageMenulist.menupopup;
   while (languageMenuPopup.firstChild.localName != "menuseparator")
     languageMenuPopup.firstChild.remove();
 
   var defaultItem = null;
 
   for (var i = 0; i < count; i++)
   {
-    var item = gDialog.LanguageMenulist.insertItemAt(i, sortedList[i].label, sortedList[i].id);
+    let item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
+    item.setAttribute("label", sortedList[i].label);
+    item.setAttribute("value", sortedList[i].id);
+    let beforeItem = gDialog.LanguageMenulist.getItemAtIndex(i);
+    languageMenuPopup.insertBefore(item, beforeItem);
+
     if (aCurLang && sortedList[i].id == aCurLang)
       defaultItem = item;
   }
 
   // Now make sure the correct item in the menu list is selected.
   if (defaultItem)
   {
     gDialog.LanguageMenulist.selectedItem = defaultItem;
--- a/editor/ui/dialogs/content/EditorPublishSettings.js
+++ b/editor/ui/dialogs/content/EditorPublishSettings.js
@@ -111,27 +111,26 @@ function AddNewSite()
 }
 
 function RemoveSite()
 {
   if (!gPublishSiteData)
     return;
 
   var index = gDialog.SiteList.selectedIndex;
-  var item;
   if (index != -1)
   {
-    item = gDialog.SiteList.selectedItems[0];
+    let item = gDialog.SiteList.selectedItem;
     var nameToRemove = item.getAttribute("label");
 
     // Remove one item from site data array
     gPublishSiteData.splice(index, 1);
     // Remove item from site list
     gDialog.SiteList.clearSelection();
-    gDialog.SiteList.removeItemAt(index);
+    item.remove();
 
     // Adjust if we removed last item and reselect a site
     if (index >= gPublishSiteData.length)
       index--;
     InitSiteSettings(index);
 
     if (nameToRemove == gDefaultSiteName)
     {
--- a/mail/base/content/ABSearchDialog.js
+++ b/mail/base/content/ABSearchDialog.js
@@ -57,35 +57,28 @@ function searchOnLoad()
 
   // initialize a flag for phonetic name search
   gSearchPhoneticName =
         Services.prefs.getComplexValue("mail.addr_book.show_phonetic_fields",
                                        Ci.nsIPrefLocalizedString).data;
 
   // Initialize globals, see abCommon.js , InitCommonJS()
   abList = document.getElementById("abPopup");
-  if (abList.getItemAtIndex(0) != (kAllDirectoryRoot + "?"))
-    abList.insertItemAt(0, gAddressBookBundle.getString("allAddressBooks"),
-                        kAllDirectoryRoot + "?");
 
   if (window.arguments && window.arguments[0])
     SelectDirectory(window.arguments[0].directory);
   else
     SelectDirectory(document.getElementById("abPopup-menupopup")
                             .firstChild.value);
 
   onMore(null);
 }
 
 function searchOnUnload()
 {
-  let abPopup = document.getElementById('abPopup');
-  if (abPopup.getItemAtIndex(0) == (kAllDirectoryRoot + "?"))
-    document.getElementById('abPopup').removeItemAt(0);
-
   CloseAbView();
 }
 
 function disableCommands()
 {
   gPropertiesCmd.setAttribute("disabled", "true");
   gComposeCmd.setAttribute("disabled", "true");
   gDeleteCmd.setAttribute("disabled", "true");
--- a/mail/base/content/ABSearchDialog.xul
+++ b/mail/base/content/ABSearchDialog.xul
@@ -58,17 +58,17 @@
 
   <dummy class="usesMailWidgets"/>
 
     <vbox id="searchTerms" flex="3" persist="height">
       <vbox>
         <hbox align="center">
           <label value="&abSearchHeading.label;" accesskey="&abSearchHeading.accesskey;" control="abPopup"/>
           <menulist id="abPopup" oncommand="SelectDirectory(this.value);">
-            <menupopup id="abPopup-menupopup" class="addrbooksPopup"/>
+            <menupopup id="abPopup-menupopup" class="addrbooksPopup" alladdressbooks="true"/>
           </menulist>
           <spacer flex="10"/>
           <button id="search-button" oncommand="onSearchButton(event);" default="true"/>
         </hbox>
         <hbox align="center">
           <spacer flex="1"/>
           <button label="&resetButton.label;" oncommand="onAbSearchReset(event);" accesskey="&resetButton.accesskey;"/>
         </hbox>
--- a/mail/base/content/FilterListDialog.js
+++ b/mail/base/content/FilterListDialog.js
@@ -438,17 +438,17 @@ function onDeleteFilter()
 
   // Save filter position before the first selected one.
   let newSelectionIndex = gFilterListbox.selectedIndex - 1;
 
   // Must reverse the loop, as the items list shrinks when we delete.
   for (let index = items.length - 1; index >= 0; --index) {
     let item = items[index];
     gCurrentFilterList.removeFilter(item._filter);
-    gFilterListbox.removeItemAt(gFilterListbox.getIndexOfItem(item));
+    item.remove();
   }
   updateCountBox();
 
   // Select filter above previously selected if one existed, otherwise the first one.
   if (newSelectionIndex == -1 && gFilterListbox.itemCount > 0)
     newSelectionIndex = 0;
   if (newSelectionIndex > -1) {
     gFilterListbox.selectedIndex = newSelectionIndex;
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -197,34 +197,35 @@ EmailConfigWizard.prototype =
     e("incoming_port").value = gStringsBundle.getString("port_auto");
     this.fillPortDropdown("smtp");
 
     // If the account provisioner is preffed off, don't display
     // the account provisioner button.
     if (!Services.prefs.getBoolPref("mail.provider.enabled"))
       _hide("provisioner_button");
 
+    let menulist = e("outgoing_hostname");
+    // Add the entry for the new host to the menulist
+    let menuitem = menulist.appendItem("", "-new-"); // label,value
+    menuitem.serverKey = null;
+
     // Populate SMTP server dropdown with already configured SMTP servers from
     // other accounts.
-    var menulist = e("outgoing_hostname");
     let smtpServers = MailServices.smtp.servers;
     while (smtpServers.hasMoreElements()) {
       let server = smtpServers.getNext().QueryInterface(Ci.nsISmtpServer);
       let label = server.displayname;
       let key = server.key;
       if (MailServices.smtp.defaultServer &&
           MailServices.smtp.defaultServer.key == key) {
         label += " " + gStringsBundle.getString("default_server_tag");
       }
-      let menuitem = menulist.appendItem(label, key, ""); // label,value,descr
+      menuitem = menulist.appendItem(label, key, ""); // label,value,descr
       menuitem.serverKey = key;
     }
-    // Add the entry for the new host to the menulist
-    let menuitem = menulist.insertItemAt(0, "", "-new-"); // pos,label,value
-    menuitem.serverKey = null;
 
     // admin-locked prefs hurray
     if (!Services.prefs.getBoolPref("signon.rememberSignons")) {
       let rememberPasswordE = e("remember_password");
       rememberPasswordE.checked = false;
       rememberPasswordE.disabled = true;
     }
 
--- a/mail/components/addrbook/content/abCommon.js
+++ b/mail/components/addrbook/content/abCommon.js
@@ -351,22 +351,16 @@ function GetParentRow(aTree, aRow)
   return row;
 }
 
 function InitCommonJS()
 {
   gDirTree = document.getElementById("dirTree");
   abList = document.getElementById("addressbookList");
   gAddressBookBundle = document.getElementById("bundle_addressBook");
-
-  // Make an entry for "All Address Books".
-  if (abList) {
-    abList.insertItemAt(0, gAddressBookBundle.getString("allAddressBooks"),
-                        kAllDirectoryRoot + "?");
-  }
 }
 
 function AbDelete()
 {
   let types = GetSelectedCardTypes();
   if (types == kNothingSelected)
     return;
 
--- a/mail/components/addrbook/content/abContactsPanel.xul
+++ b/mail/components/addrbook/content/abContactsPanel.xul
@@ -116,17 +116,17 @@
       <toolbarbutton id="abContextMenuButton"
                      tooltiptext="&abContextMenuButton.tooltip;"
                      onclick="showContextMenu('sidebarAbContextMenu', event, [this, 'after_end', 0, 0, true]);"/>
     </hbox>
     <hbox id="panel-bar" class="toolbar" align="center">
       <menulist id="addressbookList"
                 oncommand="AddressBookMenuListChange();" flex="1"
                 persist="value">
-        <menupopup id="addressbookList-menupopup" class="addrbooksPopup"/>
+        <menupopup id="addressbookList-menupopup" class="addrbooksPopup" alladdressbooks="true"/>
       </menulist>
     </hbox>
 
     <separator class="thin"/>
 
     <vbox>
       <label value="&searchContacts.label;"
              accesskey="&searchContacts.accesskey;"
--- a/mail/components/cloudfile/content/addAccountDialog.js
+++ b/mail/components/cloudfile/content/addAccountDialog.js
@@ -159,20 +159,18 @@ var addAccountDialog = {
     }
     let newHeight = this._settings.contentDocument.body.offsetHeight;
     this._settings.style.height = this._settings.style.minHeight = newHeight + "px";
     window.sizeToContent();
   },
 
   removeTitleMenuItem: function AAD_removeTitleMenuItem() {
     let menuitem = this._accountType.querySelector('menuitem[value=""]');
-    if (menuitem) {
-      let index = this._accountType.getIndexOfItem(menuitem);
-      this._accountType.removeItemAt(index);
-    }
+    if (menuitem)
+      menuitem.remove();
   },
 
   // Return number of additions to the menulist, zero if none happened.
   addAccountTypes: function AAD_addAccountTypes() {
     let accountTypeTotal = 0;
     for (let [key, provider] of cloudFileAccounts.enumerateProviders()) {
       // If we already have an account for this type, don't add it to the list.
       // This limitation will hopefully be removed in the future.
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4772,17 +4772,17 @@ function RemoveAllAttachments()
     return;
 
   let fileHandler = Services.io.getProtocolHandler("file")
                             .QueryInterface(Ci.nsIFileProtocolHandler);
   let removedAttachments = Cc["@mozilla.org/array;1"]
                              .createInstance(Ci.nsIMutableArray);
 
   while (bucket.itemCount > 0) {
-    let item = bucket.removeItemAt(bucket.itemCount - 1);
+    let item = bucket.getItemAtIndex(bucket.itemCount - 1);
     if (item.attachment.size != -1) {
       gAttachmentsSize -= item.attachment.size;
     }
 
     if (item.attachment.sendViaCloud && item.cloudProvider) {
       let originalUrl = item.originalUrl;
       if (!originalUrl)
         originalUrl = item.attachment.url;
@@ -4793,16 +4793,17 @@ function RemoveAllAttachments()
         item.cloudProvider.deleteFile(file,
           new deletionListener(item.attachment, item.cloudProvider));
     }
 
     removedAttachments.appendElement(item.attachment);
     // Let's release the attachment object hold by the node else it won't go
     // away until the window is destroyed.
     item.attachment = null;
+    item.remove();
   }
 
   if (removedAttachments.length > 0) {
     // Bug workaround: Force update of selectedCount and selectedItem.
     bucket.clearSelection();
     updateAttachmentPane("show");
     gContentChanged = true;
     dispatchAttachmentBucketEvent("attachments-removed", removedAttachments);
@@ -4865,17 +4866,17 @@ function RemoveSelectedAttachment()
   let focusIndex = bucket.currentIndex;
 
   let fileHandler = Services.io.getProtocolHandler("file")
                             .QueryInterface(Ci.nsIFileProtocolHandler);
   let removedAttachments = Cc["@mozilla.org/array;1"]
                              .createInstance(Ci.nsIMutableArray);
 
   for (let i = bucket.selectedCount - 1; i >= 0; i--) {
-    let item = bucket.removeItemAt(bucket.getIndexOfItem(bucket.getSelectedItem(i)));
+    let item = bucket.getSelectedItem(i);
     if (item.attachment.size != -1) {
       gAttachmentsSize -= item.attachment.size;
     }
 
     if (item.attachment.sendViaCloud && item.cloudProvider) {
       let originalUrl = item.originalUrl;
       if (!originalUrl)
         originalUrl = item.attachment.url;
@@ -4886,16 +4887,17 @@ function RemoveSelectedAttachment()
         item.cloudProvider.deleteFile(file,
           new deletionListener(item.attachment, item.cloudProvider));
     }
 
     removedAttachments.appendElement(item.attachment);
     // Let's release the attachment object held by the node else it won't go
     // away until the window is destroyed
     item.attachment = null;
+    item.remove();
   }
 
   updateAttachmentPane();
 
   // Bug workaround: Force update of selectedCount and selectedItem, both wrong
   // after item removal, to avoid confusion for listening command controllers.
   bucket.clearSelection();
 
--- a/mail/components/preferences/applicationManager.js
+++ b/mail/components/preferences/applicationManager.js
@@ -49,17 +49,17 @@ var gAppManagerDialog = {
   onCancel: function appManager_onCancel() {
     // do nothing
   },
 
   remove: function appManager_remove() {
     var list = document.getElementById("appList");
     this._removed.push(list.selectedItem.app);
     var index = list.selectedIndex;
-    list.removeItemAt(index);
+    list.selectedItem.remove();
     if (list.getRowCount() == 0) {
       // The list is now empty, make the bottom part disappear
       document.getElementById("appDetails").hidden = true;
     }
     else {
       // Select the item at the same index, if we removed the last
       // item of the list, select the previous item
       if (index == list.getRowCount())
--- a/mail/components/preferences/applications.js
+++ b/mail/components/preferences/applications.js
@@ -1710,22 +1710,22 @@ var gApplicationsPane = {
   onDelete: function(aEvent) {
     // We want to delete if either the request came from the confirmDelete
     // method (which is the only thing that populates the aEvent parameter),
     // or we've hit the delete/backspace key while the list has focus.
     if ((aEvent || document.commandDispatcher.focusedElement == this._list) &&
         this._list.selectedIndex != -1) {
       let typeItem = this._list.getItemAtIndex(this._list.selectedIndex);
       let handlerInfo = this._handledTypes[typeItem.type];
-      this._list.removeItemAt(this._list.selectedIndex);
       let index = this._visibleTypes.indexOf(handlerInfo);
       if (index != -1)
         this._visibleTypes.splice(index, 1);
       handlerInfo.remove();
       delete this._handledTypes[typeItem.type];
+      typeItem.remove();
     }
   },
 
   _setIconClassForPreferredAction: function(aHandlerInfo, aElement) {
     // If this returns true, the attribute that CSS sniffs for was set to something
     // so you shouldn't manually set an icon URI.
     // This removes the existing actionIcon attribute if any, even if returning false.
     aElement.removeAttribute("actionIcon");
--- a/mail/components/preferences/attachmentReminder.js
+++ b/mail/components/preferences/attachmentReminder.js
@@ -36,41 +36,44 @@ var gAttachmentReminderOptionsDialog = {
 
   addKeyword: function()
   {
     var input = {value: ""}; // Default to empty.
     var ok = Services.prompt.prompt(window,
                                     this.bundle.getString("attachmentReminderNewDialogTitle"),
                                     this.bundle.getString("attachmentReminderNewText"),
                                     input, null, {value:0});
-    if (ok && input.value)
-      this.keywordListBox.appendItem(input.value, input.value);
+    if (ok && input.value) {
+      let newKey = this.keywordListBox.appendItem(input.value, input.value);
+      this.keywordListBox.ensureElementIsVisible(newKey);
+      this.keywordListBox.selectItem(newKey);
+    }
   },
 
   editKeyword: function()
   {
     if (this.keywordListBox.selectedIndex < 0)
       return;
-    var keywordToEdit = this.keywordListBox.getItemAtIndex(this.keywordListBox.selectedIndex);
+    var keywordToEdit = this.keywordListBox.selectedItem;
     var input = {value: keywordToEdit.getAttribute("value")};
     var ok = Services.prompt.prompt(window,
                                     this.bundle.getString("attachmentReminderEditDialogTitle"),
                                     this.bundle.getString("attachmentReminderEditText"),
                                     input, null, {value:0});
     if (ok && input.value) {
-      this.keywordListBox.removeItemAt(this.keywordListBox.selectedIndex);
-      this.keywordListBox.appendItem(input.value, input.value);
+      this.keywordListBox.selectedItem.value = input.value;
+      this.keywordListBox.selectedItem.label = input.value;
     }
   },
 
   removeKeyword: function()
   {
     if (this.keywordListBox.selectedIndex < 0)
       return;
-    this.keywordListBox.removeItemAt(this.keywordListBox.selectedIndex);
+    this.keywordListBox.selectedItem.remove();
   },
 
   saveKeywords: function()
   {
     var keywordList = "";
     for (var i = 0; i < this.keywordListBox.getRowCount(); i++) {
       keywordList += this.keywordListBox.getItemAtIndex(i).getAttribute("value");
       if (i != this.keywordListBox.getRowCount() - 1)
--- a/mail/components/preferences/display.inc.xul
+++ b/mail/components/preferences/display.inc.xul
@@ -63,17 +63,19 @@
                 <column/>
               </columns>
               <rows id="fontsRows">
                 <row id="fontRow">
                   <hbox align="center">
                     <label accesskey="&defaultFont.accesskey;"
                            control="defaultFont">&defaultFont.label;</label>
                     <menulist id="defaultFont" flex="1" sizetopopup="pref" crop="center"
-                              onsyncfrompreference="return gDisplayPane.readFontSelection()"/>
+                              onsyncfrompreference="return gDisplayPane.readFontSelection()">
+                      <menupopup/>
+                    </menulist>
                     <label accesskey="&defaultSize.accesskey;"
                            control="defaultFontSize">&defaultSize.label;</label>
                     <menulist id="defaultFontSize">
                       <menupopup>
                         <menuitem value="9" label="9"/>
                         <menuitem value="10" label="10"/>
                         <menuitem value="11" label="11"/>
                         <menuitem value="12" label="12"/>
--- a/mail/components/preferences/display.js
+++ b/mail/components/preferences/display.js
@@ -16,17 +16,21 @@ var gDisplayPane = {
       let preference = document.getElementById("mail.preferences.display.selectedTabIndex");
       if (preference.value)
         document.getElementById("displayPrefs").selectedIndex = preference.value;
     }
     this._rebuildFonts();
     this.updateMarkAsReadOptions(document.getElementById("automaticallyMarkAsRead").checked);
     var menulist = document.getElementById("defaultFont");
     if (menulist.selectedIndex == -1) {
-      menulist.insertItemAt(0, "", "", "");
+      // Prepend menuitem with empty name and value.
+      let item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
+      item.setAttribute("label", "");
+      item.setAttribute("value", "");
+      menulist.menupopup.insertBefore(item, menulist.menupopup.firstChild);
       menulist.selectedIndex = 0;
     }
 
     this.mInitialized = true;
 
     this.mTagListBox = document.getElementById("tagList");
     this.buildTagList();
   },
@@ -233,17 +237,17 @@ var gDisplayPane = {
 
   removeTag: function()
   {
     var index = this.mTagListBox.selectedIndex;
     if (index >= 0)
     {
       var itemToRemove = this.mTagListBox.getItemAtIndex(index);
       MailServices.tags.deleteKey(itemToRemove.getAttribute("value"));
-      this.mTagListBox.removeItemAt(index);
+      itemToRemove.remove();
       var numItemsInListBox = this.mTagListBox.getRowCount();
       this.mTagListBox.selectedIndex = index < numItemsInListBox ? index : numItemsInListBox - 1;
     }
   },
 
   /**
    * Open the edit tag dialog
    */
--- a/mailnews/addrbook/content/addrbookWidgets.xml
+++ b/mailnews/addrbook/content/addrbookWidgets.xml
@@ -68,56 +68,60 @@
               }
             }
           }
 
           this._sort();
 
           this._teardown();
 
+          let menulist = this.parentNode;
+
+          if (this.hasAttribute("none")) {
+            // Create a dummy menuitem representing no selection.
+            this._directories.unshift(null);
+            let listItem = menulist.appendItem(this.getAttribute("none"), "");
+            listItem.setAttribute("class", "menuitem-iconic abMenuItem");
+            listItem.setAttribute("IsNone", "true");
+          }
+
+          if (this.hasAttribute("alladdressbooks")) {
+            // Insert a menuitem representing All Addressbooks.
+            let allABLabel = this.getAttribute("alladdressbooks");
+            if (allABLabel == "true")
+              allABLabel = this._stringBundle.getString("allAddressBooks");
+            const allABURI = "moz-abdirectory://?";
+            this._directories.unshift(null);
+            let listItem = menulist.appendItem(allABLabel, allABURI);
+            listItem.setAttribute("class", "menuitem-iconic abMenuItem");
+            listItem.setAttribute("AddrBook", "true");
+            listItem.setAttribute("IsAllAB", "true");
+          }
+
           // Now create menuitems for all displayed directories.
-          let menulist = this.parentNode;
           let value = this._value;
           for (let ab of this._directories) {
+            if (!ab) // Skip the empty members added above.
+              continue;
+
             let listItem = menulist.appendItem(ab.dirName, ab[value]);
             listItem.setAttribute("class", "menuitem-iconic abMenuItem");
 
             // Style the items by type.
             if (ab.isMailList)
               listItem.setAttribute("MailList", "true");
             else
               listItem.setAttribute("AddrBook", "true");
 
             if (ab.isRemote)
               listItem.setAttribute("IsRemote", "true");
             if (ab.isSecure)
               listItem.setAttribute("IsSecure", "true");
           }
 
-          if (this.hasAttribute("alladdressbooks")) {
-            // Insert a menuitem representing All addressbooks.
-            let allABLabel = this.getAttribute("alladdressbooks");
-            if (allABLabel == "true")
-              allABLabel = this._stringBundle.getString("allAddressBooks");
-            const allABURI = "moz-abdirectory://?";
-            this._directories.unshift(null);
-            let listItem = menulist.insertItemAt(0, allABLabel, allABURI);
-            listItem.setAttribute("class", "menuitem-iconic abMenuItem");
-            listItem.setAttribute("AddrBook", "true");
-            listItem.setAttribute("IsAllAB", "true");
-          }
-
-          if (this.hasAttribute("none")) {
-            // Create a dummy menuitem representing no selection.
-            this._directories.unshift(null);
-            let listItem = menulist.insertItemAt(0, this.getAttribute("none"), "");
-            listItem.setAttribute("class", "menuitem-iconic abMenuItem");
-            listItem.setAttribute("IsNone", "true");
-          }
-
           // Attempt to select the persisted or otherwise first directory.
           menulist.value = aSelectValue || this.parentNode.value;
           if (!menulist.selectedItem && this.hasChildNodes())
             menulist.selectedIndex = 0;
         ]]></body>
       </method>
 
       <method name="_teardown">
--- a/mailnews/base/prefs/content/am-junk.js
+++ b/mailnews/base/prefs/content/am-junk.js
@@ -53,18 +53,18 @@ function onInit(aPageId, aServerId)
 
   var currentArray = [];
   if (document.getElementById("server.useWhiteList").checked)
     currentArray = document.getElementById("server.whiteListAbURI").value.split(" ");
 
   // set up the whitelist UI
   var wList = document.getElementById("whiteListAbURI");
   // Ensure the whitelist is empty
-  for (let i = wList.itemCount - 1; i >= 0; i--) {
-    wList.removeItemAt(i);
+  while (wList.hasChildNodes()) {
+    wList.lastChild.remove();
   }
 
   // Populate the listbox with address books
   let abItems = [];
   for (let ab of fixIterator(MailServices.ab.directories,
                              Ci.nsIAbDirectory)) {
     // We skip mailing lists and remote address books.
     if (ab.isMailList || ab.isRemote)
--- a/suite/common/pref/pref-spelling.js
+++ b/suite/common/pref/pref-spelling.js
@@ -83,25 +83,30 @@ function InitLanguageMenu() {
   dictList.sort(
     function compareFn(a, b) {
       return a[0].localeCompare(b[0]);
     }
   );
 
   var languageMenuList = document.getElementById("languageMenuList");
   // Remove any languages from the list.
-  var languageMenuPopup = languageMenuList.firstChild;
+  var languageMenuPopup = languageMenuList.menupopup;
   while (languageMenuPopup.firstChild.localName != "menuseparator")
     languageMenuPopup.firstChild.remove();
 
   var curLang  = languageMenuList.value;
   var defaultItem = null;
 
   for (let i = 0; i < count; i++) {
-    let item = languageMenuList.insertItemAt(i, dictList[i][0], dictList[i][1]);
+    let item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuitem");
+    item.setAttribute("label", dictList[i][0]);
+    item.setAttribute("value", dictList[i][1]);
+    let beforeItem = gDialog.LanguageMenulist.getItemAtIndex(i);
+    languageMenuPopup.insertBefore(item, beforeItem);
+
     if (curLang && dictList[i][1] == curLang)
       defaultItem = item;
   }
 
   // Now make sure the correct item in the menu list is selected.
   if (defaultItem) {
     languageMenuList.selectedItem = defaultItem;
     gLastSelectedLang = defaultItem;