 diff --git a/editor/libeditor/nsHTMLEditRules.cpp b/editor/libeditor/nsHTMLEditRules.cpp
 --- a/editor/libeditor/nsHTMLEditRules.cpp
 +++ b/editor/libeditor/nsHTMLEditRules.cpp
-@@ -1388,55 +1388,18 @@ nsHTMLEditRules::WillInsertText(EditActi
+@@ -482,17 +482,20 @@ nsHTMLEditRules::AfterEditInner(EditActi
+          action != EditAction::insertIMEText) )
+     {
+       NS_ENSURE_STATE(mHTMLEditor);
+       res = mHTMLEditor->CollapseAdjacentTextNodes(mDocChangeRange);
+       NS_ENSURE_SUCCESS(res, res);
+     }
+ 
+     // clean up any empty nodes in the selection
+-    res = RemoveEmptyNodes();
++    if ((action != EditAction::insertNode) &&
++        (action != EditAction::htmlPaste) &&
++        (action != EditAction::loadHTML))
++      res = RemoveEmptyNodes();
+     NS_ENSURE_SUCCESS(res, res);
+ 
+     // attempt to transform any unneeded nbsp's into spaces after doing various operations
+     if ((action == EditAction::insertText) ||
+         (action == EditAction::insertIMEText) ||
+         (action == EditAction::deleteSelection) ||
+         (action == EditAction::insertBreak) ||
+         (action == EditAction::htmlPaste ||
+@@ -1388,55 +1391,18 @@ nsHTMLEditRules::WillInsertText(EditActi
      int32_t pos = 0;
      NS_NAMED_LITERAL_STRING(newlineStr, LFSTR);
  

     return aSelection->Collapse(node, offset);
   }
 
@@ -6635,16 +6598,17 @@ nsHTMLEditRules::SplitParagraph(nsIDOMNo
     aSelection->Collapse(child,0);
   }
   else

                                     offset + 1, getter_AddRefs(pNode));
       NS_ENSURE_SUCCESS(res, res);
 
@@ -6767,16 +6737,18 @@ nsHTMLEditRules::ReturnInListItem(Select
         if (nodeAtom == nsGkAtoms::dd || nodeAtom == nsGkAtoms::dt) {
           int32_t itemOffset;
           nsCOMPtr<nsIDOMNode> list = nsEditor::GetNodeLocation(aListItem, &itemOffset);
