Bug 1391165 - part2: TextEditRules::CollapseSelectionToTrailingBRIfNeeded() should use nsINode::GetNextSibling() for retrieving next child of a node r?smaug
nsINode::GetChildAt() is too expensive if it's used for next sibling of a node.
This patch makes it use nsINode::GetNextSibling() instead.
MozReview-Commit-ID: CAC7gFNo77w
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -513,17 +513,17 @@ TextEditRules::CollapseSelectionToTraili
nsINode* root = mTextEditor->GetRoot();
if (NS_WARN_IF(!root)) {
return NS_ERROR_NULL_POINTER;
}
if (parentNode != root) {
return NS_OK;
}
- nsINode* nextNode = parentNode->GetChildAt(parentOffset + 1);
+ nsINode* nextNode = selNode->GetNextSibling();
if (nextNode && TextEditUtils::IsMozBR(nextNode)) {
rv = aSelection->Collapse(parentNode, parentOffset + 1);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
}
return NS_OK;
}