Bug 796839 - Part 2 - Don't set inline properties on empty text nodes; r=roc

This part, similar to the previous one, ensures that we skip empty text
nodes when setting inline properties.  Previously we were implicitly
getting this behavior becasue we were calling IsEditable, but we need to
be explicit about this.
This commit is contained in:
Ehsan Akhgari 2012-10-04 20:37:45 -04:00
parent 9d564e7cf4
commit 9fe0740025

View File

@ -54,6 +54,15 @@ class nsISupports;
using namespace mozilla;
static bool
IsEmptyTextNode(nsHTMLEditor* aThis, nsINode* aNode)
{
bool isEmptyTextNode = false;
return nsEditor::IsTextNode(aNode) &&
NS_SUCCEEDED(aThis->IsEmptyNode(aNode, &isEmptyTextNode)) &&
isEmptyTextNode;
}
NS_IMETHODIMP nsHTMLEditor::AddDefaultProperty(nsIAtom *aProperty,
const nsAString & aAttribute,
const nsAString & aValue)
@ -424,7 +433,7 @@ nsHTMLEditor::SetInlinePropertyOnNodeImpl(nsIContent* aNode,
for (nsIContent* child = aNode->GetFirstChild();
child;
child = child->GetNextSibling()) {
if (IsEditable(child)) {
if (IsEditable(child) && !IsEmptyTextNode(this, child)) {
arrayOfNodes.AppendObject(child);
}
}