Bug 1357920 - Port bug 1354002 - Set execCommand("defaultparagraphseparator", false, "br/p") depending on mail.compose.default_to_paragraph to SeaMonkey. r=frg
authorIan Neal <iann_cvs@blueyonder.co.uk>
Wed, 19 Apr 2017 15:52:00 +0200
changeset 28385 064ea09a484db674bea276f4f634dd9b7bf85d24
parent 28384 dd97865d7a80a00490e1cf1226b05ca6d2fe18bc
child 28386 5f8fb8c490aa4ecbf5236a84ab6f069b85235dd7
push id1986
push userclokep@gmail.com
push dateWed, 02 Aug 2017 14:43:31 +0000
treeherdercomm-beta@b51c9adf2c9e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfrg
bugs1357920, 1354002
Bug 1357920 - Port bug 1354002 - Set execCommand("defaultparagraphseparator", false, "br/p") depending on mail.compose.default_to_paragraph to SeaMonkey. r=frg
suite/mailnews/compose/MsgComposeCommands.js
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -243,38 +243,21 @@ var stateListener = {
 
       if (range.startContainer != mailBody) {
         dump("Unexpected selection in NotifyComposeBodyReadyReply\n");
         return;
       }
 
       this.editor.enableUndo(false);
 
-      // Delete a <br> if we see one.
-      let deleted2ndBR = false;
-      let currentNode = mailBody.childNodes[start];
-      if (currentNode.nodeName == "BR") {
-        currentNode.remove();
-        currentNode = mailBody.childNodes[start];
-        if (currentNode && currentNode.nodeName == "BR") {
-          currentNode.remove();
-          deleted2ndBR = true;
-        }
-      }
-
       let pElement = this.editor.createElementWithDefaults("p");
       let brElement = this.editor.createElementWithDefaults("br");
       pElement.appendChild(brElement);
       this.editor.insertElementAtSelection(pElement, false);
 
-      if (deleted2ndBR) {
-        let brElement2 = this.editor.createElementWithDefaults("br");
-        this.editor.insertElementAtSelection(brElement2, false);
-      }
-
       // Position into the paragraph.
       selection.collapse(pElement, 0);
 
       this.paragraphState.setAttribute("state", "p");
 
       this.editor.enableUndo(true);
       this.editor.resetModificationCount();
     } else {
@@ -3140,19 +3123,20 @@ function InitEditor(editor)
   var eEditorMailMask = Components.interfaces.nsIPlaintextEditor.eEditorMailMask;
   editor.flags |= eEditorMailMask;
   GetMsgSubjectElement().editor.flags |= eEditorMailMask;
 
   // Control insertion of line breaks.
   editor.returnInParagraphCreatesNewParagraph =
     Services.prefs.getBoolPref("mail.compose.default_to_paragraph") ||
     Services.prefs.getBoolPref("editor.CR_creates_new_p");
-  // Traditionally we want <br> elements for newlines, unless we're
-  // splitting a paragraph (which is not affected by this setting).
-  editor.document.execCommand("defaultparagraphseparator", false, "br");
+  editor.document.execCommand("defaultparagraphseparator", false,
+    gMsgCompose.composeHTML &&
+    Services.prefs.getBoolPref("mail.compose.default_to_paragraph") ?
+                               "p" : "br");
 
   gMsgCompose.initEditor(editor, window.content);
   InlineSpellCheckerUI.init(editor);
   EnableInlineSpellCheck(getPref("mail.spellcheck.inline"));
   document.getElementById("menu_inlineSpellCheck").setAttribute("disabled", !InlineSpellCheckerUI.canSpellCheck);
 
   // Listen for spellchecker changes, set the document language to the
   // dictionary picked by the user via the right-click menu in the editor.