Bug 1406395 - P1: Backout changeset 7df868e0e356 (bug 1384661 part 3). r=smaug
authorbtian <btian@mozilla.com>
Fri, 13 Oct 2017 12:03:44 +0800
changeset 386967 0ac3f44070ff6419f04a494018bcc15781fcf4b6
parent 386966 ec3abaf3421e48bc1bb8f7c720075d5fa486e7a6
child 386968 329296ede1cbcbd4969d4c185180f329fe7a4fd5
push id32705
push userryanvm@gmail.com
push dateThu, 19 Oct 2017 01:01:49 +0000
treeherdermozilla-central@a21099ce055f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1406395, 1384661
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1406395 - P1: Backout changeset 7df868e0e356 (bug 1384661 part 3). r=smaug
dom/base/nsINode.cpp
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -404,21 +404,17 @@ nsINode::GetSelectionRootContent(nsIPres
   return content;
 }
 
 nsINodeList*
 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;
 }
 
 void
 nsINode::GetTextContentInternal(nsAString& aTextContent, OOMReporter& aError)
 {
@@ -1551,18 +1547,18 @@ CheckForOutdatedParent(nsINode* aParent,
     }
   }
 }
 
 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.
   nsMutationGuard::DidMutate();
 
   // Do this before checking the child-count since this could cause mutations
   nsIDocument* doc = GetUncomposedDoc();
   mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
@@ -1596,24 +1592,16 @@ nsINode::doInsertChildAt(nsIContent* aKi
   bool isAppend = (aIndex == childCount);
 
   nsresult rv = aChildArray.InsertChildAt(aKid, aIndex);
   NS_ENSURE_SUCCESS(rv, rv);
   if (aIndex == 0) {
     mFirstChild = aKid;
   }
 
-  // Invalidate cached array of child nodes
-  nsSlots* slots = GetExistingSlots();
-  if (slots && slots->mChildNodes) {
-    auto childNodes =
-      static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get());
-    childNodes->InvalidateCache();
-  }
-
   nsIContent* parent =
     IsNodeOfType(eDOCUMENT) ? nullptr : static_cast<nsIContent*>(this);
 
   rv = aKid->BindToTree(doc, parent,
                         parent ? parent->GetBindingParent() : nullptr,
                         true);
   if (NS_FAILED(rv)) {
     if (GetFirstChild() == aKid) {
@@ -1909,40 +1897,31 @@ nsINode::Append(const Sequence<OwningNod
 void
 nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify,
                          nsIContent* aKid, nsAttrAndChildArray& aChildArray)
 {
   // NOTE: This function must not trigger any calls to
   // 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);
 
   nsIContent* previousSibling = aKid->GetPreviousSibling();
 
   if (GetFirstChild() == aKid) {
     mFirstChild = aKid->GetNextSibling();
   }
 
   aChildArray.RemoveChildAt(aIndex);
 
-  // Invalidate cached array of child nodes
-  nsSlots* slots = GetExistingSlots();
-  if (slots && slots->mChildNodes) {
-    auto childNodes =
-      static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get());
-    childNodes->InvalidateCache();
-  }
-
   if (aNotify) {
     nsNodeUtils::ContentRemoved(this, aKid, previousSibling);
   }
 
   aKid->UnbindFromTree();
 }
 
 // When replacing, aRefChild is the content being replaced; when