Bug 777732 - Remove compose windows recycling (part 2). r=mkmelin
authorJorg K
Wed, 30 Mar 2016 09:53:23 +0200
changeset 24733 452569be7f752111e13aa60f07978024399c2276
parent 24732 2b8ddf24b85ec9acbe3a6c0ed505b1910308fd12
child 24734 ddcbed3a77c0a510faca283156d781e2126763cc
push id1657
push userclokep@gmail.com
push dateMon, 06 Jun 2016 19:50:21 +0000
treeherdercomm-beta@9fac989284b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs777732
Bug 777732 - Remove compose windows recycling (part 2). r=mkmelin
mail/components/addrbook/content/abContactsPanel.js
mail/components/compose/content/bigFileObserver.js
mail/components/compose/content/cloudAttachmentLinkManager.js
mail/extensions/smime/content/msgCompSMIMEOverlay.js
mailnews/extensions/smime/content/msgCompSMIMEOverlay.js
--- a/mail/components/addrbook/content/abContactsPanel.js
+++ b/mail/components/addrbook/content/abContactsPanel.js
@@ -80,27 +80,16 @@ function AddressBookMenuListChange()
   } else {
     addrbookColumn.hidden = true;
     addrbookColumn.setAttribute("ignoreincolumnpicker", "true");
   }
 
   CommandUpdate_AddressBook();
 }
 
-function AbPanelOnComposerClose()
-{
-  CloseAbView();
-  onAbClearSearch(false);
-}
-
-function AbPanelOnComposerReOpen()
-{
-  SetAbView(GetSelectedDirectory());
-}
-
 var mutationObs = null;
 
 function AbPanelLoad()
 {
   InitCommonJS();
 
   document.title = parent.document.getElementById("sidebar-title").value;
 
@@ -111,19 +100,16 @@ function AbPanelLoad()
   var temp = abPopup.value;
   abPopup.selectedItem = null;
   abPopup.value = temp;
   if (!abPopup.selectedItem)
     abPopup.selectedIndex = 0;
 
   ChangeDirectoryByURI(abPopup.value);
 
-  parent.addEventListener("compose-window-close", AbPanelOnComposerClose, true);
-  parent.addEventListener("compose-window-reopen", AbPanelOnComposerReOpen, true);
-
   mutationObs = new MutationObserver(function(aMutations) {
     aMutations.forEach(function(mutation) {
       if (GetSelectedDirectory() == (kAllDirectoryRoot + "?") &&
           mutation.type == "attributes" &&
           mutation.attributeName == "hidden") {
         let curState = document.getElementById("addrbook").hidden;
         gShowAbColumnInComposeSidebar = !curState;
       }
@@ -133,18 +119,16 @@ function AbPanelLoad()
   document.getElementById("addrbook").hidden = !gShowAbColumnInComposeSidebar;
 
   mutationObs.observe(document.getElementById("addrbook"),
                       { attributes: true, childList: true });
 }
 
 function AbPanelUnload()
 {
-  parent.removeEventListener("compose-window-close", AbPanelOnComposerClose, true);
-  parent.removeEventListener("compose-window-reopen", AbPanelOnComposerReOpen, true);
   mutationObs.disconnect();
 
   CloseAbView();
 }
 
 function AbPanelNewCard()
 {
   goNewCardDialog(abList.value);
--- a/mail/components/compose/content/bigFileObserver.js
+++ b/mail/components/compose/content/bigFileObserver.js
@@ -36,38 +36,16 @@ var gBigFileObserver = {
     bucket.addEventListener("attachment-upload-failed", this, false);
     bucket.addEventListener("attachments-converted", this, false);
 
     this.sessionHidden = false;
     this.privacyWarned = false;
     this.bigFiles = [];
   },
 
-  uninit: function() {
-    let bucket = document.getElementById("attachmentBucket");
-    bucket.removeEventListener("attachments-added", this, false);
-    bucket.removeEventListener("attachments-removed", this, false);
-    bucket.removeEventListener("attachments-uploading", this, false);
-    bucket.removeEventListener("attachment-uploaded", this, false);
-    bucket.removeEventListener("attachment-upload-failed", this, false);
-    bucket.removeEventListener("attachments-converted", this, false);
-
-    let nb = document.getElementById("attachmentNotificationBox");
-
-    let removeValues = [kUploadNotificationValue,
-                        kPrivacyWarningNotificationValue];
-
-    for (let value of removeValues) {
-      let notification = nb.getNotificationWithValue(value);
-      if (notification) {
-        nb.removeNotification(notification);
-      }
-    };
-  },
-
   handleEvent: function(event) {
     if (this.hidden)
       return;
 
     const bucketCallbacks = {
       "attachments-added": this.attachmentsAdded,
       "attachments-removed": this.attachmentsRemoved,
       "attachments-converted": this.attachmentsConverted,
@@ -321,10 +299,8 @@ var gBigFileObserver = {
     }
     return false;
   },
 
 };
 
 window.addEventListener("compose-window-init",
   gBigFileObserver.init.bind(gBigFileObserver), true);
-window.addEventListener("compose-window-close",
-  gBigFileObserver.uninit.bind(gBigFileObserver), true);
--- a/mail/components/compose/content/cloudAttachmentLinkManager.js
+++ b/mail/components/compose/content/cloudAttachmentLinkManager.js
@@ -18,25 +18,16 @@ var gCloudAttachmentLinkManager = {
       let attachment = bucket.getItemAtIndex(i).attachment;
       if (attachment && attachment.sendViaCloud)
         this.cloudAttachments.push(attachment);
     }
 
     gMsgCompose.RegisterStateListener(this);
   },
 
-  uninit: function() {
-    let bucket = document.getElementById("attachmentBucket");
-    bucket.removeEventListener("attachment-uploaded", this, false);
-    bucket.removeEventListener("attachments-removed", this, false);
-    bucket.removeEventListener("attachments-converted", this, false);
-
-    gMsgCompose.UnregisterStateListener(this);
-  },
-
   NotifyComposeFieldsReady: function() {},
 
   NotifyComposeBodyReady: function() {
 
     // Look all the possible compose typed (nsIMsgComposeParams.idl):
     switch (gComposeType) {
 
     case Components.interfaces.nsIMsgCompType.New:
@@ -605,12 +596,10 @@ var gCloudAttachmentLinkManager = {
           element.removeAttribute("id");
       }
     }
   },
 };
 
 window.addEventListener("compose-window-init",
   gCloudAttachmentLinkManager.init.bind(gCloudAttachmentLinkManager), true);
-window.addEventListener("compose-window-close",
-  gCloudAttachmentLinkManager.uninit.bind(gCloudAttachmentLinkManager), true);
 window.addEventListener("compose-send-message",
   gCloudAttachmentLinkManager.send.bind(gCloudAttachmentLinkManager), true);
--- a/mail/extensions/smime/content/msgCompSMIMEOverlay.js
+++ b/mail/extensions/smime/content/msgCompSMIMEOverlay.js
@@ -17,92 +17,39 @@ var gEncryptedURIService =
                   .getService(Components.interfaces.nsIEncryptedSMIMEURIsService);
 
 var gNextSecurityButtonCommand = "";
 var gSMFields = null;
 
 var gEncryptOptionChanged;
 var gSignOptionChanged;
 
-function onComposerClose()
-{
-  gSMFields = null;
-  setNoEncryptionUI();
-  setNoSignatureUI();
-
-  if (!gMsgCompose || !gMsgCompose.compFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = null;
-}
-
-function onComposerReOpen()
-{
-  // Are we already set up ? Or are the required fields missing ?
-  if (gSMFields || !gMsgCompose || !gMsgCompose.compFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = null;
-
-  gSMFields = Components.classes["@mozilla.org/messenger-smime/composefields;1"]
-                        .createInstance(Components.interfaces.nsIMsgSMIMECompFields);
-  if (!gSMFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = gSMFields;
-
-  // Set up the intial security state.
-  gSMFields.requireEncryptMessage =
-    gCurrentIdentity.getIntAttribute("encryptionpolicy") == kEncryptionPolicy_Always;
-  if (!gSMFields.requireEncryptMessage &&
-      gEncryptedURIService &&
-      gEncryptedURIService.isEncrypted(gMsgCompose.originalMsgURI))
-  {
-    // Override encryption setting if original is known as encrypted.
-    gSMFields.requireEncryptMessage = true;
-  }
-  if (gSMFields.requireEncryptMessage)
-    setEncryptionUI();
-  else
-    setNoEncryptionUI();
-
-  gSMFields.signMessage = gCurrentIdentity.getBoolAttribute("sign_mail");
-  if (gSMFields.signMessage)
-    setSignatureUI();
-  else
-    setNoSignatureUI();
-}
-
 addEventListener("load", smimeComposeOnLoad, false);
 
 // this function gets called multiple times.
 function smimeComposeOnLoad()
 {
   removeEventListener("load", smimeComposeOnLoad, false);
 
   onComposerReOpen();
 
   top.controllers.appendController(SecurityController);
 
   addEventListener("compose-from-changed", onComposerFromChanged, true);
   addEventListener("compose-send-message", onComposerSendMessage, true);
-  addEventListener("compose-window-close", onComposerClose, true);
-  addEventListener("compose-window-reopen", onComposerReOpen, true);
 
   addEventListener("unload", smimeComposeOnUnload, false);
 }
 
 function smimeComposeOnUnload()
 {
   removeEventListener("unload", smimeComposeOnUnload, false);
 
   removeEventListener("compose-from-changed", onComposerFromChanged, true);
   removeEventListener("compose-send-message", onComposerSendMessage, true);
-  removeEventListener("compose-window-close", onComposerClose, true);
-  removeEventListener("compose-window-reopen", onComposerReOpen, true);
 
   top.controllers.removeController(SecurityController);
 }
 
 function GetServer()
 {
   let servers = MailServices.accounts.getServersForIdentity(gCurrentIdentity);
   return servers.queryElementAt(0, Components.interfaces.nsIMsgIncomingServer);
--- a/mailnews/extensions/smime/content/msgCompSMIMEOverlay.js
+++ b/mailnews/extensions/smime/content/msgCompSMIMEOverlay.js
@@ -15,92 +15,39 @@ var gEncryptedURIService =
         Components.classes["@mozilla.org/messenger-smime/smime-encrypted-uris-service;1"]
                   .getService(Components.interfaces.nsIEncryptedSMIMEURIsService);
 
 var gNextSecurityButtonCommand = "";
 var gSMFields = null;
 var gEncryptOptionChanged;
 var gSignOptionChanged;
 
-function onComposerClose()
-{
-  gSMFields = null;
-  setNoEncryptionUI();
-  setNoSignatureUI();
-
-  if (!gMsgCompose || !gMsgCompose.compFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = null;
-}
-
-function onComposerReOpen()
-{
-  // Are we already set up ? Or are the required fields missing ?
-  if (gSMFields || !gMsgCompose || !gMsgCompose.compFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = null;
-
-  gSMFields = Components.classes["@mozilla.org/messenger-smime/composefields;1"]
-                        .createInstance(Components.interfaces.nsIMsgSMIMECompFields);
-  if (!gSMFields)
-    return;
-
-  gMsgCompose.compFields.securityInfo = gSMFields;
-
-  // Set up the intial security state.
-  gSMFields.requireEncryptMessage =
-    gCurrentIdentity.getIntAttribute("encryptionpolicy") == kEncryptionPolicy_Always;
-  if (!gSMFields.requireEncryptMessage &&
-      gEncryptedURIService &&
-      gEncryptedURIService.isEncrypted(gMsgCompose.originalMsgURI))
-  {
-    // Override encryption setting if original is known as encrypted.
-    gSMFields.requireEncryptMessage = true;
-  }
-  if (gSMFields.requireEncryptMessage)
-    setEncryptionUI();
-  else
-    setNoEncryptionUI();
-
-  gSMFields.signMessage = gCurrentIdentity.getBoolAttribute("sign_mail");
-  if (gSMFields.signMessage)
-    setSignatureUI();
-  else
-    setNoSignatureUI();
-}
-
 addEventListener("load", smimeComposeOnLoad, false);
 
 // this function gets called multiple times
 function smimeComposeOnLoad()
 {
   removeEventListener("load", smimeComposeOnLoad, false);
 
   onComposerReOpen();
 
   top.controllers.appendController(SecurityController);
 
   addEventListener("compose-from-changed", onComposerFromChanged, true);
   addEventListener("compose-send-message", onComposerSendMessage, true);
-  addEventListener("compose-window-close", onComposerClose, true);
-  addEventListener("compose-window-reopen", onComposerReOpen, true);
 
   addEventListener("unload", smimeComposeOnUnload, false);
 }
 
 function smimeComposeOnUnload()
 {
   removeEventListener("unload", smimeComposeOnUnload, false);
 
   removeEventListener("compose-from-changed", onComposerFromChanged, true);
   removeEventListener("compose-send-message", onComposerSendMessage, true);
-  removeEventListener("compose-window-close", onComposerClose, true);
-  removeEventListener("compose-window-reopen", onComposerReOpen, true);
 
   top.controllers.removeController(SecurityController);
 }
 
 function showNeedSetupInfo()
 {
   let compSmimeBundle = document.getElementById("bundle_comp_smime");
   let brandBundle = document.getElementById("bundle_brand");