From 29f303fd85fbca6bc811463f398bf915c8862f60 Mon Sep 17 00:00:00 2001 From: btian Date: Fri, 13 Oct 2017 12:03:44 +0800 Subject: [PATCH] Bug 1406395 - P1: Backout changeset 7df868e0e356 (bug 1384661 part 3). r=smaug --- dom/base/nsINode.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 412bcfa0560b..e9531a070cb6 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -409,11 +409,7 @@ nsINode::ChildNodes() { nsSlots* slots = Slots(); if (!slots->mChildNodes) { - // Check |!IsElement()| first to catch the common case - // without virtual call |IsNodeOfType| - slots->mChildNodes = !IsElement() && IsNodeOfType(nsINode::eATTRIBUTE) ? - new nsAttrChildContentList(this) : - new nsParentNodeChildContentList(this); + slots->mChildNodes = new nsAttrChildContentList(this); } return slots->mChildNodes; @@ -1556,8 +1552,8 @@ nsresult nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify, nsAttrAndChildArray& aChildArray) { - MOZ_ASSERT(!aKid->GetParentNode(), "Inserting node that already has parent"); - MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE)); + NS_PRECONDITION(!aKid->GetParentNode(), + "Inserting node that already has parent"); // The id-handling code, and in the future possibly other code, need to // react to unexpected attribute changes. @@ -1601,14 +1597,6 @@ nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex, mFirstChild = aKid; } - // Invalidate cached array of child nodes - nsSlots* slots = GetExistingSlots(); - if (slots && slots->mChildNodes) { - auto childNodes = - static_cast(slots->mChildNodes.get()); - childNodes->InvalidateCache(); - } - nsIContent* parent = IsNodeOfType(eDOCUMENT) ? nullptr : static_cast(this); @@ -1914,10 +1902,9 @@ nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify, // nsIDocument::GetRootElement() calls until *after* it has removed aKid from // aChildArray. Any calls before then could potentially restore a stale // value for our cached root element, per note in nsDocument::RemoveChildAt(). - MOZ_ASSERT(aKid && aKid->GetParentNode() == this && - aKid == GetChildAt(aIndex) && - IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid"); - MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE)); + NS_PRECONDITION(aKid && aKid->GetParentNode() == this && + aKid == GetChildAt(aIndex) && + IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid"); nsMutationGuard::DidMutate(); mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify); @@ -1930,14 +1917,6 @@ nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify, aChildArray.RemoveChildAt(aIndex); - // Invalidate cached array of child nodes - nsSlots* slots = GetExistingSlots(); - if (slots && slots->mChildNodes) { - auto childNodes = - static_cast(slots->mChildNodes.get()); - childNodes->InvalidateCache(); - } - if (aNotify) { nsNodeUtils::ContentRemoved(this, aKid, previousSibling); }