Bug 1391315 - Avoid using nsINode::GetChildAt() in TextEditRules::DocumentIsEmpty(); r=masayuki

This method will become a lot slower when bug 651120 lands.
This commit is contained in:
Ehsan Akhgari 2017-08-17 13:07:59 -04:00
parent 32cc925261
commit 950a791753

View File

@ -372,11 +372,10 @@ TextEditRules::DocumentIsEmpty()
return true;
}
uint32_t childCount = rootElement->GetChildCount();
for (uint32_t i = 0; i < childCount; i++) {
nsINode* node = rootElement->GetChildAt(i);
if (!EditorBase::IsTextNode(node) ||
node->Length()) {
for (nsIContent* child = rootElement->GetFirstChild();
child; child = child->GetNextSibling()) {
if (!EditorBase::IsTextNode(child) ||
child->Length()) {
return false;
}
}