Bug 700981 part 4. Add a fast-path to IsAllowedAsChild for the case of a child that has no kids. r=smaug

This commit is contained in:
Boris Zbarsky 2012-03-22 00:10:51 -04:00
Родитель 3e93284311
Коммит 3c1d835acc
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -4030,7 +4030,14 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent,
"Nodes that are not documents, document fragments or "
"elements can't be parents!");
if (aParent && nsContentUtils::ContentIsDescendantOf(aParent, aNewChild)) {
// A common case is that aNewChild has no kids, in which case
// aParent can't be a descendant of aNewChild unless they're
// actually equal to each other. Fast-path that case, since aParent
// could be pretty deep in the DOM tree.
if (aParent &&
(aNewChild == aParent ||
(aNewChild->GetFirstChild() &&
nsContentUtils::ContentIsDescendantOf(aParent, aNewChild)))) {
return false;
}