Bug 796839 - Part 1: Make sure not to try wrapping empty text nodes when applying alignment in editable regions; r=roc
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 04 Oct 2012 11:34:58 -0400
changeset 109314 d5abea9273a9
parent 109313 a05bad13ec39
child 109315 d97ca37eaa2d
push id23619
push useremorley@mozilla.com
push date2012-10-05 10:54 +0000
treeherdermozilla-central@3b458f4e0f42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs796839
milestone18.0a1
Bug 796839 - Part 1: Make sure not to try wrapping empty text nodes when applying alignment in editable regions; r=roc

The code here is just missing this condition, and this patch is needed
to make the last part of this series pass tests. Previously,
nsEditor::IsEditable would return false when it hit an empty text node,
which implied this property almost by accident. This check makes this
property explicit, so this patch by itself doesn't really change
semantics.
editor/libeditor/html/nsHTMLEditRules.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -4549,19 +4549,21 @@ nsHTMLEditRules::WillAlign(Selection* aS
       NS_ENSURE_SUCCESS(res, res);
       // clear out curDiv so that we don't put nodes after this one into it
       curDiv = 0;
       continue;
     }
 
     // Skip insignificant formatting text nodes to prevent
     // unnecessary structure splitting!
+    bool isEmptyTextNode = false;
     if (nsEditor::IsTextNode(curNode) &&
        ((nsHTMLEditUtils::IsTableElement(curParent) && !nsHTMLEditUtils::IsTableCellOrCaption(curParent)) ||
-        nsHTMLEditUtils::IsList(curParent)))
+        nsHTMLEditUtils::IsList(curParent) ||
+        (NS_SUCCEEDED(mHTMLEditor->IsEmptyNode(curNode, &isEmptyTextNode)) && isEmptyTextNode)))
       continue;
 
     // if it's a list item, or a list
     // inside a list, forget any "current" div, and instead put divs inside
     // the appropriate block (td, li, etc)
     if ( nsHTMLEditUtils::IsListItem(curNode)
          || nsHTMLEditUtils::IsList(curNode))
     {