Bug 1617449 - Make the "Remove Account" dialog in-content. r=mkmelin
☠☠ backed out by 68a089e63044 ☠ ☠
authorRichard Marti <richard.marti@gmail.com>
Mon, 24 Feb 2020 12:44:26 +0200
changeset 37420 2a7bb79c9728de95188518f89c2b83e268e3bdaa
parent 37419 bb6db0e80a06f4550e6bc9f1c80b3faf15763340
child 37421 1274488084757043ccf09e1fcf7ab67adba4c524
push id2566
push userclokep@gmail.com
push dateMon, 09 Mar 2020 19:20:31 +0000
treeherdercomm-beta@a352facfa0a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1617449
Bug 1617449 - Make the "Remove Account" dialog in-content. r=mkmelin
mailnews/base/prefs/content/AccountManager.js
mailnews/base/prefs/content/removeAccount.js
mailnews/base/prefs/content/removeAccount.xhtml
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -23,16 +23,17 @@
  * - in the IFRAME inside the page, if there is an onInit() method,
  *   it is called. The onInit method can further update this page based
  *   on values set in the previous step.
  */
 
 /* import-globals-from accountUtils.js */
 /* import-globals-from am-prefs.js */
 /* import-globals-from amUtils.js */
+/* globals gSubDialog */
 
 var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
 var { BrowserUtils } = ChromeUtils.import(
   "resource://gre/modules/BrowserUtils.jsm"
 );
 var { Gloda } = ChromeUtils.import("resource:///modules/gloda/Gloda.jsm");
 var { fixIterator } = ChromeUtils.import(
   "resource:///modules/iteratorUtils.jsm"
@@ -915,42 +916,44 @@ function onRemoveAccount(event) {
 
   // Confirm account deletion.
   let removeArgs = {
     server,
     account: currentAccount,
     result: false,
   };
 
-  window.docShell.rootTreeItem.domWindow.openDialog(
-    "chrome://messenger/content/removeAccount.xhtml",
-    "removeAccount",
-    "chrome,titlebar,modal,centerscreen,resizable=no",
-    removeArgs
-  );
+  let onCloseDialog = function() {
+    // If result is true, the account was removed.
+    if (!removeArgs.result) {
+      return;
+    }
 
-  // If result is true, the account was removed.
-  if (!removeArgs.result) {
-    return;
-  }
+    // clear cached data out of the account array
+    currentAccount = currentPageId = null;
+    if (serverId in accountArray) {
+      delete accountArray[serverId];
+    }
 
-  // clear cached data out of the account array
-  currentAccount = currentPageId = null;
-  if (serverId in accountArray) {
-    delete accountArray[serverId];
-  }
+    if (serverIndex >= 0 && serverIndex < serverList.length) {
+      selectServer(serverList[serverIndex], null);
+    }
 
-  if (serverIndex >= 0 && serverIndex < serverList.length) {
-    selectServer(serverList[serverIndex], null);
-  }
+    // Either the default account was deleted so there is a new one
+    // or the default account was not changed. Either way, there is
+    // no need to unmark the old one.
+    markDefaultServer(MailServices.accounts.defaultAccount, null);
+  };
 
-  // Either the default account was deleted so there is a new one
-  // or the default account was not changed. Either way, there is
-  // no need to unmark the old one.
-  markDefaultServer(MailServices.accounts.defaultAccount, null);
+  gSubDialog.open(
+    "chrome://messenger/content/removeAccount.xhtml",
+    "resizable=no",
+    removeArgs,
+    onCloseDialog
+  );
 }
 
 function saveAccount(accountValues, account) {
   var identity = null;
   var server = null;
 
   if (account) {
     identity = account.defaultIdentity;
--- a/mailnews/base/prefs/content/removeAccount.js
+++ b/mailnews/base/prefs/content/removeAccount.js
@@ -78,31 +78,32 @@ function openLocalDirectory() {
   } catch (e) {
     // Reveal may fail e.g. on Linux, then just show the path as a string.
     document.getElementById("localDirectory").value = localDir;
     document.getElementById("localDirectory").collapsed = false;
   }
 }
 
 function showInfo() {
+  let removeAccountBox = document.getElementById("removeAccountBox");
   let descs = document.querySelectorAll("vbox.indent");
   for (let desc of descs) {
     desc.collapsed = false;
   }
 
   // TODO: bug 1238271, this should use showFor attributes if possible.
   if (gServer.type == "imap" || gServer.type == "nntp") {
     document.getElementById("serverAccount").collapsed = false;
   } else if (gServer.type == "im") {
     document.getElementById("chatAccount").collapsed = false;
   } else {
     document.getElementById("localAccount").collapsed = false;
   }
 
-  window.sizeToContent();
+  window.resizeBy(0, removeAccountBox.getBoundingClientRect().height);
   gDialog.getButton("disclosure").disabled = true;
   gDialog.getButton("disclosure").blur();
 }
 
 function removeAccount() {
   let removeAccount = document.getElementById("removeAccount").checked;
   let removeData = document.getElementById("removeData").checked;
   let account = window.arguments[0].account;
--- a/mailnews/base/prefs/content/removeAccount.xhtml
+++ b/mailnews/base/prefs/content/removeAccount.xhtml
@@ -45,17 +45,17 @@
       <vbox id="removeDataPossibility" collapsed="false">
       <checkbox id="removeData"
                 label="&removeData.label;"
                 labelChat="&removeDataChat.label;"
                 checked="false"
                 accesskey="&removeData.accesskey;"
                 accesskeyChat="&removeDataChat.accesskey;"
                 oncommand="enableRemove();"/>
-      <vbox class="indent" collapsed="true">
+      <vbox id="removeAccountBox" class="indent" collapsed="true">
         <description id="localAccount" collapsed="true">
           &removeDataLocalAccount.desc;
         </description>
         <description id="serverAccount" collapsed="true">
           &removeDataServerAccount.desc;
         </description>
         <description id="chatAccount" collapsed="true">
           &removeDataChatAccount.desc;