Bug 545859 - Signature is misplaced when the compose window was invoked by a mailto: link with body parameter and signature position set to "above quote". r+a=Standard8
authorrsx11m <rsx11m.pub@gmail.com>
Fri, 14 Dec 2012 16:27:22 -0600
changeset 13611 b72e2bda999c7f8fcd69456469289ef1e4ce0274
parent 13610 bb0e6b6c5db88579d59bfd891dd682dcb0fc0da2
child 13612 e31303ce709860a4a5c5c101344f01f7ddc48ef0
push id30
push userbugzilla@standard8.plus.com
push dateFri, 08 Feb 2013 19:06:23 +0000
bugs545859
Bug 545859 - Signature is misplaced when the compose window was invoked by a mailto: link with body parameter and signature position set to "above quote". r+a=Standard8
mailnews/compose/src/nsMsgCompose.cpp
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -624,18 +624,19 @@ nsMsgCompose::ConvertAndLoadComposeWindo
   // Now, insert it into the editor...
   nsCOMPtr<nsIHTMLEditor> htmlEditor (do_QueryInterface(m_editor));
   nsCOMPtr<nsIPlaintextEditor> textEditor (do_QueryInterface(m_editor));
   nsCOMPtr<nsIEditorMailSupport> mailEditor (do_QueryInterface(m_editor));
   int32_t reply_on_top = 0;
   bool sig_bottom = true;
   m_identity->GetReplyOnTop(&reply_on_top);
   m_identity->GetSigBottom(&sig_bottom);
-
   bool sigOnTop = (reply_on_top == 1 && !sig_bottom);
+  bool isForwarded = (mType == nsIMsgCompType::ForwardInline);
+
   if (aQuoted)
   {
     mInsertingQuotedContent = true;
     if (!aPrefix.IsEmpty())
     {
       if (!aHTMLEditor)
         aPrefix.AppendLiteral("\n");
 
@@ -709,52 +710,52 @@ nsMsgCompose::ConvertAndLoadComposeWindo
     {
       mInsertingQuotedContent = true;
       htmlEditor->RebuildDocumentFromSource(aBuf);
       mInsertingQuotedContent = false;
 
       // when forwarding a message as inline, tag any embedded objects
       // which refer to local images or files so we know not to include
       // send them
-      if (mType == nsIMsgCompType::ForwardInline)
+      if (isForwarded)
         (void)TagEmbeddedObjects(mailEditor);
 
       if (!aSignature.IsEmpty())
       {
-        if (sigOnTop)
+        if (isForwarded && sigOnTop)
           m_editor->BeginningOfDocument();
         else
           m_editor->EndOfDocument();
         htmlEditor->InsertHTML(aSignature);
-        if (sigOnTop)
+        if (isForwarded && sigOnTop)
           m_editor->EndOfDocument();
       }
       else
         m_editor->EndOfDocument();
     }
     else if (htmlEditor)
     {
-      if (sigOnTop && !aSignature.IsEmpty())
+      if (isForwarded && sigOnTop && !aSignature.IsEmpty())
       {
         textEditor->InsertLineBreak();
         InsertDivWrappedTextAtSelection(aSignature,
                                         NS_LITERAL_STRING("moz-signature"));
         m_editor->EndOfDocument();
       }
 
       if (!aBuf.IsEmpty())
       {
         if (mailEditor)
           mailEditor->InsertTextWithQuotations(aBuf);
         else
           textEditor->InsertText(aBuf);
         m_editor->EndOfDocument();
       }
 
-      if (!sigOnTop && !aSignature.IsEmpty()) {
+      if ((!isForwarded || !sigOnTop) && !aSignature.IsEmpty()) {
         textEditor->InsertLineBreak();
         InsertDivWrappedTextAtSelection(aSignature,
                                         NS_LITERAL_STRING("moz-signature"));
       }
     }
   }
 
   if (aBuf.IsEmpty())