Bug 597369 - Reset override when different message is displayed. r=mkmelin. a=jorgk.
authorJorg K
Sun, 07 Feb 2016 22:17:02 +0100
changeset 26757 ed5ff7b03a4334a6ec068ea83814a16b463f6e85
parent 26756 41bd20a67a026a9785a0c11cd6fe284bd8eda5c4
child 26758 b78a55a2bec615cb0b475d17e97f5875f9ec2c80
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs597369
Bug 597369 - Reset override when different message is displayed. r=mkmelin. a=jorgk.
mail/base/content/folderDisplay.js
mail/base/content/mailCommands.js
mail/base/content/mailWindow.js
mail/base/content/messageDisplay.js
--- a/mail/base/content/folderDisplay.js
+++ b/mail/base/content/folderDisplay.js
@@ -1375,16 +1375,19 @@ FolderDisplayWidget.prototype = {
     //  message as invalidating the choice we automatically made for them when
     //  they initiated the message delete / move. (bug 243532)
     // Note: legacy code used to check whether the message being displayed was
     //  the one being deleted, so it didn't erroneously clear the next message
     //  to display (bug 183394).  This is not a problem for us because we hook
     //  our notification when the message load is initiated, rather than when
     //  the message completes loading.
     this._nextViewIndexAfterDelete = null;
+
+    // If we're displaying a different message, reset the override.
+    msgWindow.charsetOverride = false;
   },
 
   /**
    * This gets called as a hint that the currently selected message is junk and
    *  said junked message is going to be moved out of the current folder, or
    *  right before a header is removed from the db view.  The legacy behaviour
    *  is to retrieve the msgToSelectAfterDelete attribute off the db view,
    *  stashing it for benefit of the code that gets called when a message
--- a/mail/base/content/mailCommands.js
+++ b/mail/base/content/mailCommands.js
@@ -148,16 +148,22 @@ function GetMsgKeyFromURI(uri) {
   // The regexp expects 'key' to be an integer (a serie of digits) : '\d+'.
   let match = /.+#(\d+)/.exec(uri);
   return (match) ? match[1] : null;
 }
 
 // type is a nsIMsgCompType and format is a nsIMsgCompFormat
 function ComposeMessage(type, format, folder, messageArray)
 {
+  if (messageArray && messageArray.length == 1) {
+    if (GetMsgKeyFromURI(messageArray[0]) != gMessageDisplay.keyForCharsetOverride) {
+      msgWindow.charsetOverride = false;
+    }
+  }
+
   // Check if the draft is already open in another window. If it is, just focus the window.
   if (type == Components.interfaces.nsIMsgCompType.Draft && messageArray.length == 1) {
     // We'll search this uri in the opened windows.
     let messageKey = GetMsgKeyFromURI(messageArray[0]);
     let wenum = Services.wm.getEnumerator("");
     while (wenum.hasMoreElements()) {
       let w = wenum.getNext();
       // Check if it is a compose window.
--- a/mail/base/content/mailWindow.js
+++ b/mail/base/content/mailWindow.js
@@ -620,11 +620,14 @@ nsBrowserAccess.prototype = {
     return false;
   }
 };
 
 function MailSetCharacterSet(aEvent) {
   if (aEvent.target.hasAttribute("charset")) {
     msgWindow.mailCharacterSet = aEvent.target.getAttribute("charset");
     msgWindow.charsetOverride = true;
+    gMessageDisplay.keyForCharsetOverride =
+      ("messageKey" in gMessageDisplay.displayedMessage ?
+       gMessageDisplay.displayedMessage.messageKey : null);
   }
   messenger.setDocumentCharset(msgWindow.mailCharacterSet);
 }
--- a/mail/base/content/messageDisplay.js
+++ b/mail/base/content/messageDisplay.js
@@ -88,16 +88,21 @@ MessageDisplayWidget.prototype = {
   /**
    * The FolderDisplayWidget that owns us.
    */
   folderDisplay: null,
   /**
    * The currently displayed message's nsIMsgDBHdr.  null if there's no message.
    */
   displayedMessage: null,
+  /**
+   * The key of the message for which a charset override was last set,
+   * null if it was never set. Note that a stale value can hang around.
+   */
+  keyForCharsetOverride: null,
 
   /**
    * Indicate whether the message being displayed is a 'dummy' because it is
    *  backed not by an nsIMsgDBHdr but instead by a file on disk or an
    *  attachment on some mail message.
    */
   isDummy: false,
   //@}