Browse Source

Some prerequisites for ReplaceChildren

Frank-Rainer Grahl 3 months ago
parent
commit
67ee307249
38 changed files with 9517 additions and 0 deletions
  1. 823 0
      mozilla-release/patches/1395973-60a1.patch
  2. 2205 0
      mozilla-release/patches/1425321-1-59a1.patch
  3. 1008 0
      mozilla-release/patches/1425321-2-59a1.patch
  4. 30 0
      mozilla-release/patches/1425321-3-59a1.patch
  5. 64 0
      mozilla-release/patches/1425440-01-59a1.patch
  6. 37 0
      mozilla-release/patches/1425440-02-59a1.patch
  7. 36 0
      mozilla-release/patches/1425440-03-59a1.patch
  8. 39 0
      mozilla-release/patches/1425440-04-59a1.patch
  9. 35 0
      mozilla-release/patches/1425440-05-59a1.patch
  10. 59 0
      mozilla-release/patches/1425440-06-59a1.patch
  11. 40 0
      mozilla-release/patches/1425440-07-59a1.patch
  12. 35 0
      mozilla-release/patches/1425440-08-59a1.patch
  13. 34 0
      mozilla-release/patches/1425440-09-59a1.patch
  14. 71 0
      mozilla-release/patches/1425440-10-59a1.patch
  15. 81 0
      mozilla-release/patches/1425440-11-59a1.patch
  16. 36 0
      mozilla-release/patches/1425440-12-59a1.patch
  17. 36 0
      mozilla-release/patches/1425440-13-59a1.patch
  18. 168 0
      mozilla-release/patches/1425440-14-59a1.patch
  19. 78 0
      mozilla-release/patches/1425440-15-59a1.patch
  20. 75 0
      mozilla-release/patches/1425440-16-59a1.patch
  21. 110 0
      mozilla-release/patches/1425440-17-59a1.patch
  22. 97 0
      mozilla-release/patches/1425440-18-59a1.patch
  23. 210 0
      mozilla-release/patches/1425440-19-59a1.patch
  24. 676 0
      mozilla-release/patches/1425440-20-59a1.patch
  25. 53 0
      mozilla-release/patches/1425440-21-59a1.patch
  26. 33 0
      mozilla-release/patches/1425440-22-59a1.patch
  27. 31 0
      mozilla-release/patches/1425440-23-59a1.patch
  28. 38 0
      mozilla-release/patches/1425440-24-59a1.patch
  29. 147 0
      mozilla-release/patches/1425440-25-59a1.patch
  30. 102 0
      mozilla-release/patches/1425440-26-59a1.patch
  31. 34 0
      mozilla-release/patches/1425440-27-59a1.patch
  32. 75 0
      mozilla-release/patches/1425440-28-59a1.patch
  33. 56 0
      mozilla-release/patches/1425440-29-59a1.patch
  34. 113 0
      mozilla-release/patches/1425440-30-59a1.patch
  35. 30 0
      mozilla-release/patches/1430516-59a1.patch
  36. 2642 0
      mozilla-release/patches/1430997-1-60a1.patch
  37. 43 0
      mozilla-release/patches/1430997-2-60a1.patch
  38. 37 0
      mozilla-release/patches/series

+ 823 - 0
mozilla-release/patches/1395973-60a1.patch

@@ -0,0 +1,823 @@
+# HG changeset patch
+# User Catalin Badea <catalin.badea392@gmail.com>
+# Date 1512404628 0
+# Node ID 1d057e2c36fe0fddb020243ea2acf7f062be7d87
+# Parent  f24084a34a27a8adf0db390d75c9f012b0021246
+Bug 1395973 - Remove index cache from nsContentIterator. r=masayuki
+
+nsContentIterator used to maintain a stack of indices so that when it
+finished iterating through a subtree it would know the position of the
+next node. Maintaining this stack is expensive and unnecessary since we
+have fast getters for next and previous siblings.
+
+
+diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp
+--- a/dom/base/nsContentIterator.cpp
++++ b/dom/base/nsContentIterator.cpp
+@@ -124,72 +124,39 @@ protected:
+    * - aStartOffset and aEndOffset are valid for its container.
+    * - The start point and the end point are in document order.
+    */
+   nsresult InitInternal(const RawRangeBoundary& aStart,
+                         const RawRangeBoundary& aEnd);
+ 
+   // Recursively get the deepest first/last child of aRoot.  This will return
+   // aRoot itself if it has no children.
+-  nsINode* GetDeepFirstChild(nsINode* aRoot,
+-                             nsTArray<int32_t>* aIndexes = nullptr);
+-  nsIContent* GetDeepFirstChild(nsIContent* aRoot,
+-                                nsTArray<int32_t>* aIndexes = nullptr);
+-  nsINode* GetDeepLastChild(nsINode* aRoot,
+-                            nsTArray<int32_t>* aIndexes = nullptr);
+-  nsIContent* GetDeepLastChild(nsIContent* aRoot,
+-                               nsTArray<int32_t>* aIndexes = nullptr);
++  nsINode* GetDeepFirstChild(nsINode* aRoot);
++  nsIContent* GetDeepFirstChild(nsIContent* aRoot);
++  nsINode* GetDeepLastChild(nsINode* aRoot);
++  nsIContent* GetDeepLastChild(nsIContent* aRoot);
+ 
+   // Get the next/previous sibling of aNode, or its parent's, or grandparent's,
+   // etc.  Returns null if aNode and all its ancestors have no next/previous
+   // sibling.
+-  nsIContent* GetNextSibling(nsINode* aNode,
+-                             nsTArray<int32_t>* aIndexes = nullptr);
+-  nsIContent* GetPrevSibling(nsINode* aNode,
+-                             nsTArray<int32_t>* aIndexes = nullptr);
++  nsIContent* GetNextSibling(nsINode* aNode);
++  nsIContent* GetPrevSibling(nsINode* aNode);
+ 
+-  nsINode* NextNode(nsINode* aNode, nsTArray<int32_t>* aIndexes = nullptr);
+-  nsINode* PrevNode(nsINode* aNode, nsTArray<int32_t>* aIndexes = nullptr);
+-
+-  // WARNING: This function is expensive
+-  nsresult RebuildIndexStack();
++  nsINode* NextNode(nsINode* aNode);
++  nsINode* PrevNode(nsINode* aNode);
+ 
+   void MakeEmpty();
+ 
+   virtual void LastRelease();
+ 
+   nsCOMPtr<nsINode> mCurNode;
+   nsCOMPtr<nsINode> mFirst;
+   nsCOMPtr<nsINode> mLast;
+   nsCOMPtr<nsINode> mCommonParent;
+ 
+-  // used by nsContentIterator to cache indices
+-  AutoTArray<int32_t, 8> mIndexes;
+-
+-  // used by nsSubtreeIterator to cache indices.  Why put them in the base
+-  // class?  Because otherwise I have to duplicate the routines GetNextSibling
+-  // etc across both classes, with slight variations for caching.  Or
+-  // alternately, create a base class for the cache itself and have all the
+-  // cache manipulation go through a vptr.  I think this is the best space and
+-  // speed combo, even though it's ugly.
+-  int32_t mCachedIndex;
+-  // another note about mCachedIndex: why should the subtree iterator use a
+-  // trivial cached index instead of the mre robust array of indicies (which is
+-  // what the basic content iterator uses)?  The reason is that subtree
+-  // iterators do not do much transitioning between parents and children.  They
+-  // tend to stay at the same level.  In fact, you can prove (though I won't
+-  // attempt it here) that they change levels at most n+m times, where n is the
+-  // height of the parent hierarchy from the range start to the common
+-  // ancestor, and m is the the height of the parent hierarchy from the range
+-  // end to the common ancestor.  If we used the index array, we would pay the
+-  // price up front for n, and then pay the cost for m on the fly later on.
+-  // With the simple cache, we only "pay as we go".  Either way, we call
+-  // ComputeIndexOf() once for each change of level in the hierarchy.  Since
+-  // a trivial index is much simpler, we use it for the subtree iterator.
+-
+   bool mIsDone;
+   bool mPre;
+ 
+ private:
+ 
+   // no copies or assigns  FIX ME
+   nsContentIterator(const nsContentIterator&);
+   nsContentIterator& operator=(const nsContentIterator&);
+@@ -245,20 +212,19 @@ nsContentIterator::LastRelease()
+   mLast = nullptr;
+   mCommonParent = nullptr;
+ }
+ 
+ /******************************************************
+  * constructor/destructor
+  ******************************************************/
+ 
+-nsContentIterator::nsContentIterator(bool aPre) :
+-  // don't need to explicitly initialize |nsCOMPtr|s, they will automatically
+-  // be nullptr
+-  mCachedIndex(0), mIsDone(false), mPre(aPre)
++nsContentIterator::nsContentIterator(bool aPre)
++  : mIsDone(false)
++  , mPre(aPre)
+ {
+ }
+ 
+ 
+ nsContentIterator::~nsContentIterator()
+ {
+ }
+ 
+@@ -271,31 +237,29 @@ nsContentIterator::~nsContentIterator()
+ nsresult
+ nsContentIterator::Init(nsINode* aRoot)
+ {
+   if (NS_WARN_IF(!aRoot)) {
+     return NS_ERROR_NULL_POINTER;
+   }
+ 
+   mIsDone = false;
+-  mIndexes.Clear();
+ 
+   if (mPre) {
+     mFirst = aRoot;
+     mLast  = GetDeepLastChild(aRoot);
+     NS_WARNING_ASSERTION(mLast, "GetDeepLastChild returned null");
+   } else {
+     mFirst = GetDeepFirstChild(aRoot);
+     NS_WARNING_ASSERTION(mFirst, "GetDeepFirstChild returned null");
+     mLast  = aRoot;
+   }
+ 
+   mCommonParent = aRoot;
+   mCurNode = mFirst;
+-  RebuildIndexStack();
+   return NS_OK;
+ }
+ 
+ nsresult
+ nsContentIterator::Init(nsIDOMRange* aDOMRange)
+ {
+   mIsDone = false;
+ 
+@@ -367,18 +331,16 @@ nsContentIterator::InitInternal(const Ra
+   }
+ 
+   // Handle ranges within a single character data node.
+   if (startIsData && aStart.Container() == aEnd.Container()) {
+     mFirst = aStart.Container()->AsContent();
+     mLast = mFirst;
+     mCurNode = mFirst;
+ 
+-    DebugOnly<nsresult> rv = RebuildIndexStack();
+-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RebuildIndexStack failed");
+     return NS_OK;
+   }
+ 
+   // Find first node in range.
+ 
+   nsIContent* cChild = nullptr;
+ 
+   // Try to get the child at our starting point. This might return null if
+@@ -521,446 +483,201 @@ nsContentIterator::InitInternal(const Ra
+   if (!mFirst || !mLast) {
+     mFirst = nullptr;
+     mLast  = nullptr;
+   }
+ 
+   mCurNode = mFirst;
+   mIsDone  = !mCurNode;
+ 
+-  if (!mCurNode) {
+-    mIndexes.Clear();
+-  } else {
+-    DebugOnly<nsresult> rv = RebuildIndexStack();
+-    NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "RebuildIndexStack failed");
+-  }
+-
+-  return NS_OK;
+-}
+-
+-
+-/******************************************************
+- * Helper routines
+- ******************************************************/
+-// WARNING: This function is expensive
+-nsresult
+-nsContentIterator::RebuildIndexStack()
+-{
+-  // Make sure we start at the right indexes on the stack!  Build array up
+-  // to common parent of start and end.  Perhaps it's too many entries, but
+-  // that's far better than too few.
+-  nsINode* parent;
+-  nsINode* current;
+-
+-  mIndexes.Clear();
+-  current = mCurNode;
+-  if (!current) {
+-    return NS_OK;
+-  }
+-
+-  while (current != mCommonParent) {
+-    parent = current->GetParentNode();
+-
+-    if (NS_WARN_IF(!parent)) {
+-      return NS_ERROR_FAILURE;
+-    }
+-
+-    mIndexes.InsertElementAt(0, parent->ComputeIndexOf(current));
+-
+-    current = parent;
+-  }
+-
+   return NS_OK;
+ }
+ 
+ void
+ nsContentIterator::MakeEmpty()
+ {
+   mCurNode      = nullptr;
+   mFirst        = nullptr;
+   mLast         = nullptr;
+   mCommonParent = nullptr;
+   mIsDone       = true;
+-  mIndexes.Clear();
+ }
+ 
+ nsINode*
+-nsContentIterator::GetDeepFirstChild(nsINode* aRoot,
+-                                     nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetDeepFirstChild(nsINode* aRoot)
+ {
+   if (NS_WARN_IF(!aRoot) || !aRoot->HasChildren()) {
+     return aRoot;
+   }
+-  // We can't pass aRoot itself to the full GetDeepFirstChild, because that
+-  // will only take nsIContent and aRoot might be a document.  Pass aRoot's
+-  // child, but be sure to preserve aIndexes.
+-  if (aIndexes) {
+-    aIndexes->AppendElement(0);
+-  }
+-  return GetDeepFirstChild(aRoot->GetFirstChild(), aIndexes);
++
++  return GetDeepFirstChild(aRoot->GetFirstChild());
+ }
+ 
+ nsIContent*
+-nsContentIterator::GetDeepFirstChild(nsIContent* aRoot,
+-                                     nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetDeepFirstChild(nsIContent* aRoot)
+ {
+   if (NS_WARN_IF(!aRoot)) {
+     return nullptr;
+   }
+ 
+   nsIContent* node = aRoot;
+   nsIContent* child = node->GetFirstChild();
+ 
+   while (child) {
+-    if (aIndexes) {
+-      // Add this node to the stack of indexes
+-      aIndexes->AppendElement(0);
+-    }
+     node = child;
+     child = node->GetFirstChild();
+   }
+ 
+   return node;
+ }
+ 
+ nsINode*
+-nsContentIterator::GetDeepLastChild(nsINode* aRoot,
+-                                    nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetDeepLastChild(nsINode* aRoot)
+ {
+   if (NS_WARN_IF(!aRoot) || !aRoot->HasChildren()) {
+     return aRoot;
+   }
+-  // We can't pass aRoot itself to the full GetDeepLastChild, because that will
+-  // only take nsIContent and aRoot might be a document.  Pass aRoot's child,
+-  // but be sure to preserve aIndexes.
+-  if (aIndexes) {
+-    aIndexes->AppendElement(aRoot->GetChildCount() - 1);
+-  }
+-  return GetDeepLastChild(aRoot->GetLastChild(), aIndexes);
++
++  return GetDeepLastChild(aRoot->GetLastChild());
+ }
+ 
+ nsIContent*
+-nsContentIterator::GetDeepLastChild(nsIContent* aRoot,
+-                                    nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetDeepLastChild(nsIContent* aRoot)
+ {
+   if (NS_WARN_IF(!aRoot)) {
+     return nullptr;
+   }
+ 
+   nsIContent* node = aRoot;
+-  int32_t numChildren = node->GetChildCount();
+-
+-  while (numChildren) {
+-    nsIContent* child = node->GetChildAt_Deprecated(--numChildren);
+-
+-    if (aIndexes) {
+-      // Add this node to the stack of indexes
+-      aIndexes->AppendElement(numChildren);
+-    }
+-    numChildren = child->GetChildCount();
++  while (node->HasChildren()) {
++    nsIContent* child = node->GetLastChild();
+     node = child;
+   }
+-
+   return node;
+ }
+ 
+ // Get the next sibling, or parent's next sibling, or grandpa's next sibling...
+ nsIContent*
+-nsContentIterator::GetNextSibling(nsINode* aNode,
+-                                  nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetNextSibling(nsINode* aNode)
+ {
+   if (NS_WARN_IF(!aNode)) {
+     return nullptr;
+   }
+ 
++  if (aNode->GetNextSibling()) {
++    return aNode->GetNextSibling();
++  }
++
+   nsINode* parent = aNode->GetParentNode();
+   if (NS_WARN_IF(!parent)) {
+     return nullptr;
+   }
+ 
+-  int32_t indx = 0;
+-
+-  NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
+-               "ContentIterator stack underflow");
+-  if (aIndexes && !aIndexes->IsEmpty()) {
+-    // use the last entry on the Indexes array for the current index
+-    indx = (*aIndexes)[aIndexes->Length()-1];
+-  } else {
+-    indx = mCachedIndex;
+-  }
+-  NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+-
+-  // reverify that the index of the current node hasn't changed.
+-  // not super cheap, but a lot cheaper than ComputeIndexOf(), and still
+-  // O(1). ignore result this time - the index may now be out of range.
+-  nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+-  if (sib != aNode) {
+-    // someone changed our index - find the new index the painful way
+-    indx = parent->ComputeIndexOf(aNode);
+-    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
++  // XXX This is a hack to preserve previous behaviour: This should be fixed
++  // in bug 1404916. If we were positioned on anonymous content, move to
++  // the first child of our parent.
++  if (parent->GetLastChild() && parent->GetLastChild() != aNode) {
++    return parent->GetFirstChild();
+   }
+ 
+-  // indx is now canonically correct
+-  if ((sib = parent->GetChildAt_Deprecated(++indx))) {
+-    // update index cache
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+-    } else {
+-      mCachedIndex = indx;
+-    }
+-  } else {
+-    if (parent != mCommonParent) {
+-      if (aIndexes) {
+-        // pop node off the stack, go up one level and return parent or fail.
+-        // Don't leave the index empty, especially if we're
+-        // returning nullptr.  This confuses other parts of the code.
+-        if (aIndexes->Length() > 1) {
+-          aIndexes->RemoveElementAt(aIndexes->Length()-1);
+-        }
+-      }
+-    }
+-
+-    // ok to leave cache out of date here if parent == mCommonParent?
+-    sib = GetNextSibling(parent, aIndexes);
+-  }
+-
+-  return sib;
++  return GetNextSibling(parent);
+ }
+ 
+ // Get the prev sibling, or parent's prev sibling, or grandpa's prev sibling...
+ nsIContent*
+-nsContentIterator::GetPrevSibling(nsINode* aNode,
+-                                  nsTArray<int32_t>* aIndexes)
++nsContentIterator::GetPrevSibling(nsINode* aNode)
+ {
+   if (NS_WARN_IF(!aNode)) {
+     return nullptr;
+   }
+ 
++  if (aNode->GetPreviousSibling()) {
++    return aNode->GetPreviousSibling();
++  }
++
+   nsINode* parent = aNode->GetParentNode();
+   if (NS_WARN_IF(!parent)) {
+     return nullptr;
+   }
+ 
+-  int32_t indx = 0;
+-
+-  NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
+-               "ContentIterator stack underflow");
+-  if (aIndexes && !aIndexes->IsEmpty()) {
+-    // use the last entry on the Indexes array for the current index
+-    indx = (*aIndexes)[aIndexes->Length()-1];
+-  } else {
+-    indx = mCachedIndex;
++  // XXX This is a hack to preserve previous behaviour: This should be fixed
++  // in bug 1404916. If we were positioned on anonymous content, move to
++  // the last child of our parent.
++  if (parent->GetFirstChild() && parent->GetFirstChild() != aNode) {
++    return parent->GetLastChild();
+   }
+ 
+-  // reverify that the index of the current node hasn't changed
+-  // ignore result this time - the index may now be out of range.
+-  nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+-  if (sib != aNode) {
+-    // someone changed our index - find the new index the painful way
+-    indx = parent->ComputeIndexOf(aNode);
+-    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+-  }
+-
+-  // indx is now canonically correct
+-  if (indx > 0 && (sib = parent->GetChildAt_Deprecated(--indx))) {
+-    // update index cache
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+-    } else {
+-      mCachedIndex = indx;
+-    }
+-  } else if (parent != mCommonParent) {
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      // pop node off the stack, go up one level and try again.
+-      aIndexes->RemoveElementAt(aIndexes->Length()-1);
+-    }
+-    return GetPrevSibling(parent, aIndexes);
+-  }
+-
+-  return sib;
++  return GetPrevSibling(parent);
+ }
+ 
+ nsINode*
+-nsContentIterator::NextNode(nsINode* aNode, nsTArray<int32_t>* aIndexes)
++nsContentIterator::NextNode(nsINode* aNode)
+ {
+   nsINode* node = aNode;
+ 
+   // if we are a Pre-order iterator, use pre-order
+   if (mPre) {
+     // if it has children then next node is first child
+     if (node->HasChildren()) {
+       nsIContent* firstChild = node->GetFirstChild();
+       MOZ_ASSERT(firstChild);
+ 
+-      // update cache
+-      if (aIndexes) {
+-        // push an entry on the index stack
+-        aIndexes->AppendElement(0);
+-      } else {
+-        mCachedIndex = 0;
+-      }
+-
+       return firstChild;
+     }
+ 
+     // else next sibling is next
+-    return GetNextSibling(node, aIndexes);
++    return GetNextSibling(node);
+   }
+ 
+   // post-order
+   nsINode* parent = node->GetParentNode();
+   if (NS_WARN_IF(!parent)) {
+     MOZ_ASSERT(parent, "The node is the root node but not the last node");
+     mIsDone = true;
+     return node;
+   }
+-  nsIContent* sibling = nullptr;
+-  int32_t indx = 0;
+ 
+-  // get the cached index
+-  NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
+-               "ContentIterator stack underflow");
+-  if (aIndexes && !aIndexes->IsEmpty()) {
+-    // use the last entry on the Indexes array for the current index
+-    indx = (*aIndexes)[aIndexes->Length()-1];
+-  } else {
+-    indx = mCachedIndex;
+-  }
+-
+-  // reverify that the index of the current node hasn't changed.  not super
+-  // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1).  ignore
+-  // result this time - the index may now be out of range.
+-  if (indx >= 0) {
+-    sibling = parent->GetChildAt_Deprecated(indx);
+-  }
+-  if (sibling != node) {
+-    // someone changed our index - find the new index the painful way
+-    indx = parent->ComputeIndexOf(node);
+-    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+-  }
+-
+-  // indx is now canonically correct
+-  sibling = parent->GetChildAt_Deprecated(++indx);
++  nsIContent* sibling = node->GetNextSibling();
+   if (sibling) {
+-    // update cache
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      // replace an entry on the index stack
+-      aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+-    } else {
+-      mCachedIndex = indx;
+-    }
+-
+     // next node is sibling's "deep left" child
+-    return GetDeepFirstChild(sibling, aIndexes);
+-  }
+-
+-  // else it's the parent, update cache
+-  if (aIndexes) {
+-    // Pop an entry off the index stack.  Don't leave the index empty,
+-    // especially if we're returning nullptr.  This confuses other parts of the
+-    // code.
+-    if (aIndexes->Length() > 1) {
+-      aIndexes->RemoveElementAt(aIndexes->Length()-1);
+-    }
+-  } else {
+-    // this might be wrong, but we are better off guessing
+-    mCachedIndex = 0;
++    return GetDeepFirstChild(sibling);
+   }
+ 
+   return parent;
+ }
+ 
+ nsINode*
+-nsContentIterator::PrevNode(nsINode* aNode, nsTArray<int32_t>* aIndexes)
++nsContentIterator::PrevNode(nsINode* aNode)
+ {
+   nsINode* node = aNode;
+ 
+   // if we are a Pre-order iterator, use pre-order
+   if (mPre) {
+     nsINode* parent = node->GetParentNode();
+     if (NS_WARN_IF(!parent)) {
+       MOZ_ASSERT(parent, "The node is the root node but not the first node");
+       mIsDone = true;
+       return aNode;
+     }
+-    nsIContent* sibling = nullptr;
+-    int32_t indx = 0;
+ 
+-    // get the cached index
+-    NS_ASSERTION(!aIndexes || !aIndexes->IsEmpty(),
+-                 "ContentIterator stack underflow");
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      // use the last entry on the Indexes array for the current index
+-      indx = (*aIndexes)[aIndexes->Length()-1];
+-    } else {
+-      indx = mCachedIndex;
+-    }
+-
+-    // reverify that the index of the current node hasn't changed.  not super
+-    // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1).
+-    // ignore result this time - the index may now be out of range.
+-    if (indx >= 0) {
+-      sibling = parent->GetChildAt_Deprecated(indx);
+-      NS_WARNING_ASSERTION(sibling, "GetChildAt_Deprecated returned null");
++    nsIContent* sibling = node->GetPreviousSibling();
++    if (sibling) {
++      return GetDeepLastChild(sibling);
+     }
+ 
+-    if (sibling != node) {
+-      // someone changed our index - find the new index the painful way
+-      indx = parent->ComputeIndexOf(node);
+-      NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+-    }
+-
+-    // indx is now canonically correct
+-    if (indx && (sibling = parent->GetChildAt_Deprecated(--indx))) {
+-      // update cache
+-      if (aIndexes && !aIndexes->IsEmpty()) {
+-        // replace an entry on the index stack
+-        aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+-      } else {
+-        mCachedIndex = indx;
+-      }
+-
+-      // prev node is sibling's "deep right" child
+-      return GetDeepLastChild(sibling, aIndexes);
+-    }
+-
+-    // else it's the parent, update cache
+-    if (aIndexes && !aIndexes->IsEmpty()) {
+-      // pop an entry off the index stack
+-      aIndexes->RemoveElementAt(aIndexes->Length()-1);
+-    } else {
+-      // this might be wrong, but we are better off guessing
+-      mCachedIndex = 0;
+-    }
+     return parent;
+   }
+ 
+   // post-order
+-  int32_t numChildren = node->GetChildCount();
+-  NS_WARNING_ASSERTION(numChildren >= 0, "no children");
+-
+-  // if it has children then prev node is last child
+-  if (numChildren) {
+-    nsIContent* lastChild = node->GetLastChild();
+-    NS_WARNING_ASSERTION(lastChild, "GetLastChild returned null");
+-    numChildren--;
+-
+-    // update cache
+-    if (aIndexes) {
+-      // push an entry on the index stack
+-      aIndexes->AppendElement(numChildren);
+-    } else {
+-      mCachedIndex = numChildren;
+-    }
+-
+-    return lastChild;
++  if (node->HasChildren()) {
++    return node->GetLastChild();
+   }
+ 
+   // else prev sibling is previous
+-  return GetPrevSibling(node, aIndexes);
++  return GetPrevSibling(node);
+ }
+ 
+ /******************************************************
+  * ContentIterator routines
+  ******************************************************/
+ 
+ void
+ nsContentIterator::First()
+@@ -998,61 +715,57 @@ nsContentIterator::Next()
+     return;
+   }
+ 
+   if (mCurNode == mLast) {
+     mIsDone = true;
+     return;
+   }
+ 
+-  mCurNode = NextNode(mCurNode, &mIndexes);
++  mCurNode = NextNode(mCurNode);
+ }
+ 
+ 
+ void
+ nsContentIterator::Prev()
+ {
+   if (NS_WARN_IF(mIsDone) || NS_WARN_IF(!mCurNode)) {
+     return;
+   }
+ 
+   if (mCurNode == mFirst) {
+     mIsDone = true;
+     return;
+   }
+ 
+-  mCurNode = PrevNode(mCurNode, &mIndexes);
++  mCurNode = PrevNode(mCurNode);
+ }
+ 
+ 
+ bool
+ nsContentIterator::IsDone()
+ {
+   return mIsDone;
+ }
+ 
+-
+ // Keeping arrays of indexes for the stack of nodes makes PositionAt
+ // interesting...
+ nsresult
+ nsContentIterator::PositionAt(nsINode* aCurNode)
+ {
+   if (NS_WARN_IF(!aCurNode)) {
+     return NS_ERROR_NULL_POINTER;
+   }
+ 
+-  nsINode* newCurNode = aCurNode;
+-  nsINode* tempNode = mCurNode;
+-
+-  mCurNode = aCurNode;
+   // take an early out if this doesn't actually change the position
+-  if (mCurNode == tempNode) {
+-    mIsDone = false;  // paranoia
++  if (mCurNode == aCurNode) {
++    mIsDone = false;
+     return NS_OK;
+   }
++  mCurNode = aCurNode;
+ 
+   // Check to see if the node falls within the traversal range.
+ 
+   RawRangeBoundary first(mFirst, 0);
+   RawRangeBoundary last(mLast, 0);
+ 
+   if (mFirst && mLast) {
+     if (mPre) {
+@@ -1086,92 +799,16 @@ nsContentIterator::PositionAt(nsINode* a
+   // for example, bug 327694.
+   if (mFirst != mCurNode && mLast != mCurNode &&
+       (NS_WARN_IF(!first.IsSet()) || NS_WARN_IF(!last.IsSet()) ||
+        NS_WARN_IF(!NodeIsInTraversalRange(mCurNode, mPre, first, last)))) {
+     mIsDone = true;
+     return NS_ERROR_FAILURE;
+   }
+ 
+-  // We can be at ANY node in the sequence.  Need to regenerate the array of
+-  // indexes back to the root or common parent!
+-  AutoTArray<nsINode*, 8>     oldParentStack;
+-  AutoTArray<int32_t, 8>      newIndexes;
+-
+-  // Get a list of the parents up to the root, then compare the new node with
+-  // entries in that array until we find a match (lowest common ancestor).  If
+-  // no match, use ComputeIndexOf, take the parent, and repeat.  This avoids
+-  // using ComputeIndexOf() N times on possibly large arrays.  We still end
+-  // up doing it a fair bit.  It's better to use Clone() if possible.
+-
+-  // we know the depth we're down (though we may not have started at the top).
+-  oldParentStack.SetCapacity(mIndexes.Length() + 1);
+-
+-  // We want to loop mIndexes.Length() + 1 times here, because we want to make
+-  // sure we include mCommonParent in the oldParentStack, for use in the next
+-  // for loop, and mIndexes only has entries for nodes from tempNode up through
+-  // an ancestor of tempNode that's a child of mCommonParent.
+-  for (int32_t i = mIndexes.Length() + 1; i > 0 && tempNode; i--) {
+-    // Insert at head since we're walking up
+-    oldParentStack.InsertElementAt(0, tempNode);
+-
+-    nsINode* parent = tempNode->GetParentNode();
+-
+-    if (NS_WARN_IF(!parent)) {
+-      // this node has no parent, and thus no index
+-      break;
+-    }
+-
+-    if (parent == mCurNode) {
+-      // The position was moved to a parent of the current position.  All we
+-      // need to do is drop some indexes.  Shortcut here.
+-      mIndexes.RemoveElementsAt(mIndexes.Length() - oldParentStack.Length(),
+-                                oldParentStack.Length());
+-      mIsDone = false;
+-      return NS_OK;
+-    }
+-    tempNode = parent;
+-  }
+-
+-  // Ok.  We have the array of old parents.  Look for a match.
+-  while (newCurNode) {
+-    nsINode* parent = newCurNode->GetParentNode();
+-
+-    if (NS_WARN_IF(!parent)) {
+-      // this node has no parent, and thus no index
+-      break;
+-    }
+-
+-    int32_t indx = parent->ComputeIndexOf(newCurNode);
+-    NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+-
+-    // insert at the head!
+-    newIndexes.InsertElementAt(0, indx);
+-
+-    // look to see if the parent is in the stack
+-    indx = oldParentStack.IndexOf(parent);
+-    if (indx >= 0) {
+-      // ok, the parent IS on the old stack!  Rework things.  We want
+-      // newIndexes to replace all nodes equal to or below the match.  Note
+-      // that index oldParentStack.Length() - 1 is the last node, which is one
+-      // BELOW the last index in the mIndexes stack.  In other words, we want
+-      // to remove elements starting at index (indx + 1).
+-      int32_t numToDrop = oldParentStack.Length() - (1 + indx);
+-      if (numToDrop > 0) {
+-        mIndexes.RemoveElementsAt(mIndexes.Length() - numToDrop, numToDrop);
+-      }
+-      mIndexes.AppendElements(newIndexes);
+-
+-      break;
+-    }
+-    newCurNode = parent;
+-  }
+-
+-  // phew!
+-
+   mIsDone = false;
+   return NS_OK;
+ }
+ 
+ nsINode*
+ nsContentIterator::GetCurrentNode()
+ {
+   if (mIsDone) {
+

+ 2205 - 0
mozilla-release/patches/1425321-1-59a1.patch

@@ -0,0 +1,2205 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514984394 -3600
+# Node ID 9de67942469381c88c87f7422b6a7116b9f20a14
+# Parent  a077f9ae88453e73c9680a8415f0dca01eb5a63c
+Bug 1425321 - Renaming nsINode::GetChildAt to GetChildAt_Deprecated, r=catalinb
+
+We want to deprecate nsINode::GetChildAt as the first step of removing DOM node
+child array storage. See bug 651120.
+
+diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp
+--- a/accessible/base/nsCoreUtils.cpp
++++ b/accessible/base/nsCoreUtils.cpp
+@@ -220,17 +220,17 @@ nsCoreUtils::GetDOMNodeFromDOMPoint(nsIN
+   if (aNode && aNode->IsElement()) {
+     uint32_t childCount = aNode->GetChildCount();
+     NS_ASSERTION(aOffset <= childCount, "Wrong offset of the DOM point!");
+ 
+     // The offset can be after last child of container node that means DOM point
+     // is placed immediately after the last child. In this case use the DOM node
+     // from the given DOM point is used as result node.
+     if (aOffset != childCount)
+-      return aNode->GetChildAt(aOffset);
++      return aNode->GetChildAt_Deprecated(aOffset);
+   }
+ 
+   return aNode;
+ }
+ 
+ bool
+ nsCoreUtils::IsAncestorOf(nsINode *aPossibleAncestorNode,
+                           nsINode *aPossibleDescendantNode,
+diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp
+--- a/accessible/generic/HyperTextAccessible.cpp
++++ b/accessible/generic/HyperTextAccessible.cpp
+@@ -237,17 +237,17 @@ HyperTextAccessible::DOMPointToOffset(ns
+     // findNode could be null if aNodeOffset == # of child nodes, which means
+     // one of two things:
+     // 1) there are no children, and the passed-in node is not mContent -- use
+     //    parentContent for the node to find
+     // 2) there are no children and the passed-in node is mContent, which means
+     //    we're an empty nsIAccessibleText
+     // 3) there are children and we're at the end of the children
+ 
+-    findNode = aNode->GetChildAt(aNodeOffset);
++    findNode = aNode->GetChildAt_Deprecated(aNodeOffset);
+     if (!findNode) {
+       if (aNodeOffset == 0) {
+         if (aNode == GetNode()) {
+           // Case #1: this accessible has no children and thus has empty text,
+           // we can only be at hypertext offset 0.
+           return 0;
+         }
+ 
+diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp
+--- a/dom/base/Attr.cpp
++++ b/dom/base/Attr.cpp
+@@ -303,17 +303,17 @@ Attr::IsNodeOfType(uint32_t aFlags) cons
+ 
+ uint32_t
+ Attr::GetChildCount() const
+ {
+   return 0;
+ }
+ 
+ nsIContent *
+-Attr::GetChildAt(uint32_t aIndex) const
++Attr::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return nullptr;
+ }
+ 
+ int32_t
+ Attr::IndexOf(const nsINode* aPossibleChild) const
+ {
+   return -1;
+diff --git a/dom/base/Attr.h b/dom/base/Attr.h
+--- a/dom/base/Attr.h
++++ b/dom/base/Attr.h
+@@ -60,17 +60,17 @@ public:
+   // nsIAttribute interface
+   void SetMap(nsDOMAttributeMap *aMap) override;
+   Element* GetElement() const;
+   nsresult SetOwnerDocument(nsIDocument* aDocument) override;
+ 
+   // nsINode interface
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual uint32_t GetChildCount() const override;
+-  virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
++  virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+   virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
+ 
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
+--- a/dom/base/FragmentOrElement.cpp
++++ b/dom/base/FragmentOrElement.cpp
+@@ -144,17 +144,17 @@ uint64_t nsMutationGuard::sGeneration = 
+ nsIContent*
+ nsIContent::FindFirstNonChromeOnlyAccessContent() const
+ {
+   // This handles also nested native anonymous content.
+   for (const nsIContent *content = this; content;
+        content = content->GetBindingParent()) {
+     if (!content->ChromeOnlyAccess()) {
+       // Oops, this function signature allows casting const to
+-      // non-const.  (Then again, so does GetChildAt(0)->GetParent().)
++      // non-const.  (Then again, so does GetChildAt_Deprecated(0)->GetParent().)
+       return const_cast<nsIContent*>(content);
+     }
+   }
+   return nullptr;
+ }
+ 
+ // https://dom.spec.whatwg.org/#dom-slotable-assignedslot
+ HTMLSlotElement*
+@@ -543,17 +543,17 @@ nsAttrChildContentList::Item(uint32_t aI
+ 
+   return CallQueryInterface(node, aReturn);
+ }
+ 
+ nsIContent*
+ nsAttrChildContentList::Item(uint32_t aIndex)
+ {
+   if (mNode) {
+-    return mNode->GetChildAt(aIndex);
++    return mNode->GetChildAt_Deprecated(aIndex);
+   }
+ 
+   return nullptr;
+ }
+ 
+ int32_t
+ nsAttrChildContentList::IndexOf(nsIContent* aContent)
+ {
+@@ -1159,17 +1159,17 @@ FragmentOrElement::InsertChildAt(nsICont
+ 
+   return doInsertChildAt(aKid, aIndex, aNotify, mAttrsAndChildren);
+ }
+ 
+ void
+ FragmentOrElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
+ {
+   nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
+-  NS_ASSERTION(oldKid == GetChildAt(aIndex), "Unexpected child in RemoveChildAt");
++  NS_ASSERTION(oldKid == GetChildAt_Deprecated(aIndex), "Unexpected child in RemoveChildAt");
+ 
+   if (oldKid) {
+     doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren);
+   }
+ }
+ 
+ void
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
+@@ -2118,17 +2118,17 @@ FragmentOrElement::AppendTextTo(nsAStrin
+ 
+ uint32_t
+ FragmentOrElement::GetChildCount() const
+ {
+   return mAttrsAndChildren.ChildCount();
+ }
+ 
+ nsIContent *
+-FragmentOrElement::GetChildAt(uint32_t aIndex) const
++FragmentOrElement::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return mAttrsAndChildren.GetSafeChildAt(aIndex);
+ }
+ 
+ int32_t
+ FragmentOrElement::IndexOf(const nsINode* aPossibleChild) const
+ {
+   return mAttrsAndChildren.IndexOfChild(aPossibleChild);
+diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
+--- a/dom/base/FragmentOrElement.h
++++ b/dom/base/FragmentOrElement.h
+@@ -113,17 +113,17 @@ public:
+   explicit FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
+ 
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ 
+   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
+ 
+   // nsINode interface methods
+   virtual uint32_t GetChildCount() const override;
+-  virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
++  virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override;
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+diff --git a/dom/base/RangeBoundary.h b/dom/base/RangeBoundary.h
+--- a/dom/base/RangeBoundary.h
++++ b/dom/base/RangeBoundary.h
+@@ -72,17 +72,17 @@ public:
+     , mRef(nullptr)
+     , mOffset(mozilla::Some(aOffset))
+   {
+     if (mParent && mParent->IsContainerNode()) {
+       // Find a reference node
+       if (aOffset == static_cast<int32_t>(aContainer->GetChildCount())) {
+         mRef = aContainer->GetLastChild();
+       } else if (aOffset != 0) {
+-        mRef = mParent->GetChildAt(aOffset - 1);
++        mRef = mParent->GetChildAt_Deprecated(aOffset - 1);
+       }
+ 
+       NS_WARNING_ASSERTION(mRef || aOffset == 0,
+                            "Constructing RangeBoundary with invalid value");
+     }
+ 
+     NS_WARNING_ASSERTION(!mRef || mRef->GetParentNode() == mParent,
+                          "Constructing RangeBoundary with invalid value");
+@@ -120,17 +120,17 @@ public:
+   {
+     if (!mParent || !mParent->IsContainerNode()) {
+       return nullptr;
+     }
+     if (!mRef) {
+       MOZ_ASSERT(Offset() == 0, "invalid RangeBoundary");
+       return mParent->GetFirstChild();
+     }
+-    MOZ_ASSERT(mParent->GetChildAt(Offset()) == mRef->GetNextSibling());
++    MOZ_ASSERT(mParent->GetChildAt_Deprecated(Offset()) == mRef->GetNextSibling());
+     return mRef->GetNextSibling();
+   }
+ 
+   /**
+    * GetNextSiblingOfChildOffset() returns next sibling of a child at offset.
+    * If this refers after the last child or the container cannot have children,
+    * this returns nullptr with warning.
+    */
+@@ -203,17 +203,17 @@ public:
+     mParent = aContainer;
+     if (mParent && mParent->IsContainerNode()) {
+       // Find a reference node
+       if (aOffset == static_cast<int32_t>(aContainer->GetChildCount())) {
+         mRef = aContainer->GetLastChild();
+       } else if (aOffset == 0) {
+         mRef = nullptr;
+       } else {
+-        mRef = mParent->GetChildAt(aOffset - 1);
++        mRef = mParent->GetChildAt_Deprecated(aOffset - 1);
+         MOZ_ASSERT(mRef);
+       }
+ 
+       NS_WARNING_ASSERTION(mRef || aOffset == 0,
+                            "Setting RangeBoundary to invalid value");
+     } else {
+       mRef = nullptr;
+     }
+diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp
+--- a/dom/base/Selection.cpp
++++ b/dom/base/Selection.cpp
+@@ -596,17 +596,17 @@ Selection::GetTableCellLocationFromRange
+ 
+   // Get the child content (the cell) pointed to by starting node of range
+   // We do minimal checking since GetTableSelectionType assures
+   //   us that this really is a table cell
+   nsCOMPtr<nsIContent> content = do_QueryInterface(aRange->GetStartContainer());
+   if (!content)
+     return NS_ERROR_FAILURE;
+ 
+-  nsCOMPtr<nsIContent> child = content->GetChildAt(aRange->StartOffset());
++  nsCOMPtr<nsIContent> child = content->GetChildAt_Deprecated(aRange->StartOffset());
+   if (!child)
+     return NS_ERROR_FAILURE;
+ 
+   // GetCellLayout depends on current frame, we need flush frame to get
+   // nsITableCellLayout
+   nsCOMPtr<nsIPresShell> presShell = mFrameSelection->GetShell();
+   if (presShell) {
+     presShell->FlushPendingNotifications(FlushType::Frames);
+@@ -703,17 +703,17 @@ Selection::GetTableSelectionType(nsIDOMR
+   }
+ 
+   if (startContent->IsHTMLElement(nsGkAtoms::tr))
+   {
+     *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL;
+   }
+   else //check to see if we are selecting a table or row (column and all cells not done yet)
+   {
+-    nsIContent *child = startNode->GetChildAt(startOffset);
++    nsIContent *child = startNode->GetChildAt_Deprecated(startOffset);
+     if (!child)
+       return NS_ERROR_FAILURE;
+ 
+     if (child->IsHTMLElement(nsGkAtoms::table))
+       *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
+     else if (child->IsHTMLElement(nsGkAtoms::tr))
+       *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW;
+   }
+diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp
+--- a/dom/base/nsContentAreaDragDrop.cpp
++++ b/dom/base/nsContentAreaDragDrop.cpp
+@@ -863,17 +863,17 @@ DragDataProducer::GetDraggableSelectionD
+           if (abs(anchorOffset - focusOffset) == 1) {
+             nsCOMPtr<nsIContent> selStartContent =
+               do_QueryInterface(selectionStart);
+ 
+             if (selStartContent) {
+               int32_t childOffset =
+                 (anchorOffset < focusOffset) ? anchorOffset : focusOffset;
+               nsIContent *childContent =
+-                selStartContent->GetChildAt(childOffset);
++                selStartContent->GetChildAt_Deprecated(childOffset);
+               // if we find an image, we'll fall into the node-dragging code,
+               // rather the the selection-dragging code
+               if (nsContentUtils::IsDraggableImage(childContent)) {
+                 NS_ADDREF(*outImageOrLinkNode = childContent);
+                 return NS_OK;
+               }
+             }
+           }
+diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp
+--- a/dom/base/nsContentIterator.cpp
++++ b/dom/base/nsContentIterator.cpp
+@@ -644,17 +644,17 @@ nsContentIterator::GetDeepLastChild(nsIC
+   if (NS_WARN_IF(!aRoot)) {
+     return nullptr;
+   }
+ 
+   nsIContent* node = aRoot;
+   int32_t numChildren = node->GetChildCount();
+ 
+   while (numChildren) {
+-    nsIContent* child = node->GetChildAt(--numChildren);
++    nsIContent* child = node->GetChildAt_Deprecated(--numChildren);
+ 
+     if (aIndexes) {
+       // Add this node to the stack of indexes
+       aIndexes->AppendElement(numChildren);
+     }
+     numChildren = child->GetChildCount();
+     node = child;
+   }
+@@ -686,25 +686,25 @@ nsContentIterator::GetNextSibling(nsINod
+   } else {
+     indx = mCachedIndex;
+   }
+   NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+ 
+   // reverify that the index of the current node hasn't changed.
+   // not super cheap, but a lot cheaper than IndexOf(), and still O(1).
+   // ignore result this time - the index may now be out of range.
+-  nsIContent* sib = parent->GetChildAt(indx);
++  nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+   if (sib != aNode) {
+     // someone changed our index - find the new index the painful way
+     indx = parent->IndexOf(aNode);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+-  if ((sib = parent->GetChildAt(++indx))) {
++  if ((sib = parent->GetChildAt_Deprecated(++indx))) {
+     // update index cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+     } else {
+       mCachedIndex = indx;
+     }
+   } else {
+     if (parent != mCommonParent) {
+@@ -747,25 +747,25 @@ nsContentIterator::GetPrevSibling(nsINod
+     // use the last entry on the Indexes array for the current index
+     indx = (*aIndexes)[aIndexes->Length()-1];
+   } else {
+     indx = mCachedIndex;
+   }
+ 
+   // reverify that the index of the current node hasn't changed
+   // ignore result this time - the index may now be out of range.
+-  nsIContent* sib = parent->GetChildAt(indx);
++  nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+   if (sib != aNode) {
+     // someone changed our index - find the new index the painful way
+     indx = parent->IndexOf(aNode);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+-  if (indx > 0 && (sib = parent->GetChildAt(--indx))) {
++  if (indx > 0 && (sib = parent->GetChildAt_Deprecated(--indx))) {
+     // update index cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+     } else {
+       mCachedIndex = indx;
+     }
+   } else if (parent != mCommonParent) {
+     if (aIndexes && !aIndexes->IsEmpty()) {
+@@ -824,26 +824,26 @@ nsContentIterator::NextNode(nsINode* aNo
+   } else {
+     indx = mCachedIndex;
+   }
+ 
+   // reverify that the index of the current node hasn't changed.  not super
+   // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
+   // this time - the index may now be out of range.
+   if (indx >= 0) {
+-    sibling = parent->GetChildAt(indx);
++    sibling = parent->GetChildAt_Deprecated(indx);
+   }
+   if (sibling != node) {
+     // someone changed our index - find the new index the painful way
+     indx = parent->IndexOf(node);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+-  sibling = parent->GetChildAt(++indx);
++  sibling = parent->GetChildAt_Deprecated(++indx);
+   if (sibling) {
+     // update cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       // replace an entry on the index stack
+       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+     } else {
+       mCachedIndex = indx;
+     }
+@@ -893,28 +893,28 @@ nsContentIterator::PrevNode(nsINode* aNo
+     } else {
+       indx = mCachedIndex;
+     }
+ 
+     // reverify that the index of the current node hasn't changed.  not super
+     // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
+     // this time - the index may now be out of range.
+     if (indx >= 0) {
+-      sibling = parent->GetChildAt(indx);
+-      NS_WARNING_ASSERTION(sibling, "GetChildAt returned null");
++      sibling = parent->GetChildAt_Deprecated(indx);
++      NS_WARNING_ASSERTION(sibling, "GetChildAt_Deprecated returned null");
+     }
+ 
+     if (sibling != node) {
+       // someone changed our index - find the new index the painful way
+       indx = parent->IndexOf(node);
+       NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+     }
+ 
+     // indx is now canonically correct
+-    if (indx && (sibling = parent->GetChildAt(--indx))) {
++    if (indx && (sibling = parent->GetChildAt_Deprecated(--indx))) {
+       // update cache
+       if (aIndexes && !aIndexes->IsEmpty()) {
+         // replace an entry on the index stack
+         aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+       } else {
+         mCachedIndex = indx;
+       }
+ 
+@@ -1390,17 +1390,17 @@ nsContentSubtreeIterator::InitWithRange(
+   // find first node in range
+   int32_t offset = mRange->StartOffset();
+ 
+   nsINode* node = nullptr;
+   if (!startContainer->GetChildCount()) {
+     // no children, start at the node itself
+     node = startContainer;
+   } else {
+-    nsIContent* child = startContainer->GetChildAt(offset);
++    nsIContent* child = startContainer->GetChildAt_Deprecated(offset);
+     if (!child) {
+       // offset after last child
+       node = startContainer;
+     } else {
+       firstCandidate = child;
+     }
+   }
+ 
+@@ -1439,17 +1439,17 @@ nsContentSubtreeIterator::InitWithRange(
+ 
+   if (offset > numChildren) {
+     // Can happen for text nodes
+     offset = numChildren;
+   }
+   if (!offset || !numChildren) {
+     node = endContainer;
+   } else {
+-    lastCandidate = endContainer->GetChildAt(--offset);
++    lastCandidate = endContainer->GetChildAt_Deprecated(--offset);
+     NS_ASSERTION(lastCandidate,
+                  "tree traversal trouble in nsContentSubtreeIterator::Init");
+   }
+ 
+   if (!lastCandidate) {
+     // then lastCandidate is prev node before node
+     lastCandidate = GetPrevSibling(node);
+   }
+diff --git a/dom/base/nsContentSink.cpp b/dom/base/nsContentSink.cpp
+--- a/dom/base/nsContentSink.cpp
++++ b/dom/base/nsContentSink.cpp
+@@ -1290,17 +1290,17 @@ nsContentSink::NotifyAppend(nsIContent* 
+   }
+ 
+   mInNotification++;
+ 
+   {
+     // Scope so we call EndUpdate before we decrease mInNotification
+     MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_CONTENT_MODEL, !mBeganUpdate);
+     nsNodeUtils::ContentAppended(aContainer,
+-                                 aContainer->GetChildAt(aStartIndex));
++                                 aContainer->GetChildAt_Deprecated(aStartIndex));
+     mLastNotificationTime = PR_Now();
+   }
+ 
+   mInNotification--;
+ }
+ 
+ NS_IMETHODIMP
+ nsContentSink::Notify(nsITimer *timer)
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -5448,17 +5448,17 @@ nsContentUtils::SetNodeTextContent(nsICo
+   nsAutoMutationBatch mb;
+ 
+   uint32_t childCount = aContent->GetChildCount();
+ 
+   if (aTryReuse && !aValue.IsEmpty()) {
+     uint32_t removeIndex = 0;
+ 
+     for (uint32_t i = 0; i < childCount; ++i) {
+-      nsIContent* child = aContent->GetChildAt(removeIndex);
++      nsIContent* child = aContent->GetChildAt_Deprecated(removeIndex);
+       if (removeIndex == 0 && child && child->IsNodeOfType(nsINode::eTEXT)) {
+         nsresult rv = child->SetText(aValue, true);
+         NS_ENSURE_SUCCESS(rv, rv);
+ 
+         removeIndex = 1;
+       }
+       else {
+         aContent->RemoveChildAt(removeIndex, true);
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
+--- a/dom/base/nsDocument.cpp
++++ b/dom/base/nsDocument.cpp
+@@ -4259,17 +4259,17 @@ nsDocument::GetRootElementInternal() con
+     }
+   }
+ 
+   const_cast<nsDocument*>(this)->mCachedRootElement = nullptr;
+   return nullptr;
+ }
+ 
+ nsIContent *
+-nsDocument::GetChildAt(uint32_t aIndex) const
++nsDocument::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return mChildren.GetSafeChildAt(aIndex);
+ }
+ 
+ int32_t
+ nsDocument::IndexOf(const nsINode* aPossibleChild) const
+ {
+   return mChildren.IndexOfChild(aPossibleChild);
+@@ -4291,17 +4291,17 @@ nsDocument::InsertChildAt(nsIContent* aK
+   }
+ 
+   return doInsertChildAt(aKid, aIndex, aNotify, mChildren);
+ }
+ 
+ void
+ nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
+ {
+-  nsCOMPtr<nsIContent> oldKid = GetChildAt(aIndex);
++  nsCOMPtr<nsIContent> oldKid = GetChildAt_Deprecated(aIndex);
+   if (!oldKid) {
+     return;
+   }
+ 
+   if (oldKid->IsElement()) {
+     // Destroy the link map up front before we mess with the child list.
+     DestroyElementMaps();
+   }
+diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
+--- a/dom/base/nsDocument.h
++++ b/dom/base/nsDocument.h
+@@ -545,17 +545,17 @@ public:
+   virtual void OnPageShow(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) override;
+   virtual void OnPageHide(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) override;
+ 
+   virtual void WillDispatchMutationEvent(nsINode* aTarget) override;
+   virtual void MutationEventDispatched(nsINode* aTarget) override;
+ 
+   // nsINode
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+-  virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
++  virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override
+   {
+diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
+--- a/dom/base/nsDocumentEncoder.cpp
++++ b/dom/base/nsDocumentEncoder.cpp
+@@ -638,17 +638,17 @@ nsDocumentEncoder::FlushText(nsAString& 
+ static nsresult ChildAt(nsIDOMNode* aNode, int32_t aIndex, nsIDOMNode*& aChild)
+ {
+   nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
+ 
+   aChild = nullptr;
+ 
+   NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
+ 
+-  nsIContent *child = content->GetChildAt(aIndex);
++  nsIContent *child = content->GetChildAt_Deprecated(aIndex);
+ 
+   if (child)
+     return CallQueryInterface(child, &aChild);
+ 
+   return NS_OK;
+ }
+ 
+ static int32_t IndexOf(nsIDOMNode* aParent, nsIDOMNode* aChild)
+@@ -840,17 +840,17 @@ nsDocumentEncoder::SerializeRangeNodes(n
+         if (aNode != aRange->GetEndContainer())
+         {
+           endOffset++;
+         }
+       }
+       // serialize the children of this node that are in the range
+       for (j=startOffset; j<endOffset; j++)
+       {
+-        childAsNode = content->GetChildAt(j);
++        childAsNode = content->GetChildAt_Deprecated(j);
+ 
+         if ((j==startOffset) || (j==endOffset-1))
+           rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);
+         else
+           rv = SerializeToStringRecursive(childAsNode, aString, false);
+ 
+         NS_ENSURE_SUCCESS(rv, rv);
+       }
+@@ -1853,17 +1853,17 @@ nsHTMLCopyEncoder::GetChildAt(nsIDOMNode
+   nsCOMPtr<nsIDOMNode> resultNode;
+ 
+   if (!aParent)
+     return resultNode;
+ 
+   nsCOMPtr<nsIContent> content = do_QueryInterface(aParent);
+   NS_PRECONDITION(content, "null content in nsHTMLCopyEncoder::GetChildAt");
+ 
+-  resultNode = do_QueryInterface(content->GetChildAt(aOffset));
++  resultNode = do_QueryInterface(content->GetChildAt_Deprecated(aOffset));
+ 
+   return resultNode;
+ }
+ 
+ bool
+ nsHTMLCopyEncoder::IsMozBR(nsIDOMNode* aNode)
+ {
+   MOZ_ASSERT(aNode);
+diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
+--- a/dom/base/nsFocusManager.cpp
++++ b/dom/base/nsFocusManager.cpp
+@@ -2494,27 +2494,27 @@ nsFocusManager::GetSelectionLocation(nsI
+       domRange->GetStartContainer(getter_AddRefs(startNode));
+       domRange->GetEndContainer(getter_AddRefs(endNode));
+       domRange->GetStartOffset(&startOffset);
+ 
+       nsIContent *childContent = nullptr;
+ 
+       startContent = do_QueryInterface(startNode);
+       if (startContent && startContent->IsElement()) {
+-        childContent = startContent->GetChildAt(startOffset);
++        childContent = startContent->GetChildAt_Deprecated(startOffset);
+         if (childContent) {
+           startContent = childContent;
+         }
+       }
+ 
+       endContent = do_QueryInterface(endNode);
+       if (endContent && endContent->IsElement()) {
+         uint32_t endOffset = 0;
+         domRange->GetEndOffset(&endOffset);
+-        childContent = endContent->GetChildAt(endOffset);
++        childContent = endContent->GetChildAt_Deprecated(endOffset);
+         if (childContent) {
+           endContent = childContent;
+         }
+       }
+     }
+   }
+   else {
+     rv = NS_ERROR_INVALID_ARG;
+@@ -3321,19 +3321,20 @@ nsFocusManager::GetNextTabbableMapArea(b
+                       tabIndex != aCurrentTabIndex)) {
+       // If aStartContent is in this map we must start iterating past it.
+       // We skip the case where aStartContent has tabindex == aStartContent
+       // since the next tab ordered element might be before it
+       // (or after for backwards) in the child list.
+       index = aForward ? -1 : (int32_t)count;
+     }
+ 
+-    // GetChildAt will return nullptr if our index < 0 or index >= count
++    // GetChildAt_Deprecated will return nullptr if our index < 0 or index >=
++    // count
+     nsCOMPtr<nsIContent> areaContent;
+-    while ((areaContent = mapContent->GetChildAt(aForward ? ++index : --index)) != nullptr) {
++    while ((areaContent = mapContent->GetChildAt_Deprecated(aForward ? ++index : --index)) != nullptr) {
+       if (areaContent->IsFocusable(&tabIndex) && tabIndex == aCurrentTabIndex) {
+         return areaContent;
+       }
+     }
+   }
+ 
+   return nullptr;
+ }
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
+--- a/dom/base/nsGenericDOMDataNode.cpp
++++ b/dom/base/nsGenericDOMDataNode.cpp
+@@ -634,17 +634,17 @@ nsGenericDOMDataNode::GetChildren(uint32
+ 
+ uint32_t
+ nsGenericDOMDataNode::GetChildCount() const
+ {
+   return 0;
+ }
+ 
+ nsIContent *
+-nsGenericDOMDataNode::GetChildAt(uint32_t aIndex) const
++nsGenericDOMDataNode::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return nullptr;
+ }
+ 
+ 
+ int32_t
+ nsGenericDOMDataNode::IndexOf(const nsINode* aPossibleChild) const
+ {
+@@ -771,30 +771,30 @@ nsGenericDOMDataNode::SplitText(uint32_t
+   return rv;
+ }
+ 
+ /* static */ int32_t
+ nsGenericDOMDataNode::FirstLogicallyAdjacentTextNode(nsIContent* aParent,
+                                                      int32_t aIndex)
+ {
+   while (aIndex-- > 0) {
+-    nsIContent* sibling = aParent->GetChildAt(aIndex);
++    nsIContent* sibling = aParent->GetChildAt_Deprecated(aIndex);
+     if (!sibling->IsNodeOfType(nsINode::eTEXT))
+       return aIndex + 1;
+   }
+   return 0;
+ }
+ 
+ /* static */ int32_t
+ nsGenericDOMDataNode::LastLogicallyAdjacentTextNode(nsIContent* aParent,
+                                                     int32_t aIndex,
+                                                     uint32_t aCount)
+ {
+   while (++aIndex < int32_t(aCount)) {
+-    nsIContent* sibling = aParent->GetChildAt(aIndex);
++    nsIContent* sibling = aParent->GetChildAt_Deprecated(aIndex);
+     if (!sibling->IsNodeOfType(nsINode::eTEXT))
+       return aIndex - 1;
+   }
+   return aCount - 1;
+ }
+ 
+ nsresult
+ nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
+@@ -815,17 +815,17 @@ nsGenericDOMDataNode::GetWholeText(nsASt
+   int32_t last =
+     LastLogicallyAdjacentTextNode(parent, index, parent->GetChildCount());
+ 
+   aWholeText.Truncate();
+ 
+   nsCOMPtr<nsIDOMText> node;
+   nsAutoString tmp;
+   do {
+-    node = do_QueryInterface(parent->GetChildAt(first));
++    node = do_QueryInterface(parent->GetChildAt_Deprecated(first));
+     node->GetData(tmp);
+     aWholeText.Append(tmp);
+   } while (first++ < last);
+ 
+   return NS_OK;
+ }
+ 
+ //----------------------------------------------------------------------
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
+--- a/dom/base/nsGenericDOMDataNode.h
++++ b/dom/base/nsGenericDOMDataNode.h
+@@ -100,17 +100,17 @@ public:
+   nsresult AppendData(const nsAString& aArg);
+   nsresult InsertData(uint32_t aOffset, const nsAString& aArg);
+   nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
+   nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
+                        const nsAString& aArg);
+ 
+   // nsINode methods
+   virtual uint32_t GetChildCount() const override;
+-  virtual nsIContent *GetChildAt(uint32_t aIndex) const override;
++  virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override
+   {
+     GetNodeValue(aTextContent);
+diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
+--- a/dom/base/nsINode.cpp
++++ b/dom/base/nsINode.cpp
+@@ -1969,17 +1969,17 @@ 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) &&
++             aKid == GetChildAt_Deprecated(aIndex) &&
+              IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
+   MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE));
+ 
+   nsMutationGuard::DidMutate();
+   mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
+ 
+   nsIContent* previousSibling = aKid->GetPreviousSibling();
+ 
+@@ -2303,18 +2303,18 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+     // while kungFuDeathGrip is still alive.
+     {
+       mozAutoDocUpdate batch(newContent->GetComposedDoc(),
+                              UPDATE_CONTENT_MODEL, true);
+       nsAutoMutationBatch mb(oldParent, true, true);
+       oldParent->RemoveChildAt(removeIndex, true);
+       if (nsAutoMutationBatch::GetCurrentBatch() == &mb) {
+         mb.RemovalDone();
+-        mb.SetPrevSibling(oldParent->GetChildAt(removeIndex - 1));
+-        mb.SetNextSibling(oldParent->GetChildAt(removeIndex));
++        mb.SetPrevSibling(oldParent->GetChildAt_Deprecated(removeIndex - 1));
++        mb.SetNextSibling(oldParent->GetChildAt_Deprecated(removeIndex));
+       }
+     }
+ 
+     // We expect one mutation (the removal) to have happened.
+     if (guard.Mutated(1)) {
+       // XBL destructors, yuck.
+ 
+       // Verify that nodeToInsertBefore, if non-null, is still our child.  If
+@@ -2513,18 +2513,18 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+   nsINode* result = aReplace ? aRefChild : aNewChild;
+   if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
+     if (!aReplace) {
+       mb.Init(this, true, true);
+     }
+     nsAutoMutationBatch* mutationBatch = nsAutoMutationBatch::GetCurrentBatch();
+     if (mutationBatch) {
+       mutationBatch->RemovalDone();
+-      mutationBatch->SetPrevSibling(GetChildAt(insPos - 1));
+-      mutationBatch->SetNextSibling(GetChildAt(insPos));
++      mutationBatch->SetPrevSibling(GetChildAt_Deprecated(insPos - 1));
++      mutationBatch->SetNextSibling(GetChildAt_Deprecated(insPos));
+     }
+ 
+     uint32_t count = fragChildren->Length();
+     if (!count) {
+       return result;
+     }
+ 
+     bool appending =
+@@ -2571,18 +2571,18 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+ 
+     // FIXME https://bugzilla.mozilla.org/show_bug.cgi?id=544654
+     //       We need to reparent here for nodes for which the parent of their
+     //       wrapper is not the wrapper for their ownerDocument (XUL elements,
+     //       form controls, ...). Also applies in the fragment code above.
+ 
+     if (nsAutoMutationBatch::GetCurrentBatch() == &mb) {
+       mb.RemovalDone();
+-      mb.SetPrevSibling(GetChildAt(insPos - 1));
+-      mb.SetNextSibling(GetChildAt(insPos));
++      mb.SetPrevSibling(GetChildAt_Deprecated(insPos - 1));
++      mb.SetNextSibling(GetChildAt_Deprecated(insPos));
+     }
+     aError = InsertChildAt(newContent, insPos, true);
+     if (aError.Failed()) {
+       return nullptr;
+     }
+   }
+ 
+   return result;
+diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
+--- a/dom/base/nsINode.h
++++ b/dom/base/nsINode.h
+@@ -501,29 +501,32 @@ public:
+ 
+   /**
+    * Get the number of children
+    * @return the number of children
+    */
+   virtual uint32_t GetChildCount() const = 0;
+ 
+   /**
++   * NOTE: this function is going to be removed soon (hopefully!) Don't use it
++   * in new code.
++   *
+    * Get a child by index
+    * @param aIndex the index of the child to get
+    * @return the child, or null if index out of bounds
+    */
+-  virtual nsIContent* GetChildAt(uint32_t aIndex) const = 0;
++  virtual nsIContent* GetChildAt_Deprecated(uint32_t aIndex) const = 0;
+ 
+   /**
+    * Get the index of a child within this content
+    * @param aPossibleChild the child to get the index of.
+    * @return the index of the child, or -1 if not a child
+    *
+-   * If the return value is not -1, then calling GetChildAt() with that value
+-   * will return aPossibleChild.
++   * If the return value is not -1, then calling GetChildAt_Deprecated() with
++   * that value will return aPossibleChild.
+    */
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
+ 
+   /**
+    * Returns the "node document" of this node.
+    *
+    * https://dom.spec.whatwg.org/#concept-node-document
+    *
+@@ -1303,17 +1306,17 @@ public:
+   nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell);
+ 
+   virtual nsINodeList* ChildNodes();
+   nsIContent* GetFirstChild() const { return mFirstChild; }
+   nsIContent* GetLastChild() const
+   {
+     uint32_t count = GetChildCount();
+ 
+-    return count > 0 ? GetChildAt(count - 1) : nullptr;
++    return count > 0 ? GetChildAt_Deprecated(count - 1) : nullptr;
+   }
+ 
+   /**
+    * Implementation is in nsIDocument.h, because it needs to cast from
+    * nsIDocument* to nsINode*.
+    */
+   nsIDocument* GetOwnerDocument() const;
+ 
+diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp
+--- a/dom/base/nsRange.cpp
++++ b/dom/base/nsRange.cpp
+@@ -3854,28 +3854,28 @@ nsRange::GetInnerTextNoFlush(DOMString& 
+     auto t = static_cast<nsGenericDOMDataNode*>(aStartContainer);
+     if (aStartContainer == aEndContainer) {
+       AppendTransformedText(result, t, aStartOffset, aEndOffset);
+       return;
+     }
+     AppendTransformedText(result, t, aStartOffset, t->TextLength());
+   } else {
+     if (uint32_t(aStartOffset) < aStartContainer->GetChildCount()) {
+-      currentNode = aStartContainer->GetChildAt(aStartOffset);
++      currentNode = aStartContainer->GetChildAt_Deprecated(aStartOffset);
+       currentState = AT_NODE;
+     }
+   }
+ 
+   nsIContent* endNode = aEndContainer;
+   TreeTraversalState endState = AFTER_NODE;
+   if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) {
+     endState = AT_NODE;
+   } else {
+     if (aEndOffset < aEndContainer->GetChildCount()) {
+-      endNode = aEndContainer->GetChildAt(aEndOffset);
++      endNode = aEndContainer->GetChildAt_Deprecated(aEndOffset);
+       endState = AT_NODE;
+     }
+   }
+ 
+   while (currentNode != endNode || currentState != endState) {
+     nsIFrame* f = currentNode->GetPrimaryFrame();
+     bool isVisibleAndNotReplaced = IsVisibleAndNotInReplacedElement(f);
+     if (currentState == AT_NODE) {
+diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp
+--- a/dom/events/ContentEventHandler.cpp
++++ b/dom/events/ContentEventHandler.cpp
+@@ -1599,24 +1599,24 @@ ContentEventHandler::GetNodePositionHavi
+   // If it's a empty element node, returns itself.
+   if (!childCount) {
+     MOZ_ASSERT(!aNodeOffset || aNodeOffset == 1);
+     return NodePosition(aNode, aNodeOffset);
+   }
+ 
+   // If there is a node at given position, return the start of it.
+   if (aNodeOffset < childCount) {
+-    return NodePosition(aNode->GetChildAt(aNodeOffset), 0);
++    return NodePosition(aNode->GetChildAt_Deprecated(aNodeOffset), 0);
+   }
+ 
+   // If the offset represents "after" the node, we need to return the last
+   // child of it.  For example, if a range is |<p>[<br>]</p>|, then, the
+   // end point is {<p>, 1}.  In such case, callers need the <br> node.
+   if (aNodeOffset == childCount) {
+-    nsINode* node = aNode->GetChildAt(childCount - 1);
++    nsINode* node = aNode->GetChildAt_Deprecated(childCount - 1);
+     return NodePosition(node,
+       node->IsNodeOfType(nsINode::eTEXT)
+         ? static_cast<int32_t>(node->AsContent()->TextLength())
+         : 1);
+   }
+ 
+   NS_WARNING("aNodeOffset is invalid value");
+   return NodePosition();
+@@ -1706,17 +1706,17 @@ ContentEventHandler::GetLastFrameInRange
+     // Don't set nextNodeOfRangeEnd to the start node of aRawRange because if
+     // endNode is same as start node of the range, the text node shouldn't be
+     // next of range end even if the offset is 0.  This could occur with empty
+     // text node.
+     if (!endOffset && aRawRange.GetStartContainer() != endNode) {
+       nextNodeOfRangeEnd = endNode;
+     }
+   } else if (endOffset < endNode->GetChildCount()) {
+-    nextNodeOfRangeEnd = endNode->GetChildAt(endOffset);
++    nextNodeOfRangeEnd = endNode->GetChildAt_Deprecated(endOffset);
+   }
+ 
+   for (iter->Last(); !iter->IsDone(); iter->Prev()) {
+     nsINode* node = iter->GetCurrentNode();
+     if (NS_WARN_IF(!node)) {
+       break;
+     }
+ 
+@@ -3040,17 +3040,17 @@ ContentEventHandler::AdjustCollapsedRang
+     // If the range is the start of the container, adjusted the range to the
+     // start of the first child.
+     childNode = container->GetFirstChild();
+     offsetInChildNode = 0;
+   } else if (static_cast<uint32_t>(offsetInParentNode) <
+                container->GetChildCount()) {
+     // If the range is next to a child node, adjust the range to the end of
+     // the previous child.
+-    childNode = container->GetChildAt(offsetInParentNode - 1);
++    childNode = container->GetChildAt_Deprecated(offsetInParentNode - 1);
+     offsetInChildNode = childNode->Length();
+   }
+ 
+   // But if the found node isn't a text node, we cannot modify the range.
+   if (!childNode || !childNode->IsNodeOfType(nsINode::eTEXT) ||
+       NS_WARN_IF(offsetInChildNode < 0)) {
+     return NS_OK;
+   }
+diff --git a/dom/events/IMEContentObserver.cpp b/dom/events/IMEContentObserver.cpp
+--- a/dom/events/IMEContentObserver.cpp
++++ b/dom/events/IMEContentObserver.cpp
+@@ -1186,17 +1186,17 @@ IMEContentObserver::GetChildNode(nsINode
+     return nullptr;
+   }
+   if (!aOffset) {
+     return aParent->GetFirstChild();
+   }
+   if (aOffset == static_cast<int32_t>(aParent->Length() - 1)) {
+     return aParent->GetLastChild();
+   }
+-  return aParent->GetChildAt(aOffset);
++  return aParent->GetChildAt_Deprecated(aOffset);
+ }
+ 
+ bool
+ IMEContentObserver::IsNextNodeOfLastAddedNode(nsINode* aParent,
+                                               nsIContent* aChild) const
+ {
+   MOZ_ASSERT(aParent);
+   MOZ_ASSERT(aChild && aChild->GetParentNode() == aParent);
+diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp
+--- a/dom/html/HTMLFieldSetElement.cpp
++++ b/dom/html/HTMLFieldSetElement.cpp
+@@ -169,17 +169,17 @@ HTMLFieldSetElement::InsertChildAt(nsICo
+   return rv;
+ }
+ 
+ void
+ HTMLFieldSetElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
+ {
+   bool firstLegendHasChanged = false;
+ 
+-  if (mFirstLegend && (GetChildAt(aIndex) == mFirstLegend)) {
++  if (mFirstLegend && (GetChildAt_Deprecated(aIndex) == mFirstLegend)) {
+     // If we are removing the first legend we have to found another one.
+     nsIContent* child = mFirstLegend->GetNextSibling();
+     mFirstLegend = nullptr;
+     firstLegendHasChanged = true;
+ 
+     for (; child; child = child->GetNextSibling()) {
+       if (child->IsHTMLElement(nsGkAtoms::legend)) {
+         mFirstLegend = child;
+diff --git a/dom/html/HTMLPictureElement.cpp b/dom/html/HTMLPictureElement.cpp
+--- a/dom/html/HTMLPictureElement.cpp
++++ b/dom/html/HTMLPictureElement.cpp
+@@ -30,17 +30,17 @@ HTMLPictureElement::~HTMLPictureElement(
+ 
+ NS_IMPL_ISUPPORTS_INHERITED0(HTMLPictureElement, nsGenericHTMLElement)
+ 
+ NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
+ 
+ void
+ HTMLPictureElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
+ {
+-  nsCOMPtr<nsIContent> child = GetChildAt(aIndex);
++  nsCOMPtr<nsIContent> child = GetChildAt_Deprecated(aIndex);
+ 
+   if (child && child->IsHTMLElement(nsGkAtoms::img)) {
+     HTMLImageElement* img = HTMLImageElement::FromContent(child);
+     if (img) {
+       img->PictureSourceRemoved(child->AsContent());
+     }
+   } else if (child && child->IsHTMLElement(nsGkAtoms::source)) {
+     // Find all img siblings after this <source> to notify them of its demise
+diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
+--- a/dom/html/HTMLSelectElement.cpp
++++ b/dom/html/HTMLSelectElement.cpp
+@@ -415,17 +415,17 @@ HTMLSelectElement::WillAddOptions(nsICon
+     if (aContentIndex >= children) {
+       // If the content insert is after the end of the parent, then we want to get
+       // the next index *after* the parent and insert there.
+       ind = GetOptionIndexAfter(aParent);
+     } else {
+       // If the content insert is somewhere in the middle of the container, then
+       // we want to get the option currently at the index and insert in front of
+       // that.
+-      nsIContent* currentKid = aParent->GetChildAt(aContentIndex);
++      nsIContent* currentKid = aParent->GetChildAt_Deprecated(aContentIndex);
+       NS_ASSERTION(currentKid, "Child not found!");
+       if (currentKid) {
+         ind = GetOptionIndexAt(currentKid);
+       } else {
+         ind = -1;
+       }
+     }
+   }
+@@ -440,17 +440,17 @@ HTMLSelectElement::WillRemoveOptions(nsI
+                                      bool aNotify)
+ {
+   if (this != aParent && this != aParent->GetParent()) {
+     return NS_OK;
+   }
+   int32_t level = this == aParent ? 0 : 1;
+ 
+   // Get the index where the options will be removed
+-  nsIContent* currentKid = aParent->GetChildAt(aContentIndex);
++  nsIContent* currentKid = aParent->GetChildAt_Deprecated(aContentIndex);
+   if (currentKid) {
+     int32_t ind;
+     if (!mNonOptionChildren) {
+       // If there are no artifacts, aContentIndex == ind
+       ind = aContentIndex;
+     } else {
+       // If there are artifacts, we have to get the index of the option the
+       // hard way
+@@ -525,17 +525,17 @@ HTMLSelectElement::GetFirstOptionIndex(n
+ int32_t
+ HTMLSelectElement::GetFirstChildOptionIndex(nsIContent* aOptions,
+                                             int32_t aStartIndex,
+                                             int32_t aEndIndex)
+ {
+   int32_t retval = -1;
+ 
+   for (int32_t i = aStartIndex; i < aEndIndex; ++i) {
+-    retval = GetFirstOptionIndex(aOptions->GetChildAt(i));
++    retval = GetFirstOptionIndex(aOptions->GetChildAt_Deprecated(i));
+     if (retval != -1) {
+       break;
+     }
+   }
+ 
+   return retval;
+ }
+ 
+diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp
+--- a/dom/html/nsHTMLContentSink.cpp
++++ b/dom/html/nsHTMLContentSink.cpp
+@@ -325,17 +325,17 @@ SinkContext::DidAddContent(nsIContent* a
+   // an insertion happen, we need to do an immediate
+   // notification for that insertion.
+   if (0 < mStackPos &&
+       mStack[mStackPos - 1].mInsertionPoint != -1 &&
+       mStack[mStackPos - 1].mNumFlushed <
+       mStack[mStackPos - 1].mContent->GetChildCount()) {
+     nsIContent* parent = mStack[mStackPos - 1].mContent;
+     int32_t childIndex = mStack[mStackPos - 1].mInsertionPoint - 1;
+-    NS_ASSERTION(parent->GetChildAt(childIndex) == aContent,
++    NS_ASSERTION(parent->GetChildAt_Deprecated(childIndex) == aContent,
+                  "Flushing the wrong child.");
+     mSink->NotifyInsert(parent, aContent, childIndex);
+     mStack[mStackPos - 1].mNumFlushed = parent->GetChildCount();
+   } else if (mSink->IsTimeToNotify()) {
+     FlushTags();
+   }
+ }
+ 
+@@ -519,17 +519,17 @@ SinkContext::FlushTags()
+ 
+       if (!flushed && (mStack[stackPos].mNumFlushed < childCount)) {
+         if (mStack[stackPos].mInsertionPoint != -1) {
+           // We might have popped the child off our stack already
+           // but not notified on it yet, which is why we have to get it
+           // directly from its parent node.
+ 
+           int32_t childIndex = mStack[stackPos].mInsertionPoint - 1;
+-          nsIContent* child = content->GetChildAt(childIndex);
++          nsIContent* child = content->GetChildAt_Deprecated(childIndex);
+           // Child not on stack anymore; can't assert it's correct
+           NS_ASSERTION(!(mStackPos > (stackPos + 1)) ||
+                        (child == mStack[stackPos + 1].mContent),
+                        "Flushing the wrong child.");
+           mSink->NotifyInsert(content, child, childIndex);
+         } else {
+           mSink->NotifyAppend(content, mStack[stackPos].mNumFlushed);
+         }
+diff --git a/dom/xbl/XBLChildrenElement.cpp b/dom/xbl/XBLChildrenElement.cpp
+--- a/dom/xbl/XBLChildrenElement.cpp
++++ b/dom/xbl/XBLChildrenElement.cpp
+@@ -118,17 +118,17 @@ nsAnonymousContentList::Item(uint32_t aI
+       if (point->HasInsertedChildren()) {
+         if (remIndex < point->InsertedChildrenLength()) {
+           return point->InsertedChild(remIndex);
+         }
+         remIndex -= point->InsertedChildrenLength();
+       }
+       else {
+         if (remIndex < point->GetChildCount()) {
+-          return point->GetChildAt(remIndex);
++          return point->GetChildAt_Deprecated(remIndex);
+         }
+         remIndex -= point->GetChildCount();
+       }
+     }
+     else {
+       if (remIndex == 0) {
+         return child;
+       }
+diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
+--- a/dom/xbl/nsXBLPrototypeBinding.cpp
++++ b/dom/xbl/nsXBLPrototypeBinding.cpp
+@@ -486,17 +486,17 @@ nsXBLPrototypeBinding::LocateInstance(El
+ 
+   nsIContent *copyParent =
+     templParent == aTemplRoot ? aCopyRoot :
+                    LocateInstance(aBoundElement, aTemplRoot, aCopyRoot, templParent);
+ 
+   if (!copyParent)
+     return nullptr;
+ 
+-  nsIContent* child = copyParent->GetChildAt(templParent->IndexOf(aTemplChild));
++  nsIContent* child = copyParent->GetChildAt_Deprecated(templParent->IndexOf(aTemplChild));
+   if (child && child->IsElement()) {
+     return child->AsElement();
+   }
+   return nullptr;
+ }
+ 
+ void
+ nsXBLPrototypeBinding::SetInitialAttributes(
+@@ -1498,17 +1498,17 @@ nsXBLPrototypeBinding::WriteContentNode(
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+   // Finally, write out the child nodes.
+   count = element->GetChildCount();
+   rv = aStream->Write32(count);
+   NS_ENSURE_SUCCESS(rv, rv);
+ 
+   for (i = 0; i < count; i++) {
+-    rv = WriteContentNode(aStream, element->GetChildAt(i));
++    rv = WriteContentNode(aStream, element->GetChildAt_Deprecated(i));
+     NS_ENSURE_SUCCESS(rv, rv);
+   }
+ 
+   return NS_OK;
+ }
+ 
+ nsresult
+ nsXBLPrototypeBinding::ReadNamespace(nsIObjectInputStream* aStream,
+diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
++++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+@@ -613,17 +613,17 @@ txMozillaXMLOutput::createTxWrapper()
+ 
+     uint32_t i, j, childCount = mDocument->GetChildCount();
+ #ifdef DEBUG
+     // Keep track of the location of the current documentElement, if there is
+     // one, so we can verify later
+     uint32_t rootLocation = 0;
+ #endif
+     for (i = 0, j = 0; i < childCount; ++i) {
+-        nsCOMPtr<nsIContent> childContent = mDocument->GetChildAt(j);
++        nsCOMPtr<nsIContent> childContent = mDocument->GetChildAt_Deprecated(j);
+ 
+ #ifdef DEBUG
+         if (childContent->IsElement()) {
+             rootLocation = j;
+         }
+ #endif
+ 
+         if (childContent->NodeInfo()->NameAtom() == nsGkAtoms::documentTypeNodeName) {
+diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp
+--- a/dom/xul/templates/nsXULContentBuilder.cpp
++++ b/dom/xul/templates/nsXULContentBuilder.cpp
+@@ -869,22 +869,22 @@ nsXULContentBuilder::SynchronizeUsingTem
+         rv = CopyAttributesToElement(aTemplateNode->AsElement(), aRealNode->AsElement(), aResult, true);
+         if (NS_FAILED(rv))
+             return rv;
+     }
+ 
+     uint32_t count = aTemplateNode->GetChildCount();
+ 
+     for (uint32_t loop = 0; loop < count; ++loop) {
+-        nsIContent *tmplKid = aTemplateNode->GetChildAt(loop);
++        nsIContent *tmplKid = aTemplateNode->GetChildAt_Deprecated(loop);
+ 
+         if (! tmplKid)
+             break;
+ 
+-        nsIContent *realKid = aRealNode->GetChildAt(loop);
++        nsIContent *realKid = aRealNode->GetChildAt_Deprecated(loop);
+         if (! realKid)
+             break;
+ 
+         // check for text nodes and update them accordingly.
+         // This code is similar to that in BuildContentFromTemplate
+         if (tmplKid->NodeInfo()->Equals(nsGkAtoms::textnode,
+                                         kNameSpaceID_XUL)) {
+             nsAutoString attrValue;
+@@ -1050,17 +1050,17 @@ nsXULContentBuilder::CreateContainerCont
+         CreateContainerContentsForQuerySet(aElement, aResult, aNotify, queryset,
+                                            &container, &newIndexInContainer);
+     }
+ 
+     if (aNotifyAtEnd && container) {
+         MOZ_AUTO_DOC_UPDATE(container->GetUncomposedDoc(), UPDATE_CONTENT_MODEL,
+                             true);
+         nsNodeUtils::ContentAppended(container,
+-                                     container->GetChildAt(newIndexInContainer));
++                                     container->GetChildAt_Deprecated(newIndexInContainer));
+     }
+ 
+     NS_IF_RELEASE(container);
+ 
+     return NS_OK;
+ }
+ 
+ nsresult
+@@ -1280,17 +1280,17 @@ nsXULContentBuilder::RemoveGeneratedCont
+         // Pull the next "ungenerated" element off the queue.
+         uint32_t last = count - 1;
+         nsCOMPtr<nsIContent> element = ungenerated[last];
+         ungenerated.RemoveElementAt(last);
+ 
+         uint32_t i = element->GetChildCount();
+ 
+         while (i-- > 0) {
+-            nsCOMPtr<nsIContent> child = element->GetChildAt(i);
++            nsCOMPtr<nsIContent> child = element->GetChildAt_Deprecated(i);
+ 
+             // Optimize for the <template> element, because we *know*
+             // it won't have any generated content: there's no reason
+             // to even check this subtree.
+             // XXX should this check |child| rather than |element|? Otherwise
+             //     it should be moved outside the inner loop. Bug 297290.
+             if (element->NodeInfo()->Equals(nsGkAtoms::_template,
+                                             kNameSpaceID_XUL) ||
+@@ -1903,39 +1903,39 @@ nsXULContentBuilder::InsertSortedNode(El
+         if (numChildren > 0) {
+             nsIContent *temp;
+             int32_t direction;
+ 
+             // rjc says: The following is an implementation of a fairly optimal
+             // binary search insertion sort... with interpolation at either end-point.
+ 
+             if (mSortState.lastWasFirst) {
+-                child = aContainer->GetChildAt(staticCount);
++                child = aContainer->GetChildAt_Deprecated(staticCount);
+                 temp = child;
+                 rv = CompareResultToNode(aResult, temp, &direction);
+                 if (direction < 0) {
+                     aContainer->InsertChildAt(aNode, staticCount, aNotify);
+                     childAdded = true;
+                 } else
+                     mSortState.lastWasFirst = false;
+             } else if (mSortState.lastWasLast) {
+-                child = aContainer->GetChildAt(realNumChildren - 1);
++                child = aContainer->GetChildAt_Deprecated(realNumChildren - 1);
+                 temp = child;
+                 rv = CompareResultToNode(aResult, temp, &direction);
+                 if (direction > 0) {
+                     aContainer->InsertChildAt(aNode, realNumChildren, aNotify);
+                     childAdded = true;
+                 } else
+                     mSortState.lastWasLast = false;
+             }
+ 
+             int32_t left = staticCount + 1, right = realNumChildren, x;
+             while (!childAdded && right >= left) {
+                 x = (left + right) / 2;
+-                child = aContainer->GetChildAt(x - 1);
++                child = aContainer->GetChildAt_Deprecated(x - 1);
+                 temp = child;
+ 
+                 rv = CompareResultToNode(aResult, temp, &direction);
+                 if ((x == left && direction < 0) ||
+                     (x == right && direction >= 0) ||
+                     left == right)
+                 {
+                     int32_t thePos = (direction > 0 ? x : x - 1);
+diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp
+--- a/editor/libeditor/EditorBase.cpp
++++ b/editor/libeditor/EditorBase.cpp
+@@ -2733,28 +2733,28 @@ EditorBase::FindBetterInsertionPoint(con
+       return EditorRawDOMPoint(aPoint.GetContainer()->GetFirstChild(), 0);
+     }
+ 
+     // In some other cases, aNode is the anonymous DIV, and offset points to the
+     // terminating mozBR.  In that case, we'll adjust aInOutNode and
+     // aInOutOffset to the preceding text node, if any.
+     if (!aPoint.IsStartOfContainer()) {
+       if (AsHTMLEditor()) {
+-        // Fall back to a slow path that uses GetChildAt() for Thunderbird's
++        // Fall back to a slow path that uses GetChildAt_Deprecated() for Thunderbird's
+         // plaintext editor.
+         nsIContent* child = aPoint.GetPreviousSiblingOfChild();
+         if (child && child->IsNodeOfType(nsINode::eTEXT)) {
+           if (NS_WARN_IF(child->Length() > INT32_MAX)) {
+             return aPoint;
+           }
+           return EditorRawDOMPoint(child, child->Length());
+         }
+       } else {
+         // If we're in a real plaintext editor, use a fast path that avoids
+-        // calling GetChildAt() which may perform a linear search.
++        // calling GetChildAt_Deprecated() which may perform a linear search.
+         nsIContent* child = aPoint.GetContainer()->GetLastChild();
+         while (child) {
+           if (child->IsNodeOfType(nsINode::eTEXT)) {
+             if (NS_WARN_IF(child->Length() > INT32_MAX)) {
+               return aPoint;
+             }
+             return EditorRawDOMPoint(child, child->Length());
+           }
+@@ -4391,17 +4391,17 @@ EditorBase::JoinNodeDeep(nsIContent& aLe
+ 
+     if (parentNode->GetAsText()) {
+       // We've joined all the way down to text nodes, we're done!
+       return ret;
+     }
+ 
+     // Get new left and right nodes, and begin anew
+     parentNode = rightNodeToJoin;
+-    rightNodeToJoin = parentNode->GetChildAt(length);
++    rightNodeToJoin = parentNode->GetChildAt_Deprecated(length);
+     if (rightNodeToJoin) {
+       leftNodeToJoin = rightNodeToJoin->GetPreviousSibling();
+     } else {
+       leftNodeToJoin = nullptr;
+     }
+ 
+     // Skip over non-editable nodes
+     while (leftNodeToJoin && !IsEditable(leftNodeToJoin)) {
+diff --git a/editor/libeditor/EditorDOMPoint.h b/editor/libeditor/EditorDOMPoint.h
+--- a/editor/libeditor/EditorDOMPoint.h
++++ b/editor/libeditor/EditorDOMPoint.h
+@@ -141,17 +141,17 @@ public:
+     , mOffset(mozilla::Some(aOffset))
+     , mIsChildInitialized(true)
+   {
+     MOZ_RELEASE_ASSERT(aContainer,
+       "This constructor shouldn't be used when pointing nowhere");
+     MOZ_ASSERT(mOffset.value() <= mParent->Length());
+     MOZ_ASSERT(mChild || mParent->Length() == mOffset.value());
+     MOZ_ASSERT(!mChild || mParent == mChild->GetParentNode());
+-    MOZ_ASSERT(mParent->GetChildAt(mOffset.value()) == mChild);
++    MOZ_ASSERT(mParent->GetChildAt_Deprecated(mOffset.value()) == mChild);
+   }
+ 
+   template<typename PT, typename CT>
+   explicit EditorDOMPointBase(const RangeBoundaryBase<PT, CT>& aOther)
+     : mParent(aOther.mParent)
+     , mChild(aOther.mRef ? aOther.mRef->GetNextSibling() :
+                            (aOther.mParent ? aOther.mParent->GetFirstChild() :
+                                              nullptr))
+@@ -568,17 +568,17 @@ public:
+     }
+     if (mIsChildInitialized) {
+       if (mParent->GetFirstChild() == mChild) {
+         NS_WARNING_ASSERTION(!mOffset.isSome() || !mOffset.value(),
+           "If mOffset was initialized, it should be 0");
+         return true;
+       }
+       NS_WARNING_ASSERTION(!mOffset.isSome() ||
+-                           mParent->GetChildAt(mOffset.value()) == mChild,
++                           mParent->GetChildAt_Deprecated(mOffset.value()) == mChild,
+         "If mOffset and mChild are mismatched");
+       return false;
+     }
+     MOZ_ASSERT(mOffset.isSome());
+     return !mOffset.value();
+   }
+ 
+   bool
+@@ -596,17 +596,17 @@ public:
+     if (mIsChildInitialized) {
+       if (!mChild) {
+         NS_WARNING_ASSERTION(!mOffset.isSome() ||
+                              mOffset.value() == mParent->Length(),
+           "If mOffset was initialized, it should be length of the container");
+         return true;
+       }
+       NS_WARNING_ASSERTION(!mOffset.isSome() ||
+-                           mParent->GetChildAt(mOffset.value()) == mChild,
++                           mParent->GetChildAt_Deprecated(mOffset.value()) == mChild,
+         "If mOffset and mChild are mismatched");
+       return false;
+     }
+     MOZ_ASSERT(mOffset.isSome());
+     return mOffset.value() == mParent->Length();
+   }
+ 
+   bool
+@@ -738,17 +738,17 @@ public:
+       return RawRangeBoundary(mParent, mOffset.value());
+     }
+     if (mIsChildInitialized && mOffset.isSome()) {
+       // If we've already set both child and offset, we should create
+       // RangeBoundary with offset after validation.
+ #ifdef DEBUG
+       if (mChild) {
+         MOZ_ASSERT(mParent == mChild->GetParentNode());
+-        MOZ_ASSERT(mParent->GetChildAt(mOffset.value()) == mChild);
++        MOZ_ASSERT(mParent->GetChildAt_Deprecated(mOffset.value()) == mChild);
+       } else {
+         MOZ_ASSERT(mParent->Length() == mOffset.value());
+       }
+ #endif // #ifdef DEBUG
+       return RawRangeBoundary(mParent,  mOffset.value());
+     }
+     // Otherwise, we should create RangeBoundaryBase only with available
+     // information.
+@@ -773,17 +773,17 @@ private:
+       return;
+     }
+     MOZ_ASSERT(mOffset.isSome());
+     MOZ_ASSERT(mOffset.value() <= mParent->Length());
+     mIsChildInitialized = true;
+     if (!mParent->IsContainerNode()) {
+       return;
+     }
+-    mChild = mParent->GetChildAt(mOffset.value());
++    mChild = mParent->GetChildAt_Deprecated(mOffset.value());
+     MOZ_ASSERT(mChild || mOffset.value() == mParent->Length());
+   }
+ 
+   ParentType mParent;
+   ChildType mChild;
+ 
+   mozilla::Maybe<uint32_t> mOffset;
+ 
+diff --git a/editor/libeditor/HTMLEditorDataTransfer.cpp b/editor/libeditor/HTMLEditorDataTransfer.cpp
+--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
++++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
+@@ -417,17 +417,17 @@ HTMLEditor::DoInsertHTMLWithContext(cons
+ 
+     // don't orphan partial list or table structure
+     if (highWaterMark >= 0) {
+       ReplaceOrphanedStructure(StartOrEnd::end, nodeList,
+                                endListAndTableArray, highWaterMark);
+     }
+ 
+     MOZ_ASSERT(pointToInsert.GetContainer()->
+-                               GetChildAt(pointToInsert.Offset()) ==
++                               GetChildAt_Deprecated(pointToInsert.Offset()) ==
+                  pointToInsert.GetChild());
+ 
+     // Loop over the node list and paste the nodes:
+     nsCOMPtr<nsINode> parentBlock =
+       IsBlockNode(pointToInsert.GetContainer()) ?
+         pointToInsert.GetContainer() :
+         GetBlockNodeParent(pointToInsert.GetContainer());
+     nsCOMPtr<nsIContent> lastInsertNode;
+diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
+--- a/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
++++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.cpp
+@@ -128,17 +128,17 @@ FindNextNode(nsINode* aNode, nsINode* aR
+ static nsINode*
+ FindNextTextNode(nsINode* aNode, int32_t aOffset, nsINode* aRoot)
+ {
+   NS_PRECONDITION(aNode, "Null starting node?");
+   NS_ASSERTION(!IsSpellCheckingTextNode(aNode), "FindNextTextNode should start with a non-text node");
+ 
+   nsINode* checkNode;
+   // Need to start at the aOffset'th child
+-  nsIContent* child = aNode->GetChildAt(aOffset);
++  nsIContent* child = aNode->GetChildAt_Deprecated(aOffset);
+ 
+   if (child) {
+     checkNode = child;
+   } else {
+     // aOffset was beyond the end of the child list.
+     // goto next node after the last descendant of aNode in
+     // a preorder DOM traversal.
+     checkNode = aNode->GetNextNonChildNode(aRoot);
+diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
+--- a/layout/base/nsCSSFrameConstructor.cpp
++++ b/layout/base/nsCSSFrameConstructor.cpp
+@@ -7327,17 +7327,17 @@ nsCSSFrameConstructor::CreateNeededFrame
+   // child lists).
+ 
+   // Scan the children of aContent to see what operations (if any) we need to
+   // perform.
+   uint32_t childCount = aContent->GetChildCount();
+   bool inRun = false;
+   nsIContent* firstChildInRun = nullptr;
+   for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent* child = aContent->GetChildAt(i);
++    nsIContent* child = aContent->GetChildAt_Deprecated(i);
+     if (child->HasFlag(NODE_NEEDS_FRAME)) {
+       NS_ASSERTION(!child->GetPrimaryFrame() ||
+                    child->GetPrimaryFrame()->GetContent() != child,
+                    //XXX the child->GetPrimaryFrame()->GetContent() != child
+                    // check is needed due to bug 135040. Remove it once that's
+                    // fixed.
+                    "NEEDS_FRAME set on a node that already has a frame?");
+       if (!inRun) {
+@@ -7807,18 +7807,18 @@ nsCSSFrameConstructor::ContentAppended(n
+                               frameItems);
+ 
+   for (nsIContent* child = aFirstNewContent;
+        child;
+        child = child->GetNextSibling()) {
+     // Invalidate now instead of before the WipeContainingBlock call, just in
+     // case we do wipe; in that case we don't need to do this walk at all.
+     // XXXbz does that matter?  Would it make more sense to save some virtual
+-    // GetChildAt calls instead and do this during construction of our
+-    // FrameConstructionItemList?
++    // GetChildAt_Deprecated calls instead and do this during construction of
++    // our FrameConstructionItemList?
+     InvalidateCanvasIfNeeded(mPresShell, child);
+   }
+ 
+   // If the container is a table and a caption was appended, it needs to be put
+   // in the table wrapper frame's additional child list.
+   nsFrameItems captionItems;
+   if (LayoutFrameType::Table == frameType) {
+     // Pull out the captions.  Note that we don't want to do that as we go,
+diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp
+--- a/layout/base/nsPresContext.cpp
++++ b/layout/base/nsPresContext.cpp
+@@ -1314,17 +1314,17 @@ void nsPresContext::SetImgAnimations(nsI
+     nsCOMPtr<imgIRequest> imgReq;
+     imgContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
+                            getter_AddRefs(imgReq));
+     SetImgAnimModeOnImgReq(imgReq, aMode);
+   }
+ 
+   uint32_t count = aParent->GetChildCount();
+   for (uint32_t i = 0; i < count; ++i) {
+-    SetImgAnimations(aParent->GetChildAt(i), aMode);
++    SetImgAnimations(aParent->GetChildAt_Deprecated(i), aMode);
+   }
+ }
+ 
+ void
+ nsPresContext::SetSMILAnimations(nsIDocument *aDoc, uint16_t aNewMode,
+                                  uint16_t aOldMode)
+ {
+   if (aDoc->HasAnimationController()) {
+diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
+--- a/layout/forms/nsTextControlFrame.cpp
++++ b/layout/forms/nsTextControlFrame.cpp
+@@ -942,23 +942,23 @@ nsTextControlFrame::SelectAllOrCollapseT
+ 
+   NS_ENSURE_TRUE(rootNode && rootContent, NS_ERROR_FAILURE);
+ 
+   int32_t numChildren = rootContent->GetChildCount();
+ 
+   if (numChildren > 0) {
+     // We never want to place the selection after the last
+     // br under the root node!
+-    nsIContent *child = rootContent->GetChildAt(numChildren - 1);
++    nsIContent *child = rootContent->GetChildAt_Deprecated(numChildren - 1);
+     if (child) {
+       if (child->IsHTMLElement(nsGkAtoms::br))
+         --numChildren;
+     }
+     if (!aSelect && numChildren) {
+-      child = rootContent->GetChildAt(numChildren - 1);
++      child = rootContent->GetChildAt_Deprecated(numChildren - 1);
+       if (child && child->IsNodeOfType(nsINode::eTEXT)) {
+         rootNode = do_QueryInterface(child);
+         const nsTextFragment* fragment = child->GetText();
+         numChildren = fragment ? fragment->GetLength() : 0;
+       }
+     }
+   }
+ 
+@@ -1265,17 +1265,17 @@ nsTextControlFrame::UpdateValueDisplay(b
+ {
+   if (!IsSingleLineTextControl()) // textareas don't use this
+     return NS_OK;
+ 
+   NS_PRECONDITION(mRootNode, "Must have a div content\n");
+   NS_PRECONDITION(!mEditorHasBeenInitialized,
+                   "Do not call this after editor has been initialized");
+ 
+-  nsIContent* textContent = mRootNode->GetChildAt(0);
++  nsIContent* textContent = mRootNode->GetChildAt_Deprecated(0);
+   if (!textContent) {
+     // Set up a textnode with our value
+     RefPtr<nsTextNode> textNode =
+       new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
+     textNode->MarkAsMaybeModifiedFrequently();
+ 
+     mRootNode->AppendChildTo(textNode, aNotify);
+     textContent = textNode;
+diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp
+--- a/layout/generic/nsFrameSelection.cpp
++++ b/layout/generic/nsFrameSelection.cpp
+@@ -1632,17 +1632,17 @@ nsFrameSelection::GetFrameForNodeOffset(
+             childIndex = 0;
+           }
+         } else {
+           childIndex = aOffset;
+         }
+       }
+ 
+       if (childIndex > 0 || numChildren > 0) {
+-        nsCOMPtr<nsIContent> childNode = theNode->GetChildAt(childIndex);
++        nsCOMPtr<nsIContent> childNode = theNode->GetChildAt_Deprecated(childIndex);
+ 
+         if (!childNode) {
+           break;
+         }
+ 
+         theNode = childNode;
+       }
+ 
+@@ -1673,17 +1673,17 @@ nsFrameSelection::GetFrameForNodeOffset(
+               *aReturnOffset = 0;
+             }
+           } else {
+             int32_t numChildren = aNode->GetChildCount();
+             int32_t newChildIndex =
+               aHint == CARET_ASSOCIATE_BEFORE ? childIndex - 1 : childIndex + 1;
+ 
+             if (newChildIndex >= 0 && newChildIndex < numChildren) {
+-              nsCOMPtr<nsIContent> newChildNode = aNode->GetChildAt(newChildIndex);
++              nsCOMPtr<nsIContent> newChildNode = aNode->GetChildAt_Deprecated(newChildIndex);
+               if (!newChildNode) {
+                 return nullptr;
+               }
+ 
+               aNode = newChildNode;
+               aOffset = aHint == CARET_ASSOCIATE_BEFORE ? aNode->GetChildCount() : 0;
+               continue;
+             } else {
+@@ -2130,17 +2130,17 @@ GetFirstSelectedContent(nsRange* aRange)
+   if (!aRange) {
+     return nullptr;
+   }
+ 
+   NS_PRECONDITION(aRange->GetStartContainer(), "Must have start parent!");
+   NS_PRECONDITION(aRange->GetStartContainer()->IsElement(),
+                   "Unexpected parent");
+ 
+-  return aRange->GetStartContainer()->GetChildAt(aRange->StartOffset());
++  return aRange->GetStartContainer()->GetChildAt_Deprecated(aRange->StartOffset());
+ }
+ 
+ // Table selection support.
+ // TODO: Separate table methods into a separate nsITableSelection interface
+ nsresult
+ nsFrameSelection::HandleTableSelection(nsINode* aParentContent,
+                                        int32_t aContentOffset,
+                                        int32_t aTarget,
+@@ -2153,17 +2153,17 @@ nsFrameSelection::HandleTableSelection(n
+   {
+     // We were selecting cells and user drags mouse in table border or inbetween cells,
+     //  just do nothing
+       return NS_OK;
+   }
+ 
+   nsresult result = NS_OK;
+ 
+-  nsIContent *childContent = aParentContent->GetChildAt(aContentOffset);
++  nsIContent *childContent = aParentContent->GetChildAt_Deprecated(aContentOffset);
+ 
+   // When doing table selection, always set the direction to next so
+   // we can be sure that anchorNode's offset always points to the
+   // selected cell
+   int8_t index = GetIndexFromSelectionType(SelectionType::eNormal);
+   if (!mDomSelections[index])
+     return NS_ERROR_NULL_POINTER;
+ 
+@@ -2415,17 +2415,17 @@ printf("HandleTableSelection: Unselectin
+ 
+           nsINode* container = range->GetStartContainer();
+           if (!container) {
+             return NS_ERROR_NULL_POINTER;
+           }
+ 
+           int32_t offset = range->StartOffset();
+           // Be sure previous selection is a table cell
+-          nsIContent* child = container->GetChildAt(offset);
++          nsIContent* child = container->GetChildAt_Deprecated(offset);
+           if (child && IsCell(child)) {
+             previousCellParent = container;
+           }
+ 
+           // We're done if we didn't find parent of a previously-selected cell
+           if (!previousCellParent) break;
+ 
+           if (previousCellParent == aParentContent && offset == aContentOffset)
+@@ -2767,17 +2767,17 @@ nsFrameSelection::GetFirstCellNodeInRang
+ 
+   nsINode* startContainer = aRange->GetStartContainer();
+   if (!startContainer) {
+     return nullptr;
+   }
+ 
+   int32_t offset = aRange->StartOffset();
+ 
+-  nsIContent* childContent = startContainer->GetChildAt(offset);
++  nsIContent* childContent = startContainer->GetChildAt_Deprecated(offset);
+   if (!childContent)
+     return nullptr;
+   // Don't return node if not a cell
+   if (!IsCell(childContent))
+     return nullptr;
+ 
+   return childContent;
+ }
+diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp
+--- a/layout/printing/nsPrintJob.cpp
++++ b/layout/printing/nsPrintJob.cpp
+@@ -2535,17 +2535,17 @@ GetCorrespondingNodeInDocument(const nsI
+     MOZ_ASSERT(index >= 0);
+     indexArray.AppendElement(index);
+     child = parent;
+   }
+   MOZ_ASSERT(child->IsNodeOfType(nsINode::eDOCUMENT));
+ 
+   nsINode* correspondingNode = aDoc;
+   for (int32_t i = indexArray.Length() - 1; i >= 0; --i) {
+-    correspondingNode = correspondingNode->GetChildAt(indexArray[i]);
++    correspondingNode = correspondingNode->GetChildAt_Deprecated(indexArray[i]);
+     NS_ENSURE_TRUE(correspondingNode, nullptr);
+   }
+ 
+   return correspondingNode;
+ }
+ 
+ static NS_NAMED_LITERAL_STRING(kEllipsis, u"\x2026");
+ 
+diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
+--- a/layout/style/nsCSSRuleProcessor.cpp
++++ b/layout/style/nsCSSRuleProcessor.cpp
+@@ -1537,17 +1537,17 @@ checkGenericEmptyMatches(Element* aEleme
+ {
+   nsIContent *child = nullptr;
+   int32_t index = -1;
+ 
+   if (aTreeMatchContext.mForStyling)
+     aElement->SetFlags(NODE_HAS_EMPTY_SELECTOR);
+ 
+   do {
+-    child = aElement->GetChildAt(++index);
++    child = aElement->GetChildAt_Deprecated(++index);
+     // stop at first non-comment (and non-whitespace for
+     // :-moz-only-whitespace) node
+   } while (child && !IsSignificantChild(child, true, isWhitespaceSignificant));
+   return (child == nullptr);
+ }
+ 
+ static const EventStates sPseudoClassStates[] = {
+ #define CSS_PSEUDO_CLASS(_name, _value, _flags, _pref) \
+@@ -1811,17 +1811,17 @@ static bool SelectorMatches(Element* aEl
+         nsIContent *firstNode = nullptr;
+         nsIContent *parent = aElement->GetParent();
+         if (parent) {
+           if (aTreeMatchContext.mForStyling)
+             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
+ 
+           int32_t index = -1;
+           do {
+-            firstNode = parent->GetChildAt(++index);
++            firstNode = parent->GetChildAt_Deprecated(++index);
+             // stop at first non-comment and non-whitespace node
+           } while (firstNode &&
+                     !IsSignificantChild(firstNode, true, false));
+         }
+         if (aElement != firstNode) {
+           return false;
+         }
+       }
+@@ -1838,17 +1838,17 @@ static bool SelectorMatches(Element* aEl
+         nsIContent *lastNode = nullptr;
+         nsIContent *parent = aElement->GetParent();
+         if (parent) {
+           if (aTreeMatchContext.mForStyling)
+             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
+ 
+           uint32_t index = parent->GetChildCount();
+           do {
+-            lastNode = parent->GetChildAt(--index);
++            lastNode = parent->GetChildAt_Deprecated(--index);
+             // stop at first non-comment and non-whitespace node
+           } while (lastNode &&
+                     !IsSignificantChild(lastNode, true, false));
+         }
+         if (aElement != lastNode) {
+           return false;
+         }
+       }
+diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp
+--- a/layout/xul/nsListBoxBodyFrame.cpp
++++ b/layout/xul/nsListBoxBodyFrame.cpp
+@@ -731,17 +731,17 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
+     FlattenedChildIterator iter(mContent);
+     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
+       if (child->IsXULElement(nsGkAtoms::listitem)) {
+         gfxContext* rendContext = aBoxLayoutState.GetRenderingContext();
+         if (rendContext) {
+           nsAutoString value;
+           uint32_t textCount = child->GetChildCount();
+           for (uint32_t j = 0; j < textCount; ++j) {
+-            nsIContent* text = child->GetChildAt(j);
++            nsIContent* text = child->GetChildAt_Deprecated(j);
+             if (text && text->IsNodeOfType(nsINode::eTEXT)) {
+               text->AppendTextTo(value);
+             }
+           }
+ 
+           RefPtr<nsFontMetrics> fm =
+             nsLayoutUtils::GetFontMetricsForStyleContext(styleContext);
+ 
+@@ -1156,17 +1156,17 @@ nsListBoxBodyFrame::GetFirstItemBox(int3
+   if (mTopFrame && mRowsToPrepend > 0) {
+     // We need to insert rows before the top frame
+     nsIContent* topContent = mTopFrame->GetContent();
+     nsIContent* topParent = topContent->GetParent();
+     int32_t contentIndex = topParent->IndexOf(topContent);
+     contentIndex -= aOffset;
+     if (contentIndex < 0)
+       return nullptr;
+-    startContent = topParent->GetChildAt(contentIndex - mRowsToPrepend);
++    startContent = topParent->GetChildAt_Deprecated(contentIndex - mRowsToPrepend);
+   } else {
+     // This will be the first item frame we create.  Use the content
+     // at the current index, which is the first index scrolled into view
+     GetListItemContentAt(mCurrentIndex+aOffset, getter_AddRefs(startContent));
+   }
+ 
+   if (startContent) {
+     nsIFrame* existingFrame;
+@@ -1218,17 +1218,17 @@ nsListBoxBodyFrame::GetNextItemBox(nsIFr
+     nsIContent* prevContent = aBox->GetContent();
+     nsIContent* parentContent = prevContent->GetParent();
+ 
+     int32_t i = parentContent->IndexOf(prevContent);
+ 
+     uint32_t childCount = parentContent->GetChildCount();
+     if (((uint32_t)i + aOffset + 1) < childCount) {
+       // There is a content node that wants a frame.
+-      nsIContent *nextContent = parentContent->GetChildAt(i + aOffset + 1);
++      nsIContent *nextContent = parentContent->GetChildAt_Deprecated(i + aOffset + 1);
+ 
+       nsIFrame* existingFrame;
+       if (!IsListItemChild(this, nextContent, &existingFrame)) {
+         return GetNextItemBox(aBox, ++aOffset, aCreated);
+       }
+       if (!existingFrame) {
+         // Either append the new frame, or insert it after the current frame
+         bool isAppend = result != mLinkupFrame && mRowsToPrepend <= 0;
+diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp
+--- a/layout/xul/nsXULTooltipListener.cpp
++++ b/layout/xul/nsXULTooltipListener.cpp
+@@ -547,17 +547,17 @@ nsXULTooltipListener::HideTooltip()
+ }
+ 
+ static void
+ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
+ {
+   *aResult = nullptr;
+   uint32_t childCount = aContent->GetChildCount();
+   for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent *child = aContent->GetChildAt(i);
++    nsIContent *child = aContent->GetChildAt_Deprecated(i);
+ 
+     if (child->IsXULElement(aTag)) {
+       *aResult = child;
+       NS_ADDREF(*aResult);
+       return;
+     }
+   }
+ }
+diff --git a/layout/xul/tree/nsTreeColumns.cpp b/layout/xul/tree/nsTreeColumns.cpp
+--- a/layout/xul/tree/nsTreeColumns.cpp
++++ b/layout/xul/tree/nsTreeColumns.cpp
+@@ -690,17 +690,17 @@ nsTreeColumns::RestoreNaturalOrder()
+ 
+   // Strong ref, since we'll be setting attributes
+   nsCOMPtr<nsIContent> colsContent =
+     nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treecols);
+   if (!colsContent)
+     return NS_OK;
+ 
+   for (uint32_t i = 0; i < colsContent->GetChildCount(); ++i) {
+-    nsCOMPtr<nsIContent> child = colsContent->GetChildAt(i);
++    nsCOMPtr<nsIContent> child = colsContent->GetChildAt_Deprecated(i);
+     nsAutoString ordinal;
+     ordinal.AppendInt(i);
+     if (child->IsElement()) {
+       child->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::ordinal, ordinal,
+                                   true);
+     }
+   }
+ 
+diff --git a/layout/xul/tree/nsTreeContentView.cpp b/layout/xul/tree/nsTreeContentView.cpp
+--- a/layout/xul/tree/nsTreeContentView.cpp
++++ b/layout/xul/tree/nsTreeContentView.cpp
+@@ -1332,17 +1332,17 @@ nsTreeContentView::GetIndexInSubtree(nsI
+                                      nsIContent* aContent, int32_t* aIndex)
+ {
+   uint32_t childCount = aContainer->GetChildCount();
+ 
+   if (!aContainer->IsXULElement())
+     return;
+ 
+   for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent *content = aContainer->GetChildAt(i);
++    nsIContent *content = aContainer->GetChildAt_Deprecated(i);
+ 
+     if (content == aContent)
+       break;
+ 
+     if (content->IsXULElement(nsGkAtoms::treeitem)) {
+       if (!content->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
+                                              nsGkAtoms::_true, eCaseMatters)) {
+         (*aIndex)++;
+diff --git a/layout/xul/tree/nsTreeUtils.cpp b/layout/xul/tree/nsTreeUtils.cpp
+--- a/layout/xul/tree/nsTreeUtils.cpp
++++ b/layout/xul/tree/nsTreeUtils.cpp
+@@ -91,17 +91,17 @@ nsTreeUtils::UpdateSortIndicators(Elemen
+ 
+   // Unset sort attribute(s) on the other columns
+   nsCOMPtr<nsIContent> parentContent = aColumn->GetParent();
+   if (parentContent &&
+       parentContent->NodeInfo()->Equals(nsGkAtoms::treecols,
+                                         kNameSpaceID_XUL)) {
+     uint32_t i, numChildren = parentContent->GetChildCount();
+     for (i = 0; i < numChildren; ++i) {
+-      nsCOMPtr<nsIContent> childContent = parentContent->GetChildAt(i);
++      nsCOMPtr<nsIContent> childContent = parentContent->GetChildAt_Deprecated(i);
+ 
+       if (childContent &&
+           childContent != aColumn &&
+           childContent->NodeInfo()->Equals(nsGkAtoms::treecol,
+                                            kNameSpaceID_XUL)) {
+         childContent->AsElement()->UnsetAttr(kNameSpaceID_None,
+                                              nsGkAtoms::sortDirection, true);
+         childContent->AsElement()->UnsetAttr(kNameSpaceID_None,
+@@ -118,17 +118,17 @@ nsTreeUtils::GetColumnIndex(Element* aCo
+ {
+   nsIContent* parentContent = aColumn->GetParent();
+   if (parentContent &&
+       parentContent->NodeInfo()->Equals(nsGkAtoms::treecols,
+                                         kNameSpaceID_XUL)) {
+     uint32_t i, numChildren = parentContent->GetChildCount();
+     int32_t colIndex = 0;
+     for (i = 0; i < numChildren; ++i) {
+-      nsIContent* childContent = parentContent->GetChildAt(i);
++      nsIContent* childContent = parentContent->GetChildAt_Deprecated(i);
+       if (childContent &&
+           childContent->NodeInfo()->Equals(nsGkAtoms::treecol,
+                                            kNameSpaceID_XUL)) {
+         if (childContent == aColumn) {
+           *aResult = colIndex;
+           return NS_OK;
+         }
+         ++colIndex;
+diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
++++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+@@ -890,17 +890,17 @@ nsTypeAheadFind::RangeStartsInsideLink(n
+   startContent = do_QueryInterface(startNode);
+   if (!startContent) {
+     NS_NOTREACHED("startContent should never be null");
+     return;
+   }
+   origContent = startContent;
+ 
+   if (startContent->IsElement()) {
+-    nsIContent *childContent = startContent->GetChildAt(startOffset);
++    nsIContent *childContent = startContent->GetChildAt_Deprecated(startOffset);
+     if (childContent) {
+       startContent = childContent;
+     }
+   }
+   else if (startOffset > 0) {
+     const nsTextFragment *textFrag = startContent->GetText();
+     if (textFrag) {
+       // look for non whitespace character before start offset
+diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm
+--- a/widget/cocoa/nsMenuBarX.mm
++++ b/widget/cocoa/nsMenuBarX.mm
+@@ -160,17 +160,17 @@ nsresult nsMenuBarX::Create(nsIWidget* a
+ 
+   return NS_OK;
+ }
+ 
+ void nsMenuBarX::ConstructNativeMenus()
+ {
+   uint32_t count = mContent->GetChildCount();
+   for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *menuContent = mContent->GetChildAt(i);
++    nsIContent *menuContent = mContent->GetChildAt_Deprecated(i);
+     if (menuContent &&
+         menuContent->IsXULElement(nsGkAtoms::menu)) {
+       nsMenuX* newMenu = new nsMenuX();
+       if (newMenu) {
+         nsresult rv = newMenu->Create(this, this, menuContent->AsElement());
+         if (NS_SUCCEEDED(rv))
+           InsertMenuAtIndex(newMenu, GetMenuCount());
+         else
+diff --git a/widget/cocoa/nsMenuItemX.mm b/widget/cocoa/nsMenuItemX.mm
+--- a/widget/cocoa/nsMenuItemX.mm
++++ b/widget/cocoa/nsMenuItemX.mm
+@@ -219,17 +219,17 @@ void nsMenuItemX::UncheckRadioSiblings(n
+ 
+   nsCOMPtr<nsIContent> parent = inCheckedContent->GetParent();
+   if (!parent)
+     return;
+ 
+   // loop over siblings
+   uint32_t count = parent->GetChildCount();
+   for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *sibling = parent->GetChildAt(i);
++    nsIContent *sibling = parent->GetChildAt_Deprecated(i);
+     if (sibling &&
+         sibling != inCheckedContent &&
+         sibling->IsElement()) { // skip this node
+       // if the current sibling is in the same group, clear it
+       if (sibling->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
+                                             myGroupName, eCaseMatters)) {
+         sibling->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::checked, NS_LITERAL_STRING("false"), true);
+       }
+diff --git a/widget/cocoa/nsMenuX.mm b/widget/cocoa/nsMenuX.mm
+--- a/widget/cocoa/nsMenuX.mm
++++ b/widget/cocoa/nsMenuX.mm
+@@ -435,17 +435,17 @@ void nsMenuX::MenuConstruct()
+         mXBLAttached = true;
+       }
+     }
+   }
+ 
+   // Iterate over the kids
+   uint32_t count = menuPopup->GetChildCount();
+   for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *child = menuPopup->GetChildAt(i);
++    nsIContent *child = menuPopup->GetChildAt_Deprecated(i);
+     if (child) {
+       // depending on the type, create a menu item, separator, or submenu
+       if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
+                                     nsGkAtoms::menuseparator)) {
+         LoadMenuItem(child);
+       } else if (child->IsXULElement(nsGkAtoms::menu)) {
+         LoadSubMenu(child);
+       }
+@@ -653,17 +653,17 @@ void nsMenuX::GetMenuPopupContent(nsICon
+   }
+ 
+   // Otherwise check our child nodes.
+ 
+   uint32_t count = mContent->GetChildCount();
+ 
+   for (uint32_t i = 0; i < count; i++) {
+     int32_t dummy;
+-    nsIContent *child = mContent->GetChildAt(i);
++    nsIContent *child = mContent->GetChildAt_Deprecated(i);
+     nsCOMPtr<nsIAtom> tag = child->OwnerDoc()->BindingManager()->ResolveTag(child, &dummy);
+     if (tag == nsGkAtoms::menupopup) {
+       *aResult = child;
+       NS_ADDREF(*aResult);
+       return;
+     }
+   }
+ }

+ 1008 - 0
mozilla-release/patches/1425321-2-59a1.patch

@@ -0,0 +1,1008 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514984463 -3600
+# Node ID e6e3487083570a5c8f31343d672e6f3bb84374e8
+# Parent  3db14151aef820e231b7edea545313e7a40c24cb
+Bug 1425321 - Renaming nsINode::RemoveChildAt to RemoveChildAt_Deprecated, r=catalinb
+
+diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp
+--- a/dom/base/Attr.cpp
++++ b/dom/base/Attr.cpp
+@@ -322,17 +322,17 @@ Attr::IndexOf(const nsINode* aPossibleCh
+ nsresult
+ Attr::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                               bool aNotify)
+ {
+   return NS_ERROR_NOT_IMPLEMENTED;
+ }
+ 
+ void
+-Attr::RemoveChildAt(uint32_t aIndex, bool aNotify)
++Attr::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+ }
+ 
+ nsresult
+ Attr::GetEventTargetParent(EventChainPreVisitor& aVisitor)
+ {
+   aVisitor.mCanHandle = true;
+   return NS_OK;
+diff --git a/dom/base/Attr.h b/dom/base/Attr.h
+--- a/dom/base/Attr.h
++++ b/dom/base/Attr.h
+@@ -64,17 +64,17 @@ public:
+ 
+   // nsINode interface
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+   virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
+ 
+   static void Initialize();
+   static void Shutdown();
+ 
+   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
+--- a/dom/base/FragmentOrElement.cpp
++++ b/dom/base/FragmentOrElement.cpp
+@@ -1156,20 +1156,20 @@ FragmentOrElement::InsertChildAt(nsICont
+                                 bool aNotify)
+ {
+   NS_PRECONDITION(aKid, "null ptr");
+ 
+   return doInsertChildAt(aKid, aIndex, aNotify, mAttrsAndChildren);
+ }
+ 
+ void
+-FragmentOrElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++FragmentOrElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
+-  NS_ASSERTION(oldKid == GetChildAt_Deprecated(aIndex), "Unexpected child in RemoveChildAt");
++  NS_ASSERTION(oldKid == GetChildAt_Deprecated(aIndex), "Unexpected child in RemoveChildAt_Deprecated");
+ 
+   if (oldKid) {
+     doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren);
+   }
+ }
+ 
+ void
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
+@@ -2297,17 +2297,17 @@ FragmentOrElement::SetInnerHTMLInternal(
+ 
+   // Needed when innerHTML is used in combination with contenteditable
+   mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
+ 
+   // Remove childnodes.
+   uint32_t childCount = target->GetChildCount();
+   nsAutoMutationBatch mb(target, true, false);
+   for (uint32_t i = 0; i < childCount; ++i) {
+-    target->RemoveChildAt(0, true);
++    target->RemoveChildAt_Deprecated(0, true);
+   }
+   mb.RemovalDone();
+ 
+   nsAutoScriptLoaderDisabler sld(doc);
+ 
+   nsIAtom* contextLocalName = NodeInfo()->NameAtom();
+   int32_t contextNameSpaceID = GetNameSpaceID();
+ 
+diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
+--- a/dom/base/FragmentOrElement.h
++++ b/dom/base/FragmentOrElement.h
+@@ -117,17 +117,17 @@ public:
+   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
+ 
+   // nsINode interface methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override;
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+                                       mozilla::ErrorResult& aError) override;
+ 
+   // nsIContent interface methods
+   virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) override;
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -5456,28 +5456,28 @@ nsContentUtils::SetNodeTextContent(nsICo
+       nsIContent* child = aContent->GetChildAt_Deprecated(removeIndex);
+       if (removeIndex == 0 && child && child->IsNodeOfType(nsINode::eTEXT)) {
+         nsresult rv = child->SetText(aValue, true);
+         NS_ENSURE_SUCCESS(rv, rv);
+ 
+         removeIndex = 1;
+       }
+       else {
+-        aContent->RemoveChildAt(removeIndex, true);
++        aContent->RemoveChildAt_Deprecated(removeIndex, true);
+       }
+     }
+ 
+     if (removeIndex == 1) {
+       return NS_OK;
+     }
+   }
+   else {
+     mb.Init(aContent, true, false);
+     for (uint32_t i = 0; i < childCount; ++i) {
+-      aContent->RemoveChildAt(0, true);
++      aContent->RemoveChildAt_Deprecated(0, true);
+     }
+   }
+   mb.RemovalDone();
+ 
+   if (aValue.IsEmpty()) {
+     return NS_OK;
+   }
+ 
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
+--- a/dom/base/nsDocument.cpp
++++ b/dom/base/nsDocument.cpp
+@@ -4289,17 +4289,17 @@ nsDocument::InsertChildAt(nsIContent* aK
+     NS_WARNING("Inserting root element when we already have one");
+     return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR;
+   }
+ 
+   return doInsertChildAt(aKid, aIndex, aNotify, mChildren);
+ }
+ 
+ void
+-nsDocument::RemoveChildAt(uint32_t aIndex, bool aNotify)
++nsDocument::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   nsCOMPtr<nsIContent> oldKid = GetChildAt_Deprecated(aIndex);
+   if (!oldKid) {
+     return;
+   }
+ 
+   if (oldKid->IsElement()) {
+     // Destroy the link map up front before we mess with the child list.
+@@ -7416,17 +7416,17 @@ nsDOMAttributeMap::BlastSubtreeToPieces(
+         NS_ASSERTION(NS_SUCCEEDED(rv), "Uh-oh, UnsetAttr shouldn't fail!");
+       }
+     }
+   }
+ 
+   uint32_t count = aNode->GetChildCount();
+   for (uint32_t i = 0; i < count; ++i) {
+     BlastSubtreeToPieces(aNode->GetFirstChild());
+-    aNode->RemoveChildAt(0, false);
++    aNode->RemoveChildAt_Deprecated(0, false);
+   }
+ }
+ 
+ enum class StyleDataType
+ {
+   InlineStyle,
+   SMILOverride,
+   RestyleBits,
+@@ -7616,17 +7616,17 @@ nsIDocument::AdoptNode(nsINode& aAdopted
+         }
+       } while ((doc = doc->GetParentDocument()));
+ 
+       // Remove from parent.
+       nsCOMPtr<nsINode> parent = adoptedNode->GetParentNode();
+       if (parent) {
+         int32_t idx = parent->IndexOf(adoptedNode);
+         MOZ_ASSERT(idx >= 0);
+-        parent->RemoveChildAt(idx, true);
++        parent->RemoveChildAt_Deprecated(idx, true);
+       } else {
+         MOZ_ASSERT(!adoptedNode->IsInUncomposedDoc());
+ 
+         // If we're adopting a node that's not in a document, it might still
+         // have a binding applied. Remove the binding from the element now
+         // that it's getting adopted into a new document.
+         // TODO Fully tear down the binding.
+         if (adoptedNode->IsElement()) {
+diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
+--- a/dom/base/nsDocument.h
++++ b/dom/base/nsDocument.h
+@@ -550,17 +550,17 @@ public:
+ 
+   // nsINode
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override
+   {
+     return NS_ERROR_NOT_IMPLEMENTED;
+   }
+ 
+   // nsIRadioGroupContainer
+   NS_IMETHOD WalkRadioGroup(const nsAString& aName,
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
+--- a/dom/base/nsGenericDOMDataNode.cpp
++++ b/dom/base/nsGenericDOMDataNode.cpp
+@@ -654,17 +654,17 @@ nsGenericDOMDataNode::IndexOf(const nsIN
+ nsresult
+ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                     bool aNotify)
+ {
+   return NS_OK;
+ }
+ 
+ void
+-nsGenericDOMDataNode::RemoveChildAt(uint32_t aIndex, bool aNotify)
++nsGenericDOMDataNode::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+ }
+ 
+ nsXBLBinding *
+ nsGenericDOMDataNode::DoGetXBLBinding() const
+ {
+   return nullptr;
+ }
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
+--- a/dom/base/nsGenericDOMDataNode.h
++++ b/dom/base/nsGenericDOMDataNode.h
+@@ -104,17 +104,17 @@ public:
+                        const nsAString& aArg);
+ 
+   // nsINode methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override
+   {
+     GetNodeValue(aTextContent);
+   }
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+                                       mozilla::ErrorResult& aError) override
+diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
+--- a/dom/base/nsINode.cpp
++++ b/dom/base/nsINode.cpp
+@@ -619,17 +619,17 @@ nsINode::RemoveChild(nsINode& aOldChild,
+ 
+   int32_t index = IndexOf(&aOldChild);
+   if (index == -1) {
+     // aOldChild isn't one of our children.
+     aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
+     return nullptr;
+   }
+ 
+-  RemoveChildAt(index, true);
++  RemoveChildAt_Deprecated(index, true);
+   return &aOldChild;
+ }
+ 
+ nsresult
+ nsINode::RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn)
+ {
+   nsCOMPtr<nsINode> oldChild = do_QueryInterface(aOldChild);
+   if (!oldChild) {
+@@ -726,17 +726,17 @@ nsINode::Normalize()
+     }
+ 
+     // Remove node
+     nsCOMPtr<nsINode> parent = node->GetParentNode();
+     NS_ASSERTION(parent || hasRemoveListeners,
+                  "Should always have a parent unless "
+                  "mutation events messed us up");
+     if (parent) {
+-      parent->RemoveChildAt(parent->IndexOf(node), true);
++      parent->RemoveChildAt_Deprecated(parent->IndexOf(node), true);
+     }
+   }
+ }
+ 
+ nsresult
+ nsINode::GetBaseURI(nsAString &aURI) const
+ {
+   nsCOMPtr<nsIURI> baseURI = GetBaseURI();
+@@ -1967,17 +1967,18 @@ 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().
++  // value for our cached root element, per note in
++  // nsDocument::RemoveChildAt_Deprecated().
+   MOZ_ASSERT(aKid && aKid->GetParentNode() == this &&
+              aKid == GetChildAt_Deprecated(aIndex) &&
+              IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
+   MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE));
+ 
+   nsMutationGuard::DidMutate();
+   mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
+ 
+@@ -2300,17 +2301,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+     nsMutationGuard guard;
+ 
+     // Scope for the mutation batch and scriptblocker, so they go away
+     // while kungFuDeathGrip is still alive.
+     {
+       mozAutoDocUpdate batch(newContent->GetComposedDoc(),
+                              UPDATE_CONTENT_MODEL, true);
+       nsAutoMutationBatch mb(oldParent, true, true);
+-      oldParent->RemoveChildAt(removeIndex, true);
++      oldParent->RemoveChildAt_Deprecated(removeIndex, true);
+       if (nsAutoMutationBatch::GetCurrentBatch() == &mb) {
+         mb.RemovalDone();
+         mb.SetPrevSibling(oldParent->GetChildAt_Deprecated(removeIndex - 1));
+         mb.SetNextSibling(oldParent->GetChildAt_Deprecated(removeIndex));
+       }
+     }
+ 
+     // We expect one mutation (the removal) to have happened.
+@@ -2380,17 +2381,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+     // Scope for the mutation batch and scriptblocker, so they go away
+     // while kungFuDeathGrip is still alive.
+     {
+       mozAutoDocUpdate batch(newContent->GetComposedDoc(),
+                              UPDATE_CONTENT_MODEL, true);
+       nsAutoMutationBatch mb(newContent, false, true);
+ 
+       for (uint32_t i = count; i > 0;) {
+-        newContent->RemoveChildAt(--i, true);
++        newContent->RemoveChildAt_Deprecated(--i, true);
+       }
+     }
+ 
+     // We expect |count| removals
+     if (guard.Mutated(count)) {
+       // XBL destructors, yuck.
+ 
+       // Verify that nodeToInsertBefore, if non-null, is still our child.  If
+@@ -2478,17 +2479,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+     // Since aRefChild is never null in the aReplace case, we know that at
+     // this point nodeToInsertBefore is the next sibling of aRefChild.
+     NS_ASSERTION(aRefChild->GetNextSibling() == nodeToInsertBefore,
+                  "Unexpected nodeToInsertBefore");
+ 
+     // An since nodeToInsertBefore is at index insPos, we want to remove
+     // at the previous index.
+     NS_ASSERTION(insPos >= 1, "insPos too small");
+-    RemoveChildAt(insPos-1, true);
++    RemoveChildAt_Deprecated(insPos-1, true);
+     --insPos;
+   }
+ 
+   // Move new child over to our document if needed. Do this after removing
+   // it from its parent so that AdoptNode doesn't fire DOMNodeRemoved
+   // DocumentType nodes are the only nodes that can have a null
+   // ownerDocument according to the DOM spec, and we need to allow
+   // inserting them w/o calling AdoptNode().
+diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
+--- a/dom/base/nsINode.h
++++ b/dom/base/nsINode.h
+@@ -762,27 +762,30 @@ public:
+    * @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
+    */
+   nsresult AppendChildTo(nsIContent* aKid, bool aNotify)
+   {
+     return InsertChildAt(aKid, GetChildCount(), aNotify);
+   }
+ 
+   /**
++   * NOTE: this function is going to be removed soon (hopefully!) Don't use it
++   * in new code.
++   *
+    * Remove a child from this node.  This method handles calling UnbindFromTree
+    * on the child appropriately.
+    *
+    * @param aIndex the index of the child to remove
+    * @param aNotify whether to notify the document (current document for
+    *        nsIContent, and |this| for nsIDocument) that the remove has
+    *        occurred
+    *
+    * Note: If there is no child at aIndex, this method will simply do nothing.
+    */
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) = 0;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) = 0;
+ 
+   /**
+    * Get a property associated with this node.
+    *
+    * @param aPropertyName  name of property to get.
+    * @param aStatus        out parameter for storing resulting status.
+    *                       Set to NS_PROPTABLE_PROP_NOT_THERE if the property
+    *                       is not set.
+diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp
+--- a/dom/html/HTMLFieldSetElement.cpp
++++ b/dom/html/HTMLFieldSetElement.cpp
+@@ -165,17 +165,17 @@ HTMLFieldSetElement::InsertChildAt(nsICo
+   if (firstLegendHasChanged) {
+     NotifyElementsForFirstLegendChange(aNotify);
+   }
+ 
+   return rv;
+ }
+ 
+ void
+-HTMLFieldSetElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++HTMLFieldSetElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   bool firstLegendHasChanged = false;
+ 
+   if (mFirstLegend && (GetChildAt_Deprecated(aIndex) == mFirstLegend)) {
+     // If we are removing the first legend we have to found another one.
+     nsIContent* child = mFirstLegend->GetNextSibling();
+     mFirstLegend = nullptr;
+     firstLegendHasChanged = true;
+@@ -183,17 +183,17 @@ HTMLFieldSetElement::RemoveChildAt(uint3
+     for (; child; child = child->GetNextSibling()) {
+       if (child->IsHTMLElement(nsGkAtoms::legend)) {
+         mFirstLegend = child;
+         break;
+       }
+     }
+   }
+ 
+-  nsGenericHTMLFormElement::RemoveChildAt(aIndex, aNotify);
++  nsGenericHTMLFormElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ 
+   if (firstLegendHasChanged) {
+     NotifyElementsForFirstLegendChange(aNotify);
+   }
+ }
+ 
+ void
+ HTMLFieldSetElement::AddElement(nsGenericHTMLFormElement* aElement)
+diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h
+--- a/dom/html/HTMLFieldSetElement.h
++++ b/dom/html/HTMLFieldSetElement.h
+@@ -38,17 +38,17 @@ public:
+   virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                                 const nsAttrValue* aValue,
+                                 const nsAttrValue* aOldValue,
+                                 nsIPrincipal* aSubjectPrincipal,
+                                 bool aNotify) override;
+ 
+   virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex,
+                                      bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+ 
+   // nsIFormControl
+   NS_IMETHOD Reset() override;
+   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
+   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+ 
+diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp
+--- a/dom/html/HTMLOptGroupElement.cpp
++++ b/dom/html/HTMLOptGroupElement.cpp
+@@ -82,21 +82,21 @@ HTMLOptGroupElement::InsertChildAt(nsICo
+   nsresult rv = nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
+   if (NS_FAILED(rv)) {
+     safeMutation.MutationFailed();
+   }
+   return rv;
+ }
+ 
+ void
+-HTMLOptGroupElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++HTMLOptGroupElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
+                                       aNotify);
+-  nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
++  nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+ nsresult
+ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                                   const nsAttrValue* aValue,
+                                   const nsAttrValue* aOldValue,
+                                   nsIPrincipal* aSubjectPrincipal,
+                                   bool aNotify)
+diff --git a/dom/html/HTMLOptGroupElement.h b/dom/html/HTMLOptGroupElement.h
+--- a/dom/html/HTMLOptGroupElement.h
++++ b/dom/html/HTMLOptGroupElement.h
+@@ -22,17 +22,17 @@ public:
+   NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLOptGroupElement, optgroup)
+ 
+   // nsISupports
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   // nsINode
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+ 
+   // nsIContent
+   virtual nsresult GetEventTargetParent(
+                      EventChainPreVisitor& aVisitor) override;
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
+                          bool aPreallocateChildren) const override;
+ 
+diff --git a/dom/html/HTMLPictureElement.cpp b/dom/html/HTMLPictureElement.cpp
+--- a/dom/html/HTMLPictureElement.cpp
++++ b/dom/html/HTMLPictureElement.cpp
+@@ -28,17 +28,17 @@ HTMLPictureElement::~HTMLPictureElement(
+ {
+ }
+ 
+ NS_IMPL_ISUPPORTS_INHERITED0(HTMLPictureElement, nsGenericHTMLElement)
+ 
+ NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
+ 
+ void
+-HTMLPictureElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++HTMLPictureElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   nsCOMPtr<nsIContent> child = GetChildAt_Deprecated(aIndex);
+ 
+   if (child && child->IsHTMLElement(nsGkAtoms::img)) {
+     HTMLImageElement* img = HTMLImageElement::FromContent(child);
+     if (img) {
+       img->PictureSourceRemoved(child->AsContent());
+     }
+@@ -50,17 +50,17 @@ HTMLPictureElement::RemoveChildAt(uint32
+         HTMLImageElement* img = HTMLImageElement::FromContent(nextSibling);
+         if (img) {
+           img->PictureSourceRemoved(child->AsContent());
+         }
+       } while ( (nextSibling = nextSibling->GetNextSibling()) );
+     }
+   }
+ 
+-  nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
++  nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+ nsresult
+ HTMLPictureElement::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify)
+ {
+   nsresult rv = nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
+ 
+   NS_ENSURE_SUCCESS(rv, rv);
+diff --git a/dom/html/HTMLPictureElement.h b/dom/html/HTMLPictureElement.h
+--- a/dom/html/HTMLPictureElement.h
++++ b/dom/html/HTMLPictureElement.h
+@@ -18,17 +18,17 @@ class HTMLPictureElement final : public 
+ public:
+   explicit HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+ 
+   // nsISupports
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
+                          bool aPreallocateChildren) const override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify) override;
+ 
+ protected:
+   virtual ~HTMLPictureElement();
+ 
+   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ };
+ 
+diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
+--- a/dom/html/HTMLSelectElement.cpp
++++ b/dom/html/HTMLSelectElement.cpp
+@@ -213,20 +213,20 @@ HTMLSelectElement::InsertChildAt(nsICont
+                                                                  aNotify);
+   if (NS_FAILED(rv)) {
+     safeMutation.MutationFailed();
+   }
+   return rv;
+ }
+ 
+ void
+-HTMLSelectElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++HTMLSelectElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   SafeOptionListMutation safeMutation(this, this, nullptr, aIndex, aNotify);
+-  nsGenericHTMLFormElementWithState::RemoveChildAt(aIndex, aNotify);
++  nsGenericHTMLFormElementWithState::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+ 
+ 
+ void
+ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
+                                          int32_t aListIndex,
+                                          int32_t aDepth,
+diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h
+--- a/dom/html/HTMLSelectElement.h
++++ b/dom/html/HTMLSelectElement.h
+@@ -288,17 +288,17 @@ public:
+   virtual nsresult GetEventTargetParent(
+                      EventChainPreVisitor& aVisitor) override;
+   virtual nsresult PostHandleEvent(
+                      EventChainPostVisitor& aVisitor) override;
+ 
+   virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+ 
+   // Overriden nsIFormControl methods
+   NS_IMETHOD Reset() override;
+   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
+   NS_IMETHOD SaveState() override;
+   virtual bool RestoreState(nsPresState* aState) override;
+   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
+ 
+diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
+--- a/dom/html/nsGenericHTMLElement.cpp
++++ b/dom/html/nsGenericHTMLElement.cpp
+@@ -3021,17 +3021,17 @@ nsGenericHTMLElement::SetInnerText(const
+   mozAutoDocUpdate updateBatch(GetComposedDoc(),
+     UPDATE_CONTENT_MODEL, true);
+   nsAutoMutationBatch mb;
+ 
+   uint32_t childCount = GetChildCount();
+ 
+   mb.Init(this, true, false);
+   for (uint32_t i = 0; i < childCount; ++i) {
+-    RemoveChildAt(0, true);
++    RemoveChildAt_Deprecated(0, true);
+   }
+   mb.RemovalDone();
+ 
+   nsString str;
+   const char16_t* s = aValue.BeginReading();
+   const char16_t* end = aValue.EndReading();
+   while (true) {
+     if (s != end && *s == '\r' && s + 1 != end && s[1] == '\n') {
+diff --git a/dom/svg/SVGSwitchElement.cpp b/dom/svg/SVGSwitchElement.cpp
+--- a/dom/svg/SVGSwitchElement.cpp
++++ b/dom/svg/SVGSwitchElement.cpp
+@@ -89,19 +89,19 @@ SVGSwitchElement::InsertChildAt(nsIConte
+   nsresult rv = SVGSwitchElementBase::InsertChildAt(aKid, aIndex, aNotify);
+   if (NS_SUCCEEDED(rv)) {
+     MaybeInvalidate();
+   }
+   return rv;
+ }
+ 
+ void
+-SVGSwitchElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++SVGSwitchElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+-  SVGSwitchElementBase::RemoveChildAt(aIndex, aNotify);
++  SVGSwitchElementBase::RemoveChildAt_Deprecated(aIndex, aNotify);
+   MaybeInvalidate();
+ }
+ 
+ //----------------------------------------------------------------------
+ // nsIContent methods
+ 
+ NS_IMETHODIMP_(bool)
+ SVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const
+diff --git a/dom/svg/SVGSwitchElement.h b/dom/svg/SVGSwitchElement.h
+--- a/dom/svg/SVGSwitchElement.h
++++ b/dom/svg/SVGSwitchElement.h
+@@ -37,17 +37,17 @@ public:
+   // interfaces:
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement,
+                                            SVGSwitchElementBase)
+   // nsINode
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+-  virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+ 
+   // nsIContent
+   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+ private:
+   void UpdateActiveChild()
+diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
+--- a/dom/xbl/nsXBLPrototypeBinding.cpp
++++ b/dom/xbl/nsXBLPrototypeBinding.cpp
+@@ -389,17 +389,17 @@ nsXBLPrototypeBinding::AttributeChanged(
+ 
+       if ((dstAttr == nsGkAtoms::text && dstNs == kNameSpaceID_XBL) ||
+           (realElement->NodeInfo()->Equals(nsGkAtoms::html,
+                                            kNameSpaceID_XUL) &&
+            dstAttr == nsGkAtoms::value)) {
+         // Flush out all our kids.
+         uint32_t childCount = realElement->GetChildCount();
+         for (uint32_t i = 0; i < childCount; i++)
+-          realElement->RemoveChildAt(0, aNotify);
++          realElement->RemoveChildAt_Deprecated(0, aNotify);
+ 
+         if (!aRemoveFlag) {
+           // Construct a new text node and insert it.
+           nsAutoString value;
+           aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
+           if (!value.IsEmpty()) {
+             RefPtr<nsTextNode> textContent =
+               new nsTextNode(realElement->NodeInfo()->NodeInfoManager());
+diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
++++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+@@ -631,17 +631,17 @@ txMozillaXMLOutput::createTxWrapper()
+             // The new documentElement should go after the document type.
+             // This is needed for cases when there is no existing
+             // documentElement in the document.
+             rootLocation = std::max(rootLocation, j + 1);
+ #endif
+             ++j;
+         }
+         else {
+-            mDocument->RemoveChildAt(j, true);
++            mDocument->RemoveChildAt_Deprecated(j, true);
+ 
+             rv = wrapper->AppendChildTo(childContent, true);
+             NS_ENSURE_SUCCESS(rv, rv);
+             break;
+         }
+     }
+ 
+     if (!mCurrentNodeStack.AppendObject(wrapper)) {
+diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
+--- a/dom/xul/XULDocument.cpp
++++ b/dom/xul/XULDocument.cpp
+@@ -3943,23 +3943,23 @@ XULDocument::OverlayForwardReference::Me
+             if (parentID && aTargetElement->GetID() == parentID) {
+                 // The element matches. "Go Deep!"
+                 //
+                 // Note that currContent is necessarily an element, because
+                 // elementInDocument can only be non-null when currContent has a
+                 // non-null ID.
+                 rv = Merge(elementInDocument, currContent->AsElement(), aNotify);
+                 if (NS_FAILED(rv)) return rv;
+-                aOverlayElement->RemoveChildAt(0, false);
++                aOverlayElement->RemoveChildAt_Deprecated(0, false);
+ 
+                 continue;
+             }
+         }
+ 
+-        aOverlayElement->RemoveChildAt(0, false);
++        aOverlayElement->RemoveChildAt_Deprecated(0, false);
+ 
+         rv = InsertElement(aTargetElement, currContent, aNotify);
+         if (NS_FAILED(rv)) return rv;
+     }
+ 
+     return NS_OK;
+ }
+ 
+@@ -4333,17 +4333,17 @@ XULDocument::InsertElement(nsINode* aPar
+     return NS_OK;
+ }
+ 
+ nsresult
+ XULDocument::RemoveElement(nsINode* aParent, nsINode* aChild)
+ {
+     int32_t nodeOffset = aParent->IndexOf(aChild);
+ 
+-    aParent->RemoveChildAt(nodeOffset, true);
++    aParent->RemoveChildAt_Deprecated(nodeOffset, true);
+     return NS_OK;
+ }
+ 
+ //----------------------------------------------------------------------
+ //
+ // CachedChromeStreamListener
+ //
+ 
+diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp
+--- a/dom/xul/nsXULElement.cpp
++++ b/dom/xul/nsXULElement.cpp
+@@ -861,17 +861,17 @@ nsXULElement::UnbindFromTree(bool aDeep,
+         }
+         slots->mFrameLoaderOrOpener = nullptr;
+     }
+ 
+     nsStyledElement::UnbindFromTree(aDeep, aNullParent);
+ }
+ 
+ void
+-nsXULElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
++nsXULElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+     nsCOMPtr<nsIContent> oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex);
+     if (!oldKid) {
+       return;
+     }
+ 
+     // On the removal of a <treeitem>, <treechildren>, or <treecell> element,
+     // the possibility exists that some of the items in the removed subtree
+@@ -929,17 +929,17 @@ nsXULElement::RemoveChildAt(uint32_t aIn
+ 
+             // If any of this fails, we'll just set the current item to null
+             if (newCurrentIndex == -1)
+               newCurrentIndex = -2;
+         }
+       }
+     }
+ 
+-    nsStyledElement::RemoveChildAt(aIndex, aNotify);
++    nsStyledElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ 
+     if (newCurrentIndex == -2) {
+         controlElement->SetCurrentItem(nullptr);
+     } else if (newCurrentIndex > -1) {
+         // Make sure the index is still valid
+         int32_t treeRows;
+         listBox->GetRowCount(&treeRows);
+         if (treeRows > 0) {
+diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h
+--- a/dom/xul/nsXULElement.h
++++ b/dom/xul/nsXULElement.h
+@@ -365,17 +365,17 @@ public:
+                        mozilla::EventChainPreVisitor& aVisitor) override;
+     virtual nsresult PreHandleEvent(
+                        mozilla::EventChainVisitor& aVisitor) override;
+     // nsIContent
+     virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
+                                 nsIContent* aBindingParent,
+                                 bool aCompileEventHandlers) override;
+     virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
+-    virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) override;
++    virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+     virtual void DestroyContent() override;
+ 
+ #ifdef DEBUG
+     virtual void List(FILE* out, int32_t aIndent) const override;
+     virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const override
+     {
+     }
+ #endif
+diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp
+--- a/dom/xul/templates/nsXULContentBuilder.cpp
++++ b/dom/xul/templates/nsXULContentBuilder.cpp
+@@ -910,20 +910,19 @@ nsXULContentBuilder::RemoveMember(nsICon
+ {
+     nsCOMPtr<nsIContent> parent = aContent->GetParent();
+     if (parent) {
+         int32_t pos = parent->IndexOf(aContent);
+ 
+         NS_ASSERTION(pos >= 0, "parent doesn't think this child has an index");
+         if (pos < 0) return NS_OK;
+ 
+-        // Note: RemoveChildAt sets |child|'s document to null so that
+-        // it'll get knocked out of the XUL doc's resource-to-element
+-        // map.
+-        parent->RemoveChildAt(pos, true);
++        // Note: RemoveChildAt_Deprecated sets |child|'s document to null so
++        // that it'll get knocked out of the XUL doc's resource-to-element map.
++        parent->RemoveChildAt_Deprecated(pos, true);
+     }
+ 
+     // Remove from the content support map.
+     mContentSupportMap.Remove(aContent);
+ 
+     // Remove from the template map
+     mTemplateMap.Remove(aContent);
+ 
+@@ -1306,17 +1305,17 @@ nsXULContentBuilder::RemoveGeneratedCont
+                 // No 'template' attribute, so this must not have been
+                 // generated. We'll need to examine its kids.
+                 if (ungenerated.AppendElement(child) == nullptr)
+                     return NS_ERROR_OUT_OF_MEMORY;
+                 continue;
+             }
+ 
+             // If we get here, it's "generated". Bye bye!
+-            element->RemoveChildAt(i, true);
++            element->RemoveChildAt_Deprecated(i, true);
+ 
+             // Remove this and any children from the content support map.
+             mContentSupportMap.Remove(child);
+ 
+             // Remove from the template map
+             mTemplateMap.Remove(child);
+         }
+     }
+diff --git a/dom/xul/templates/nsXULSortService.cpp b/dom/xul/templates/nsXULSortService.cpp
+--- a/dom/xul/templates/nsXULSortService.cpp
++++ b/dom/xul/templates/nsXULSortService.cpp
+@@ -273,17 +273,17 @@ XULSortServiceImpl::SortContainer(nsICon
+     nsIContent* parent = child->GetParent();
+ 
+     if (parent) {
+       // remember the parent so that it can be reinserted back
+       // into the same parent. This is necessary as multiple rules
+       // may generate results which get placed in different locations.
+       items[i].parent = parent;
+       int32_t index = parent->IndexOf(child);
+-      parent->RemoveChildAt(index, true);
++      parent->RemoveChildAt_Deprecated(index, true);
+     }
+   }
+ 
+   // now add the items back in sorted order
+   for (i = 0; i < numResults; i++)
+   {
+     nsIContent* child = items[i].content;
+     nsIContent* parent = items[i].parent;
+diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
+--- a/layout/forms/nsTextControlFrame.cpp
++++ b/layout/forms/nsTextControlFrame.cpp
+@@ -1299,17 +1299,17 @@ nsTextControlFrame::UpdateValueDisplay(b
+   // EnsureEditorInitialized takes care of this.
+   if ((mPlaceholderDiv || mPreviewDiv) && !aBeforeEditorInit) {
+     AutoWeakFrame weakFrame(this);
+     txtCtrl->UpdateOverlayTextVisibility(aNotify);
+     NS_ENSURE_STATE(weakFrame.IsAlive());
+   }
+ 
+   if (aBeforeEditorInit && value.IsEmpty()) {
+-    mRootNode->RemoveChildAt(0, true);
++    mRootNode->RemoveChildAt_Deprecated(0, true);
+     return NS_OK;
+   }
+ 
+   if (!value.IsEmpty() && IsPasswordTextControl()) {
+     TextEditRules::FillBufWithPWChars(&value, value.Length());
+   }
+   return textContent->SetText(value, aNotify);
+ }
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
+--- a/parser/html/nsHtml5TreeOperation.cpp
++++ b/parser/html/nsHtml5TreeOperation.cpp
+@@ -240,34 +240,34 @@ nsHtml5TreeOperation::Detach(nsIContent*
+   MOZ_ASSERT(aBuilder);
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsCOMPtr<nsINode> parent = aNode->GetParentNode();
+   if (parent) {
+     nsHtml5OtherDocUpdate update(parent->OwnerDoc(),
+         aBuilder->GetDocument());
+     int32_t pos = parent->IndexOf(aNode);
+     NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
+-    parent->RemoveChildAt(pos, true);
++    parent->RemoveChildAt_Deprecated(pos, true);
+   }
+ }
+ 
+ nsresult
+ nsHtml5TreeOperation::AppendChildrenToNewParent(nsIContent* aNode,
+                                                 nsIContent* aParent,
+                                                 nsHtml5DocumentBuilder* aBuilder)
+ {
+   MOZ_ASSERT(aBuilder);
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
+                                aBuilder->GetDocument());
+ 
+   bool didAppend = false;
+   while (aNode->HasChildren()) {
+     nsCOMPtr<nsIContent> child = aNode->GetFirstChild();
+-    aNode->RemoveChildAt(0, true);
++    aNode->RemoveChildAt_Deprecated(0, true);
+     nsresult rv = aParent->AppendChildTo(child, false);
+     NS_ENSURE_SUCCESS(rv, rv);
+     didAppend = true;
+   }
+   if (didAppend) {
+     nsNodeUtils::ContentAppended(aParent, aParent->GetLastChild());
+   }
+   return NS_OK;

+ 30 - 0
mozilla-release/patches/1425321-3-59a1.patch

@@ -0,0 +1,30 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514984649 -3600
+# Node ID ffe10b96183ff05dce18845bb2d1bedb541ba9e8
+# Parent  be95a1123de433980a10aedd531d884ab52fe2c5
+Bug 1425321 - Renaming nsINode::GetChildAt to GetChildAt_Deprecated, r=me
+
+diff --git a/accessible/windows/sdn/sdnAccessible.cpp b/accessible/windows/sdn/sdnAccessible.cpp
+--- a/accessible/windows/sdn/sdnAccessible.cpp
++++ b/accessible/windows/sdn/sdnAccessible.cpp
+@@ -408,17 +408,17 @@ sdnAccessible::get_childAt(unsigned aChi
+ {
+   if (!aNode)
+     return E_INVALIDARG;
+   *aNode = nullptr;
+ 
+   if (IsDefunct())
+     return CO_E_OBJNOTCONNECTED;
+ 
+-  nsINode* resultNode = mNode->GetChildAt(aChildIndex);
++  nsINode* resultNode = mNode->GetChildAt_Deprecated(aChildIndex);
+   if (resultNode) {
+     *aNode = static_cast<ISimpleDOMNode*>(new sdnAccessible(resultNode));
+     (*aNode)->AddRef();
+   }
+ 
+ 
+   return S_OK;
+ }
+

+ 64 - 0
mozilla-release/patches/1425440-01-59a1.patch

@@ -0,0 +1,64 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993287 -3600
+#      Wed Jan 03 16:28:07 2018 +0100
+# Node ID ad03ffad73fe90c83089cfe5e14e782ebe8297da
+# Parent  7a47accb11c59245d427149ab0fe251c2977d782
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsTreeUtils, r=catalinb
+
+diff --git a/layout/xul/tree/nsTreeUtils.cpp b/layout/xul/tree/nsTreeUtils.cpp
+--- a/layout/xul/tree/nsTreeUtils.cpp
++++ b/layout/xul/tree/nsTreeUtils.cpp
+@@ -89,22 +89,19 @@ nsTreeUtils::UpdateSortIndicators(Elemen
+   aColumn->SetAttr(kNameSpaceID_None, nsGkAtoms::sortDirection, aDirection, true);
+   aColumn->SetAttr(kNameSpaceID_None, nsGkAtoms::sortActive, NS_LITERAL_STRING("true"), true);
+ 
+   // Unset sort attribute(s) on the other columns
+   nsCOMPtr<nsIContent> parentContent = aColumn->GetParent();
+   if (parentContent &&
+       parentContent->NodeInfo()->Equals(nsGkAtoms::treecols,
+                                         kNameSpaceID_XUL)) {
+-    uint32_t i, numChildren = parentContent->GetChildCount();
+-    for (i = 0; i < numChildren; ++i) {
+-      nsCOMPtr<nsIContent> childContent = parentContent->GetChildAt_Deprecated(i);
+-
+-      if (childContent &&
+-          childContent != aColumn &&
++    for (nsINode* childContent = parentContent->GetFirstChild();
++         childContent; childContent = childContent->GetNextSibling()) {
++      if (childContent != aColumn &&
+           childContent->NodeInfo()->Equals(nsGkAtoms::treecol,
+                                            kNameSpaceID_XUL)) {
+         childContent->AsElement()->UnsetAttr(kNameSpaceID_None,
+                                              nsGkAtoms::sortDirection, true);
+         childContent->AsElement()->UnsetAttr(kNameSpaceID_None,
+                                              nsGkAtoms::sortActive, true);
+       }
+     }
+@@ -115,22 +112,21 @@ nsTreeUtils::UpdateSortIndicators(Elemen
+ 
+ nsresult
+ nsTreeUtils::GetColumnIndex(Element* aColumn, int32_t* aResult)
+ {
+   nsIContent* parentContent = aColumn->GetParent();
+   if (parentContent &&
+       parentContent->NodeInfo()->Equals(nsGkAtoms::treecols,
+                                         kNameSpaceID_XUL)) {
+-    uint32_t i, numChildren = parentContent->GetChildCount();
+     int32_t colIndex = 0;
+-    for (i = 0; i < numChildren; ++i) {
+-      nsIContent* childContent = parentContent->GetChildAt_Deprecated(i);
+-      if (childContent &&
+-          childContent->NodeInfo()->Equals(nsGkAtoms::treecol,
++
++    for (nsINode* childContent = parentContent->GetFirstChild();
++         childContent; childContent = childContent->GetNextSibling()) {
++      if (childContent->NodeInfo()->Equals(nsGkAtoms::treecol,
+                                            kNameSpaceID_XUL)) {
+         if (childContent == aColumn) {
+           *aResult = colIndex;
+           return NS_OK;
+         }
+         ++colIndex;
+       }
+     }

+ 37 - 0
mozilla-release/patches/1425440-02-59a1.patch

@@ -0,0 +1,37 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993317 -3600
+#      Wed Jan 03 16:28:37 2018 +0100
+# Node ID 9f8bb5d303fa4cf92fd4a14cbcb72e2928762522
+# Parent  712a4aac2b79ca94c7aa6c47ccf6d8755e7b1e91
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsTreeContentView, r=catalinb
+
+diff --git a/layout/xul/tree/nsTreeContentView.cpp b/layout/xul/tree/nsTreeContentView.cpp
+--- a/layout/xul/tree/nsTreeContentView.cpp
++++ b/layout/xul/tree/nsTreeContentView.cpp
+@@ -1326,23 +1326,21 @@ nsTreeContentView::SerializeSeparator(El
+   row->SetSeparator(true);
+   aRows.AppendElement(std::move(row));
+ }
+ 
+ void
+ nsTreeContentView::GetIndexInSubtree(nsIContent* aContainer,
+                                      nsIContent* aContent, int32_t* aIndex)
+ {
+-  uint32_t childCount = aContainer->GetChildCount();
+-
+   if (!aContainer->IsXULElement())
+     return;
+ 
+-  for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent *content = aContainer->GetChildAt_Deprecated(i);
++  for (nsIContent* content = aContainer->GetFirstChild();
++       content; content = content->GetNextSibling()) {
+ 
+     if (content == aContent)
+       break;
+ 
+     if (content->IsXULElement(nsGkAtoms::treeitem)) {
+       if (!content->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::hidden,
+                                              nsGkAtoms::_true, eCaseMatters)) {
+         (*aIndex)++;

+ 36 - 0
mozilla-release/patches/1425440-03-59a1.patch

@@ -0,0 +1,36 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993335 -3600
+#      Wed Jan 03 16:28:55 2018 +0100
+# Node ID 8817148653e9ba43697765b20e6d8488872e9a34
+# Parent  9f8bb5d303fa4cf92fd4a14cbcb72e2928762522
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsTreeColumns, r=catalinb
+
+diff --git a/layout/xul/tree/nsTreeColumns.cpp b/layout/xul/tree/nsTreeColumns.cpp
+--- a/layout/xul/tree/nsTreeColumns.cpp
++++ b/layout/xul/tree/nsTreeColumns.cpp
+@@ -682,20 +682,21 @@ nsTreeColumns::RestoreNaturalOrder()
+   nsIContent* content = mTree->GetBaseElement();
+ 
+   // Strong ref, since we'll be setting attributes
+   nsCOMPtr<nsIContent> colsContent =
+     nsTreeUtils::GetImmediateChild(content, nsGkAtoms::treecols);
+   if (!colsContent)
+     return NS_OK;
+ 
+-  for (uint32_t i = 0; i < colsContent->GetChildCount(); ++i) {
+-    nsCOMPtr<nsIContent> child = colsContent->GetChildAt_Deprecated(i);
++  int32_t i = 0;
++  for (nsINode* child = colsContent->GetFirstChild();
++       child; child = child->GetNextSibling()) {
+     nsAutoString ordinal;
+-    ordinal.AppendInt(i);
++    ordinal.AppendInt(i++);
+     if (child->IsElement()) {
+       child->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::ordinal, ordinal,
+                                   true);
+     }
+   }
+ 
+   nsTreeColumns::InvalidateColumns();
+ 

+ 39 - 0
mozilla-release/patches/1425440-04-59a1.patch

@@ -0,0 +1,39 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993353 -3600
+#      Wed Jan 03 16:29:13 2018 +0100
+# Node ID 6e89e8d403125831080ce92a47ed74cde3d7769d
+# Parent  20694c339f17024c49f0e9d2c539301d10d6b97b
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsXULTooltipListener, r=catalinb
+
+diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp
+--- a/layout/xul/nsXULTooltipListener.cpp
++++ b/layout/xul/nsXULTooltipListener.cpp
+@@ -545,23 +545,20 @@ nsXULTooltipListener::HideTooltip()
+   DestroyTooltip();
+   return NS_OK;
+ }
+ 
+ static void
+ GetImmediateChild(nsIContent* aContent, nsIAtom *aTag, nsIContent** aResult)
+ {
+   *aResult = nullptr;
+-  uint32_t childCount = aContent->GetChildCount();
+-  for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent *child = aContent->GetChildAt_Deprecated(i);
+-
+-    if (child->IsXULElement(aTag)) {
+-      *aResult = child;
+-      NS_ADDREF(*aResult);
++  for (nsCOMPtr<nsIContent> childContent = aContent->GetFirstChild();
++       childContent; childContent = childContent->GetNextSibling()) {
++    if (childContent->IsXULElement(aTag)) {
++      childContent.forget(aResult);
+       return;
+     }
+   }
+ }
+ 
+ nsresult
+ nsXULTooltipListener::FindTooltip(nsIContent* aTarget, nsIContent** aTooltip)
+ {

+ 35 - 0
mozilla-release/patches/1425440-05-59a1.patch

@@ -0,0 +1,35 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993370 -3600
+#      Wed Jan 03 16:29:30 2018 +0100
+# Node ID 75eea134e76ae1b8cc9dfedc8445456d1ba70e03
+# Parent  6e89e8d403125831080ce92a47ed74cde3d7769d
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsListBoxBodyFrame, r=catalinb
+
+diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp
+--- a/layout/xul/nsListBoxBodyFrame.cpp
++++ b/layout/xul/nsListBoxBodyFrame.cpp
+@@ -730,20 +730,19 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
+       width += margin.LeftRight();
+ 
+     FlattenedChildIterator iter(mContent);
+     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
+       if (child->IsXULElement(nsGkAtoms::listitem)) {
+         gfxContext* rendContext = aBoxLayoutState.GetRenderingContext();
+         if (rendContext) {
+           nsAutoString value;
+-          uint32_t textCount = child->GetChildCount();
+-          for (uint32_t j = 0; j < textCount; ++j) {
+-            nsIContent* text = child->GetChildAt_Deprecated(j);
+-            if (text && text->IsNodeOfType(nsINode::eTEXT)) {
++          for (nsIContent* text = child->GetFirstChild();
++               text; text = text->GetNextSibling()) {
++            if (text->IsNodeOfType(nsINode::eTEXT)) {
+               text->AppendTextTo(value);
+             }
+           }
+ 
+           RefPtr<nsFontMetrics> fm =
+             nsLayoutUtils::GetFontMetricsForStyleContext(styleContext);
+ 
+           nscoord textWidth =

+ 59 - 0
mozilla-release/patches/1425440-06-59a1.patch

@@ -0,0 +1,59 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993384 -3600
+#      Wed Jan 03 16:29:44 2018 +0100
+# Node ID 5ac1716f22f0610dce34c01e9bd158f794d61e68
+# Parent  75eea134e76ae1b8cc9dfedc8445456d1ba70e03
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsTextControlFrame, r=catalinb
+
+diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
+--- a/layout/forms/nsTextControlFrame.cpp
++++ b/layout/forms/nsTextControlFrame.cpp
+@@ -942,23 +942,25 @@ nsTextControlFrame::SelectAllOrCollapseT
+ 
+   NS_ENSURE_TRUE(rootNode && rootContent, NS_ERROR_FAILURE);
+ 
+   int32_t numChildren = rootContent->GetChildCount();
+ 
+   if (numChildren > 0) {
+     // We never want to place the selection after the last
+     // br under the root node!
+-    nsIContent *child = rootContent->GetChildAt_Deprecated(numChildren - 1);
++    nsIContent *child = rootContent->GetLastChild();
+     if (child) {
+-      if (child->IsHTMLElement(nsGkAtoms::br))
++      if (child->IsHTMLElement(nsGkAtoms::br)) {
++        child = child->GetPreviousSibling();
+         --numChildren;
++      }
+     }
+     if (!aSelect && numChildren) {
+-      child = rootContent->GetChildAt_Deprecated(numChildren - 1);
++      child = child->GetPreviousSibling();
+       if (child && child->IsNodeOfType(nsINode::eTEXT)) {
+         rootNode = do_QueryInterface(child);
+         const nsTextFragment* fragment = child->GetText();
+         numChildren = fragment ? fragment->GetLength() : 0;
+       }
+     }
+   }
+ 
+@@ -1265,17 +1267,17 @@ nsTextControlFrame::UpdateValueDisplay(b
+ {
+   if (!IsSingleLineTextControl()) // textareas don't use this
+     return NS_OK;
+ 
+   NS_PRECONDITION(mRootNode, "Must have a div content\n");
+   NS_PRECONDITION(!mEditorHasBeenInitialized,
+                   "Do not call this after editor has been initialized");
+ 
+-  nsIContent* textContent = mRootNode->GetChildAt_Deprecated(0);
++  nsIContent* textContent = mRootNode->GetFirstChild();
+   if (!textContent) {
+     // Set up a textnode with our value
+     RefPtr<nsTextNode> textNode =
+       new nsTextNode(mContent->NodeInfo()->NodeInfoManager());
+     textNode->MarkAsMaybeModifiedFrequently();
+ 
+     mRootNode->AppendChildTo(textNode, aNotify);
+     textContent = textNode;

+ 40 - 0
mozilla-release/patches/1425440-07-59a1.patch

@@ -0,0 +1,40 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993399 -3600
+#      Wed Jan 03 16:29:59 2018 +0100
+# Node ID a52d6d2099335faeb0e3639ac8979c205ef57fba
+# Parent  5ac1716f22f0610dce34c01e9bd158f794d61e68
+Bug 1425440 - Get rid of GetChildAt_Deprecated in txMozillaXMLOutput, r=catalinb
+
+diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
++++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+@@ -620,25 +620,24 @@ txMozillaXMLOutput::createTxWrapper()
+     nsresult rv = nsContentUtils::NameSpaceManager()->
+         RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
+     NS_ENSURE_SUCCESS(rv, rv);
+ 
+     nsCOMPtr<Element> wrapper =
+       mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
+                             nsGkAtoms::transformiix, namespaceID);
+ 
+-    uint32_t i, j, childCount = mDocument->GetChildCount();
++    uint32_t j = 0;
+ #ifdef DEBUG
+     // Keep track of the location of the current documentElement, if there is
+     // one, so we can verify later
+     uint32_t rootLocation = 0;
+ #endif
+-    for (i = 0, j = 0; i < childCount; ++i) {
+-        nsCOMPtr<nsIContent> childContent = mDocument->GetChildAt_Deprecated(j);
+-
++    for (nsCOMPtr<nsIContent> childContent = mDocument->GetFirstChild();
++         childContent; childContent = childContent->GetNextSibling()) {
+ #ifdef DEBUG
+         if (childContent->IsElement()) {
+             rootLocation = j;
+         }
+ #endif
+ 
+         if (childContent->NodeInfo()->NameAtom() == nsGkAtoms::documentTypeNodeName) {
+ #ifdef DEBUG

+ 35 - 0
mozilla-release/patches/1425440-08-59a1.patch

@@ -0,0 +1,35 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1514993415 -3600
+#      Wed Jan 03 16:30:15 2018 +0100
+# Node ID 074809c8e26631af5f37372c4c14a15f846acf6b
+# Parent  a52d6d2099335faeb0e3639ac8979c205ef57fba
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsCSSFrameConstructor, r=catalinb
+
+diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp
+--- a/layout/base/nsCSSFrameConstructor.cpp
++++ b/layout/base/nsCSSFrameConstructor.cpp
+@@ -7247,21 +7247,20 @@ nsCSSFrameConstructor::CreateNeededFrame
+ 
+   // It might be better to use GetChildArray and scan it completely first and
+   // then issue all notifications. (We have to scan it completely first because
+   // constructing frames can set attributes, which can change the storage of
+   // child lists).
+ 
+   // Scan the children of aContent to see what operations (if any) we need to
+   // perform.
+-  uint32_t childCount = aContent->GetChildCount();
+   bool inRun = false;
+   nsIContent* firstChildInRun = nullptr;
+-  for (uint32_t i = 0; i < childCount; i++) {
+-    nsIContent* child = aContent->GetChildAt_Deprecated(i);
++  for (nsIContent* child = aContent->GetFirstChild();
++       child; child = child->GetNextSibling()) {
+     if (child->HasFlag(NODE_NEEDS_FRAME)) {
+       NS_ASSERTION(!child->GetPrimaryFrame() ||
+                    child->GetPrimaryFrame()->GetContent() != child,
+                    //XXX the child->GetPrimaryFrame()->GetContent() != child
+                    // check is needed due to bug 135040. Remove it once that's
+                    // fixed.
+                    "NEEDS_FRAME set on a node that already has a frame?");
+       if (!inRun) {

+ 34 - 0
mozilla-release/patches/1425440-09-59a1.patch

@@ -0,0 +1,34 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515159407 -3600
+#      Fri Jan 05 14:36:47 2018 +0100
+# Node ID d47e642852b17e46c178d26d324b245199e2bc3c
+# Parent  a37695e59774af91ca8e9e50bee369364cf4feaa
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsPresContext, r=catalinb
+
+diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp
+--- a/layout/base/nsPresContext.cpp
++++ b/layout/base/nsPresContext.cpp
+@@ -1288,19 +1288,19 @@ void nsPresContext::SetImgAnimations(nsI
+   nsCOMPtr<nsIImageLoadingContent> imgContent(do_QueryInterface(aParent));
+   if (imgContent) {
+     nsCOMPtr<imgIRequest> imgReq;
+     imgContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
+                            getter_AddRefs(imgReq));
+     SetImgAnimModeOnImgReq(imgReq, aMode);
+   }
+ 
+-  uint32_t count = aParent->GetChildCount();
+-  for (uint32_t i = 0; i < count; ++i) {
+-    SetImgAnimations(aParent->GetChildAt_Deprecated(i), aMode);
++  for (nsIContent* childContent = aParent->GetFirstChild();
++       childContent; childContent = childContent->GetNextSibling()) {
++    SetImgAnimations(childContent, aMode);
+   }
+ }
+ 
+ void
+ nsPresContext::SetSMILAnimations(nsIDocument *aDoc, uint16_t aNewMode,
+                                  uint16_t aOldMode)
+ {
+   if (aDoc->HasAnimationController()) {

+ 71 - 0
mozilla-release/patches/1425440-10-59a1.patch

@@ -0,0 +1,71 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515162205 -3600
+#      Fri Jan 05 15:23:25 2018 +0100
+# Node ID 804de8550bbd947860e64779da6e6b0f68a68f91
+# Parent  bba4a6269557ba7214a09c9c260f83d9a84885e8
+Bug 1425440 - Get rid of GetChildAt_Deprecated in IMEContentObserver, r=catalinb
+
+diff --git a/dom/events/IMEContentObserver.cpp b/dom/events/IMEContentObserver.cpp
+--- a/dom/events/IMEContentObserver.cpp
++++ b/dom/events/IMEContentObserver.cpp
+@@ -1258,33 +1258,16 @@ IMEContentObserver::ClearAddedNodesDurin
+ {
+   mFirstAddedContainer = mLastAddedContainer = nullptr;
+   mFirstAddedContent = mLastAddedContent = nullptr;
+   MOZ_LOG(sIMECOLog, LogLevel::Debug,
+     ("0x%p IMEContentObserver::ClearAddedNodesDuringDocumentChange()"
+      ", finished storing consecutive nodes", this));
+ }
+ 
+-// static
+-nsIContent*
+-IMEContentObserver::GetChildNode(nsINode* aParent, int32_t aOffset)
+-{
+-  if (!aParent->HasChildren() || aOffset < 0 ||
+-      aOffset >= static_cast<int32_t>(aParent->Length())) {
+-    return nullptr;
+-  }
+-  if (!aOffset) {
+-    return aParent->GetFirstChild();
+-  }
+-  if (aOffset == static_cast<int32_t>(aParent->Length() - 1)) {
+-    return aParent->GetLastChild();
+-  }
+-  return aParent->GetChildAt_Deprecated(aOffset);
+-}
+-
+ bool
+ IMEContentObserver::IsNextNodeOfLastAddedNode(nsINode* aParent,
+                                               nsIContent* aChild) const
+ {
+   MOZ_ASSERT(aParent);
+   MOZ_ASSERT(aChild && aChild->GetParentNode() == aParent);
+   MOZ_ASSERT(mRootContent);
+   MOZ_ASSERT(HasAddedNodesDuringDocumentChange());
+diff --git a/dom/events/IMEContentObserver.h b/dom/events/IMEContentObserver.h
+--- a/dom/events/IMEContentObserver.h
++++ b/dom/events/IMEContentObserver.h
+@@ -183,22 +183,16 @@ private:
+   void OnIMEReceivedFocus();
+   void Clear();
+   bool IsObservingContent(nsPresContext* aPresContext,
+                           nsIContent* aContent) const;
+   bool IsReflowLocked() const;
+   bool IsSafeToNotifyIME() const;
+   bool IsEditorComposing() const;
+ 
+-  /**
+-   * nsINode::GetChildAt() is slow.  So, this avoids to use it if it's
+-   * first child or last child of aParent.
+-   */
+-  static nsIContent* GetChildNode(nsINode* aParent, int32_t aOffset);
+-
+   // Following methods are called by DocumentObserver when
+   // beginning to update the contents and ending updating the contents.
+   void BeginDocumentUpdate();
+   void EndDocumentUpdate();
+ 
+   // Following methods manages added nodes during a document change.
+ 
+   /**

+ 81 - 0
mozilla-release/patches/1425440-11-59a1.patch

@@ -0,0 +1,81 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515494694 -3600
+#      Tue Jan 09 11:44:54 2018 +0100
+# Node ID 30b995a49772ed07790ea802c8501bf2cee444fa
+# Parent  ad4aebf7ceea0c5d33388e493e7cd1c0d2ff5683
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsMenuX, r=catalinb
+
+diff --git a/widget/cocoa/nsMenuX.mm b/widget/cocoa/nsMenuX.mm
+--- a/widget/cocoa/nsMenuX.mm
++++ b/widget/cocoa/nsMenuX.mm
+@@ -433,27 +433,24 @@ void nsMenuX::MenuConstruct()
+         xpconnect->WrapNative(cx, JS::CurrentGlobalOrNull(cx), menuPopup,
+                               NS_GET_IID(nsISupports), ignoredObj.address());
+         mXBLAttached = true;
+       }
+     }
+   }
+ 
+   // Iterate over the kids
+-  uint32_t count = menuPopup->GetChildCount();
+-  for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *child = menuPopup->GetChildAt_Deprecated(i);
+-    if (child) {
+-      // depending on the type, create a menu item, separator, or submenu
+-      if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
+-                                    nsGkAtoms::menuseparator)) {
+-        LoadMenuItem(child);
+-      } else if (child->IsXULElement(nsGkAtoms::menu)) {
+-        LoadSubMenu(child);
+-      }
++  for (nsIContent* child = menuPopup->GetFirstChild();
++       child; child = child->GetNextSibling()) {
++    // depending on the type, create a menu item, separator, or submenu
++    if (child->IsAnyOfXULElements(nsGkAtoms::menuitem,
++                                  nsGkAtoms::menuseparator)) {
++      LoadMenuItem(child);
++    } else if (child->IsXULElement(nsGkAtoms::menu)) {
++      LoadSubMenu(child);
+     }
+   } // for each menu item
+ 
+   gConstructingMenu = false;
+   mNeedsRebuild = false;
+   // printf("Done building, mMenuObjectsArray.Count() = %d \n", mMenuObjectsArray.Count());
+ }
+ 
+@@ -639,31 +636,27 @@ bool nsMenuX::OnClose()
+ void nsMenuX::GetMenuPopupContent(nsIContent** aResult)
+ {
+   if (!aResult)
+     return;
+   *aResult = nullptr;
+ 
+   // Check to see if we are a "menupopup" node (if we are a native menu).
+   {
+-    int32_t dummy;
+     nsCOMPtr<nsIAtom> tag = mContent->OwnerDoc()->BindingManager()->ResolveTag(mContent, &dummy);
+     if (tag == nsGkAtoms::menupopup) {
+       NS_ADDREF(*aResult = mContent);
+       return;
+     }
+   }
+ 
+   // Otherwise check our child nodes.
+ 
+-  uint32_t count = mContent->GetChildCount();
+-
+-  for (uint32_t i = 0; i < count; i++) {
+-    int32_t dummy;
+-    nsIContent *child = mContent->GetChildAt_Deprecated(i);
++  for (nsIContent* child = mContent->GetFirstChild();
++       child; child = child->GetNextSibling()) {
+     nsCOMPtr<nsIAtom> tag = child->OwnerDoc()->BindingManager()->ResolveTag(child, &dummy);
+     if (tag == nsGkAtoms::menupopup) {
+       *aResult = child;
+       NS_ADDREF(*aResult);
+       return;
+     }
+   }
+ }

+ 36 - 0
mozilla-release/patches/1425440-12-59a1.patch

@@ -0,0 +1,36 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515494694 -3600
+#      Tue Jan 09 11:44:54 2018 +0100
+# Node ID 90492852dfc9021f4b34b77f24b07e335b1629db
+# Parent  30b995a49772ed07790ea802c8501bf2cee444fa
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsMenuItemX, r=catalinb
+
+diff --git a/widget/cocoa/nsMenuItemX.mm b/widget/cocoa/nsMenuItemX.mm
+--- a/widget/cocoa/nsMenuItemX.mm
++++ b/widget/cocoa/nsMenuItemX.mm
+@@ -217,21 +217,19 @@ void nsMenuItemX::UncheckRadioSiblings(n
+   if (!myGroupName.Length()) // no groupname, nothing to do
+     return;
+ 
+   nsCOMPtr<nsIContent> parent = inCheckedContent->GetParent();
+   if (!parent)
+     return;
+ 
+   // loop over siblings
+-  uint32_t count = parent->GetChildCount();
+-  for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *sibling = parent->GetChildAt_Deprecated(i);
+-    if (sibling &&
+-        sibling != inCheckedContent &&
++  for (nsIContent* sibling = parent->GetFirstChild();
++       sibling; sibling = sibling->GetNextSibling()) {
++    if (sibling != inCheckedContent &&
+         sibling->IsElement()) { // skip this node
+       // if the current sibling is in the same group, clear it
+       if (sibling->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
+                                             myGroupName, eCaseMatters)) {
+         sibling->AsElement()->SetAttr(kNameSpaceID_None, nsGkAtoms::checked, NS_LITERAL_STRING("false"), true);
+       }
+     }
+   }

+ 36 - 0
mozilla-release/patches/1425440-13-59a1.patch

@@ -0,0 +1,36 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515494694 -3600
+#      Tue Jan 09 11:44:54 2018 +0100
+# Node ID 8011797b1542dc75f3522437055087520baec71e
+# Parent  90492852dfc9021f4b34b77f24b07e335b1629db
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsMenuBarX, r=catalinb
+
+diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm
+--- a/widget/cocoa/nsMenuBarX.mm
++++ b/widget/cocoa/nsMenuBarX.mm
+@@ -158,21 +158,19 @@ nsresult nsMenuBarX::Create(nsIWidget* a
+   // Give this to the parent window. The parent takes ownership.
+   static_cast<nsCocoaWindow*>(mParentWindow)->SetMenuBar(this);
+ 
+   return NS_OK;
+ }
+ 
+ void nsMenuBarX::ConstructNativeMenus()
+ {
+-  uint32_t count = mContent->GetChildCount();
+-  for (uint32_t i = 0; i < count; i++) {
+-    nsIContent *menuContent = mContent->GetChildAt_Deprecated(i);
+-    if (menuContent &&
+-        menuContent->IsXULElement(nsGkAtoms::menu)) {
++  for (nsIContent* menuContent = mContent->GetFirstChild();
++       menuContent; menuContent = menuContent->GetNextSibling()) {
++    if (menuContent->IsXULElement(nsGkAtoms::menu)) {
+       nsMenuX* newMenu = new nsMenuX();
+       if (newMenu) {
+         nsresult rv = newMenu->Create(this, this, menuContent->AsElement());
+         if (NS_SUCCEEDED(rv))
+           InsertMenuAtIndex(newMenu, GetMenuCount());
+         else
+           delete newMenu;
+       }

+ 168 - 0
mozilla-release/patches/1425440-14-59a1.patch

@@ -0,0 +1,168 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515767593 -3600
+#      Fri Jan 12 15:33:13 2018 +0100
+# Node ID b3046ae63cbfbbd1ef6d0588e97f3c2a5321b0c2
+# Parent  d90bb4a1edda3f30d0297c25f7cbedcca6d1b3b3
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsRange, r=catalinb
+
+diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp
+--- a/dom/base/nsRange.cpp
++++ b/dom/base/nsRange.cpp
+@@ -3753,25 +3753,27 @@ ElementIsVisibleNoFlush(Element* aElemen
+     return false;
+   }
+   RefPtr<nsStyleContext> sc =
+     nsComputedDOMStyle::GetStyleContextNoFlush(aElement, nullptr);
+   return sc && sc->StyleVisibility()->IsVisible();
+ }
+ 
+ static void
+-AppendTransformedText(InnerTextAccumulator& aResult,
+-                      nsGenericDOMDataNode* aTextNode,
+-                      uint32_t aStart, uint32_t aEnd)
++AppendTransformedText(InnerTextAccumulator& aResult, nsIContent* aContainer)
+ {
+-  nsIFrame* frame = aTextNode->GetPrimaryFrame();
++  auto textNode = static_cast<nsGenericDOMDataNode*>(aContainer);
++
++  nsIFrame* frame = textNode->GetPrimaryFrame();
+   if (!IsVisibleAndNotInReplacedElement(frame)) {
+     return;
+   }
+-  nsIFrame::RenderedText text = frame->GetRenderedText(aStart, aEnd);
++
++  nsIFrame::RenderedText text =
++    frame->GetRenderedText(0, aContainer->GetChildCount());
+   aResult.Append(text.mString);
+ }
+ 
+ /**
+  * States for tree traversal. AT_NODE means that we are about to enter
+  * the current DOM node. AFTER_NODE means that we have just finished traversing
+  * the children of the current DOM node and are about to apply any
+  * "after processing the node's children" steps before we finish visiting
+@@ -3839,45 +3841,35 @@ IsLastNonemptyRowGroupOfTable(nsIFrame* 
+       }
+     }
+   }
+   return true;
+ }
+ 
+ void
+ nsRange::GetInnerTextNoFlush(DOMString& aValue, ErrorResult& aError,
+-                             nsIContent* aStartContainer, uint32_t aStartOffset,
+-                             nsIContent* aEndContainer, uint32_t aEndOffset)
++                             nsIContent* aContainer)
+ {
+   InnerTextAccumulator result(aValue);
+-  nsIContent* currentNode = aStartContainer;
++
++  if (aContainer->IsNodeOfType(nsINode::eTEXT)) {
++    AppendTransformedText(result, aContainer);
++    return;
++  }
++
++  nsIContent* currentNode = aContainer;
+   TreeTraversalState currentState = AFTER_NODE;
+-  if (aStartContainer->IsNodeOfType(nsINode::eTEXT)) {
+-    auto t = static_cast<nsGenericDOMDataNode*>(aStartContainer);
+-    if (aStartContainer == aEndContainer) {
+-      AppendTransformedText(result, t, aStartOffset, aEndOffset);
+-      return;
+-    }
+-    AppendTransformedText(result, t, aStartOffset, t->TextLength());
+-  } else {
+-    if (uint32_t(aStartOffset) < aStartContainer->GetChildCount()) {
+-      currentNode = aStartContainer->GetChildAt_Deprecated(aStartOffset);
+-      currentState = AT_NODE;
+-    }
+-  }
+-
+-  nsIContent* endNode = aEndContainer;
++
++  nsIContent* endNode = aContainer;
+   TreeTraversalState endState = AFTER_NODE;
+-  if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) {
+-    endState = AT_NODE;
+-  } else {
+-    if (aEndOffset < aEndContainer->GetChildCount()) {
+-      endNode = aEndContainer->GetChildAt_Deprecated(aEndOffset);
+-      endState = AT_NODE;
+-    }
++
++  nsIContent* firstChild = aContainer->GetFirstChild();
++  if (firstChild) {
++    currentNode = firstChild;
++    currentState = AT_NODE;
+   }
+ 
+   while (currentNode != endNode || currentState != endState) {
+     nsIFrame* f = currentNode->GetPrimaryFrame();
+     bool isVisibleAndNotReplaced = IsVisibleAndNotInReplacedElement(f);
+     if (currentState == AT_NODE) {
+       bool isText = currentNode->IsNodeOfType(nsINode::eTEXT);
+       if (isText && currentNode->GetParent()->IsHTMLElement(nsGkAtoms::rp) &&
+@@ -3927,15 +3919,11 @@ nsRange::GetInnerTextNoFlush(DOMString& 
+     if (next) {
+       currentNode = next;
+       currentState = AT_NODE;
+     } else {
+       currentNode = currentNode->GetParent();
+     }
+   }
+ 
+-  if (aEndContainer->IsNodeOfType(nsINode::eTEXT)) {
+-    nsGenericDOMDataNode* t = static_cast<nsGenericDOMDataNode*>(aEndContainer);
+-    AppendTransformedText(result, t, 0, aEndOffset);
+-  }
+   // Do not flush trailing line breaks! Required breaks at the end of the text
+   // are suppressed.
+ }
+diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h
+--- a/dom/base/nsRange.h
++++ b/dom/base/nsRange.h
+@@ -358,20 +358,17 @@ public:
+   void SetEndBefore(nsINode& aNode, ErrorResult& aErr);
+   void SetStart(nsINode& aNode, uint32_t aOffset, ErrorResult& aErr);
+   void SetStart(const RawRangeBoundary& aPoint, ErrorResult& aErr);
+   void SetStartAfter(nsINode& aNode, ErrorResult& aErr);
+   void SetStartBefore(nsINode& aNode, ErrorResult& aErr);
+ 
+   static void GetInnerTextNoFlush(mozilla::dom::DOMString& aValue,
+                                   mozilla::ErrorResult& aError,
+-                                  nsIContent* aStartContainer,
+-                                  uint32_t aStartOffset,
+-                                  nsIContent* aEndContainer,
+-                                  uint32_t aEndOffset);
++                                  nsIContent* aContainer);
+ 
+   nsINode* GetParentObject() const { return mOwner; }
+   virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) override final;
+   DocGroup* GetDocGroup() const;
+ 
+ private:
+   // no copy's or assigns
+   nsRange(const nsRange&);
+diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
+--- a/dom/html/nsGenericHTMLElement.cpp
++++ b/dom/html/nsGenericHTMLElement.cpp
+@@ -3001,17 +3001,17 @@ nsGenericHTMLElement::GetInnerText(mozil
+     // ensure the document is styled.
+     if (!presShell || !presShell->DidInitialize() ||
+         IsOrHasAncestorWithDisplayNone(this, presShell)) {
+       GetTextContentInternal(aValue, aError);
+       return;
+     }
+   }
+ 
+-  nsRange::GetInnerTextNoFlush(aValue, aError, this, 0, this, GetChildCount());
++  nsRange::GetInnerTextNoFlush(aValue, aError, this);
+ }
+ 
+ void
+ nsGenericHTMLElement::SetInnerText(const nsAString& aValue)
+ {
+   // Batch possible DOMSubtreeModified events.
+   mozAutoSubtreeModified subtree(OwnerDoc(), nullptr);
+   FireNodeRemovedForChildren();

+ 78 - 0
mozilla-release/patches/1425440-15-59a1.patch

@@ -0,0 +1,78 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515767593 -3600
+#      Fri Jan 12 15:33:13 2018 +0100
+# Node ID a0a5df1b4070ebe5acd614f6ab74aabba9d000d1
+# Parent  b3046ae63cbfbbd1ef6d0588e97f3c2a5321b0c2
+Bug 1425440 - Get rid of GetChildAt_Deprecated in selection, r=catalinb
+
+diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp
+--- a/dom/base/Selection.cpp
++++ b/dom/base/Selection.cpp
+@@ -592,21 +592,17 @@ Selection::GetTableCellLocationFromRange
+   // Don't fail if range does not point to a single table cell,
+   //  let aSelectionType tell user if we don't have a cell
+   if (*aSelectionType  != nsISelectionPrivate::TABLESELECTION_CELL)
+     return NS_OK;
+ 
+   // Get the child content (the cell) pointed to by starting node of range
+   // We do minimal checking since GetTableSelectionType assures
+   //   us that this really is a table cell
+-  nsCOMPtr<nsIContent> content = do_QueryInterface(aRange->GetStartContainer());
+-  if (!content)
+-    return NS_ERROR_FAILURE;
+-
+-  nsCOMPtr<nsIContent> child = content->GetChildAt_Deprecated(aRange->StartOffset());
++  nsCOMPtr<nsIContent> child = aRange->GetChildAtStartOffset();
+   if (!child)
+     return NS_ERROR_FAILURE;
+ 
+   // GetCellLayout depends on current frame, we need flush frame to get
+   // nsITableCellLayout
+   nsCOMPtr<nsIPresShell> presShell = mFrameSelection->GetShell();
+   if (presShell) {
+     presShell->FlushPendingNotifications(FlushType::Frames);
+@@ -683,40 +679,36 @@ Selection::GetTableSelectionType(nsIDOMR
+   if (!startNode) return NS_ERROR_FAILURE;
+ 
+   nsINode* endNode = range->GetEndContainer();
+   if (!endNode) return NS_ERROR_FAILURE;
+ 
+   // Not a single selected node
+   if (startNode != endNode) return NS_OK;
+ 
+-  int32_t startOffset = range->StartOffset();
+-  int32_t endOffset = range->EndOffset();
++  nsIContent* child = range->GetChildAtStartOffset();
+ 
+   // Not a single selected node
+-  if ((endOffset - startOffset) != 1)
++  if (!child || child != range->GetChildAtEndOffset()) {
+     return NS_OK;
++  }
+ 
+   nsIContent* startContent = static_cast<nsIContent*>(startNode);
+   if (!(startNode->IsElement() && startContent->IsHTMLElement())) {
+     // Implies a check for being an element; if we ever make this work
+     // for non-HTML, need to keep checking for elements.
+     return NS_OK;
+   }
+ 
+   if (startContent->IsHTMLElement(nsGkAtoms::tr))
+   {
+     *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_CELL;
+   }
+   else //check to see if we are selecting a table or row (column and all cells not done yet)
+   {
+-    nsIContent *child = startNode->GetChildAt_Deprecated(startOffset);
+-    if (!child)
+-      return NS_ERROR_FAILURE;
+-
+     if (child->IsHTMLElement(nsGkAtoms::table))
+       *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_TABLE;
+     else if (child->IsHTMLElement(nsGkAtoms::tr))
+       *aTableSelectionType = nsISelectionPrivate::TABLESELECTION_ROW;
+   }
+ 
+   return NS_OK;
+ }

+ 75 - 0
mozilla-release/patches/1425440-16-59a1.patch

@@ -0,0 +1,75 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515767594 -3600
+#      Fri Jan 12 15:33:14 2018 +0100
+# Node ID 7a9a1c11053a404c9eda71266984cab6d17c1d6d
+# Parent  a0a5df1b4070ebe5acd614f6ab74aabba9d000d1
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsFrameSelection, r=catalinb
+
+diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp
+--- a/layout/generic/nsFrameSelection.cpp
++++ b/layout/generic/nsFrameSelection.cpp
+@@ -2056,17 +2056,17 @@ GetFirstSelectedContent(nsRange* aRange)
+   if (!aRange) {
+     return nullptr;
+   }
+ 
+   NS_PRECONDITION(aRange->GetStartContainer(), "Must have start parent!");
+   NS_PRECONDITION(aRange->GetStartContainer()->IsElement(),
+                   "Unexpected parent");
+ 
+-  return aRange->GetStartContainer()->GetChildAt_Deprecated(aRange->StartOffset());
++  return aRange->GetChildAtStartOffset();
+ }
+ 
+ // Table selection support.
+ // TODO: Separate table methods into a separate nsITableSelection interface
+ nsresult
+ nsFrameSelection::HandleTableSelection(nsINode* aParentContent,
+                                        int32_t aContentOffset,
+                                        int32_t aTarget,
+@@ -2341,17 +2341,17 @@ printf("HandleTableSelection: Unselectin
+ 
+           nsINode* container = range->GetStartContainer();
+           if (!container) {
+             return NS_ERROR_NULL_POINTER;
+           }
+ 
+           int32_t offset = range->StartOffset();
+           // Be sure previous selection is a table cell
+-          nsIContent* child = container->GetChildAt_Deprecated(offset);
++          nsIContent* child = range->GetChildAtStartOffset();
+           if (child && IsCell(child)) {
+             previousCellParent = container;
+           }
+ 
+           // We're done if we didn't find parent of a previously-selected cell
+           if (!previousCellParent) break;
+ 
+           if (previousCellParent == aParentContent && offset == aContentOffset)
+@@ -2686,24 +2686,17 @@ nsFrameSelection::SelectRowOrColumn(nsIC
+   return NS_OK;
+ }
+ 
+ nsIContent*
+ nsFrameSelection::GetFirstCellNodeInRange(nsRange *aRange) const
+ {
+   if (!aRange) return nullptr;
+ 
+-  nsINode* startContainer = aRange->GetStartContainer();
+-  if (!startContainer) {
+-    return nullptr;
+-  }
+-
+-  int32_t offset = aRange->StartOffset();
+-
+-  nsIContent* childContent = startContainer->GetChildAt_Deprecated(offset);
++  nsIContent* childContent = aRange->GetChildAtStartOffset();
+   if (!childContent)
+     return nullptr;
+   // Don't return node if not a cell
+   if (!IsCell(childContent))
+     return nullptr;
+ 
+   return childContent;
+ }

+ 110 - 0
mozilla-release/patches/1425440-17-59a1.patch

@@ -0,0 +1,110 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515767594 -3600
+#      Fri Jan 12 15:33:14 2018 +0100
+# Node ID f3975b636f8d6917489f802399f74b9c42785e15
+# Parent  7a9a1c11053a404c9eda71266984cab6d17c1d6d
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsTypeAheadFind, r=catalinb
+
+diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
++++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.cpp
+@@ -452,18 +452,18 @@ nsTypeAheadFind::FindItNow(nsIPresShell 
+       if (!returnRange)
+         break;  // Nothing found in this doc, go to outer loop (try next doc)
+ 
+       // ------- Test resulting found range for success conditions ------
+       bool isInsideLink = false, isStartingLink = false;
+ 
+       if (aIsLinksOnly) {
+         // Don't check if inside link when searching all text
+-        RangeStartsInsideLink(returnRange, presShell, &isInsideLink,
+-                              &isStartingLink);
++        RangeStartsInsideLink(static_cast<nsRange*>(returnRange.get()),
++                              presShell, &isInsideLink, &isStartingLink);
+       }
+ 
+       bool usesIndependentSelection;
+       if (!IsRangeVisible(presShell, presContext, returnRange,
+                           aIsFirstVisiblePreferred, false,
+                           getter_AddRefs(mStartPointRange),
+                           &usesIndependentSelection) ||
+           (aIsLinksOnly && !isInsideLink) ||
+@@ -869,17 +869,17 @@ nsTypeAheadFind::GetSearchContainers(nsI
+ 
+   presShell.forget(aPresShell);
+   presContext.forget(aPresContext);
+ 
+   return NS_OK;
+ }
+ 
+ void
+-nsTypeAheadFind::RangeStartsInsideLink(nsIDOMRange *aRange,
++nsTypeAheadFind::RangeStartsInsideLink(nsRange *aRange,
+                                        nsIPresShell *aPresShell,
+                                        bool *aIsInsideLink,
+                                        bool *aIsStartingLink)
+ {
+   *aIsInsideLink = false;
+   *aIsStartingLink = true;
+ 
+   // ------- Get nsIContent to test -------
+@@ -892,17 +892,17 @@ nsTypeAheadFind::RangeStartsInsideLink(n
+   startContent = do_QueryInterface(startNode);
+   if (!startContent) {
+     NS_NOTREACHED("startContent should never be null");
+     return;
+   }
+   origContent = startContent;
+ 
+   if (startContent->IsElement()) {
+-    nsIContent *childContent = startContent->GetChildAt_Deprecated(startOffset);
++    nsIContent *childContent = aRange->GetChildAtStartOffset();
+     if (childContent) {
+       startContent = childContent;
+     }
+   }
+   else if (startOffset > 0) {
+     const nsTextFragment *textFrag = startContent->GetText();
+     if (textFrag) {
+       // look for non whitespace character before start offset
+diff --git a/toolkit/components/typeaheadfind/nsTypeAheadFind.h b/toolkit/components/typeaheadfind/nsTypeAheadFind.h
+--- a/toolkit/components/typeaheadfind/nsTypeAheadFind.h
++++ b/toolkit/components/typeaheadfind/nsTypeAheadFind.h
+@@ -17,16 +17,17 @@
+ #include "nsIDOMRange.h"
+ #include "nsIDocShellTreeItem.h"
+ #include "nsITypeAheadFind.h"
+ #include "nsISound.h"
+ 
+ class nsPIDOMWindowInner;
+ class nsIPresShell;
+ class nsPresContext;
++class nsRange;
+ 
+ #define TYPEAHEADFIND_NOTFOUND_WAV_URL \
+         "chrome://global/content/notfound.wav"
+ 
+ class nsTypeAheadFind : public nsITypeAheadFind,
+                         public nsIObserver,
+                         public nsSupportsWeakReference
+ {
+@@ -44,17 +45,17 @@ protected:
+ 
+   nsresult PrefsReset();
+ 
+   void SaveFind();
+   void PlayNotFoundSound();
+   nsresult GetWebBrowserFind(nsIDocShell *aDocShell,
+                              nsIWebBrowserFind **aWebBrowserFind);
+ 
+-  void RangeStartsInsideLink(nsIDOMRange *aRange, nsIPresShell *aPresShell,
++  void RangeStartsInsideLink(nsRange *aRange, nsIPresShell *aPresShell,
+                              bool *aIsInsideLink, bool *aIsStartingLink);
+ 
+   void GetSelection(nsIPresShell *aPresShell, nsISelectionController **aSelCon,
+                     nsISelection **aDomSel);
+   // *aNewRange may not be collapsed.  If you want to collapse it in a
+   // particular way, you need to do it yourself.
+   bool IsRangeVisible(nsIPresShell *aPresShell, nsPresContext *aPresContext,
+                         nsIDOMRange *aRange, bool aMustBeVisible,

+ 97 - 0
mozilla-release/patches/1425440-18-59a1.patch

@@ -0,0 +1,97 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1515792254 -3600
+#      Fri Jan 12 22:24:14 2018 +0100
+# Node ID 0fa20efa446906e82545076eb72c66a18ae1ed43
+# Parent  4ed959e7652263aa2a57d582aed2460b4bdaab7c
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsCSSRuleProcessor, r=catalinb
+
+diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp
+--- a/layout/style/nsCSSRuleProcessor.cpp
++++ b/layout/style/nsCSSRuleProcessor.cpp
+@@ -1347,26 +1347,25 @@ edgeOfTypeMatches(Element* aElement, Tre
+ }
+ 
+ static inline bool
+ checkGenericEmptyMatches(Element* aElement,
+                          TreeMatchContext& aTreeMatchContext,
+                          bool isWhitespaceSignificant)
+ {
+   nsIContent *child = nullptr;
+-  int32_t index = -1;
+ 
+   if (aTreeMatchContext.mForStyling)
+     aElement->SetFlags(NODE_HAS_EMPTY_SELECTOR);
+ 
+-  do {
+-    child = aElement->GetChildAt_Deprecated(++index);
+-    // stop at first non-comment (and non-whitespace for
+-    // :-moz-only-whitespace) node
+-  } while (child && !IsSignificantChild(child, true, isWhitespaceSignificant));
++  // stop at first non-comment (and non-whitespace for :-moz-only-whitespace)
++  // node
++  for (child = aElement->GetFirstChild();
++       child && !IsSignificantChild(child, true, isWhitespaceSignificant);
++       child = child->GetNextSibling());
+   return (child == nullptr);
+ }
+ 
+ static const EventStates sPseudoClassStates[] = {
+ #define CSS_PSEUDO_CLASS(_name, _value, _flags, _pref) \
+   EventStates(),
+ #define CSS_STATE_PSEUDO_CLASS(_name, _value, _flags, _pref, _states) \
+   _states,
+@@ -1625,22 +1624,20 @@ static bool SelectorMatches(Element* aEl
+     case CSSPseudoClassType::firstNode:
+       {
+         nsIContent *firstNode = nullptr;
+         nsIContent *parent = aElement->GetParent();
+         if (parent) {
+           if (aTreeMatchContext.mForStyling)
+             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
+ 
+-          int32_t index = -1;
+-          do {
+-            firstNode = parent->GetChildAt_Deprecated(++index);
+-            // stop at first non-comment and non-whitespace node
+-          } while (firstNode &&
+-                    !IsSignificantChild(firstNode, true, false));
++          // stop at first non-comment and non-whitespace node
++          for (firstNode = parent->GetFirstChild();
++               firstNode && !IsSignificantChild(firstNode, true, false);
++               firstNode = firstNode->GetNextSibling());
+         }
+         if (aElement != firstNode) {
+           return false;
+         }
+       }
+       break;
+ 
+     case CSSPseudoClassType::lastChild:
+@@ -1652,22 +1649,20 @@ static bool SelectorMatches(Element* aEl
+     case CSSPseudoClassType::lastNode:
+       {
+         nsIContent *lastNode = nullptr;
+         nsIContent *parent = aElement->GetParent();
+         if (parent) {
+           if (aTreeMatchContext.mForStyling)
+             parent->SetFlags(NODE_HAS_EDGE_CHILD_SELECTOR);
+ 
+-          uint32_t index = parent->GetChildCount();
+-          do {
+-            lastNode = parent->GetChildAt_Deprecated(--index);
+-            // stop at first non-comment and non-whitespace node
+-          } while (lastNode &&
+-                    !IsSignificantChild(lastNode, true, false));
++          // stop at first non-comment and non-whitespace node
++          for (lastNode = parent->GetLastChild();
++               lastNode && !IsSignificantChild(lastNode, true, false);
++               lastNode = lastNode->GetPreviousSibling());
+         }
+         if (aElement != lastNode) {
+           return false;
+         }
+       }
+       break;
+ 
+     case CSSPseudoClassType::onlyChild:

+ 210 - 0
mozilla-release/patches/1425440-19-59a1.patch

@@ -0,0 +1,210 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516033083 -3600
+#      Mon Jan 15 17:18:03 2018 +0100
+# Node ID f1035d52904deb761d52baffb8a645a496baea78
+# Parent  d350d4735de6bdc5184abfdb3fe9a7f3108c349e
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsDocumentEncoder, r=catalinb
+
+diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
+--- a/dom/base/nsDocumentEncoder.cpp
++++ b/dom/base/nsDocumentEncoder.cpp
+@@ -628,122 +628,16 @@ nsDocumentEncoder::FlushText(nsAString& 
+     rv = ConvertAndWrite(aString, mStream, mUnicodeEncoder.get(), mIsPlainText);
+ 
+     aString.Truncate();
+   }
+ 
+   return rv;
+ }
+ 
+-#if 0 // This code is really fast at serializing a range, but unfortunately
+-      // there are problems with it so we don't use it now, maybe later...
+-static nsresult ChildAt(nsIDOMNode* aNode, int32_t aIndex, nsIDOMNode*& aChild)
+-{
+-  nsCOMPtr<nsIContent> content(do_QueryInterface(aNode));
+-
+-  aChild = nullptr;
+-
+-  NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
+-
+-  nsIContent *child = content->GetChildAt_Deprecated(aIndex);
+-
+-  if (child)
+-    return CallQueryInterface(child, &aChild);
+-
+-  return NS_OK;
+-}
+-
+-static int32_t IndexOf(nsIDOMNode* aParent, nsIDOMNode* aChild)
+-{
+-  nsCOMPtr<nsIContent> parent(do_QueryInterface(aParent));
+-  nsCOMPtr<nsIContent> child(do_QueryInterface(aChild));
+-
+-  if (!parent)
+-    return -1;
+-
+-  return parent->IndexOf(child);
+-}
+-
+-static inline int32_t GetIndex(nsTArray<int32_t>& aIndexArray)
+-{
+-  int32_t count = aIndexArray.Length();
+-
+-  if (count) {
+-    return aIndexArray.ElementAt(count - 1);
+-  }
+-
+-  return 0;
+-}
+-
+-static nsresult GetNextNode(nsIDOMNode* aNode, nsTArray<int32_t>& aIndexArray,
+-                            nsIDOMNode*& aNextNode,
+-                            nsRangeIterationDirection& aDirection)
+-{
+-  bool hasChildren;
+-
+-  aNextNode = nullptr;
+-
+-  aNode->HasChildNodes(&hasChildren);
+-
+-  if (hasChildren && aDirection == kDirectionIn) {
+-    ChildAt(aNode, 0, aNextNode);
+-    NS_ENSURE_TRUE(aNextNode, NS_ERROR_FAILURE);
+-
+-    aIndexArray.AppendElement(0);
+-
+-    aDirection = kDirectionIn;
+-  } else if (aDirection == kDirectionIn) {
+-    aNextNode = aNode;
+-
+-    NS_ADDREF(aNextNode);
+-
+-    aDirection = kDirectionOut;
+-  } else {
+-    nsCOMPtr<nsIDOMNode> parent;
+-
+-    aNode->GetParentNode(getter_AddRefs(parent));
+-    NS_ENSURE_TRUE(parent, NS_ERROR_FAILURE);
+-
+-    int32_t count = aIndexArray.Length();
+-
+-    if (count) {
+-      int32_t indx = aIndexArray.ElementAt(count - 1);
+-
+-      ChildAt(parent, indx + 1, aNextNode);
+-
+-      if (aNextNode)
+-        aIndexArray.ElementAt(count - 1) = indx + 1;
+-      else
+-        aIndexArray.RemoveElementAt(count - 1);
+-    } else {
+-      int32_t indx = IndexOf(parent, aNode);
+-
+-      if (indx >= 0) {
+-        ChildAt(parent, indx + 1, aNextNode);
+-
+-        if (aNextNode)
+-          aIndexArray.AppendElement(indx + 1);
+-      }
+-    }
+-
+-    if (aNextNode) {
+-      aDirection = kDirectionIn;
+-    } else {
+-      aDirection = kDirectionOut;
+-
+-      aNextNode = parent;
+-
+-      NS_ADDREF(aNextNode);
+-    }
+-  }
+-
+-  return NS_OK;
+-}
+-#endif
+-
+ static bool IsTextNode(nsINode *aNode)
+ {
+   return aNode && aNode->IsNodeOfType(nsINode::eTEXT);
+ }
+ 
+ nsresult
+ nsDocumentEncoder::SerializeRangeNodes(nsRange* aRange,
+                                        nsINode* aNode,
+@@ -812,24 +706,22 @@ nsDocumentEncoder::SerializeRangeNodes(n
+ 
+         // serialize the start of this node
+         rv = SerializeNodeStart(aNode, 0, -1, aString);
+         NS_ENSURE_SUCCESS(rv, rv);
+       }
+ 
+       // do some calculations that will tell us which children of this
+       // node are in the range.
+-      nsIContent* childAsNode = nullptr;
+       int32_t startOffset = 0, endOffset = -1;
+       if (startNode == content && mStartRootIndex >= aDepth)
+         startOffset = mStartOffsets[mStartRootIndex - aDepth];
+       if (endNode == content && mEndRootIndex >= aDepth)
+         endOffset = mEndOffsets[mEndRootIndex - aDepth];
+       // generated content will cause offset values of -1 to be returned.
+-      int32_t j;
+       uint32_t childCount = content->GetChildCount();
+ 
+       if (startOffset == -1) startOffset = 0;
+       if (endOffset == -1) endOffset = childCount;
+       else
+       {
+         // if we are at the "tip" of the selection, endOffset is fine.
+         // otherwise, we need to add one.  This is because of the semantics
+@@ -837,27 +729,41 @@ nsDocumentEncoder::SerializeRangeNodes(n
+         // intermediate points on the list use the endOffset of the
+         // location of the ancestor, rather than just past it.  So we need
+         // to add one here in order to include it in the children we serialize.
+         if (aNode != aRange->GetEndContainer())
+         {
+           endOffset++;
+         }
+       }
+-      // serialize the children of this node that are in the range
+-      for (j=startOffset; j<endOffset; j++)
+-      {
+-        childAsNode = content->GetChildAt_Deprecated(j);
++
++      if (endOffset) {
++        // serialize the children of this node that are in the range
++        nsIContent* childAsNode = content->GetFirstChild();
++        int32_t j = 0;
++
++        for (; j < startOffset && childAsNode; ++j) {
++          childAsNode = childAsNode->GetNextSibling();
++        }
++
++        NS_ENSURE_TRUE(!!childAsNode, NS_ERROR_FAILURE);
++        MOZ_ASSERT(j == startOffset);
+ 
+-        if ((j==startOffset) || (j==endOffset-1))
+-          rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);
+-        else
+-          rv = SerializeToStringRecursive(childAsNode, aString, false);
++        for (; childAsNode && j < endOffset; ++j)
++        {
++          if ((j==startOffset) || (j==endOffset-1)) {
++            rv = SerializeRangeNodes(aRange, childAsNode, aString, aDepth+1);
++          } else {
++            rv = SerializeToStringRecursive(childAsNode, aString, false);
++          }
+ 
+-        NS_ENSURE_SUCCESS(rv, rv);
++          NS_ENSURE_SUCCESS(rv, rv);
++
++          childAsNode = childAsNode->GetNextSibling();
++        }
+       }
+ 
+       // serialize the end of this node
+       if (aNode != mCommonParent)
+       {
+         rv = SerializeNodeEnd(aNode, aString);
+         NS_ENSURE_SUCCESS(rv, rv);
+       }

+ 676 - 0
mozilla-release/patches/1425440-20-59a1.patch

@@ -0,0 +1,676 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516033118 -3600
+#      Mon Jan 15 17:18:38 2018 +0100
+# Node ID 0b1c98a4a3d4d0551040243886d23dddfd9038d6
+# Parent  58183baf9235f82bcdf22869ce361cd28075c57e
+Bug 1425440 - Introduce nsINode::RemoveChildNode, r=catalinb
+
+diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp
+--- a/dom/base/Attr.cpp
++++ b/dom/base/Attr.cpp
+@@ -326,16 +326,21 @@ Attr::InsertChildAt(nsIContent* aKid, ui
+   return NS_ERROR_NOT_IMPLEMENTED;
+ }
+ 
+ void
+ Attr::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+ }
+ 
++void
++Attr::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++}
++
+ nsresult
+ Attr::GetEventTargetParent(EventChainPreVisitor& aVisitor)
+ {
+   aVisitor.mCanHandle = true;
+   return NS_OK;
+ }
+ 
+ void
+diff --git a/dom/base/Attr.h b/dom/base/Attr.h
+--- a/dom/base/Attr.h
++++ b/dom/base/Attr.h
+@@ -65,16 +65,17 @@ public:
+   // nsINode interface
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+   virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
+ 
+   static void Initialize();
+   static void Shutdown();
+ 
+   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Attr,
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
+--- a/dom/base/FragmentOrElement.cpp
++++ b/dom/base/FragmentOrElement.cpp
+@@ -1167,16 +1167,22 @@ FragmentOrElement::RemoveChildAt_Depreca
+   NS_ASSERTION(oldKid == GetChildAt_Deprecated(aIndex), "Unexpected child in RemoveChildAt_Deprecated");
+ 
+   if (oldKid) {
+     doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren);
+   }
+ }
+ 
+ void
++FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
++}
++
++void
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
+                                           OOMReporter& aError)
+ {
+   if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {
+     aError.ReportOOM();
+   }
+ }
+ 
+diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
+--- a/dom/base/FragmentOrElement.h
++++ b/dom/base/FragmentOrElement.h
+@@ -118,16 +118,17 @@ public:
+ 
+   // nsINode interface methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override;
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+                                       mozilla::ErrorResult& aError) override;
+ 
+   // nsIContent interface methods
+   virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) override;
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
+--- a/dom/base/nsDocument.cpp
++++ b/dom/base/nsDocument.cpp
+@@ -4316,16 +4316,38 @@ nsDocument::RemoveChildAt_Deprecated(uin
+   mCachedRootElement = nullptr;
+   doRemoveChildAt(aIndex, aNotify, oldKid, mChildren);
+   MOZ_ASSERT(mCachedRootElement != oldKid,
+              "Stale pointer in mCachedRootElement, after we tried to clear it "
+              "(maybe somebody called GetRootElement() too early?)");
+ }
+ 
+ void
++nsDocument::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  if (aKid->IsElement()) {
++    // Destroy the link map up front before we mess with the child list.
++    DestroyElementMaps();
++  }
++
++  // Preemptively clear mCachedRootElement, since we may be about to remove it
++  // from our child list, and we don't want to return this maybe-obsolete value
++  // from any GetRootElement() calls that happen inside of doRemoveChildAt().
++  // (NOTE: for this to be useful, doRemoveChildAt() must NOT trigger any
++  // GetRootElement() calls until after it's removed the child from mChildren.
++  // Any call before that point would restore this soon-to-be-obsolete cached
++  // answer, and our clearing here would be fruitless.)
++  mCachedRootElement = nullptr;
++  doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mChildren);
++  MOZ_ASSERT(mCachedRootElement != aKid,
++             "Stale pointer in mCachedRootElement, after we tried to clear it "
++             "(maybe somebody called GetRootElement() too early?)");
++}
++
++void
+ nsDocument::EnsureOnDemandBuiltInUASheet(StyleSheet* aSheet)
+ {
+   if (mOnDemandBuiltInUASheets.Contains(aSheet)) {
+     return;
+   }
+   BeginUpdate(UPDATE_STYLE);
+   AddOnDemandBuiltInUASheet(aSheet);
+   EndUpdate(UPDATE_STYLE);
+diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
+--- a/dom/base/nsDocument.h
++++ b/dom/base/nsDocument.h
+@@ -551,16 +551,17 @@ public:
+   // nsINode
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override
+   {
+     return NS_ERROR_NOT_IMPLEMENTED;
+   }
+ 
+   // nsIRadioGroupContainer
+   NS_IMETHOD WalkRadioGroup(const nsAString& aName,
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
+--- a/dom/base/nsGenericDOMDataNode.cpp
++++ b/dom/base/nsGenericDOMDataNode.cpp
+@@ -658,16 +658,21 @@ nsGenericDOMDataNode::InsertChildAt(nsIC
+   return NS_OK;
+ }
+ 
+ void
+ nsGenericDOMDataNode::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+ }
+ 
++void
++nsGenericDOMDataNode::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++}
++
+ nsXBLBinding *
+ nsGenericDOMDataNode::DoGetXBLBinding() const
+ {
+   return nullptr;
+ }
+ 
+ bool
+ nsGenericDOMDataNode::IsNodeOfType(uint32_t aFlags) const
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
+--- a/dom/base/nsGenericDOMDataNode.h
++++ b/dom/base/nsGenericDOMDataNode.h
+@@ -105,16 +105,17 @@ public:
+ 
+   // nsINode methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+   virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override
+   {
+     GetNodeValue(aTextContent);
+   }
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+                                       mozilla::ErrorResult& aError) override
+diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
+--- a/dom/base/nsINode.cpp
++++ b/dom/base/nsINode.cpp
+@@ -1968,17 +1968,17 @@ 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_Deprecated().
++  // nsDocument::RemoveChildNode().
+   MOZ_ASSERT(aKid && aKid->GetParentNode() == this &&
+              aKid == GetChildAt_Deprecated(aIndex) &&
+              IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
+   MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE));
+ 
+   nsMutationGuard::DidMutate();
+   mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
+ 
+diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
+--- a/dom/base/nsINode.h
++++ b/dom/base/nsINode.h
+@@ -778,16 +778,27 @@ public:
+    *        nsIContent, and |this| for nsIDocument) that the remove has
+    *        occurred
+    *
+    * Note: If there is no child at aIndex, this method will simply do nothing.
+    */
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) = 0;
+ 
+   /**
++   * Remove a child from this node.  This method handles calling UnbindFromTree
++   * on the child appropriately.
++   *
++   * @param aKid the content to remove
++   * @param aNotify whether to notify the document (current document for
++   *        nsIContent, and |this| for nsIDocument) that the remove has
++   *        occurred
++   */
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) = 0;
++
++  /**
+    * Get a property associated with this node.
+    *
+    * @param aPropertyName  name of property to get.
+    * @param aStatus        out parameter for storing resulting status.
+    *                       Set to NS_PROPTABLE_PROP_NOT_THERE if the property
+    *                       is not set.
+    * @return               the property. Null if the property is not set
+    *                       (though a null return value does not imply the
+diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp
+--- a/dom/html/HTMLFieldSetElement.cpp
++++ b/dom/html/HTMLFieldSetElement.cpp
+@@ -191,16 +191,42 @@ HTMLFieldSetElement::RemoveChildAt_Depre
+   nsGenericHTMLFormElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ 
+   if (firstLegendHasChanged) {
+     NotifyElementsForFirstLegendChange(aNotify);
+   }
+ }
+ 
+ void
++HTMLFieldSetElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  bool firstLegendHasChanged = false;
++
++  if (mFirstLegend && aKid == mFirstLegend) {
++    // If we are removing the first legend we have to found another one.
++    nsIContent* child = mFirstLegend->GetNextSibling();
++    mFirstLegend = nullptr;
++    firstLegendHasChanged = true;
++
++    for (; child; child = child->GetNextSibling()) {
++      if (child->IsHTMLElement(nsGkAtoms::legend)) {
++        mFirstLegend = child;
++        break;
++      }
++    }
++  }
++
++  nsGenericHTMLFormElement::RemoveChildNode(aKid, aNotify);
++
++  if (firstLegendHasChanged) {
++    NotifyElementsForFirstLegendChange(aNotify);
++  }
++}
++
++void
+ HTMLFieldSetElement::AddElement(nsGenericHTMLFormElement* aElement)
+ {
+   mDependentElements.AppendElement(aElement);
+ 
+   // If the element that we are adding aElement is a fieldset, then all the
+   // invalid elements in aElement are also invalid elements of this.
+   HTMLFieldSetElement* fieldSet = FromContent(aElement);
+   if (fieldSet) {
+diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h
+--- a/dom/html/HTMLFieldSetElement.h
++++ b/dom/html/HTMLFieldSetElement.h
+@@ -39,16 +39,17 @@ public:
+                                 const nsAttrValue* aValue,
+                                 const nsAttrValue* aOldValue,
+                                 nsIPrincipal* aSubjectPrincipal,
+                                 bool aNotify) override;
+ 
+   virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex,
+                                      bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+ 
+   // nsIFormControl
+   NS_IMETHOD Reset() override;
+   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
+   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+ 
+diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp
+--- a/dom/html/HTMLOptGroupElement.cpp
++++ b/dom/html/HTMLOptGroupElement.cpp
+@@ -89,16 +89,24 @@ HTMLOptGroupElement::InsertChildAt(nsICo
+ void
+ HTMLOptGroupElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
+                                       aNotify);
+   nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
++void
++HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, IndexOf(aKid),
++                                      aNotify);
++  nsGenericHTMLElement::RemoveChildNode(aKid, aNotify);
++}
++
+ nsresult
+ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                                   const nsAttrValue* aValue,
+                                   const nsAttrValue* aOldValue,
+                                   nsIPrincipal* aSubjectPrincipal,
+                                   bool aNotify)
+ {
+   if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) {
+diff --git a/dom/html/HTMLOptGroupElement.h b/dom/html/HTMLOptGroupElement.h
+--- a/dom/html/HTMLOptGroupElement.h
++++ b/dom/html/HTMLOptGroupElement.h
+@@ -23,16 +23,17 @@ public:
+ 
+   // nsISupports
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   // nsINode
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+ 
+   // nsIContent
+   virtual nsresult GetEventTargetParent(
+                      EventChainPreVisitor& aVisitor) override;
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
+                          bool aPreallocateChildren) const override;
+ 
+diff --git a/dom/html/HTMLPictureElement.cpp b/dom/html/HTMLPictureElement.cpp
+--- a/dom/html/HTMLPictureElement.cpp
++++ b/dom/html/HTMLPictureElement.cpp
+@@ -53,16 +53,40 @@ HTMLPictureElement::RemoveChildAt_Deprec
+         }
+       } while ( (nextSibling = nextSibling->GetNextSibling()) );
+     }
+   }
+ 
+   nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
++void
++HTMLPictureElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  if (aKid && aKid->IsHTMLElement(nsGkAtoms::img)) {
++    HTMLImageElement* img = HTMLImageElement::FromContent(aKid);
++    if (img) {
++      img->PictureSourceRemoved(aKid->AsContent());
++    }
++  } else if (aKid && aKid->IsHTMLElement(nsGkAtoms::source)) {
++    // Find all img siblings after this <source> to notify them of its demise
++    nsCOMPtr<nsIContent> nextSibling = aKid->GetNextSibling();
++    if (nextSibling && nextSibling->GetParentNode() == this) {
++      do {
++        HTMLImageElement* img = HTMLImageElement::FromContent(nextSibling);
++        if (img) {
++          img->PictureSourceRemoved(aKid->AsContent());
++        }
++      } while ( (nextSibling = nextSibling->GetNextSibling()) );
++    }
++  }
++
++  nsGenericHTMLElement::RemoveChildNode(aKid, aNotify);
++}
++
+ nsresult
+ HTMLPictureElement::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify)
+ {
+   nsresult rv = nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
+ 
+   NS_ENSURE_SUCCESS(rv, rv);
+   NS_ENSURE_TRUE(aKid, rv);
+ 
+diff --git a/dom/html/HTMLPictureElement.h b/dom/html/HTMLPictureElement.h
+--- a/dom/html/HTMLPictureElement.h
++++ b/dom/html/HTMLPictureElement.h
+@@ -19,16 +19,17 @@ public:
+   explicit HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+ 
+   // nsISupports
+   NS_DECL_ISUPPORTS_INHERITED
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult,
+                          bool aPreallocateChildren) const override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify) override;
+ 
+ protected:
+   virtual ~HTMLPictureElement();
+ 
+   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+ };
+ 
+diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
+--- a/dom/html/HTMLSelectElement.cpp
++++ b/dom/html/HTMLSelectElement.cpp
+@@ -219,17 +219,22 @@ HTMLSelectElement::InsertChildAt(nsICont
+ 
+ void
+ HTMLSelectElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   SafeOptionListMutation safeMutation(this, this, nullptr, aIndex, aNotify);
+   nsGenericHTMLFormElementWithState::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+-
++void
++HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  SafeOptionListMutation safeMutation(this, this, nullptr, IndexOf(aKid), aNotify);
++  nsGenericHTMLFormElementWithState::RemoveChildNode(aKid, aNotify);
++}
+ 
+ void
+ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
+                                          int32_t aListIndex,
+                                          int32_t aDepth,
+                                          bool aNotify)
+ {
+   MOZ_ASSERT(aDepth == 0 || aDepth == 1);
+diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h
+--- a/dom/html/HTMLSelectElement.h
++++ b/dom/html/HTMLSelectElement.h
+@@ -289,16 +289,17 @@ public:
+                      EventChainPreVisitor& aVisitor) override;
+   virtual nsresult PostHandleEvent(
+                      EventChainPostVisitor& aVisitor) override;
+ 
+   virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable, int32_t* aTabIndex) override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+ 
+   // Overriden nsIFormControl methods
+   NS_IMETHOD Reset() override;
+   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
+   NS_IMETHOD SaveState() override;
+   virtual bool RestoreState(nsPresState* aState) override;
+   virtual bool IsDisabledForEvents(EventMessage aMessage) override;
+ 
+diff --git a/dom/svg/SVGSwitchElement.cpp b/dom/svg/SVGSwitchElement.cpp
+--- a/dom/svg/SVGSwitchElement.cpp
++++ b/dom/svg/SVGSwitchElement.cpp
+@@ -95,16 +95,23 @@ SVGSwitchElement::InsertChildAt(nsIConte
+ 
+ void
+ SVGSwitchElement::RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify)
+ {
+   SVGSwitchElementBase::RemoveChildAt_Deprecated(aIndex, aNotify);
+   MaybeInvalidate();
+ }
+ 
++void
++SVGSwitchElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++  SVGSwitchElementBase::RemoveChildNode(aKid, aNotify);
++  MaybeInvalidate();
++}
++
+ //----------------------------------------------------------------------
+ // nsIContent methods
+ 
+ NS_IMETHODIMP_(bool)
+ SVGSwitchElement::IsAttributeMapped(const nsIAtom* name) const
+ {
+   static const MappedAttributeEntry* const map[] = {
+     sFEFloodMap,
+diff --git a/dom/svg/SVGSwitchElement.h b/dom/svg/SVGSwitchElement.h
+--- a/dom/svg/SVGSwitchElement.h
++++ b/dom/svg/SVGSwitchElement.h
+@@ -38,16 +38,17 @@ public:
+ 
+   NS_DECL_ISUPPORTS_INHERITED
+   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGSwitchElement,
+                                            SVGSwitchElementBase)
+   // nsINode
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++  virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+ 
+   // nsIContent
+   NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
+ 
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+ private:
+   void UpdateActiveChild()
+diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp
+--- a/dom/xul/nsXULElement.cpp
++++ b/dom/xul/nsXULElement.cpp
+@@ -960,16 +960,111 @@ nsXULElement::RemoveChildAt_Deprecated(u
+                                            static_cast<nsIContent*>(this),
+                                            NS_LITERAL_STRING("select"),
+                                            false,
+                                            true);
+     }
+ }
+ 
+ void
++nsXULElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
++{
++    // On the removal of a <treeitem>, <treechildren>, or <treecell> element,
++    // the possibility exists that some of the items in the removed subtree
++    // are selected (and therefore need to be deselected). We need to account for this.
++    nsCOMPtr<nsIDOMXULMultiSelectControlElement> controlElement;
++    nsCOMPtr<nsIListBoxObject> listBox;
++    bool fireSelectionHandler = false;
++
++    // -1 = do nothing, -2 = null out current item
++    // anything else = index to re-set as current
++    int32_t newCurrentIndex = -1;
++
++    if (aKid->NodeInfo()->Equals(nsGkAtoms::listitem, kNameSpaceID_XUL)) {
++      // This is the nasty case. We have (potentially) a slew of selected items
++      // and cells going away.
++      // First, retrieve the tree.
++      // Check first whether this element IS the tree
++      controlElement = do_QueryObject(this);
++
++      // If it's not, look at our parent
++      if (!controlElement)
++        GetParentTree(getter_AddRefs(controlElement));
++      nsCOMPtr<nsIContent> controlContent(do_QueryInterface(controlElement));
++      RefPtr<nsXULElement> xulElement = FromContentOrNull(controlContent);
++
++      nsCOMPtr<nsIDOMElement> oldKidElem = do_QueryInterface(aKid);
++      if (xulElement && oldKidElem) {
++        // Iterate over all of the items and find out if they are contained inside
++        // the removed subtree.
++        int32_t length;
++        controlElement->GetSelectedCount(&length);
++        for (int32_t i = 0; i < length; i++) {
++          nsCOMPtr<nsIDOMXULSelectControlItemElement> node;
++          controlElement->MultiGetSelectedItem(i, getter_AddRefs(node));
++          // we need to QI here to do an XPCOM-correct pointercompare
++          nsCOMPtr<nsIDOMElement> selElem = do_QueryInterface(node);
++          if (selElem == oldKidElem &&
++              NS_SUCCEEDED(controlElement->RemoveItemFromSelection(node))) {
++            length--;
++            i--;
++            fireSelectionHandler = true;
++          }
++        }
++
++        nsCOMPtr<nsIDOMXULSelectControlItemElement> curItem;
++        controlElement->GetCurrentItem(getter_AddRefs(curItem));
++        nsCOMPtr<nsIContent> curNode = do_QueryInterface(curItem);
++        if (curNode && nsContentUtils::ContentIsDescendantOf(curNode, aKid)) {
++            // Current item going away
++            IgnoredErrorResult ignored;
++            nsCOMPtr<nsIBoxObject> box = xulElement->GetBoxObject(ignored);
++            listBox = do_QueryInterface(box);
++            if (listBox && oldKidElem) {
++              listBox->GetIndexOfItem(oldKidElem, &newCurrentIndex);
++            }
++
++            // If any of this fails, we'll just set the current item to null
++            if (newCurrentIndex == -1)
++              newCurrentIndex = -2;
++        }
++      }
++    }
++
++    nsStyledElement::RemoveChildNode(aKid, aNotify);
++
++    if (newCurrentIndex == -2) {
++        controlElement->SetCurrentItem(nullptr);
++    } else if (newCurrentIndex > -1) {
++        // Make sure the index is still valid
++        int32_t treeRows;
++        listBox->GetRowCount(&treeRows);
++        if (treeRows > 0) {
++            newCurrentIndex = std::min((treeRows - 1), newCurrentIndex);
++            nsCOMPtr<nsIDOMElement> newCurrentItem;
++            listBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem));
++            nsCOMPtr<nsIDOMXULSelectControlItemElement> xulCurItem = do_QueryInterface(newCurrentItem);
++            if (xulCurItem)
++                controlElement->SetCurrentItem(xulCurItem);
++        } else {
++            controlElement->SetCurrentItem(nullptr);
++        }
++    }
++
++    nsIDocument* doc;
++    if (fireSelectionHandler && (doc = GetComposedDoc())) {
++      nsContentUtils::DispatchTrustedEvent(doc,
++                                           static_cast<nsIContent*>(this),
++                                           NS_LITERAL_STRING("select"),
++                                           false,
++                                           true);
++    }
++}
++
++void
+ nsXULElement::UnregisterAccessKey(const nsAString& aOldValue)
+ {
+     // If someone changes the accesskey, unregister the old one
+     //
+     nsIDocument* doc = GetComposedDoc();
+     if (doc && !aOldValue.IsEmpty()) {
+         nsIPresShell *shell = doc->GetShell();
+ 
+diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h
+--- a/dom/xul/nsXULElement.h
++++ b/dom/xul/nsXULElement.h
+@@ -366,16 +366,17 @@ public:
+     virtual nsresult PreHandleEvent(
+                        mozilla::EventChainVisitor& aVisitor) override;
+     // nsIContent
+     virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
+                                 nsIContent* aBindingParent,
+                                 bool aCompileEventHandlers) override;
+     virtual void UnbindFromTree(bool aDeep, bool aNullParent) override;
+     virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
++    virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+     virtual void DestroyContent() override;
+ 
+ #ifdef DEBUG
+     virtual void List(FILE* out, int32_t aIndent) const override;
+     virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const override
+     {
+     }
+ #endif

+ 53 - 0
mozilla-release/patches/1425440-21-59a1.patch

@@ -0,0 +1,53 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108630 -3600
+#      Tue Jan 16 14:17:10 2018 +0100
+# Node ID 0a65645b66b6f2dffb2bf0f16bc14ae9471a40a3
+# Parent  bbe18bb4514bd21ef38c4772b9125332958d66ea
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsHtml5TreeOperation, r=catalinb
+
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
+--- a/parser/html/nsHtml5TreeOperation.cpp
++++ b/parser/html/nsHtml5TreeOperation.cpp
+@@ -236,38 +236,35 @@ IsElementOrTemplateContent(nsINode* aNod
+ 
+ void
+ nsHtml5TreeOperation::Detach(nsIContent* aNode, nsHtml5DocumentBuilder* aBuilder)
+ {
+   MOZ_ASSERT(aBuilder);
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsCOMPtr<nsINode> parent = aNode->GetParentNode();
+   if (parent) {
+-    nsHtml5OtherDocUpdate update(parent->OwnerDoc(),
+-        aBuilder->GetDocument());
+-    int32_t pos = parent->IndexOf(aNode);
+-    NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
+-    parent->RemoveChildAt_Deprecated(pos, true);
++    nsHtml5OtherDocUpdate update(parent->OwnerDoc(), aBuilder->GetDocument());
++    parent->RemoveChildNode(aNode, true);
+   }
+ }
+ 
+ nsresult
+ nsHtml5TreeOperation::AppendChildrenToNewParent(nsIContent* aNode,
+                                                 nsIContent* aParent,
+                                                 nsHtml5DocumentBuilder* aBuilder)
+ {
+   MOZ_ASSERT(aBuilder);
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
+                                aBuilder->GetDocument());
+ 
+   bool didAppend = false;
+   while (aNode->HasChildren()) {
+     nsCOMPtr<nsIContent> child = aNode->GetFirstChild();
+-    aNode->RemoveChildAt_Deprecated(0, true);
++    aNode->RemoveChildNode(child, true);
+     nsresult rv = aParent->AppendChildTo(child, false);
+     NS_ENSURE_SUCCESS(rv, rv);
+     didAppend = true;
+   }
+   if (didAppend) {
+     nsNodeUtils::ContentAppended(aParent, aParent->GetLastChild());
+   }
+   return NS_OK;

+ 33 - 0
mozilla-release/patches/1425440-22-59a1.patch

@@ -0,0 +1,33 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108630 -3600
+#      Tue Jan 16 14:17:10 2018 +0100
+# Node ID b0f95e1a8de90e0b1533721bd86d1bd34cedbd3b
+# Parent  0a65645b66b6f2dffb2bf0f16bc14ae9471a40a3
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsTextControlFrame, r=catalinb
+
+diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp
+--- a/layout/forms/nsTextControlFrame.cpp
++++ b/layout/forms/nsTextControlFrame.cpp
+@@ -1304,17 +1304,20 @@ nsTextControlFrame::UpdateValueDisplay(b
+   // EnsureEditorInitialized takes care of this.
+   if ((mPlaceholderDiv || mPreviewDiv) && !aBeforeEditorInit) {
+     AutoWeakFrame weakFrame(this);
+     txtCtrl->UpdateOverlayTextVisibility(aNotify);
+     NS_ENSURE_STATE(weakFrame.IsAlive());
+   }
+ 
+   if (aBeforeEditorInit && value.IsEmpty()) {
+-    mRootNode->RemoveChildAt_Deprecated(0, true);
++    nsIContent* node = mRootNode->GetFirstChild();
++    if (node) {
++      mRootNode->RemoveChildNode(node, true);
++    }
+     return NS_OK;
+   }
+ 
+   if (!value.IsEmpty() && IsPasswordTextControl()) {
+     TextEditRules::FillBufWithPWChars(&value, value.Length());
+   }
+   return textContent->SetText(value, aNotify);
+ }

+ 31 - 0
mozilla-release/patches/1425440-23-59a1.patch

@@ -0,0 +1,31 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108630 -3600
+#      Tue Jan 16 14:17:10 2018 +0100
+# Node ID 293349fdff10dfdfaff678d42ed125b0f559e39b
+# Parent  5bf66fee95a5d4610697e9a019cf36636f1d7da3
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsXULSortService, r=catalinb
+
+diff --git a/dom/xul/templates/nsXULSortService.cpp b/dom/xul/templates/nsXULSortService.cpp
+--- a/dom/xul/templates/nsXULSortService.cpp
++++ b/dom/xul/templates/nsXULSortService.cpp
+@@ -272,18 +272,17 @@ XULSortServiceImpl::SortContainer(nsICon
+     nsIContent* child = items[i].content;
+     nsIContent* parent = child->GetParent();
+ 
+     if (parent) {
+       // remember the parent so that it can be reinserted back
+       // into the same parent. This is necessary as multiple rules
+       // may generate results which get placed in different locations.
+       items[i].parent = parent;
+-      int32_t index = parent->IndexOf(child);
+-      parent->RemoveChildAt_Deprecated(index, true);
++      parent->RemoveChildNode(child, true);
+     }
+   }
+ 
+   // now add the items back in sorted order
+   for (i = 0; i < numResults; i++)
+   {
+     nsIContent* child = items[i].content;
+     nsIContent* parent = items[i].parent;

+ 38 - 0
mozilla-release/patches/1425440-24-59a1.patch

@@ -0,0 +1,38 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108631 -3600
+#      Tue Jan 16 14:17:11 2018 +0100
+# Node ID 9ef23aa75c3d494ea56cd2ecf72c3b326acd7249
+# Parent  293349fdff10dfdfaff678d42ed125b0f559e39b
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsGenericHTMLElement, r=catalinb
+
+diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
+--- a/dom/html/nsGenericHTMLElement.cpp
++++ b/dom/html/nsGenericHTMLElement.cpp
+@@ -3097,22 +3097,22 @@ nsGenericHTMLElement::SetInnerText(const
+   FireNodeRemovedForChildren();
+ 
+   // Might as well stick a batch around this since we're performing several
+   // mutations.
+   mozAutoDocUpdate updateBatch(GetComposedDoc(),
+     UPDATE_CONTENT_MODEL, true);
+   nsAutoMutationBatch mb;
+ 
+-  uint32_t childCount = GetChildCount();
+-
+   mb.Init(this, true, false);
+-  for (uint32_t i = 0; i < childCount; ++i) {
+-    RemoveChildAt_Deprecated(0, true);
++
++  while (HasChildren()) {
++    RemoveChildNode(nsINode::GetFirstChild(), true);
+   }
++
+   mb.RemovalDone();
+ 
+   nsString str;
+   const char16_t* s = aValue.BeginReading();
+   const char16_t* end = aValue.EndReading();
+   while (true) {
+     if (s != end && *s == '\r' && s + 1 != end && s[1] == '\n') {
+       // a \r\n pair should only generate one <br>, so just skip the \r

+ 147 - 0
mozilla-release/patches/1425440-25-59a1.patch

@@ -0,0 +1,147 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108631 -3600
+#      Tue Jan 16 14:17:11 2018 +0100
+# Node ID 5fc568e52a68faaaf24be23198d5ab309500e622
+# Parent  9ef23aa75c3d494ea56cd2ecf72c3b326acd7249
+Bug 1425440 - Get rid of GetChildAt_Deprecated in nsGenericDOMDataNode, r=catalinb
+
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
+--- a/dom/base/nsGenericDOMDataNode.cpp
++++ b/dom/base/nsGenericDOMDataNode.cpp
+@@ -771,69 +771,84 @@ nsGenericDOMDataNode::SplitText(uint32_t
+   nsCOMPtr<nsIContent> newChild;
+   nsresult rv = SplitData(aOffset, getter_AddRefs(newChild));
+   if (NS_SUCCEEDED(rv)) {
+     rv = CallQueryInterface(newChild, aReturn);
+   }
+   return rv;
+ }
+ 
+-/* static */ int32_t
+-nsGenericDOMDataNode::FirstLogicallyAdjacentTextNode(nsIContent* aParent,
+-                                                     int32_t aIndex)
++static nsIContent*
++FirstLogicallyAdjacentTextNode(nsIContent* aNode)
+ {
+-  while (aIndex-- > 0) {
+-    nsIContent* sibling = aParent->GetChildAt_Deprecated(aIndex);
+-    if (!sibling->IsNodeOfType(nsINode::eTEXT))
+-      return aIndex + 1;
++  nsCOMPtr<nsIContent> parent = aNode->GetParent();
++
++  while (aNode) {
++    nsIContent* sibling = aNode->GetPreviousSibling();
++    if (!sibling || !sibling->IsNodeOfType(nsINode::eTEXT)) {
++      return aNode;
++    }
++    aNode = sibling;
+   }
+-  return 0;
++
++  return parent->GetFirstChild();
+ }
+ 
+-/* static */ int32_t
+-nsGenericDOMDataNode::LastLogicallyAdjacentTextNode(nsIContent* aParent,
+-                                                    int32_t aIndex,
+-                                                    uint32_t aCount)
++static nsIContent*
++LastLogicallyAdjacentTextNode(nsIContent* aNode)
+ {
+-  while (++aIndex < int32_t(aCount)) {
+-    nsIContent* sibling = aParent->GetChildAt_Deprecated(aIndex);
+-    if (!sibling->IsNodeOfType(nsINode::eTEXT))
+-      return aIndex - 1;
++  nsCOMPtr<nsIContent> parent = aNode->GetParent();
++
++  while (aNode) {
++    nsIContent* sibling = aNode->GetNextSibling();
++    if (!sibling) break;
++
++    if (!sibling->IsNodeOfType(nsINode::eTEXT)) {
++      return aNode;
++    }
++
++    aNode = sibling;
+   }
+-  return aCount - 1;
++
++  return parent->GetLastChild();
+ }
+ 
+ nsresult
+ nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
+ {
+   nsIContent* parent = GetParent();
+ 
+   // Handle parent-less nodes
+   if (!parent)
+     return GetData(aWholeText);
+ 
+   int32_t index = parent->IndexOf(this);
+   NS_WARNING_ASSERTION(index >= 0,
+                        "Trying to use .wholeText with an anonymous"
+                        "text node child of a binding parent?");
+   NS_ENSURE_TRUE(index >= 0, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+-  int32_t first =
+-    FirstLogicallyAdjacentTextNode(parent, index);
+-  int32_t last =
+-    LastLogicallyAdjacentTextNode(parent, index, parent->GetChildCount());
++  nsCOMPtr<nsIContent> first = FirstLogicallyAdjacentTextNode(this);
++  nsCOMPtr<nsIContent> last = LastLogicallyAdjacentTextNode(this);
+ 
+   aWholeText.Truncate();
+ 
+   nsCOMPtr<nsIDOMText> node;
+   nsAutoString tmp;
+-  do {
+-    node = do_QueryInterface(parent->GetChildAt_Deprecated(first));
++
++  while (true) {
++    node = do_QueryInterface(first);
+     node->GetData(tmp);
+     aWholeText.Append(tmp);
+-  } while (first++ < last);
++
++    if (first == last) {
++      break;
++    }
++
++    first = first->GetNextSibling();
++  }
+ 
+   return NS_OK;
+ }
+ 
+ //----------------------------------------------------------------------
+ 
+ // Implementation of the nsIContent interface text functions
+ 
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
+--- a/dom/base/nsGenericDOMDataNode.h
++++ b/dom/base/nsGenericDOMDataNode.h
+@@ -229,23 +229,16 @@ protected:
+ 
+     return parent && parent->IsElement() ? parent->AsElement() : nullptr;
+   }
+ 
+   nsresult SplitText(uint32_t aOffset, nsIDOMText** aReturn);
+ 
+   nsresult GetWholeText(nsAString& aWholeText);
+ 
+-  static int32_t FirstLogicallyAdjacentTextNode(nsIContent* aParent,
+-                                                int32_t aIndex);
+-
+-  static int32_t LastLogicallyAdjacentTextNode(nsIContent* aParent,
+-                                               int32_t aIndex,
+-                                               uint32_t aCount);
+-
+   nsresult SetTextInternal(uint32_t aOffset, uint32_t aCount,
+                            const char16_t* aBuffer, uint32_t aLength,
+                            bool aNotify,
+                            CharacterDataChangeInfo::Details* aDetails = nullptr);
+ 
+   /**
+    * Method to clone this node. This needs to be overriden by all derived
+    * classes. If aCloneText is true the text content will be cloned too.

+ 102 - 0
mozilla-release/patches/1425440-26-59a1.patch

@@ -0,0 +1,102 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516108631 -3600
+#      Tue Jan 16 14:17:11 2018 +0100
+# Node ID 88a3fe239646fecc58f55d6d04f115fc3c590fad
+# Parent  a468d29036dacc652ca485253c1375a98de95373
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in FragmentOrElement and nsIDocument, r=catalinb
+
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
+--- a/dom/base/FragmentOrElement.cpp
++++ b/dom/base/FragmentOrElement.cpp
+@@ -1169,16 +1169,18 @@ FragmentOrElement::RemoveChildAt_Depreca
+   if (oldKid) {
+     doRemoveChildAt(aIndex, aNotify, oldKid, mAttrsAndChildren);
+   }
+ }
+ 
+ void
+ FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
+ {
++  // Let's keep the node alive.
++  nsCOMPtr<nsIContent> kungFuDeathGrip = aKid;
+   doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
+ }
+ 
+ void
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
+                                           OOMReporter& aError)
+ {
+   if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {
+@@ -2300,20 +2302,19 @@ FragmentOrElement::SetInnerHTMLInternal(
+   mozAutoSubtreeModified subtree(doc, nullptr);
+ 
+   target->FireNodeRemovedForChildren();
+ 
+   // Needed when innerHTML is used in combination with contenteditable
+   mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
+ 
+   // Remove childnodes.
+-  uint32_t childCount = target->GetChildCount();
+   nsAutoMutationBatch mb(target, true, false);
+-  for (uint32_t i = 0; i < childCount; ++i) {
+-    target->RemoveChildAt_Deprecated(0, true);
++  while (target->HasChildren()) {
++    target->RemoveChildNode(target->GetFirstChild(), true);
+   }
+   mb.RemovalDone();
+ 
+   nsAutoScriptLoaderDisabler sld(doc);
+ 
+   nsIAtom* contextLocalName = NodeInfo()->NameAtom();
+   int32_t contextNameSpaceID = GetNameSpaceID();
+ 
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
+--- a/dom/base/nsDocument.cpp
++++ b/dom/base/nsDocument.cpp
+@@ -7435,20 +7435,20 @@ nsDOMAttributeMap::BlastSubtreeToPieces(
+                              false);
+ 
+         // XXX Should we abort here?
+         NS_ASSERTION(NS_SUCCEEDED(rv), "Uh-oh, UnsetAttr shouldn't fail!");
+       }
+     }
+   }
+ 
+-  uint32_t count = aNode->GetChildCount();
+-  for (uint32_t i = 0; i < count; ++i) {
+-    BlastSubtreeToPieces(aNode->GetFirstChild());
+-    aNode->RemoveChildAt_Deprecated(0, false);
++  while (aNode->HasChildren()) {
++    nsIContent* node = aNode->GetFirstChild();
++    BlastSubtreeToPieces(node);
++    aNode->RemoveChildNode(node, false);
+   }
+ }
+ 
+ enum class StyleDataType
+ {
+   InlineStyle,
+   SMILOverride,
+   RestyleBits,
+@@ -7636,19 +7636,17 @@ nsIDocument::AdoptNode(nsINode& aAdopted
+             return nullptr;
+           }
+         }
+       } while ((doc = doc->GetParentDocument()));
+ 
+       // Remove from parent.
+       nsCOMPtr<nsINode> parent = adoptedNode->GetParentNode();
+       if (parent) {
+-        int32_t idx = parent->IndexOf(adoptedNode);
+-        MOZ_ASSERT(idx >= 0);
+-        parent->RemoveChildAt_Deprecated(idx, true);
++        parent->RemoveChildNode(adoptedNode->AsContent(), true);
+       } else {
+         MOZ_ASSERT(!adoptedNode->IsInUncomposedDoc());
+ 
+         // If we're adopting a node that's not in a document, it might still
+         // have a binding applied. Remove the binding from the element now
+         // that it's getting adopted into a new document.
+         // TODO Fully tear down the binding.
+         if (adoptedNode->IsElement()) {

+ 34 - 0
mozilla-release/patches/1425440-27-59a1.patch

@@ -0,0 +1,34 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516114817 -3600
+#      Tue Jan 16 16:00:17 2018 +0100
+# Node ID 7fbbc0208dc83109e22460c945982323366010ed
+# Parent  2951624227ccd8ccdaf1eca58b2d9adb0ecacc9c
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsXBLPrototypeBinding, r=catalinb
+
+diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
+--- a/dom/xbl/nsXBLPrototypeBinding.cpp
++++ b/dom/xbl/nsXBLPrototypeBinding.cpp
+@@ -379,19 +379,19 @@ nsXBLPrototypeBinding::AttributeChanged(
+       // set or unset on us.  We may also be a tag that is having
+       // xbl:text set on us.
+ 
+       if ((dstAttr == nsGkAtoms::text && dstNs == kNameSpaceID_XBL) ||
+           (realElement->NodeInfo()->Equals(nsGkAtoms::html,
+                                            kNameSpaceID_XUL) &&
+            dstAttr == nsGkAtoms::value)) {
+         // Flush out all our kids.
+-        uint32_t childCount = realElement->GetChildCount();
+-        for (uint32_t i = 0; i < childCount; i++)
+-          realElement->RemoveChildAt_Deprecated(0, aNotify);
++        while (realElement->HasChildren()) {
++          realElement->RemoveChildNode(realElement->GetFirstChild(), aNotify);
++        }
+ 
+         if (!aRemoveFlag) {
+           // Construct a new text node and insert it.
+           nsAutoString value;
+           aChangedElement->GetAttr(aNameSpaceID, aAttribute, value);
+           if (!value.IsEmpty()) {
+             RefPtr<nsTextNode> textContent =
+               new nsTextNode(realElement->NodeInfo()->NodeInfoManager());

+ 75 - 0
mozilla-release/patches/1425440-28-59a1.patch

@@ -0,0 +1,75 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516125594 -3600
+#      Tue Jan 16 18:59:54 2018 +0100
+# Node ID 96be89486722f49f99afbd5b3c02495f5306902c
+# Parent  aa97f8900daef878107eb17f1afd802a88605544
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in nsContentUtils, r=catalinb
+
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -5268,42 +5268,47 @@ nsContentUtils::SetNodeTextContent(nsICo
+   }
+ 
+   // Might as well stick a batch around this since we're performing several
+   // mutations.
+   mozAutoDocUpdate updateBatch(aContent->GetComposedDoc(),
+     UPDATE_CONTENT_MODEL, true);
+   nsAutoMutationBatch mb;
+ 
+-  uint32_t childCount = aContent->GetChildCount();
+-
+   if (aTryReuse && !aValue.IsEmpty()) {
+-    uint32_t removeIndex = 0;
+-
+-    for (uint32_t i = 0; i < childCount; ++i) {
+-      nsIContent* child = aContent->GetChildAt_Deprecated(removeIndex);
+-      if (removeIndex == 0 && child && child->IsNodeOfType(nsINode::eTEXT)) {
+-        nsresult rv = child->SetText(aValue, true);
+-        NS_ENSURE_SUCCESS(rv, rv);
+-
+-        removeIndex = 1;
++    // Let's remove nodes until we find a eTEXT.
++    while (aContent->HasChildren()) {
++      nsIContent* child = aContent->GetFirstChild();
++      if (child->IsNodeOfType(nsINode::eTEXT)) {
++        break;
+       }
+-      else {
+-        aContent->RemoveChildAt_Deprecated(removeIndex, true);
++      aContent->RemoveChildNode(child, true);
++    }
++
++    // If we have a node, it must be a eTEXT and we reuse it.
++    if (aContent->HasChildren()) {
++      nsIContent* child = aContent->GetFirstChild();
++      MOZ_ASSERT(child->IsNodeOfType(nsINode::eTEXT));
++      nsresult rv = child->SetText(aValue, true);
++      NS_ENSURE_SUCCESS(rv, rv);
++
++      // All the following nodes, if they exist, must be deleted.
++      while (nsIContent* nextChild = child->GetNextSibling()) {
++        aContent->RemoveChildNode(nextChild, true);
+       }
+     }
+ 
+-    if (removeIndex == 1) {
++    if (aContent->HasChildren()) {
+       return NS_OK;
+     }
+   }
+   else {
+     mb.Init(aContent, true, false);
+-    for (uint32_t i = 0; i < childCount; ++i) {
+-      aContent->RemoveChildAt_Deprecated(0, true);
++    while (aContent->HasChildren()) {
++      aContent->RemoveChildNode(aContent->GetFirstChild(), true);
+     }
+   }
+   mb.RemovalDone();
+ 
+   if (aValue.IsEmpty()) {
+     return NS_OK;
+   }
+ 

+ 56 - 0
mozilla-release/patches/1425440-29-59a1.patch

@@ -0,0 +1,56 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516125623 -3600
+#      Tue Jan 16 19:00:23 2018 +0100
+# Node ID 0ab5dd16c2ff18408e8a4225c2358de74c830ca0
+# Parent  96be89486722f49f99afbd5b3c02495f5306902c
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in txMozillaXMLOutput, r=catalinb
+
+diff --git a/dom/xslt/xslt/txMozillaXMLOutput.cpp b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+--- a/dom/xslt/xslt/txMozillaXMLOutput.cpp
++++ b/dom/xslt/xslt/txMozillaXMLOutput.cpp
+@@ -620,41 +620,40 @@ txMozillaXMLOutput::createTxWrapper()
+     nsresult rv = nsContentUtils::NameSpaceManager()->
+         RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
+     NS_ENSURE_SUCCESS(rv, rv);
+ 
+     nsCOMPtr<Element> wrapper =
+       mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
+                             nsGkAtoms::transformiix, namespaceID);
+ 
+-    uint32_t j = 0;
+ #ifdef DEBUG
+     // Keep track of the location of the current documentElement, if there is
+     // one, so we can verify later
+-    uint32_t rootLocation = 0;
++    uint32_t j = 0, rootLocation = 0;
+ #endif
+     for (nsCOMPtr<nsIContent> childContent = mDocument->GetFirstChild();
+          childContent; childContent = childContent->GetNextSibling()) {
+ #ifdef DEBUG
+         if (childContent->IsElement()) {
+             rootLocation = j;
+         }
+ #endif
+ 
+         if (childContent->NodeInfo()->NameAtom() == nsGkAtoms::documentTypeNodeName) {
+ #ifdef DEBUG
+             // The new documentElement should go after the document type.
+             // This is needed for cases when there is no existing
+             // documentElement in the document.
+             rootLocation = std::max(rootLocation, j + 1);
++            ++j;
+ #endif
+-            ++j;
+         }
+         else {
+-            mDocument->RemoveChildAt_Deprecated(j, true);
++            mDocument->RemoveChildNode(childContent, true);
+ 
+             rv = wrapper->AppendChildTo(childContent, true);
+             NS_ENSURE_SUCCESS(rv, rv);
+             break;
+         }
+     }
+ 
+     if (!mCurrentNodeStack.AppendObject(wrapper)) {

+ 113 - 0
mozilla-release/patches/1425440-30-59a1.patch

@@ -0,0 +1,113 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516892690 -3600
+#      Thu Jan 25 16:04:50 2018 +0100
+# Node ID 39c98c0933e15dc9e66c418fbcb549fda306ab73
+# Parent  fe2b132359683161271fb57537a2518acd3f9915
+Bug 1425440 - Replace RemoveChildAt_Deprecated with RemoveChildNode in XULDocument, r=catalinb
+
+diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
+--- a/dom/xul/XULDocument.cpp
++++ b/dom/xul/XULDocument.cpp
+@@ -3875,18 +3875,17 @@ XULDocument::OverlayForwardReference::Me
+         nsAutoString value;
+         aOverlayElement->GetAttr(nameSpaceID, attr, value);
+ 
+         // Element in the overlay has the 'removeelement' attribute set
+         // so remove it from the actual document.
+         if (attr == nsGkAtoms::removeelement && value.EqualsLiteral("true")) {
+             nsCOMPtr<nsINode> parent = aTargetElement->GetParentNode();
+             if (!parent) return NS_ERROR_FAILURE;
+-            rv = RemoveElement(parent, aTargetElement);
+-            if (NS_FAILED(rv)) return rv;
++            parent->RemoveChildNode(aTargetElement, true);
+             return NS_OK;
+         }
+ 
+         rv = aTargetElement->SetAttr(nameSpaceID, attr, prefix, value, aNotify);
+         if (!NS_FAILED(rv) && !aNotify) {
+             rv = mDocument->BroadcastAttributeChangeFromOverlay(
+                     aTargetElement, nameSpaceID, attr, prefix, value);
+         }
+@@ -3943,23 +3942,29 @@ XULDocument::OverlayForwardReference::Me
+             if (parentID && aTargetElement->GetID() == parentID) {
+                 // The element matches. "Go Deep!"
+                 //
+                 // Note that currContent is necessarily an element, because
+                 // elementInDocument can only be non-null when currContent has a
+                 // non-null ID.
+                 rv = Merge(elementInDocument, currContent->AsElement(), aNotify);
+                 if (NS_FAILED(rv)) return rv;
+-                aOverlayElement->RemoveChildAt_Deprecated(0, false);
++                nsIContent* firstChild = aOverlayElement->GetFirstChild();
++                if (firstChild) {
++                  aOverlayElement->RemoveChildNode(firstChild, false);
++                }
+ 
+                 continue;
+             }
+         }
+ 
+-        aOverlayElement->RemoveChildAt_Deprecated(0, false);
++        nsIContent* firstChild = aOverlayElement->GetFirstChild();
++        if (firstChild) {
++          aOverlayElement->RemoveChildNode(firstChild, false);
++        }
+ 
+         rv = InsertElement(aTargetElement, currContent, aNotify);
+         if (NS_FAILED(rv)) return rv;
+     }
+ 
+     return NS_OK;
+ }
+ 
+@@ -4328,25 +4333,16 @@ XULDocument::InsertElement(nsINode* aPar
+     }
+ 
+     if (!wasInserted) {
+         return aParent->AppendChildTo(aChild, aNotify);
+     }
+     return NS_OK;
+ }
+ 
+-nsresult
+-XULDocument::RemoveElement(nsINode* aParent, nsINode* aChild)
+-{
+-    int32_t nodeOffset = aParent->IndexOf(aChild);
+-
+-    aParent->RemoveChildAt_Deprecated(nodeOffset, true);
+-    return NS_OK;
+-}
+-
+ //----------------------------------------------------------------------
+ //
+ // CachedChromeStreamListener
+ //
+ 
+ XULDocument::CachedChromeStreamListener::CachedChromeStreamListener(XULDocument* aDocument, bool aProtoLoaded)
+     : mDocument(aDocument),
+       mProtoLoaded(aProtoLoaded)
+diff --git a/dom/xul/XULDocument.h b/dom/xul/XULDocument.h
+--- a/dom/xul/XULDocument.h
++++ b/dom/xul/XULDocument.h
+@@ -606,20 +606,16 @@ protected:
+                                  const nsAString &aAttr);
+ 
+     // FIXME: This should probably be renamed, there's nothing guaranteeing that
+     // aChild is an Element as far as I can tell!
+     static
+     nsresult
+     InsertElement(nsINode* aParent, nsIContent* aChild, bool aNotify);
+ 
+-    static
+-    nsresult
+-    RemoveElement(nsINode* aParent, nsINode* aChild);
+-
+     /**
+      * The current prototype that we are walking to construct the
+      * content model.
+      */
+     RefPtr<nsXULPrototypeDocument> mCurrentPrototype;
+ 
+     /**
+      * The master document (outermost, .xul) prototype, from which

+ 30 - 0
mozilla-release/patches/1430516-59a1.patch

@@ -0,0 +1,30 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516189971 -3600
+# Node ID f4d2bd7f41da8e6ddfb5e2a5664893b0288645a7
+# Parent  871fecd7db1d0847e0b4c48c17eda859f14254f7
+Bug 1430516 - Fixing a regression when a table cell is selected, r=catalinb
+
+diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp
+--- a/dom/base/Selection.cpp
++++ b/dom/base/Selection.cpp
+@@ -682,17 +682,17 @@ Selection::GetTableSelectionType(nsIDOMR
+   if (!endNode) return NS_ERROR_FAILURE;
+ 
+   // Not a single selected node
+   if (startNode != endNode) return NS_OK;
+ 
+   nsIContent* child = range->GetChildAtStartOffset();
+ 
+   // Not a single selected node
+-  if (!child || child != range->GetChildAtEndOffset()) {
++  if (!child || child->GetNextSibling() != range->GetChildAtEndOffset()) {
+     return NS_OK;
+   }
+ 
+   nsIContent* startContent = static_cast<nsIContent*>(startNode);
+   if (!(startNode->IsElement() && startContent->IsHTMLElement())) {
+     // Implies a check for being an element; if we ever make this work
+     // for non-HTML, need to keep checking for elements.
+     return NS_OK;
+

+ 2642 - 0
mozilla-release/patches/1430997-1-60a1.patch

@@ -0,0 +1,2642 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516714218 -3600
+# Node ID 149124e4fde985158d5d78a87ade1cced1a2410b
+# Parent  a89f28254bc7517716778fa2ccb22ee02e67ab7c
+Bug 1430997 - Rename nsINode::IndexOf to nsINode::ComputeIndexOf, r=catalinb
+
+diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp
+--- a/accessible/base/Logging.cpp
++++ b/accessible/base/Logging.cpp
+@@ -829,17 +829,17 @@ logging::Node(const char* aDescr, nsINod
+   }
+ 
+   if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
+     printf("%s: %p, document\n", aDescr, static_cast<void*>(aNode));
+     return;
+   }
+ 
+   nsINode* parentNode = aNode->GetParentNode();
+-  int32_t idxInParent = parentNode ? parentNode->IndexOf(aNode) : - 1;
++  int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : - 1;
+ 
+   if (aNode->IsNodeOfType(nsINode::eTEXT)) {
+     printf("%s: %p, text node, idx in parent: %d\n",
+            aDescr, static_cast<void*>(aNode), idxInParent);
+     return;
+   }
+ 
+   if (!aNode->IsElement()) {
+diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp
+--- a/accessible/generic/HyperTextAccessible.cpp
++++ b/accessible/generic/HyperTextAccessible.cpp
+@@ -423,17 +423,17 @@ HyperTextAccessible::OffsetToDOMPoint(in
+     innerOffset = 1;
+   }
+ 
+   // Case of embedded object. The point is either before or after the element.
+   NS_ASSERTION(innerOffset == 0 || innerOffset == 1, "A wrong inner offset!");
+   nsINode* node = child->GetNode();
+   nsINode* parentNode = node->GetParentNode();
+   return parentNode ?
+-    DOMPoint(parentNode, parentNode->IndexOf(node) + innerOffset) :
++    DOMPoint(parentNode, parentNode->ComputeIndexOf(node) + innerOffset) :
+     DOMPoint();
+ }
+ 
+ DOMPoint
+ HyperTextAccessible::ClosestNotGeneratedDOMPoint(const DOMPoint& aDOMPoint,
+                                                  nsIContent* aElementContent)
+ {
+   MOZ_ASSERT(aDOMPoint.node, "The node must not be null");
+@@ -2076,17 +2076,17 @@ HyperTextAccessible::GetDOMPointByFrameO
+     NS_ASSERTION(!aAccessible->IsDoc(),
+                  "Shouldn't be called on document accessible!");
+ 
+     nsIContent* content = aAccessible->GetContent();
+     NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
+ 
+     nsIContent* parent = content->GetParent();
+ 
+-    aPoint->idx = parent->IndexOf(content) + 1;
++    aPoint->idx = parent->ComputeIndexOf(content) + 1;
+     aPoint->node = parent;
+ 
+   } else if (aFrame->IsTextFrame()) {
+     nsIContent* content = aFrame->GetContent();
+     NS_ENSURE_STATE(content);
+ 
+     nsIFrame *primaryFrame = content->GetPrimaryFrame();
+     nsresult rv = RenderedToContentOffset(primaryFrame, aOffset, &(aPoint->idx));
+@@ -2096,17 +2096,17 @@ HyperTextAccessible::GetDOMPointByFrameO
+ 
+   } else {
+     nsIContent* content = aFrame->GetContent();
+     NS_ENSURE_STATE(content);
+ 
+     nsIContent* parent = content->GetParent();
+     NS_ENSURE_STATE(parent);
+ 
+-    aPoint->idx = parent->IndexOf(content);
++    aPoint->idx = parent->ComputeIndexOf(content);
+     aPoint->node = parent;
+   }
+ 
+   return NS_OK;
+ }
+ 
+ // HyperTextAccessible
+ void
+diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp
+--- a/dom/base/Attr.cpp
++++ b/dom/base/Attr.cpp
+@@ -309,17 +309,17 @@ Attr::GetChildCount() const
+ 
+ nsIContent *
+ Attr::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return nullptr;
+ }
+ 
+ int32_t
+-Attr::IndexOf(const nsINode* aPossibleChild) const
++Attr::ComputeIndexOf(const nsINode* aPossibleChild) const
+ {
+   return -1;
+ }
+ 
+ nsresult
+ Attr::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                               bool aNotify)
+ {
+diff --git a/dom/base/Attr.h b/dom/base/Attr.h
+--- a/dom/base/Attr.h
++++ b/dom/base/Attr.h
+@@ -61,17 +61,17 @@ public:
+   void SetMap(nsDOMAttributeMap *aMap) override;
+   Element* GetElement() const;
+   nsresult SetOwnerDocument(nsIDocument* aDocument) override;
+ 
+   // nsINode interface
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+-  virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
++  virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override;
+   virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
+ 
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
+--- a/dom/base/FragmentOrElement.cpp
++++ b/dom/base/FragmentOrElement.cpp
+@@ -553,17 +553,17 @@ nsAttrChildContentList::Item(uint32_t aI
+ 
+   return nullptr;
+ }
+ 
+ int32_t
+ nsAttrChildContentList::IndexOf(nsIContent* aContent)
+ {
+   if (mNode) {
+-    return mNode->IndexOf(aContent);
++    return mNode->ComputeIndexOf(aContent);
+   }
+ 
+   return -1;
+ }
+ 
+ //----------------------------------------------------------------------
+ NS_IMETHODIMP
+ nsParentNodeChildContentList::GetLength(uint32_t* aLength)
+@@ -1171,17 +1171,17 @@ FragmentOrElement::RemoveChildAt_Depreca
+   }
+ }
+ 
+ void
+ FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
+ {
+   // Let's keep the node alive.
+   nsCOMPtr<nsIContent> kungFuDeathGrip = aKid;
+-  doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
++  doRemoveChildAt(ComputeIndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
+ }
+ 
+ void
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
+                                           OOMReporter& aError)
+ {
+   if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {
+     aError.ReportOOM();
+@@ -2132,17 +2132,17 @@ FragmentOrElement::GetChildCount() const
+ 
+ nsIContent *
+ FragmentOrElement::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return mAttrsAndChildren.GetSafeChildAt(aIndex);
+ }
+ 
+ int32_t
+-FragmentOrElement::IndexOf(const nsINode* aPossibleChild) const
++FragmentOrElement::ComputeIndexOf(const nsINode* aPossibleChild) const
+ {
+   return mAttrsAndChildren.IndexOfChild(aPossibleChild);
+ }
+ 
+ static inline bool
+ IsVoidTag(nsIAtom* aTag)
+ {
+   static const nsIAtom* voidElements[] = {
+diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
+--- a/dom/base/FragmentOrElement.h
++++ b/dom/base/FragmentOrElement.h
+@@ -114,17 +114,17 @@ public:
+ 
+   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ 
+   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
+ 
+   // nsINode interface methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+-  virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
++  virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override;
+   virtual void SetTextContentInternal(const nsAString& aTextContent,
+                                       nsIPrincipal* aSubjectPrincipal,
+diff --git a/dom/base/RangeBoundary.h b/dom/base/RangeBoundary.h
+--- a/dom/base/RangeBoundary.h
++++ b/dom/base/RangeBoundary.h
+@@ -173,17 +173,17 @@ public:
+     }
+ 
+     if (!mParent) {
+       return 0;
+     }
+ 
+     MOZ_ASSERT(mRef);
+     MOZ_ASSERT(mRef->GetParentNode() == mParent);
+-    mOffset = mozilla::Some(mParent->IndexOf(mRef) + 1);
++    mOffset = mozilla::Some(mParent->ComputeIndexOf(mRef) + 1);
+ 
+     return mOffset.value();
+   }
+ 
+   void
+   InvalidateOffset()
+   {
+     MOZ_ASSERT(mParent);
+diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp
+--- a/dom/base/Selection.cpp
++++ b/dom/base/Selection.cpp
+@@ -1681,17 +1681,17 @@ Selection::GetPrimaryFrameForFocusNode(n
+   if (!content->TextIsOnlyWhitespace()) {
+     return NS_ERROR_FAILURE;
+   }
+ 
+   nsCOMPtr<nsIContent> parent = content->GetParent();
+   if (NS_WARN_IF(!parent)) {
+     return NS_ERROR_FAILURE;
+   }
+-  int32_t offset = parent->IndexOf(content);
++  int32_t offset = parent->ComputeIndexOf(content);
+ 
+   return GetPrimaryOrCaretFrameForNodeOffset(parent, offset, aReturnFrame,
+                                              aOffsetUsed, aVisual);
+ }
+ 
+ nsresult
+ Selection::GetPrimaryOrCaretFrameForNodeOffset(nsIContent* aContent,
+                                                uint32_t aOffset,
+@@ -2580,17 +2580,17 @@ Selection::Collapse(const RawRangeBounda
+     nsTextFrame* f =
+       do_QueryFrame(nsCaret::GetFrameAndOffset(this, aPoint.Container(),
+                                                aPoint.Offset(), &frameOffset));
+     if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
+       // RawRangeBounary::Offset() causes computing offset if it's not been
+       // done yet.  However, it's called only when the container is a text
+       // node.  In such case, offset has always been set since it cannot have
+       // any children.  So, this doesn't cause computing offset with expensive
+-      // method, nsINode::IndexOf().
++      // method, nsINode::ComputeIndexOf().
+       if ((aPoint.Container()->AsContent() == f->GetContent() &&
+            f->GetContentEnd() == static_cast<int32_t>(aPoint.Offset())) ||
+           (aPoint.Container() == f->GetContent()->GetParentNode() &&
+            f->GetContent() == aPoint.GetPreviousSiblingOfChildAtOffset())) {
+         frameSelection->SetHint(CARET_ASSOCIATE_AFTER);
+       }
+     }
+   }
+diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp
+--- a/dom/base/nsContentIterator.cpp
++++ b/dom/base/nsContentIterator.cpp
+@@ -177,18 +177,18 @@ protected:
+   // iterators do not do much transitioning between parents and children.  They
+   // tend to stay at the same level.  In fact, you can prove (though I won't
+   // attempt it here) that they change levels at most n+m times, where n is the
+   // height of the parent hierarchy from the range start to the common
+   // ancestor, and m is the the height of the parent hierarchy from the range
+   // end to the common ancestor.  If we used the index array, we would pay the
+   // price up front for n, and then pay the cost for m on the fly later on.
+   // With the simple cache, we only "pay as we go".  Either way, we call
+-  // IndexOf() once for each change of level in the hierarchy.  Since a trivial
+-  // index is much simpler, we use it for the subtree iterator.
++  // ComputeIndexOf() once for each change of level in the hierarchy.  Since
++  // a trivial index is much simpler, we use it for the subtree iterator.
+ 
+   bool mIsDone;
+   bool mPre;
+ 
+ private:
+ 
+   // no copies or assigns  FIX ME
+   nsContentIterator(const nsContentIterator&);
+@@ -558,17 +558,17 @@ nsContentIterator::RebuildIndexStack()
+ 
+   while (current != mCommonParent) {
+     parent = current->GetParentNode();
+ 
+     if (NS_WARN_IF(!parent)) {
+       return NS_ERROR_FAILURE;
+     }
+ 
+-    mIndexes.InsertElementAt(0, parent->IndexOf(current));
++    mIndexes.InsertElementAt(0, parent->ComputeIndexOf(current));
+ 
+     current = parent;
+   }
+ 
+   return NS_OK;
+ }
+ 
+ void
+@@ -684,22 +684,22 @@ nsContentIterator::GetNextSibling(nsINod
+     // use the last entry on the Indexes array for the current index
+     indx = (*aIndexes)[aIndexes->Length()-1];
+   } else {
+     indx = mCachedIndex;
+   }
+   NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+ 
+   // reverify that the index of the current node hasn't changed.
+-  // not super cheap, but a lot cheaper than IndexOf(), and still O(1).
+-  // ignore result this time - the index may now be out of range.
++  // not super cheap, but a lot cheaper than ComputeIndexOf(), and still
++  // O(1). ignore result this time - the index may now be out of range.
+   nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+   if (sib != aNode) {
+     // someone changed our index - find the new index the painful way
+-    indx = parent->IndexOf(aNode);
++    indx = parent->ComputeIndexOf(aNode);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+   if ((sib = parent->GetChildAt_Deprecated(++indx))) {
+     // update index cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+@@ -750,17 +750,17 @@ nsContentIterator::GetPrevSibling(nsINod
+     indx = mCachedIndex;
+   }
+ 
+   // reverify that the index of the current node hasn't changed
+   // ignore result this time - the index may now be out of range.
+   nsIContent* sib = parent->GetChildAt_Deprecated(indx);
+   if (sib != aNode) {
+     // someone changed our index - find the new index the painful way
+-    indx = parent->IndexOf(aNode);
++    indx = parent->ComputeIndexOf(aNode);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+   if (indx > 0 && (sib = parent->GetChildAt_Deprecated(--indx))) {
+     // update index cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       aIndexes->ElementAt(aIndexes->Length()-1) = indx;
+@@ -821,24 +821,24 @@ nsContentIterator::NextNode(nsINode* aNo
+   if (aIndexes && !aIndexes->IsEmpty()) {
+     // use the last entry on the Indexes array for the current index
+     indx = (*aIndexes)[aIndexes->Length()-1];
+   } else {
+     indx = mCachedIndex;
+   }
+ 
+   // reverify that the index of the current node hasn't changed.  not super
+-  // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
+-  // this time - the index may now be out of range.
++  // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1).  ignore
++  // result this time - the index may now be out of range.
+   if (indx >= 0) {
+     sibling = parent->GetChildAt_Deprecated(indx);
+   }
+   if (sibling != node) {
+     // someone changed our index - find the new index the painful way
+-    indx = parent->IndexOf(node);
++    indx = parent->ComputeIndexOf(node);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+   }
+ 
+   // indx is now canonically correct
+   sibling = parent->GetChildAt_Deprecated(++indx);
+   if (sibling) {
+     // update cache
+     if (aIndexes && !aIndexes->IsEmpty()) {
+@@ -890,26 +890,26 @@ nsContentIterator::PrevNode(nsINode* aNo
+     if (aIndexes && !aIndexes->IsEmpty()) {
+       // use the last entry on the Indexes array for the current index
+       indx = (*aIndexes)[aIndexes->Length()-1];
+     } else {
+       indx = mCachedIndex;
+     }
+ 
+     // reverify that the index of the current node hasn't changed.  not super
+-    // cheap, but a lot cheaper than IndexOf(), and still O(1).  ignore result
+-    // this time - the index may now be out of range.
++    // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1).
++    // ignore result this time - the index may now be out of range.
+     if (indx >= 0) {
+       sibling = parent->GetChildAt_Deprecated(indx);
+       NS_WARNING_ASSERTION(sibling, "GetChildAt_Deprecated returned null");
+     }
+ 
+     if (sibling != node) {
+       // someone changed our index - find the new index the painful way
+-      indx = parent->IndexOf(node);
++      indx = parent->ComputeIndexOf(node);
+       NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+     }
+ 
+     // indx is now canonically correct
+     if (indx && (sibling = parent->GetChildAt_Deprecated(--indx))) {
+       // update cache
+       if (aIndexes && !aIndexes->IsEmpty()) {
+         // replace an entry on the index stack
+@@ -1093,19 +1093,19 @@ nsContentIterator::PositionAt(nsINode* a
+ 
+   // We can be at ANY node in the sequence.  Need to regenerate the array of
+   // indexes back to the root or common parent!
+   AutoTArray<nsINode*, 8>     oldParentStack;
+   AutoTArray<int32_t, 8>      newIndexes;
+ 
+   // Get a list of the parents up to the root, then compare the new node with
+   // entries in that array until we find a match (lowest common ancestor).  If
+-  // no match, use IndexOf, take the parent, and repeat.  This avoids using
+-  // IndexOf() N times on possibly large arrays.  We still end up doing it a
+-  // fair bit.  It's better to use Clone() if possible.
++  // no match, use ComputeIndexOf, take the parent, and repeat.  This avoids
++  // using ComputeIndexOf() N times on possibly large arrays.  We still end
++  // up doing it a fair bit.  It's better to use Clone() if possible.
+ 
+   // we know the depth we're down (though we may not have started at the top).
+   oldParentStack.SetCapacity(mIndexes.Length() + 1);
+ 
+   // We want to loop mIndexes.Length() + 1 times here, because we want to make
+   // sure we include mCommonParent in the oldParentStack, for use in the next
+   // for loop, and mIndexes only has entries for nodes from tempNode up through
+   // an ancestor of tempNode that's a child of mCommonParent.
+@@ -1135,17 +1135,17 @@ nsContentIterator::PositionAt(nsINode* a
+   while (newCurNode) {
+     nsINode* parent = newCurNode->GetParentNode();
+ 
+     if (NS_WARN_IF(!parent)) {
+       // this node has no parent, and thus no index
+       break;
+     }
+ 
+-    int32_t indx = parent->IndexOf(newCurNode);
++    int32_t indx = parent->ComputeIndexOf(newCurNode);
+     NS_WARNING_ASSERTION(indx >= 0, "bad indx");
+ 
+     // insert at the head!
+     newIndexes.InsertElementAt(0, indx);
+ 
+     // look to see if the parent is in the stack
+     indx = oldParentStack.IndexOf(parent);
+     if (indx >= 0) {
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
+--- a/dom/base/nsContentUtils.cpp
++++ b/dom/base/nsContentUtils.cpp
+@@ -2408,17 +2408,17 @@ nsContentUtils::InProlog(nsINode *aNode)
+   nsINode* parent = aNode->GetParentNode();
+   if (!parent || !parent->IsNodeOfType(nsINode::eDOCUMENT)) {
+     return false;
+   }
+ 
+   nsIDocument* doc = static_cast<nsIDocument*>(parent);
+   nsIContent* root = doc->GetRootElement();
+ 
+-  return !root || doc->IndexOf(aNode) < doc->IndexOf(root);
++  return !root || doc->ComputeIndexOf(aNode) < doc->ComputeIndexOf(root);
+ }
+ 
+ nsIDocument*
+ nsContentUtils::GetDocumentFromCaller()
+ {
+   AutoJSContext cx;
+ 
+   nsCOMPtr<nsPIDOMWindowInner> win =
+@@ -2753,17 +2753,17 @@ nsContentUtils::GetAncestorsAndOffsets(n
+   aAncestorNodes->AppendElement(content.get());
+   aAncestorOffsets->AppendElement(aOffset);
+ 
+   // insert all the ancestors
+   nsIContent* child = content;
+   nsIContent* parent = child->GetParent();
+   while (parent) {
+     aAncestorNodes->AppendElement(parent);
+-    aAncestorOffsets->AppendElement(parent->IndexOf(child));
++    aAncestorOffsets->AppendElement(parent->ComputeIndexOf(child));
+     child = parent;
+     parent = parent->GetParent();
+   }
+ 
+   return NS_OK;
+ }
+ 
+ // static
+@@ -2863,18 +2863,18 @@ nsContentUtils::PositionIsBefore(nsINode
+ /* static */
+ int32_t
+ nsContentUtils::ComparePoints(nsINode* aParent1, int32_t aOffset1,
+                               nsINode* aParent2, int32_t aOffset2,
+                               bool* aDisconnected)
+ {
+   if (aParent1 == aParent2) {
+     // XXX This is odd.  aOffset1 and/or aOffset2 may be -1, e.g., it's result
+-    //     of nsINode::IndexOf(), but this compares such invalid offset with
+-    //     valid offset.
++    //     of nsINode::ComputeIndexOf(), but this compares such invalid
++    //     offset with valid offset.
+     return aOffset1 < aOffset2 ? -1 :
+            aOffset1 > aOffset2 ? 1 :
+            0;
+   }
+ 
+   AutoTArray<nsINode*, 32> parents1, parents2;
+   nsINode* node1 = aParent1;
+   nsINode* node2 = aParent2;
+@@ -2901,39 +2901,39 @@ nsContentUtils::ComparePoints(nsINode* a
+ 
+   // Find where the parent chains differ
+   nsINode* parent = parents1.ElementAt(pos1);
+   uint32_t len;
+   for (len = std::min(pos1, pos2); len > 0; --len) {
+     nsINode* child1 = parents1.ElementAt(--pos1);
+     nsINode* child2 = parents2.ElementAt(--pos2);
+     if (child1 != child2) {
+-      return parent->IndexOf(child1) < parent->IndexOf(child2) ? -1 : 1;
++      return parent->ComputeIndexOf(child1) < parent->ComputeIndexOf(child2) ? -1 : 1;
+     }
+     parent = child1;
+   }
+ 
+ 
+   // The parent chains never differed, so one of the nodes is an ancestor of
+   // the other
+ 
+   NS_ASSERTION(!pos1 || !pos2,
+                "should have run out of parent chain for one of the nodes");
+ 
+   if (!pos1) {
+     nsINode* child2 = parents2.ElementAt(--pos2);
+     // XXX aOffset1 may be -1 as mentioned above.  So, why does this return
+     //     it's *before* of the valid DOM point?
+-    return aOffset1 <= parent->IndexOf(child2) ? -1 : 1;
++    return aOffset1 <= parent->ComputeIndexOf(child2) ? -1 : 1;
+   }
+ 
+   nsINode* child1 = parents1.ElementAt(--pos1);
+   // XXX aOffset2 may be -1 as mentioned above.  So, why does this return it's
+   //     *after* of the valid DOM point?
+-  return parent->IndexOf(child1) < aOffset2 ? -1 : 1;
++  return parent->ComputeIndexOf(child1) < aOffset2 ? -1 : 1;
+ }
+ 
+ /* static */
+ int32_t
+ nsContentUtils::ComparePoints(nsIDOMNode* aParent1, int32_t aOffset1,
+                               nsIDOMNode* aParent2, int32_t aOffset2,
+                               bool* aDisconnected)
+ {
+@@ -3238,17 +3238,17 @@ nsContentUtils::GenerateStateKey(nsICont
+     }
+ 
+     // Now start at aContent and append the indices of it and all its ancestors
+     // in their containers.  That should at least pin down its position in the
+     // DOM...
+     nsINode* parent = aContent->GetParentNode();
+     nsINode* content = aContent;
+     while (parent) {
+-      KeyAppendInt(parent->IndexOf(content), aKey);
++      KeyAppendInt(parent->ComputeIndexOf(content), aKey);
+       content = parent;
+       parent = content->GetParentNode();
+     }
+   }
+ 
+   return NS_OK;
+ }
+ 
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
+--- a/dom/base/nsDocument.cpp
++++ b/dom/base/nsDocument.cpp
+@@ -4265,17 +4265,17 @@ nsDocument::GetRootElementInternal() con
+ 
+ nsIContent *
+ nsDocument::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return mChildren.GetSafeChildAt(aIndex);
+ }
+ 
+ int32_t
+-nsDocument::IndexOf(const nsINode* aPossibleChild) const
++nsDocument::ComputeIndexOf(const nsINode* aPossibleChild) const
+ {
+   return mChildren.IndexOfChild(aPossibleChild);
+ }
+ 
+ uint32_t
+ nsDocument::GetChildCount() const
+ {
+   return mChildren.ChildCount();
+@@ -4331,17 +4331,17 @@ nsDocument::RemoveChildNode(nsIContent* 
+   // Preemptively clear mCachedRootElement, since we may be about to remove it
+   // from our child list, and we don't want to return this maybe-obsolete value
+   // from any GetRootElement() calls that happen inside of doRemoveChildAt().
+   // (NOTE: for this to be useful, doRemoveChildAt() must NOT trigger any
+   // GetRootElement() calls until after it's removed the child from mChildren.
+   // Any call before that point would restore this soon-to-be-obsolete cached
+   // answer, and our clearing here would be fruitless.)
+   mCachedRootElement = nullptr;
+-  doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mChildren);
++  doRemoveChildAt(ComputeIndexOf(aKid), aNotify, aKid, mChildren);
+   MOZ_ASSERT(mCachedRootElement != aKid,
+              "Stale pointer in mCachedRootElement, after we tried to clear it "
+              "(maybe somebody called GetRootElement() too early?)");
+ }
+ 
+ void
+ nsDocument::EnsureOnDemandBuiltInUASheet(StyleSheet* aSheet)
+ {
+diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
+--- a/dom/base/nsDocument.h
++++ b/dom/base/nsDocument.h
+@@ -546,17 +546,17 @@ public:
+   virtual void OnPageHide(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) override;
+ 
+   virtual void WillDispatchMutationEvent(nsINode* aTarget) override;
+   virtual void MutationEventDispatched(nsINode* aTarget) override;
+ 
+   // nsINode
+   virtual bool IsNodeOfType(uint32_t aFlags) const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+-  virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
++  virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
+   virtual uint32_t GetChildCount() const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
+                          bool aPreallocateChildren) const override
+   {
+diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
+--- a/dom/base/nsDocumentEncoder.cpp
++++ b/dom/base/nsDocumentEncoder.cpp
+@@ -1792,17 +1792,17 @@ nsHTMLCopyEncoder::GetNodeLocation(nsIDO
+     result = inChild->GetParentNode(getter_AddRefs(*outParent));
+     if ((NS_SUCCEEDED(result)) && (*outParent))
+     {
+       nsCOMPtr<nsIContent> content = do_QueryInterface(*outParent);
+       nsCOMPtr<nsIContent> cChild = do_QueryInterface(inChild);
+       if (!cChild || !content)
+         return NS_ERROR_NULL_POINTER;
+ 
+-      *outOffset = content->IndexOf(cChild);
++      *outOffset = content->ComputeIndexOf(cChild);
+     }
+   }
+   return result;
+ }
+ 
+ bool
+ nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
+ {
+diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
+--- a/dom/base/nsFocusManager.cpp
++++ b/dom/base/nsFocusManager.cpp
+@@ -3310,17 +3310,17 @@ nsFocusManager::GetNextTabbableMapArea(b
+   nsCOMPtr<nsIDocument> doc = aImageContent->GetComposedDoc();
+   if (doc) {
+     nsCOMPtr<nsIContent> mapContent = doc->FindImageMap(useMap);
+     if (!mapContent)
+       return nullptr;
+     uint32_t count = mapContent->GetChildCount();
+     // First see if the the start content is in this map
+ 
+-    int32_t index = mapContent->IndexOf(aStartContent);
++    int32_t index = mapContent->ComputeIndexOf(aStartContent);
+     int32_t tabIndex;
+     if (index < 0 || (aStartContent->IsFocusable(&tabIndex) &&
+                       tabIndex != aCurrentTabIndex)) {
+       // If aStartContent is in this map we must start iterating past it.
+       // We skip the case where aStartContent has tabindex == aStartContent
+       // since the next tab ordered element might be before it
+       // (or after for backwards) in the child list.
+       index = aForward ? -1 : (int32_t)count;
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
+--- a/dom/base/nsGenericDOMDataNode.cpp
++++ b/dom/base/nsGenericDOMDataNode.cpp
+@@ -641,17 +641,17 @@ nsGenericDOMDataNode::GetChildCount() co
+ nsIContent *
+ nsGenericDOMDataNode::GetChildAt_Deprecated(uint32_t aIndex) const
+ {
+   return nullptr;
+ }
+ 
+ 
+ int32_t
+-nsGenericDOMDataNode::IndexOf(const nsINode* aPossibleChild) const
++nsGenericDOMDataNode::ComputeIndexOf(const nsINode* aPossibleChild) const
+ {
+   return -1;
+ }
+ 
+ nsresult
+ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                     bool aNotify)
+ {
+@@ -749,17 +749,17 @@ nsGenericDOMDataNode::SplitData(uint32_t
+   rv = SetTextInternal(cutStartOffset, cutLength, nullptr, 0, true,
+                        aCloneAfterOriginal ? &details : nullptr);
+   if (NS_FAILED(rv)) {
+     return rv;
+   }
+ 
+   nsCOMPtr<nsINode> parent = GetParentNode();
+   if (parent) {
+-    int32_t insertionIndex = parent->IndexOf(this);
++    int32_t insertionIndex = parent->ComputeIndexOf(this);
+     if (aCloneAfterOriginal) {
+       ++insertionIndex;
+     }
+     parent->InsertChildAt(newContent, insertionIndex, true);
+   }
+ 
+   newContent.swap(*aReturn);
+   return rv;
+@@ -815,17 +815,17 @@ nsresult
+ nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
+ {
+   nsIContent* parent = GetParent();
+ 
+   // Handle parent-less nodes
+   if (!parent)
+     return GetData(aWholeText);
+ 
+-  int32_t index = parent->IndexOf(this);
++  int32_t index = parent->ComputeIndexOf(this);
+   NS_WARNING_ASSERTION(index >= 0,
+                        "Trying to use .wholeText with an anonymous"
+                        "text node child of a binding parent?");
+   NS_ENSURE_TRUE(index >= 0, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+   nsCOMPtr<nsIContent> first = FirstLogicallyAdjacentTextNode(this);
+   nsCOMPtr<nsIContent> last = LastLogicallyAdjacentTextNode(this);
+ 
+   aWholeText.Truncate();
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
+--- a/dom/base/nsGenericDOMDataNode.h
++++ b/dom/base/nsGenericDOMDataNode.h
+@@ -101,17 +101,17 @@ public:
+   nsresult InsertData(uint32_t aOffset, const nsAString& aArg);
+   nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
+   nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
+                        const nsAString& aArg);
+ 
+   // nsINode methods
+   virtual uint32_t GetChildCount() const override;
+   virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
+-  virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
++  virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
+   virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
+                                  bool aNotify) override;
+   virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
+   virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
+   virtual void GetTextContentInternal(nsAString& aTextContent,
+                                       mozilla::OOMReporter& aError) override
+   {
+     GetNodeValue(aTextContent);
+diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
+--- a/dom/base/nsINode.cpp
++++ b/dom/base/nsINode.cpp
+@@ -612,17 +612,17 @@ nsINode::RemoveChild(nsINode& aOldChild,
+     aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
+     return nullptr;
+   }
+ 
+   if (aOldChild.GetParentNode() == this) {
+     nsContentUtils::MaybeFireNodeRemoved(&aOldChild, this, OwnerDoc());
+   }
+ 
+-  int32_t index = IndexOf(&aOldChild);
++  int32_t index = ComputeIndexOf(&aOldChild);
+   if (index == -1) {
+     // aOldChild isn't one of our children.
+     aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
+     return nullptr;
+   }
+ 
+   RemoveChildAt_Deprecated(index, true);
+   return &aOldChild;
+@@ -726,17 +726,17 @@ nsINode::Normalize()
+     }
+ 
+     // Remove node
+     nsCOMPtr<nsINode> parent = node->GetParentNode();
+     NS_ASSERTION(parent || hasRemoveListeners,
+                  "Should always have a parent unless "
+                  "mutation events messed us up");
+     if (parent) {
+-      parent->RemoveChildAt_Deprecated(parent->IndexOf(node), true);
++      parent->RemoveChildAt_Deprecated(parent->ComputeIndexOf(node), true);
+     }
+   }
+ }
+ 
+ nsresult
+ nsINode::GetBaseURI(nsAString &aURI) const
+ {
+   nsCOMPtr<nsIURI> baseURI = GetBaseURI();
+@@ -1010,19 +1010,19 @@ nsINode::CompareDocumentPosition(nsINode
+   // Find where the parent chain differs and check indices in the parent.
+   const nsINode* parent = top1;
+   uint32_t len;
+   for (len = std::min(pos1, pos2); len > 0; --len) {
+     const nsINode* child1 = parents1.ElementAt(--pos1);
+     const nsINode* child2 = parents2.ElementAt(--pos2);
+     if (child1 != child2) {
+       // child1 or child2 can be an attribute here. This will work fine since
+-      // IndexOf will return -1 for the attribute making the attribute be
+-      // considered before any child.
+-      return parent->IndexOf(child1) < parent->IndexOf(child2) ?
++      // ComputeIndexOf will return -1 for the attribute making the
++      // attribute be considered before any child.
++      return parent->ComputeIndexOf(child1) < parent->ComputeIndexOf(child2) ?
+         static_cast<uint16_t>(nsIDOMNode::DOCUMENT_POSITION_PRECEDING) :
+         static_cast<uint16_t>(nsIDOMNode::DOCUMENT_POSITION_FOLLOWING);
+     }
+     parent = child1;
+   }
+ 
+   // We hit the end of one of the parent chains without finding a difference
+   // between the chains. That must mean that one node is an ancestor of the
+@@ -1479,17 +1479,17 @@ nsINode::Traverse(nsINode *tmp, nsCycleC
+         if ((currentDoc && currentDoc->HasKnownLiveWrapper())) {
+           return false;
+         }
+         // If we're not in anonymous content and we have a black parent,
+         // return early.
+         nsIContent* parent = tmp->GetParent();
+         if (parent && !parent->UnoptimizableCCNode() &&
+             parent->HasKnownLiveWrapper()) {
+-          MOZ_ASSERT(parent->IndexOf(tmp) >= 0, "Parent doesn't own us?");
++          MOZ_ASSERT(parent->ComputeIndexOf(tmp) >= 0, "Parent doesn't own us?");
+           return false;
+         }
+       }
+     }
+   }
+ 
+   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNodeInfo)
+   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(GetParent())
+@@ -1971,17 +1971,17 @@ nsINode::doRemoveChildAt(uint32_t aIndex
+ {
+   // 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::RemoveChildNode().
+   MOZ_ASSERT(aKid && aKid->GetParentNode() == this &&
+              aKid == GetChildAt_Deprecated(aIndex) &&
+-             IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
++             ComputeIndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
+   MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE));
+ 
+   nsMutationGuard::DidMutate();
+   mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
+ 
+   nsIContent* previousSibling = aKid->GetPreviousSibling();
+ 
+   if (GetFirstChild() == aKid) {
+@@ -2066,18 +2066,18 @@ bool IsAllowedAsChild(nsIContent* aNewCh
+       }
+ 
+       nsIContent* docTypeContent = parentDocument->GetDoctype();
+       if (!docTypeContent) {
+         // It's all good.
+         return true;
+       }
+ 
+-      int32_t doctypeIndex = aParent->IndexOf(docTypeContent);
+-      int32_t insertIndex = aParent->IndexOf(aRefChild);
++      int32_t doctypeIndex = aParent->ComputeIndexOf(docTypeContent);
++      int32_t insertIndex = aParent->ComputeIndexOf(aRefChild);
+ 
+       // Now we're OK in the following two cases only:
+       // 1) We're replacing something that's not before the doctype
+       // 2) We're inserting before something that comes after the doctype
+       return aIsReplace ? (insertIndex >= doctypeIndex) :
+         insertIndex > doctypeIndex;
+     }
+   case nsIDOMNode::DOCUMENT_TYPE_NODE :
+@@ -2102,18 +2102,18 @@ bool IsAllowedAsChild(nsIContent* aNewCh
+         return true;
+       }
+ 
+       if (!aRefChild) {
+         // Trying to append a doctype, but have a documentElement
+         return false;
+       }
+ 
+-      int32_t rootIndex = aParent->IndexOf(rootElement);
+-      int32_t insertIndex = aParent->IndexOf(aRefChild);
++      int32_t rootIndex = aParent->ComputeIndexOf(rootElement);
++      int32_t insertIndex = aParent->ComputeIndexOf(aRefChild);
+ 
+       // Now we're OK if and only if insertIndex <= rootIndex.  Indeed, either
+       // we end up replacing aRefChild or we end up before it.  Either one is
+       // ok as long as aRefChild is not after rootElement.
+       return insertIndex <= rootIndex;
+     }
+   case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :
+     {
+@@ -2221,17 +2221,18 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+   uint16_t nodeType = aNewChild->NodeType();
+ 
+   // Before we do anything else, fire all DOMNodeRemoved mutation events
+   // We do this up front as to avoid having to deal with script running
+   // at random places further down.
+   // Scope firing mutation events so that we don't carry any state that
+   // might be stale
+   {
+-    // This check happens again further down (though then using IndexOf).
++    // This check happens again further down (though then using
++    // ComputeIndexOf).
+     // We're only checking this here to avoid firing mutation events when
+     // none should be fired.
+     // It's ok that we do the check twice in the case when firing mutation
+     // events as we need to recheck after running script anyway.
+     if (aRefChild && aRefChild->GetParentNode() != this) {
+       aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
+       return nullptr;
+     }
+@@ -2281,17 +2282,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+   }
+ 
+   Maybe<AutoTArray<nsCOMPtr<nsIContent>, 50> > fragChildren;
+ 
+   // Remove the new child from the old parent if one exists
+   nsIContent* newContent = aNewChild->AsContent();
+   nsCOMPtr<nsINode> oldParent = newContent->GetParentNode();
+   if (oldParent) {
+-    int32_t removeIndex = oldParent->IndexOf(newContent);
++    int32_t removeIndex = oldParent->ComputeIndexOf(newContent);
+     if (removeIndex < 0) {
+       // newContent is anonymous.  We can't deal with this, so just bail
+       NS_ERROR("How come our flags didn't catch this?");
+       aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
+       return nullptr;
+     }
+ 
+     // Hold a strong ref to nodeToInsertBefore across the removal of newContent
+@@ -2456,17 +2457,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
+   nsAutoMutationBatch mb;
+ 
+   // Figure out which index we want to insert at.  Note that we use
+   // nodeToInsertBefore to determine this, because it's possible that
+   // aRefChild == aNewChild, in which case we just removed it from the
+   // parent list.
+   int32_t insPos;
+   if (nodeToInsertBefore) {
+-    insPos = IndexOf(nodeToInsertBefore);
++    insPos = ComputeIndexOf(nodeToInsertBefore);
+     if (insPos < 0) {
+       // XXXbz How the heck would _that_ happen, exactly?
+       aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
+       return nullptr;
+     }
+   }
+   else {
+     insPos = GetChildCount();
+diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
+--- a/dom/base/nsINode.h
++++ b/dom/base/nsINode.h
+@@ -518,17 +518,17 @@ public:
+   /**
+    * Get the index of a child within this content
+    * @param aPossibleChild the child to get the index of.
+    * @return the index of the child, or -1 if not a child
+    *
+    * If the return value is not -1, then calling GetChildAt_Deprecated() with
+    * that value will return aPossibleChild.
+    */
+-  virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
++  virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const = 0;
+ 
+   /**
+    * Returns the "node document" of this node.
+    *
+    * https://dom.spec.whatwg.org/#concept-node-document
+    *
+    * Note that in the case that this node is a document node this method
+    * will return |this|.  That is different to the Node.ownerDocument DOM
+diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp
+--- a/dom/base/nsRange.cpp
++++ b/dom/base/nsRange.cpp
+@@ -118,17 +118,17 @@ nsRange::CompareNodeToRange(nsINode* aNo
+     parent = aNode;
+     nodeStart = 0;
+     uint32_t childCount = aNode->GetChildCount();
+     MOZ_ASSERT(childCount <= INT32_MAX,
+                "There shouldn't be over INT32_MAX children");
+     nodeEnd = static_cast<int32_t>(childCount);
+   }
+   else {
+-    nodeStart = parent->IndexOf(aNode);
++    nodeStart = parent->ComputeIndexOf(aNode);
+     nodeEnd = nodeStart + 1;
+     MOZ_ASSERT(nodeStart < nodeEnd, "nodeStart shouldn't be INT32_MAX");
+   }
+ 
+   nsINode* rangeStartContainer = aRange->GetStartContainer();
+   nsINode* rangeEndContainer = aRange->GetEndContainer();
+   uint32_t rangeStartOffset = aRange->StartOffset();
+   uint32_t rangeEndOffset = aRange->EndOffset();
+@@ -964,17 +964,17 @@ nsRange::IntersectsNode(nsINode& aNode, 
+   nsINode* parent = aNode.GetParentNode();
+   if (!parent) {
+     // Steps 2 and 4.
+     // |parent| is null, so |node|'s root is |node| itself.
+     return GetRoot() == &aNode;
+   }
+ 
+   // Step 5.
+-  int32_t nodeIndex = parent->IndexOf(&aNode);
++  int32_t nodeIndex = parent->ComputeIndexOf(&aNode);
+ 
+   // Steps 6-7.
+   // Note: if disconnected is true, ComparePoints returns 1.
+   bool disconnected = false;
+   bool result = nsContentUtils::ComparePoints(mStart.Container(), mStart.Offset(),
+                                              parent, nodeIndex + 1,
+                                              &disconnected) < 0 &&
+                nsContentUtils::ComparePoints(parent, nodeIndex,
+@@ -1099,17 +1099,17 @@ nsRange::DoSetRange(const RawRangeBounda
+   }
+ }
+ 
+ static int32_t
+ IndexOf(nsINode* aChild)
+ {
+   nsINode* parent = aChild->GetParentNode();
+ 
+-  return parent ? parent->IndexOf(aChild) : -1;
++  return parent ? parent->ComputeIndexOf(aChild) : -1;
+ }
+ 
+ void
+ nsRange::SetSelection(mozilla::dom::Selection* aSelection)
+ {
+   if (mSelection == aSelection) {
+     return;
+   }
+@@ -1566,19 +1566,20 @@ nsRange::SetEnd(const RawRangeBoundary& 
+ }
+ 
+ void
+ nsRange::SelectNodesInContainer(nsINode* aContainer,
+                                 nsIContent* aStartContent,
+                                 nsIContent* aEndContent)
+ {
+   MOZ_ASSERT(aContainer);
+-  MOZ_ASSERT(aContainer->IndexOf(aStartContent) <= aContainer->IndexOf(aEndContent));
+-  MOZ_ASSERT(aStartContent && aContainer->IndexOf(aStartContent) != -1);
+-  MOZ_ASSERT(aEndContent && aContainer->IndexOf(aEndContent) != -1);
++  MOZ_ASSERT(aContainer->ComputeIndexOf(aStartContent) <=
++               aContainer->ComputeIndexOf(aEndContent));
++  MOZ_ASSERT(aStartContent && aContainer->ComputeIndexOf(aStartContent) != -1);
++  MOZ_ASSERT(aEndContent && aContainer->ComputeIndexOf(aEndContent) != -1);
+ 
+   nsINode* newRoot = ComputeRootNode(aContainer, mMaySpanAnonymousSubtrees);
+   MOZ_ASSERT(newRoot);
+   if (!newRoot) {
+     return;
+   }
+ 
+   RawRangeBoundary start(aContainer, aStartContent->GetPreviousSibling());
+@@ -1775,17 +1776,17 @@ nsRange::SelectNode(nsINode& aNode, Erro
+ 
+   nsINode* container = aNode.GetParentNode();
+   nsINode* newRoot = IsValidBoundary(container);
+   if (!newRoot) {
+     aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
+     return;
+   }
+ 
+-  int32_t index = container->IndexOf(&aNode);
++  int32_t index = container->ComputeIndexOf(&aNode);
+   // MOZ_ASSERT(index != -1);
+   // We need to compute the index here unfortunately, because, while we have
+   // support for XBL, |container| may be the node's binding parent without
+   // actually containing it.
+   if (NS_WARN_IF(index < 0) ||
+       !IsValidOffset(static_cast<uint32_t>(index)) ||
+       !IsValidOffset(static_cast<uint32_t>(index) + 1)) {
+     aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
+@@ -3664,17 +3665,17 @@ nsRange::ExcludeNonSelectableNodes(nsTAr
+           // Create a new range for the remainder.
+           nsINode* startContainer = node;
+           int32_t startOffset = 0;
+           // Don't start *inside* a node with independent selection though
+           // (e.g. <input>).
+           if (content && content->HasIndependentSelection()) {
+             nsINode* parent = startContainer->GetParent();
+             if (parent) {
+-              startOffset = parent->IndexOf(startContainer);
++              startOffset = parent->ComputeIndexOf(startContainer);
+               startContainer = parent;
+             }
+           }
+           rv = CreateRange(startContainer, startOffset, endContainer, endOffset,
+                            getter_AddRefs(newRange));
+           if (NS_FAILED(rv) || newRange->Collapsed()) {
+             newRange = nullptr;
+           }
+diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h
+--- a/dom/base/nsRange.h
++++ b/dom/base/nsRange.h
+@@ -251,33 +251,33 @@ public:
+   {
+     MOZ_ASSERT(aNode);
+     MOZ_ASSERT(aOffset);
+     *aOffset = 0;
+     nsINode* parentNode = aNode->GetParentNode();
+     if (!parentNode) {
+       return nullptr;
+     }
+-    int32_t indexInParent = parentNode->IndexOf(aNode);
++    int32_t indexInParent = parentNode->ComputeIndexOf(aNode);
+     if (NS_WARN_IF(indexInParent < 0)) {
+       return nullptr;
+     }
+     *aOffset = static_cast<uint32_t>(indexInParent) + 1;
+     return parentNode;
+   }
+   static nsINode* GetContainerAndOffsetBefore(nsINode* aNode, uint32_t* aOffset)
+   {
+     MOZ_ASSERT(aNode);
+     MOZ_ASSERT(aOffset);
+     *aOffset = 0;
+     nsINode* parentNode = aNode->GetParentNode();
+     if (!parentNode) {
+       return nullptr;
+     }
+-    int32_t indexInParent = parentNode->IndexOf(aNode);
++    int32_t indexInParent = parentNode->ComputeIndexOf(aNode);
+     if (NS_WARN_IF(indexInParent < 0)) {
+       return nullptr;
+     }
+     *aOffset = static_cast<uint32_t>(indexInParent);
+     return parentNode;
+   }
+ 
+   NS_IMETHOD GetUsedFontFaces(nsIDOMFontFaceList** aResult);
+@@ -468,18 +468,18 @@ protected:
+   nsINode* IsValidBoundary(nsINode* aNode) const
+   {
+     return ComputeRootNode(aNode, mMaySpanAnonymousSubtrees);
+   }
+ 
+   /**
+    * XXX nsRange should accept 0 - UINT32_MAX as offset.  However, users of
+    *     nsRange treat offset as int32_t.  Additionally, some other internal
+-   *     APIs like nsINode::IndexOf() use int32_t.  Therefore, nsRange should
+-   *     accept only 0 - INT32_MAX as valid offset for now.
++   *     APIs like nsINode::ComputeIndexOf() use int32_t.  Therefore,
++   *     nsRange should accept only 0 - INT32_MAX as valid offset for now.
+    */
+   static bool IsValidOffset(uint32_t aOffset)
+   {
+     return aOffset <= INT32_MAX;
+   }
+   static bool IsValidOffset(nsINode* aNode, uint32_t aOffset);
+ 
+   static nsINode* ComputeRootNode(nsINode* aNode,
+diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp
+--- a/dom/events/ContentEventHandler.cpp
++++ b/dom/events/ContentEventHandler.cpp
+@@ -1195,28 +1195,28 @@ ContentEventHandler::SetRawRangeFromFlat
+         startNode = content;
+         startNodeOffset = static_cast<int32_t>(xpOffset);
+       } else if (aOffset < offset + textLength) {
+         // Rule #1.2 [<element>
+         startNode = content->GetParent();
+         if (NS_WARN_IF(!startNode)) {
+           return NS_ERROR_FAILURE;
+         }
+-        startNodeOffset = startNode->IndexOf(content);
++        startNodeOffset = startNode->ComputeIndexOf(content);
+         if (NS_WARN_IF(startNodeOffset == -1)) {
+           // The content is being removed from the parent!
+           return NS_ERROR_FAILURE;
+         }
+       } else if (!content->HasChildren()) {
+         // Rule #1.3: <element/>[
+         startNode = content->GetParent();
+         if (NS_WARN_IF(!startNode)) {
+           return NS_ERROR_FAILURE;
+         }
+-        startNodeOffset = startNode->IndexOf(content) + 1;
++        startNodeOffset = startNode->ComputeIndexOf(content) + 1;
+         if (NS_WARN_IF(startNodeOffset == 0)) {
+           // The content is being removed from the parent!
+           return NS_ERROR_FAILURE;
+         }
+       } else {
+         // Rule #1.4: <element>[
+         startNode = content;
+         startNodeOffset = 0;
+@@ -1299,17 +1299,17 @@ ContentEventHandler::SetRawRangeFromFlat
+         return NS_OK;
+       }
+ 
+       // Rule #2.4: <element/>]
+       nsINode* endNode = content->GetParent();
+       if (NS_WARN_IF(!endNode)) {
+         return NS_ERROR_FAILURE;
+       }
+-      int32_t indexInParent = endNode->IndexOf(content);
++      int32_t indexInParent = endNode->ComputeIndexOf(content);
+       if (NS_WARN_IF(indexInParent == -1)) {
+         // The content is being removed from the parent!
+         return NS_ERROR_FAILURE;
+       }
+       rv = aRawRange->SetEnd(endNode, indexInParent + 1);
+       if (NS_WARN_IF(NS_FAILED(rv))) {
+         return rv;
+       }
+@@ -2853,17 +2853,17 @@ ContentEventHandler::GetFlatTextLengthIn
+   NodePosition endPosition(aEndPosition);
+ 
+   // This may be called for retrieving the text of removed nodes.  Even in this
+   // case, the node thinks it's still in the tree because UnbindFromTree() will
+   // be called after here.  However, the node was already removed from the
+   // array of children of its parent.  So, be careful to handle this case.
+   if (aIsRemovingNode) {
+     DebugOnly<nsIContent*> parent = aStartPosition.Container()->GetParent();
+-    MOZ_ASSERT(parent && parent->IndexOf(aStartPosition.Container()) == -1,
++    MOZ_ASSERT(parent && parent->ComputeIndexOf(aStartPosition.Container()) == -1,
+       "At removing the node, the node shouldn't be in the array of children "
+       "of its parent");
+     MOZ_ASSERT(aStartPosition.Container() == endPosition.Container(),
+       "At removing the node, start and end node should be same");
+     MOZ_ASSERT(aStartPosition.Offset() == 0,
+       "When the node is being removed, the start offset should be 0");
+     MOZ_ASSERT(static_cast<uint32_t>(endPosition.Offset()) ==
+                  endPosition.Container()->GetChildCount(),
+@@ -2894,17 +2894,17 @@ ContentEventHandler::GetFlatTextLengthIn
+         }
+         endPosition = NodePositionBefore(firstChild, 0);
+       } else {
+         // When the end node is empty, move the end position after the node.
+         nsIContent* parentContent = endPosition.Container()->GetParent();
+         if (NS_WARN_IF(!parentContent)) {
+           return NS_ERROR_FAILURE;
+         }
+-        int32_t indexInParent = parentContent->IndexOf(endPosition.Container());
++        int32_t indexInParent = parentContent->ComputeIndexOf(endPosition.Container());
+         if (NS_WARN_IF(indexInParent < 0)) {
+           return NS_ERROR_FAILURE;
+         }
+         endPosition = NodePositionBefore(parentContent, indexInParent + 1);
+       }
+     }
+ 
+     if (endPosition.IsSetAndValid()) {
+@@ -3140,18 +3140,18 @@ static void AdjustRangeForSelection(nsIC
+   // do this hack.  If you did this, ContentEventHandler couldn't distinguish
+   // if the range includes open tag of the next node in some cases, e.g.,
+   // textNode]<p></p> vs. textNode<p>]</p>
+   if (!aRootParent->IsHTMLElement(nsGkAtoms::textarea)) {
+     return;
+   }
+ 
+   *aNode = node->GetParent();
+-  MOZ_ASSERT((*aNode)->IndexOf(node) != -1);
+-  *aNodeOffset = (*aNode)->IndexOf(node) + 1;
++  MOZ_ASSERT((*aNode)->ComputeIndexOf(node) != -1);
++  *aNodeOffset = (*aNode)->ComputeIndexOf(node) + 1;
+ }
+ 
+ nsresult
+ ContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent)
+ {
+   aEvent->mSucceeded = false;
+ 
+   // Get selection to manipulate
+diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp
+--- a/dom/html/HTMLFieldSetElement.cpp
++++ b/dom/html/HTMLFieldSetElement.cpp
+@@ -147,17 +147,17 @@ HTMLFieldSetElement::InsertChildAt(nsICo
+ 
+   if (aChild->IsHTMLElement(nsGkAtoms::legend)) {
+     if (!mFirstLegend) {
+       mFirstLegend = aChild;
+       // We do not want to notify the first time mFirstElement is set.
+     } else {
+       // If mFirstLegend is before aIndex, we do not change it.
+       // Otherwise, mFirstLegend is now aChild.
+-      if (int32_t(aIndex) <= IndexOf(mFirstLegend)) {
++      if (int32_t(aIndex) <= ComputeIndexOf(mFirstLegend)) {
+         mFirstLegend = aChild;
+         firstLegendHasChanged = true;
+       }
+     }
+   }
+ 
+   nsresult rv = nsGenericHTMLFormElement::InsertChildAt(aChild, aIndex, aNotify);
+   NS_ENSURE_SUCCESS(rv, rv);
+diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp
+--- a/dom/html/HTMLImageElement.cpp
++++ b/dom/html/HTMLImageElement.cpp
+@@ -57,17 +57,17 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Image)
+ static bool IsPreviousSibling(nsINode *aSubject, nsINode *aNode)
+ {
+   if (aSubject == aNode) {
+     return false;
+   }
+ 
+   nsINode *parent = aSubject->GetParentNode();
+   if (parent && parent == aNode->GetParentNode()) {
+-    return parent->IndexOf(aSubject) < parent->IndexOf(aNode);
++    return parent->ComputeIndexOf(aSubject) < parent->ComputeIndexOf(aNode);
+   }
+ 
+   return false;
+ }
+ #endif
+ 
+ namespace mozilla {
+ namespace dom {
+diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp
+--- a/dom/html/HTMLOptGroupElement.cpp
++++ b/dom/html/HTMLOptGroupElement.cpp
+@@ -92,18 +92,18 @@ HTMLOptGroupElement::RemoveChildAt_Depre
+   SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
+                                       aNotify);
+   nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+ void
+ HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
+ {
+-  SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, IndexOf(aKid),
+-                                      aNotify);
++  SafeOptionListMutation safeMutation(GetSelect(), this, nullptr,
++                                      ComputeIndexOf(aKid), aNotify);
+   nsGenericHTMLElement::RemoveChildNode(aKid, aNotify);
+ }
+ 
+ nsresult
+ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
+                                   const nsAttrValue* aValue,
+                                   const nsAttrValue* aOldValue,
+                                   nsIPrincipal* aSubjectPrincipal,
+diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
+--- a/dom/html/HTMLSelectElement.cpp
++++ b/dom/html/HTMLSelectElement.cpp
+@@ -222,17 +222,18 @@ HTMLSelectElement::RemoveChildAt_Depreca
+ {
+   SafeOptionListMutation safeMutation(this, this, nullptr, aIndex, aNotify);
+   nsGenericHTMLFormElementWithState::RemoveChildAt_Deprecated(aIndex, aNotify);
+ }
+ 
+ void
+ HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
+ {
+-  SafeOptionListMutation safeMutation(this, this, nullptr, IndexOf(aKid), aNotify);
++  SafeOptionListMutation safeMutation(this, this, nullptr,
++                                      ComputeIndexOf(aKid), aNotify);
+   nsGenericHTMLFormElementWithState::RemoveChildNode(aKid, aNotify);
+ }
+ 
+ void
+ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
+                                          int32_t aListIndex,
+                                          int32_t aDepth,
+                                          bool aNotify)
+@@ -494,17 +495,17 @@ HTMLSelectElement::GetOptionIndexAfter(n
+     return Length();
+   }
+ 
+   int32_t retval = -1;
+ 
+   nsCOMPtr<nsIContent> parent = aOptions->GetParent();
+ 
+   if (parent) {
+-    int32_t index = parent->IndexOf(aOptions);
++    int32_t index = parent->ComputeIndexOf(aOptions);
+     int32_t count = parent->GetChildCount();
+ 
+     retval = GetFirstChildOptionIndex(parent, index+1, count);
+ 
+     if (retval == -1) {
+       retval = GetOptionIndexAfter(parent);
+     }
+   }
+diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp
+--- a/dom/html/TextTrackManager.cpp
++++ b/dom/html/TextTrackManager.cpp
+@@ -46,17 +46,17 @@ CompareTextTracks::CompareTextTracks(HTM
+ 
+ int32_t
+ CompareTextTracks::TrackChildPosition(TextTrack* aTextTrack) const {
+   MOZ_DIAGNOSTIC_ASSERT(aTextTrack);
+   HTMLTrackElement* trackElement = aTextTrack->GetTrackElement();
+   if (!trackElement) {
+     return -1;
+   }
+-  return mMediaElement->IndexOf(trackElement);
++  return mMediaElement->ComputeIndexOf(trackElement);
+ }
+ 
+ bool
+ CompareTextTracks::Equals(TextTrack* aOne, TextTrack* aTwo) const {
+   // Two tracks can never be equal. If they have corresponding TrackElements
+   // they would need to occupy the same tree position (impossible) and in the
+   // case of tracks coming from AddTextTrack source we put the newest at the
+   // last position, so they won't be equal as well.
+@@ -530,17 +530,17 @@ private:
+ 
+ class CompareSimpleTextTrackEvents {
+ private:
+   int32_t TrackChildPosition(SimpleTextTrackEvent* aEvent) const
+   {
+     if (aEvent->mTrack) {
+       HTMLTrackElement* trackElement = aEvent->mTrack->GetTrackElement();
+       if (trackElement) {
+-        return mMediaElement->IndexOf(trackElement);
++        return mMediaElement->ComputeIndexOf(trackElement);
+       }
+     }
+     return -1;
+   }
+   HTMLMediaElement* mMediaElement;
+ public:
+   explicit CompareSimpleTextTrackEvents(HTMLMediaElement* aMediaElement)
+   {
+diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
+--- a/dom/html/nsGenericHTMLElement.cpp
++++ b/dom/html/nsGenericHTMLElement.cpp
+@@ -499,17 +499,17 @@ nsGenericHTMLElement::FindAncestorForm(H
+     if (content->IsHTMLElement(nsGkAtoms::form)) {
+ #ifdef DEBUG
+       if (!nsContentUtils::IsInSameAnonymousTree(this, content)) {
+         // It's possible that we started unbinding at |content| or
+         // some ancestor of it, and |content| and |this| used to all be
+         // anonymous.  Check for this the hard way.
+         for (nsIContent* child = this; child != content;
+              child = child->GetParent()) {
+-          NS_ASSERTION(child->GetParent()->IndexOf(child) != -1,
++          NS_ASSERTION(child->GetParent()->ComputeIndexOf(child) != -1,
+                        "Walked too far?");
+         }
+       }
+ #endif
+       return static_cast<HTMLFormElement*>(content);
+     }
+ 
+     nsIContent *prevContent = content;
+diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp
+--- a/dom/html/nsHTMLContentSink.cpp
++++ b/dom/html/nsHTMLContentSink.cpp
+@@ -978,17 +978,17 @@ HTMLContentSink::NotifyRootInsertion()
+   // Now make sure to notify that we have now inserted our root.  If
+   // there has been no initial reflow yet it'll be a no-op, but if
+   // there has been one we need this to get its frames constructed.
+   // Note that if mNotifiedRootInsertion is true we don't notify here,
+   // since that just means there are multiple <html> tags in the
+   // document; in those cases we just want to put all the attrs on one
+   // tag.
+   mNotifiedRootInsertion = true;
+-  int32_t index = mDocument->IndexOf(mRoot);
++  int32_t index = mDocument->ComputeIndexOf(mRoot);
+   NS_ASSERTION(index != -1, "mRoot not child of document?");
+   NotifyInsert(nullptr, mRoot, index);
+ 
+   // Now update the notification information in all our
+   // contexts, since we just inserted the root and notified on
+   // our whole tree
+   UpdateChildCounts();
+ }
+diff --git a/dom/xbl/XBLChildrenElement.cpp b/dom/xbl/XBLChildrenElement.cpp
+--- a/dom/xbl/XBLChildrenElement.cpp
++++ b/dom/xbl/XBLChildrenElement.cpp
+@@ -159,17 +159,17 @@ nsAnonymousContentList::IndexOf(nsIConte
+       if (point->HasInsertedChildren()) {
+         int32_t insIndex = point->IndexOfInsertedChild(aContent);
+         if (insIndex != -1) {
+           return index + insIndex;
+         }
+         index += point->InsertedChildrenLength();
+       }
+       else {
+-        int32_t insIndex = point->IndexOf(aContent);
++        int32_t insIndex = point->ComputeIndexOf(aContent);
+         if (insIndex != -1) {
+           return index + insIndex;
+         }
+         index += point->GetChildCount();
+       }
+     }
+     else {
+       if (child == aContent) {
+diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
+--- a/dom/xbl/nsXBLPrototypeBinding.cpp
++++ b/dom/xbl/nsXBLPrototypeBinding.cpp
+@@ -486,17 +486,18 @@ nsXBLPrototypeBinding::LocateInstance(El
+ 
+   nsIContent *copyParent =
+     templParent == aTemplRoot ? aCopyRoot :
+                    LocateInstance(aBoundElement, aTemplRoot, aCopyRoot, templParent);
+ 
+   if (!copyParent)
+     return nullptr;
+ 
+-  nsIContent* child = copyParent->GetChildAt_Deprecated(templParent->IndexOf(aTemplChild));
++  nsIContent* child =
++    copyParent->GetChildAt_Deprecated(templParent->ComputeIndexOf(aTemplChild));
+   if (child && child->IsElement()) {
+     return child->AsElement();
+   }
+   return nullptr;
+ }
+ 
+ void
+ nsXBLPrototypeBinding::SetInitialAttributes(
+diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp
+--- a/dom/xml/nsXMLContentSink.cpp
++++ b/dom/xml/nsXMLContentSink.cpp
+@@ -380,17 +380,17 @@ nsXMLContentSink::OnTransformDone(nsresu
+   }
+ 
+   // Notify document observers that all the content has been stuck
+   // into the document.
+   // XXX do we need to notify for things like PIs?  Or just the
+   // documentElement?
+   nsIContent *rootElement = mDocument->GetRootElement();
+   if (rootElement) {
+-    NS_ASSERTION(mDocument->IndexOf(rootElement) != -1,
++    NS_ASSERTION(mDocument->ComputeIndexOf(rootElement) != -1,
+                  "rootElement not in doc?");
+     mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
+     nsNodeUtils::ContentInserted(mDocument, rootElement);
+     mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
+   }
+ 
+   // Start the layout process
+   StartLayout(false);
+diff --git a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
+--- a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
++++ b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
+@@ -572,17 +572,17 @@ txXPathNodeUtils::comparePosition(const 
+         // Hopefully this is a common case.
+         if (parent == otherParent) {
+             if (!parent) {
+                 // Both node and otherNode are root nodes in respective orphan
+                 // tree.
+                 return node < otherNode ? -1 : 1;
+             }
+ 
+-            return parent->IndexOf(node) < parent->IndexOf(otherNode) ?
++            return parent->ComputeIndexOf(node) < parent->ComputeIndexOf(otherNode) ?
+                    -1 : 1;
+         }
+ 
+         parents.AppendElement(node);
+         otherParents.AppendElement(otherNode);
+         node = parent;
+         otherNode = otherParent;
+     }
+@@ -609,18 +609,18 @@ txXPathNodeUtils::comparePosition(const 
+         otherNode = otherParents.ElementAt(otherTotal - i);
+         if (node != otherNode) {
+             if (!parent) {
+                 // The two nodes are in different orphan subtrees.
+                 NS_ASSERTION(i == 0, "this shouldn't happen");
+                 return node < otherNode ? -1 : 1;
+             }
+ 
+-            int32_t index = parent->IndexOf(node);
+-            int32_t otherIndex = parent->IndexOf(otherNode);
++            int32_t index = parent->ComputeIndexOf(node);
++            int32_t otherIndex = parent->ComputeIndexOf(otherNode);
+             NS_ASSERTION(index != otherIndex && index >= 0 && otherIndex >= 0,
+                          "invalid index in compareTreePosition");
+ 
+             return index < otherIndex ? -1 : 1;
+         }
+ 
+         parent = node;
+     }
+diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
+--- a/dom/xul/XULDocument.cpp
++++ b/dom/xul/XULDocument.cpp
+@@ -2276,17 +2276,17 @@ XULDocument::PrepareToWalk()
+                    ("xul: error parsing '%s'", urlspec.get()));
+         }
+ 
+         return NS_OK;
+     }
+ 
+     uint32_t piInsertionPoint = 0;
+     if (mState != eState_Master) {
+-        int32_t indexOfRoot = IndexOf(GetRootElement());
++        int32_t indexOfRoot = ComputeIndexOf(GetRootElement());
+         NS_ASSERTION(indexOfRoot >= 0,
+                      "No root content when preparing to walk overlay!");
+         piInsertionPoint = indexOfRoot;
+     }
+ 
+     const nsTArray<RefPtr<nsXULPrototypePI> >& processingInstructions =
+         mCurrentPrototype->GetProcessingInstructions();
+ 
+@@ -4290,17 +4290,17 @@ XULDocument::InsertElement(nsINode* aPar
+             if (content)
+                 break;
+ 
+             token = nsCRT::strtok(rest, ", ", &rest);
+         }
+         free(str);
+ 
+         if (content) {
+-            int32_t pos = aParent->IndexOf(content);
++            int32_t pos = aParent->ComputeIndexOf(content);
+ 
+             if (pos != -1) {
+                 pos = isInsertAfter ? pos + 1 : pos;
+                 nsresult rv = aParent->InsertChildAt(aChild, pos, aNotify);
+                 if (NS_FAILED(rv))
+                     return rv;
+ 
+                 wasInserted = true;
+diff --git a/dom/xul/XULDocument.cpp.1430997-1.later b/dom/xul/XULDocument.cpp.1430997-1.later
+new file mode 100644
+--- /dev/null
++++ b/dom/xul/XULDocument.cpp.1430997-1.later
+@@ -0,0 +1,21 @@
++--- XULDocument.cpp
+++++ XULDocument.cpp
++@@ -4024,17 +4024,17 @@ XULDocument::InsertElement(nsINode* aPar
++         return aParent->AppendChildTo(aChild, aNotify);
++     }
++     return NS_OK;
++ }
++ 
++ nsresult
++ XULDocument::RemoveElement(nsINode* aParent, nsINode* aChild)
++ {
++-    int32_t nodeOffset = aParent->IndexOf(aChild);
+++    int32_t nodeOffset = aParent->ComputeIndexOf(aChild);
++ 
++     aParent->RemoveChildAt_Deprecated(nodeOffset, true);
++     return NS_OK;
++ }
++ 
++ //----------------------------------------------------------------------
++ //
++ // CachedChromeStreamListener
+diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp
+--- a/dom/xul/templates/nsXULContentBuilder.cpp
++++ b/dom/xul/templates/nsXULContentBuilder.cpp
+@@ -905,17 +905,17 @@ nsXULContentBuilder::SynchronizeUsingTem
+     return NS_OK;
+ }
+ 
+ nsresult
+ nsXULContentBuilder::RemoveMember(nsIContent* aContent)
+ {
+     nsCOMPtr<nsIContent> parent = aContent->GetParent();
+     if (parent) {
+-        int32_t pos = parent->IndexOf(aContent);
++        int32_t pos = parent->ComputeIndexOf(aContent);
+ 
+         NS_ASSERTION(pos >= 0, "parent doesn't think this child has an index");
+         if (pos < 0) return NS_OK;
+ 
+         // Note: RemoveChildAt_Deprecated sets |child|'s document to null so
+         // that it'll get knocked out of the XUL doc's resource-to-element map.
+         parent->RemoveChildAt_Deprecated(pos, true);
+     }
+diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp
+--- a/editor/libeditor/EditorBase.cpp
++++ b/editor/libeditor/EditorBase.cpp
+@@ -1147,17 +1147,17 @@ EditorBase::BeginningOfDocument()
+   }
+ 
+   // Otherwise, it's a leaf node and we set the selection just in front of it.
+   nsCOMPtr<nsIContent> parent = firstNode->GetParent();
+   if (!parent) {
+     return NS_ERROR_NULL_POINTER;
+   }
+ 
+-  MOZ_ASSERT(parent->IndexOf(firstNode) == 0,
++  MOZ_ASSERT(parent->ComputeIndexOf(firstNode) == 0,
+              "How come the first node isn't the left most child in its parent?");
+   return selection->Collapse(parent, 0);
+ }
+ 
+ NS_IMETHODIMP
+ EditorBase::EndOfDocument()
+ {
+   RefPtr<Selection> selection = GetSelection();
+@@ -1640,17 +1640,17 @@ EditorBase::JoinNodes(nsINode& aLeftNode
+   nsCOMPtr<nsINode> parent = aLeftNode.GetParentNode();
+   MOZ_ASSERT(parent);
+ 
+   AutoRules beginRulesSniffing(this, EditAction::joinNode,
+                                nsIEditor::ePrevious);
+ 
+   // Remember some values; later used for saved selection updating.
+   // Find the offset between the nodes to be joined.
+-  int32_t offset = parent->IndexOf(&aRightNode);
++  int32_t offset = parent->ComputeIndexOf(&aRightNode);
+   // Find the number of children of the lefthand node
+   uint32_t oldLeftNodeLen = aLeftNode.Length();
+ 
+   if (mRules && mRules->AsHTMLEditRules()) {
+     RefPtr<HTMLEditRules> htmlEditRules = mRules->AsHTMLEditRules();
+     htmlEditRules->WillJoinNodes(aLeftNode, aRightNode);
+   }
+ 
+@@ -1934,17 +1934,17 @@ EditorBase::MoveNode(nsIContent* aNode,
+   MOZ_ASSERT(aOffset == -1 ||
+              (0 <= aOffset &&
+               AssertedCast<uint32_t>(aOffset) <= aParent->Length()));
+ 
+   nsCOMPtr<nsINode> oldParent = aNode->GetParentNode();
+   if (NS_WARN_IF(!oldParent)) {
+     return NS_ERROR_FAILURE;
+   }
+-  int32_t oldOffset = oldParent->IndexOf(aNode);
++  int32_t oldOffset = oldParent->ComputeIndexOf(aNode);
+ 
+   if (aOffset == -1) {
+     // Magic value meaning "move to end of aParent"
+     aOffset = AssertedCast<int32_t>(aParent->Length());
+   }
+ 
+   // Don't do anything if it's already in right place
+   if (aParent == oldParent && aOffset == oldOffset) {
+@@ -3512,33 +3512,33 @@ EditorBase::GetChildOffset(nsIDOMNode* a
+ // static
+ int32_t
+ EditorBase::GetChildOffset(nsINode* aChild,
+                            nsINode* aParent)
+ {
+   MOZ_ASSERT(aChild);
+   MOZ_ASSERT(aParent);
+ 
+-  // nsINode::IndexOf() is expensive.  So, if we can return index without
+-  // calling it, we should do that.
++  // nsINode::ComputeIndexOf() is expensive.  So, if we can return index
++  // without calling it, we should do that.
+ 
+   // If there is no previous siblings, it means that it's the first child.
+   if (aParent->GetFirstChild() == aChild) {
+-    MOZ_ASSERT(aParent->IndexOf(aChild) == 0);
++    MOZ_ASSERT(aParent->ComputeIndexOf(aChild) == 0);
+     return 0;
+   }
+ 
+   // If there is no next siblings, it means that it's the last child.
+   if (aParent->GetLastChild() == aChild) {
+     int32_t lastChildIndex = static_cast<int32_t>(aParent->Length() - 1);
+-    MOZ_ASSERT(aParent->IndexOf(aChild) == lastChildIndex);
++    MOZ_ASSERT(aParent->ComputeIndexOf(aChild) == lastChildIndex);
+     return lastChildIndex;
+   }
+ 
+-  int32_t index = aParent->IndexOf(aChild);
++  int32_t index = aParent->ComputeIndexOf(aChild);
+   MOZ_ASSERT(index != -1);
+   return index;
+ }
+ 
+ // static
+ already_AddRefed<nsIDOMNode>
+ EditorBase::GetNodeLocation(nsIDOMNode* aChild,
+                             int32_t* outOffset)
+diff --git a/editor/libeditor/EditorDOMPoint.h b/editor/libeditor/EditorDOMPoint.h
+--- a/editor/libeditor/EditorDOMPoint.h
++++ b/editor/libeditor/EditorDOMPoint.h
+@@ -347,17 +347,17 @@ public:
+       return mOffset.value();
+     }
+     MOZ_ASSERT(mChild->GetParentNode() == mParent);
+     // Fix offset now.
+     if (mChild == mParent->GetFirstChild()) {
+       const_cast<SelfType*>(this)->mOffset = mozilla::Some(0);
+     } else {
+       const_cast<SelfType*>(this)->mOffset =
+-        mozilla::Some(mParent->IndexOf(mChild));
++        mozilla::Some(mParent->ComputeIndexOf(mChild));
+     }
+     return mOffset.value();
+   }
+ 
+   /**
+    * Set() sets a point to aOffset or aChild.
+    * If it's set with aOffset, mChild is invalidated.  If it's set with aChild,
+    * mOffset may be invalidated.
+diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp
+--- a/editor/libeditor/HTMLEditRules.cpp
++++ b/editor/libeditor/HTMLEditRules.cpp
+@@ -831,17 +831,17 @@ HTMLEditRules::GetAlignment(bool* aMixed
+   NS_ENSURE_STATE(htmlEditor->GetSelection());
+   OwningNonNull<Selection> selection = *htmlEditor->GetSelection();
+ 
+   // Get selection location
+   NS_ENSURE_TRUE(htmlEditor->GetRoot(), NS_ERROR_FAILURE);
+   OwningNonNull<Element> root = *htmlEditor->GetRoot();
+ 
+   int32_t rootOffset = root->GetParentNode() ?
+-                       root->GetParentNode()->IndexOf(root) : -1;
++                       root->GetParentNode()->ComputeIndexOf(root) : -1;
+ 
+   nsRange* firstRange = selection->GetRangeAt(0);
+   if (NS_WARN_IF(!firstRange)) {
+     return NS_ERROR_FAILURE;
+   }
+   EditorRawDOMPoint atStartOfSelection(firstRange->StartRef());
+   if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
+     return NS_ERROR_FAILURE;
+@@ -2374,17 +2374,17 @@ HTMLEditRules::WillDeleteSelection(Selec
+         // interline position is false (left)
+         //
+         // In any other case we set the position to startnode -1 and
+         // interlineposition to false, only moving the caret to the
+         // end-of-hr-line position.
+         bool moveOnly = true;
+ 
+         selNode = visNode->GetParentNode();
+-        selOffset = selNode ? selNode->IndexOf(visNode) : -1;
++        selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
+ 
+         bool interLineIsRight;
+         rv = aSelection->GetInterlinePosition(&interLineIsRight);
+         NS_ENSURE_SUCCESS(rv, rv);
+ 
+         if (startNode == selNode && startOffset - 1 == selOffset &&
+             !interLineIsRight) {
+           moveOnly = false;
+@@ -5455,22 +5455,22 @@ HTMLEditRules::CheckForInvisibleBR(Eleme
+       mHTMLEditor->GetRightmostChild(&aBlock, true);
+ 
+     if (!rightmostNode) {
+       return nullptr;
+     }
+ 
+     testNode = rightmostNode->GetParentNode();
+     // Since rightmostNode is always the last child, its index is equal to the
+-    // child count, so instead of IndexOf() we use the faster GetChildCount(),
+-    // and assert the equivalence below.
++    // child count, so instead of ComputeIndexOf() we use the faster
++    // GetChildCount(), and assert the equivalence below.
+     testOffset = testNode->GetChildCount();
+ 
+     // Use offset + 1, so last node is included in our evaluation
+-    MOZ_ASSERT(testNode->IndexOf(rightmostNode) + 1 == testOffset);
++    MOZ_ASSERT(testNode->ComputeIndexOf(rightmostNode) + 1 == testOffset);
+   } else if (aOffset) {
+     testNode = &aBlock;
+     // We'll check everything to the left of the input position
+     testOffset = aOffset;
+   } else {
+     return nullptr;
+   }
+ 
+@@ -5564,17 +5564,17 @@ HTMLEditRules::ExpandSelectionForDeletio
+       // element boundaries, or if we hit the root.
+       if (HTMLEditUtils::IsTableElement(wsObj.mStartReasonNode) ||
+           selCommon == wsObj.mStartReasonNode ||
+           root == wsObj.mStartReasonNode) {
+         break;
+       }
+       selStartNode = wsObj.mStartReasonNode->GetParentNode();
+       selStartOffset = selStartNode ?
+-        selStartNode->IndexOf(wsObj.mStartReasonNode) : -1;
++        selStartNode->ComputeIndexOf(wsObj.mStartReasonNode) : -1;
+     }
+   }
+ 
+   // Find next visible thingy after end of selection
+   if (selEndNode != selCommon && selEndNode != root) {
+     for (;;) {
+       WSRunObject wsObj(mHTMLEditor, selEndNode, selEndOffset);
+       wsObj.NextVisibleNode(selEndNode, selEndOffset, address_of(unused),
+@@ -5584,27 +5584,27 @@ HTMLEditRules::ExpandSelectionForDeletio
+           break;
+         }
+         if (!firstBRParent) {
+           firstBRParent = selEndNode;
+           firstBROffset = selEndOffset;
+         }
+         selEndNode = wsObj.mEndReasonNode->GetParentNode();
+         selEndOffset = selEndNode
+-          ? selEndNode->IndexOf(wsObj.mEndReasonNode) + 1 : 0;
++          ? selEndNode->ComputeIndexOf(wsObj.mEndReasonNode) + 1 : 0;
+       } else if (wsType == WSType::thisBlock) {
+         // We want to keep looking up.  But stop if we are crossing table
+         // element boundaries, or if we hit the root.
+         if (HTMLEditUtils::IsTableElement(wsObj.mEndReasonNode) ||
+             selCommon == wsObj.mEndReasonNode ||
+             root == wsObj.mEndReasonNode) {
+           break;
+         }
+         selEndNode = wsObj.mEndReasonNode->GetParentNode();
+-        selEndOffset = 1 + selEndNode->IndexOf(wsObj.mEndReasonNode);
++        selEndOffset = 1 + selEndNode->ComputeIndexOf(wsObj.mEndReasonNode);
+       } else {
+         break;
+       }
+     }
+   }
+   // Now set the selection to the new range
+   aSelection.Collapse(selStartNode, selStartOffset);
+ 
+@@ -6789,17 +6789,17 @@ HTMLEditRules::ReturnInHeader(Selection&
+                               nsINode& aNode,
+                               int32_t aOffset)
+ {
+   NS_ENSURE_STATE(mHTMLEditor);
+   RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
+ 
+   // Remember where the header is
+   nsCOMPtr<nsINode> headerParent = aHeader.GetParentNode();
+-  int32_t offset = headerParent ? headerParent->IndexOf(&aHeader) : -1;
++  int32_t offset = headerParent ? headerParent->ComputeIndexOf(&aHeader) : -1;
+ 
+   // Get ws code to adjust any ws
+   nsCOMPtr<nsINode> node = &aNode;
+   nsresult rv = WSRunObject::PrepareToSplitAcrossBlocks(htmlEditor,
+                                                         address_of(node),
+                                                         &aOffset);
+   NS_ENSURE_SUCCESS(rv, rv);
+   if (NS_WARN_IF(!node->IsContent())) {
+@@ -7269,17 +7269,17 @@ HTMLEditRules::ReturnInListItem(Selectio
+       }
+     } else {
+       rv = htmlEditor->IsEmptyNode(&aListItem, &isEmptyNode, true);
+       NS_ENSURE_SUCCESS(rv, rv);
+       if (isEmptyNode) {
+         nsCOMPtr<nsIAtom> nodeAtom = aListItem.NodeInfo()->NameAtom();
+         if (nodeAtom == nsGkAtoms::dd || nodeAtom == nsGkAtoms::dt) {
+           nsCOMPtr<nsINode> list = aListItem.GetParentNode();
+-          int32_t itemOffset = list ? list->IndexOf(&aListItem) : -1;
++          int32_t itemOffset = list ? list->ComputeIndexOf(&aListItem) : -1;
+ 
+           nsIAtom* listAtom = nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd
+                                                         : nsGkAtoms::dt;
+           MOZ_DIAGNOSTIC_ASSERT(itemOffset != -1);
+           EditorRawDOMPoint atNextListItem(list, aListItem.GetNextSibling(),
+                                            itemOffset + 1);
+           RefPtr<Element> newListItem =
+             htmlEditor->CreateNode(listAtom, atNextListItem);
+@@ -7731,17 +7731,17 @@ EditorDOMPoint
+ HTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft,
+                               nsIContent& aNodeRight)
+ {
+   // Caller responsible for left and right node being the same type
+   nsCOMPtr<nsINode> parent = aNodeLeft.GetParentNode();
+   if (NS_WARN_IF(!parent)) {
+     return EditorDOMPoint();
+   }
+-  int32_t parOffset = parent->IndexOf(&aNodeLeft);
++  int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
+   nsCOMPtr<nsINode> rightParent = aNodeRight.GetParentNode();
+ 
+   // If they don't have the same parent, first move the right node to after the
+   // left one
+   if (parent != rightParent) {
+     if (NS_WARN_IF(!mHTMLEditor)) {
+       return EditorDOMPoint();
+     }
+diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
+--- a/editor/libeditor/HTMLEditor.cpp
++++ b/editor/libeditor/HTMLEditor.cpp
+@@ -541,42 +541,42 @@ HTMLEditor::BeginningOfDocument()
+     wsObj.NextVisibleNode(curNode, curOffset, address_of(visNode), &visOffset,
+                           &visType);
+     if (visType == WSType::normalWS || visType == WSType::text) {
+       selNode = visNode;
+       selOffset = visOffset;
+       done = true;
+     } else if (visType == WSType::br || visType == WSType::special) {
+       selNode = visNode->GetParentNode();
+-      selOffset = selNode ? selNode->IndexOf(visNode) : -1;
++      selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
+       done = true;
+     } else if (visType == WSType::otherBlock) {
+       // By definition of WSRunObject, a block element terminates a
+       // whitespace run. That is, although we are calling a method that is
+       // named "NextVisibleNode", the node returned might not be
+       // visible/editable!
+       //
+       // If the given block does not contain any visible/editable items, we
+       // want to skip it and continue our search.
+ 
+       if (!IsContainer(visNode)) {
+         // However, we were given a block that is not a container.  Since the
+         // block can not contain anything that's visible, such a block only
+         // makes sense if it is visible by itself, like a <hr>.  We want to
+         // place the caret in front of that block.
+         selNode = visNode->GetParentNode();
+-        selOffset = selNode ? selNode->IndexOf(visNode) : -1;
++        selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
+         done = true;
+       } else {
+         bool isEmptyBlock;
+         if (NS_SUCCEEDED(IsEmptyNode(visNode, &isEmptyBlock)) &&
+             isEmptyBlock) {
+           // Skip the empty block
+           curNode = visNode->GetParentNode();
+-          curOffset = curNode ? curNode->IndexOf(visNode) : -1;
++          curOffset = curNode ? curNode->ComputeIndexOf(visNode) : -1;
+           curOffset++;
+         } else {
+           curNode = visNode;
+           curOffset = 0;
+         }
+         // Keep looping
+       }
+     } else {
+@@ -1606,17 +1606,17 @@ HTMLEditor::SelectElement(nsIDOMElement*
+ 
+   RefPtr<Selection> selection = GetSelection();
+   NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
+   nsINode* parent = element->GetParentNode();
+   if (NS_WARN_IF(!parent)) {
+     return NS_ERROR_FAILURE;
+   }
+ 
+-  int32_t offsetInParent = parent->IndexOf(element);
++  int32_t offsetInParent = parent->ComputeIndexOf(element);
+ 
+   // Collapse selection to just before desired element,
+   nsresult rv = selection->Collapse(parent, offsetInParent);
+   if (NS_SUCCEEDED(rv)) {
+     // then extend it to just after
+     rv = selection->Extend(parent, offsetInParent + 1);
+   }
+   return rv;
+diff --git a/editor/libeditor/HTMLStyleEditor.cpp b/editor/libeditor/HTMLStyleEditor.cpp
+--- a/editor/libeditor/HTMLStyleEditor.cpp
++++ b/editor/libeditor/HTMLStyleEditor.cpp
+@@ -842,29 +842,29 @@ HTMLEditor::PromoteRangeIfStartsOrEndsIn
+   while (parent && !parent->IsHTMLElement(nsGkAtoms::body) &&
+          !HTMLEditUtils::IsNamedAnchor(parent)) {
+     parent = parent->GetParentNode();
+   }
+   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
+ 
+   if (HTMLEditUtils::IsNamedAnchor(parent)) {
+     startNode = parent->GetParentNode();
+-    startOffset = startNode ? startNode->IndexOf(parent) : -1;
++    startOffset = startNode ? startNode->ComputeIndexOf(parent) : -1;
+   }
+ 
+   parent = endNode;
+   while (parent && !parent->IsHTMLElement(nsGkAtoms::body) &&
+          !HTMLEditUtils::IsNamedAnchor(parent)) {
+     parent = parent->GetParentNode();
+   }
+   NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
+ 
+   if (HTMLEditUtils::IsNamedAnchor(parent)) {
+     endNode = parent->GetParentNode();
+-    endOffset = endNode ? endNode->IndexOf(parent) + 1 : 0;
++    endOffset = endNode ? endNode->ComputeIndexOf(parent) + 1 : 0;
+   }
+ 
+   nsresult rv = aRange.SetStartAndEnd(startNode, startOffset,
+                                       endNode, endOffset);
+   if (NS_WARN_IF(NS_FAILED(rv))) {
+     return rv;
+   }
+ 
+@@ -878,26 +878,26 @@ HTMLEditor::PromoteInlineRange(nsRange& 
+   int32_t startOffset = aRange.StartOffset();
+   nsCOMPtr<nsINode> endNode = aRange.GetEndContainer();
+   int32_t endOffset = aRange.EndOffset();
+ 
+   while (startNode && !startNode->IsHTMLElement(nsGkAtoms::body) &&
+          IsEditable(startNode) && IsAtFrontOfNode(*startNode, startOffset)) {
+     nsCOMPtr<nsINode> parent = startNode->GetParentNode();
+     NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
+-    startOffset = parent->IndexOf(startNode);
++    startOffset = parent->ComputeIndexOf(startNode);
+     startNode = parent;
+   }
+ 
+   while (endNode && !endNode->IsHTMLElement(nsGkAtoms::body) &&
+          IsEditable(endNode) && IsAtEndOfNode(*endNode, endOffset)) {
+     nsCOMPtr<nsINode> parent = endNode->GetParentNode();
+     NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
+     // We are AFTER this node
+-    endOffset = 1 + parent->IndexOf(endNode);
++    endOffset = 1 + parent->ComputeIndexOf(endNode);
+     endNode = parent;
+   }
+ 
+   nsresult rv = aRange.SetStartAndEnd(startNode, startOffset,
+                                       endNode, endOffset);
+   if (NS_WARN_IF(NS_FAILED(rv))) {
+     return rv;
+   }
+@@ -914,17 +914,17 @@ HTMLEditor::IsAtFrontOfNode(nsINode& aNo
+   }
+ 
+   if (IsTextNode(&aNode)) {
+     return false;
+   }
+ 
+   nsCOMPtr<nsIContent> firstNode = GetFirstEditableChild(aNode);
+   NS_ENSURE_TRUE(firstNode, true);
+-  if (aNode.IndexOf(firstNode) < aOffset) {
++  if (aNode.ComputeIndexOf(firstNode) < aOffset) {
+     return false;
+   }
+   return true;
+ }
+ 
+ bool
+ HTMLEditor::IsAtEndOfNode(nsINode& aNode,
+                           int32_t aOffset)
+@@ -934,17 +934,17 @@ HTMLEditor::IsAtEndOfNode(nsINode& aNode
+   }
+ 
+   if (IsTextNode(&aNode)) {
+     return false;
+   }
+ 
+   nsCOMPtr<nsIContent> lastNode = GetLastEditableChild(aNode);
+   NS_ENSURE_TRUE(lastNode, true);
+-  if (aNode.IndexOf(lastNode) < aOffset) {
++  if (aNode.ComputeIndexOf(lastNode) < aOffset) {
+     return true;
+   }
+   return false;
+ }
+ 
+ 
+ nsresult
+ HTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
+diff --git a/editor/libeditor/HTMLTableEditor.cpp b/editor/libeditor/HTMLTableEditor.cpp
+--- a/editor/libeditor/HTMLTableEditor.cpp
++++ b/editor/libeditor/HTMLTableEditor.cpp
+@@ -667,17 +667,17 @@ HTMLEditor::InsertTableRow(int32_t aNumb
+ 
+     nsCOMPtr<Element> parentRow =
+       GetElementOrParentByTagName(trStr, cellNodeForRowParent);
+     NS_ENSURE_TRUE(parentRow, NS_ERROR_NULL_POINTER);
+ 
+     // The row parent and offset where we will insert new row
+     nsCOMPtr<nsINode> parentOfRow = parentRow->GetParentNode();
+     NS_ENSURE_TRUE(parentOfRow, NS_ERROR_NULL_POINTER);
+-    int32_t newRowOffset = parentOfRow->IndexOf(parentRow);
++    int32_t newRowOffset = parentOfRow->ComputeIndexOf(parentRow);
+ 
+     // Adjust for when adding past the end
+     if (aAfter && startRowIndex >= rowCount) {
+       newRowOffset++;
+     }
+ 
+     for (int32_t row = 0; row < aNumber; row++) {
+       // Create a new row
+diff --git a/editor/libeditor/SelectionState.cpp b/editor/libeditor/SelectionState.cpp
+--- a/editor/libeditor/SelectionState.cpp
++++ b/editor/libeditor/SelectionState.cpp
+@@ -259,17 +259,17 @@ RangeUpdater::SelAdjDeleteNode(nsINode* 
+   }
+   MOZ_ASSERT(aNode);
+   size_t count = mArray.Length();
+   if (!count) {
+     return;
+   }
+ 
+   nsCOMPtr<nsINode> parent = aNode->GetParentNode();
+-  int32_t offset = parent ? parent->IndexOf(aNode) : -1;
++  int32_t offset = parent ? parent->ComputeIndexOf(aNode) : -1;
+ 
+   // check for range endpoints that are after aNode and in the same parent
+   for (size_t i = 0; i < count; i++) {
+     RangeItem* item = mArray[i];
+     MOZ_ASSERT(item);
+ 
+     if (item->mStartContainer == parent && item->mStartOffset > offset) {
+       item->mStartOffset--;
+diff --git a/editor/libeditor/WSRunObject.cpp b/editor/libeditor/WSRunObject.cpp
+--- a/editor/libeditor/WSRunObject.cpp
++++ b/editor/libeditor/WSRunObject.cpp
+@@ -138,17 +138,17 @@ WSRunObject::PrepareToDeleteRange(HTMLEd
+ nsresult
+ WSRunObject::PrepareToDeleteNode(HTMLEditor* aHTMLEditor,
+                                  nsIContent* aContent)
+ {
+   NS_ENSURE_TRUE(aContent && aHTMLEditor, NS_ERROR_NULL_POINTER);
+ 
+   nsCOMPtr<nsINode> parent = aContent->GetParentNode();
+   NS_ENSURE_STATE(parent);
+-  int32_t offset = parent->IndexOf(aContent);
++  int32_t offset = parent->ComputeIndexOf(aContent);
+ 
+   WSRunObject leftWSObj(aHTMLEditor, parent, offset);
+   WSRunObject rightWSObj(aHTMLEditor, parent, offset + 1);
+ 
+   return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
+ }
+ 
+ nsresult
+diff --git a/editor/txtsvc/nsFilteredContentIterator.cpp b/editor/txtsvc/nsFilteredContentIterator.cpp
+--- a/editor/txtsvc/nsFilteredContentIterator.cpp
++++ b/editor/txtsvc/nsFilteredContentIterator.cpp
+@@ -245,17 +245,17 @@ ContentToParentOffset(nsIContent* aConte
+ 
+   if (!aContent)
+     return;
+ 
+   nsCOMPtr<nsIContent> parent = aContent->GetParent();
+   if (!parent)
+     return;
+ 
+-  *aOffset = parent->IndexOf(aContent);
++  *aOffset = parent->ComputeIndexOf(aContent);
+   parent.forget(aParent);
+ }
+ 
+ ///////////////////////////////////////////////////////////////////////////
+ // ContentIsInTraversalRange: returns true if content is visited during
+ // the traversal of the range in the specified mode.
+ //
+ static bool
+diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp
+--- a/layout/base/nsLayoutUtils.cpp
++++ b/layout/base/nsLayoutUtils.cpp
+@@ -1869,18 +1869,18 @@ nsLayoutUtils::DoCompareTreePosition(nsI
+   // TODO: remove the uglyness, see bug 598468.
+   NS_ASSERTION(gPreventAssertInCompareTreePosition || parent,
+                "no common ancestor at all???");
+ #endif // DEBUG
+   if (!parent) { // different documents??
+     return 0;
+   }
+ 
+-  int32_t index1 = parent->IndexOf(content1Ancestor);
+-  int32_t index2 = parent->IndexOf(content2Ancestor);
++  int32_t index1 = parent->ComputeIndexOf(content1Ancestor);
++  int32_t index2 = parent->ComputeIndexOf(content2Ancestor);
+   if (index1 < 0 || index2 < 0) {
+     // one of them must be anonymous; we can't determine the order
+     return 0;
+   }
+ 
+   return index1 - index2;
+ }
+ 
+diff --git a/layout/generic/BRFrame.cpp b/layout/generic/BRFrame.cpp
+--- a/layout/generic/BRFrame.cpp
++++ b/layout/generic/BRFrame.cpp
+@@ -217,17 +217,17 @@ BRFrame::GetLogicalBaseline(mozilla::Wri
+   return mAscent;
+ }
+ 
+ nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(const nsPoint& aPoint)
+ {
+   ContentOffsets offsets;
+   offsets.content = mContent->GetParent();
+   if (offsets.content) {
+-    offsets.offset = offsets.content->IndexOf(mContent);
++    offsets.offset = offsets.content->ComputeIndexOf(mContent);
+     offsets.secondaryOffset = offsets.offset;
+     offsets.associate = CARET_ASSOCIATE_AFTER;
+   }
+   return offsets;
+ }
+ 
+ nsIFrame::FrameSearchResult
+ BRFrame::PeekOffsetNoAmount(bool aForward, int32_t* aOffset)
+diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
+--- a/layout/generic/nsFrame.cpp
++++ b/layout/generic/nsFrame.cpp
+@@ -2291,17 +2291,17 @@ nsFrame::DisplaySelectionOverlay(nsDispl
+     return; // selection is hidden or off
+ 
+   nsIContent *newContent = mContent->GetParent();
+ 
+   //check to see if we are anonymous content
+   int32_t offset = 0;
+   if (newContent) {
+     // XXXbz there has GOT to be a better way of determining this!
+-    offset = newContent->IndexOf(mContent);
++    offset = newContent->ComputeIndexOf(mContent);
+   }
+ 
+   //look up to see what selection(s) are on this frame
+   UniquePtr<SelectionDetails> details
+     = frameSelection->LookUpSelection(newContent, offset, 1, false);
+   if (!details)
+     return;
+ 
+@@ -4024,17 +4024,17 @@ nsFrame::GetDataForTableSelection(const 
+   if (!foundCell && !foundTable) return NS_OK;
+ 
+   nsIContent* tableOrCellContent = frame->GetContent();
+   if (!tableOrCellContent) return NS_ERROR_FAILURE;
+ 
+   nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
+   if (!parentContent) return NS_ERROR_FAILURE;
+ 
+-  int32_t offset = parentContent->IndexOf(tableOrCellContent);
++  int32_t offset = parentContent->ComputeIndexOf(tableOrCellContent);
+   // Not likely?
+   if (offset < 0) return NS_ERROR_FAILURE;
+ 
+   // Everything is OK -- set the return values
+   parentContent.forget(aParentContent);
+ 
+   *aContentOffset = offset;
+ 
+@@ -4759,25 +4759,25 @@ static FrameContentRange GetRangeForFram
+   LayoutFrameType type = aFrame->Type();
+   if (type == LayoutFrameType::Text) {
+     int32_t offset, offsetEnd;
+     aFrame->GetOffsets(offset, offsetEnd);
+     return FrameContentRange(content, offset, offsetEnd);
+   }
+   if (type == LayoutFrameType::Br) {
+     parent = content->GetParent();
+-    int32_t beginOffset = parent->IndexOf(content);
++    int32_t beginOffset = parent->ComputeIndexOf(content);
+     return FrameContentRange(parent, beginOffset, beginOffset);
+   }
+   // Loop to deal with anonymous content, which has no index; this loop
+   // probably won't run more than twice under normal conditions
+   do {
+     parent  = content->GetParent();
+     if (parent) {
+-      int32_t beginOffset = parent->IndexOf(content);
++      int32_t beginOffset = parent->ComputeIndexOf(content);
+       if (beginOffset >= 0)
+         return FrameContentRange(parent, beginOffset, beginOffset + 1);
+       content = parent;
+     }
+   } while (parent);
+ 
+   // The root content node must act differently
+   return FrameContentRange(content, 0, content->GetChildCount());
+@@ -7676,17 +7676,17 @@ nsIFrame::GetContainingBlock(uint32_t aF
+ int32_t nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
+ {
+   int32_t result = -1;
+ 
+   nsIContent* content = aFrame->GetContent();
+   if (content) {
+     nsIContent* parentContent = content->GetParent();
+     if (parentContent) {
+-      result = parentContent->IndexOf(content);
++      result = parentContent->ComputeIndexOf(content);
+     }
+   }
+ 
+   return result;
+ }
+ 
+ /**
+  * List a frame tree to stderr. Meant to be called from gdb.
+@@ -8022,17 +8022,17 @@ nsFrame::GetPointFromOffset(int32_t inOf
+ {
+   NS_PRECONDITION(outPoint != nullptr, "Null parameter");
+   nsRect contentRect = GetContentRectRelativeToSelf();
+   nsPoint pt = contentRect.TopLeft();
+   if (mContent)
+   {
+     nsIContent* newContent = mContent->GetParent();
+     if (newContent){
+-      int32_t newOffset = newContent->IndexOf(mContent);
++      int32_t newOffset = newContent->ComputeIndexOf(mContent);
+ 
+       // Find the direction of the frame from the EmbeddingLevelProperty,
+       // which is the resolved bidi level set in
+       // nsBidiPresUtils::ResolveParagraph (odd levels = right-to-left).
+       // If the embedding level isn't set, just use the CSS direction
+       // property.
+       bool hasBidiData;
+       FrameBidiData bidiData = GetProperty(BidiDataProperty(), &hasBidiData);
+@@ -8231,17 +8231,17 @@ nsFrame::GetNextPrevLineFromeBlockFrame(
+             {
+               nsIContent* content = resultFrame->GetContent();
+               if (content)
+               {
+                 nsIContent* parent = content->GetParent();
+                 if (parent)
+                 {
+                   aPos->mResultContent = parent;
+-                  aPos->mContentOffset = parent->IndexOf(content);
++                  aPos->mContentOffset = parent->ComputeIndexOf(content);
+                   aPos->mAttach = CARET_ASSOCIATE_BEFORE;
+                   if ((point.x - offset.x+ tempRect.x)>tempRect.width)
+                   {
+                     aPos->mContentOffset++;//go to end of this frame
+                     aPos->mAttach = CARET_ASSOCIATE_AFTER;
+                   }
+                   //result frame is the result frames parent.
+                   aPos->mResultFrame = resultFrame->GetParent();
+@@ -8382,17 +8382,17 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsD
+       aFrame->IsBrFrame()) {
+     nsIContent* content = aFrame->GetContent();
+     result.mContent = content->GetParent();
+     // In some cases (bug 310589, bug 370174) we end up here with a null content.
+     // This probably shouldn't ever happen, but since it sometimes does, we want
+     // to avoid crashing here.
+     NS_ASSERTION(result.mContent, "Unexpected orphan content");
+     if (result.mContent)
+-      result.mOffset = result.mContent->IndexOf(content) +
++      result.mOffset = result.mContent->ComputeIndexOf(content) +
+         (aDirection == eDirPrevious ? 1 : 0);
+     return result;
+   }
+ 
+   // If this is a preformatted text frame, see if it ends with a newline
+   if (aFrame->HasSignificantTerminalNewline()) {
+     int32_t startOffset, endOffset;
+     aFrame->GetOffsets(startOffset, endOffset);
+diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp
+--- a/layout/generic/nsFrameSelection.cpp
++++ b/layout/generic/nsFrameSelection.cpp
+@@ -619,17 +619,17 @@ nsINode*
+ ParentOffset(nsINode *aNode, int32_t *aChildOffset)
+ {
+   if (!aNode || !aChildOffset)
+     return nullptr;
+ 
+   nsIContent* parent = aNode->GetParent();
+   if (parent)
+   {
+-    *aChildOffset = parent->IndexOf(aNode);
++    *aChildOffset = parent->ComputeIndexOf(aNode);
+ 
+     return parent;
+   }
+ 
+   return nullptr;
+ }
+ 
+ static nsINode*
+@@ -2860,17 +2860,17 @@ nsFrameSelection::GetParentTable(nsICont
+ }
+ 
+ nsresult
+ nsFrameSelection::SelectCellElement(nsIContent *aCellElement)
+ {
+   nsIContent *parent = aCellElement->GetParent();
+ 
+   // Get child offset
+-  int32_t offset = parent->IndexOf(aCellElement);
++  int32_t offset = parent->ComputeIndexOf(aCellElement);
+ 
+   return CreateAndAddRange(parent, offset);
+ }
+ 
+ nsresult
+ nsFrameSelection::CreateAndAddRange(nsINode* aContainer, int32_t aOffset)
+ {
+   if (!aContainer) {
+diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp
+--- a/layout/generic/nsImageFrame.cpp
++++ b/layout/generic/nsImageFrame.cpp
+@@ -1938,17 +1938,17 @@ nsImageFrame::ShouldDisplaySelection()
+       {
+         int32_t rangeCount;
+         selection->GetRangeCount(&rangeCount);
+         if (rangeCount == 1) //if not one then let code drop to nsFrame::Paint
+         {
+           nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
+           if (parentContent)
+           {
+-            int32_t thisOffset = parentContent->IndexOf(mContent);
++            int32_t thisOffset = parentContent->ComputeIndexOf(mContent);
+             nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(parentContent);
+             nsCOMPtr<nsIDOMNode> rangeNode;
+             uint32_t rangeOffset;
+             nsCOMPtr<nsIDOMRange> range;
+             selection->GetRangeAt(0,getter_AddRefs(range));
+             if (range)
+             {
+               range->GetStartContainer(getter_AddRefs(rangeNode));
+diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp
+--- a/layout/printing/nsPrintJob.cpp
++++ b/layout/printing/nsPrintJob.cpp
+@@ -2526,17 +2526,17 @@ GetCorrespondingNodeInDocument(const nsI
+   // Selections in anonymous subtrees aren't supported.
+   if (aNode->IsInAnonymousSubtree()) {
+     return nullptr;
+   }
+ 
+   nsTArray<int32_t> indexArray;
+   const nsINode* child = aNode;
+   while (const nsINode* parent = child->GetParentNode()) {
+-    int32_t index = parent->IndexOf(child);
++    int32_t index = parent->ComputeIndexOf(child);
+     MOZ_ASSERT(index >= 0);
+     indexArray.AppendElement(index);
+     child = parent;
+   }
+   MOZ_ASSERT(child->IsNodeOfType(nsINode::eDOCUMENT));
+ 
+   nsINode* correspondingNode = aDoc;
+   for (int32_t i = indexArray.Length() - 1; i >= 0; --i) {
+diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
+--- a/layout/tables/nsTableFrame.cpp
++++ b/layout/tables/nsTableFrame.cpp
+@@ -2660,17 +2660,17 @@ nsTableFrame::HomogenousInsertFrames(Chi
+       nsIContent* content = nullptr;
+       aPrevFrame = nullptr;
+       while (pseudoFrame  && (parentContent ==
+                               (content = pseudoFrame->GetContent()))) {
+         pseudoFrame = pseudoFrame->PrincipalChildList().FirstChild();
+       }
+       nsCOMPtr<nsIContent> container = content->GetParent();
+       if (MOZ_LIKELY(container)) { // XXX need this null-check, see bug 411823.
+-        int32_t newIndex = container->IndexOf(content);
++        int32_t newIndex = container->ComputeIndexOf(content);
+         nsIFrame* kidFrame;
+         nsTableColGroupFrame* lastColGroup = nullptr;
+         if (isColGroup) {
+           kidFrame = mColGroups.FirstChild();
+           lastColGroup = nsTableColGroupFrame::GetLastRealColGroup(this);
+         }
+         else {
+           kidFrame = mFrames.FirstChild();
+@@ -2684,17 +2684,17 @@ nsTableFrame::HomogenousInsertFrames(Chi
+               break;
+             }
+           }
+           pseudoFrame = kidFrame;
+           while (pseudoFrame  && (parentContent ==
+                                   (content = pseudoFrame->GetContent()))) {
+             pseudoFrame = pseudoFrame->PrincipalChildList().FirstChild();
+           }
+-          int32_t index = container->IndexOf(content);
++          int32_t index = container->ComputeIndexOf(content);
+           if (index > lastIndex && index < newIndex) {
+             lastIndex = index;
+             aPrevFrame = kidFrame;
+           }
+           kidFrame = kidFrame->GetNextSibling();
+         }
+       }
+     }
+diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp
+--- a/layout/xul/nsListBoxBodyFrame.cpp
++++ b/layout/xul/nsListBoxBodyFrame.cpp
+@@ -1151,17 +1151,17 @@ nsListBoxBodyFrame::GetFirstItemBox(int3
+   // to be created at the top.  Let's determine which
+   // content needs a new frame first.
+ 
+   nsCOMPtr<nsIContent> startContent;
+   if (mTopFrame && mRowsToPrepend > 0) {
+     // We need to insert rows before the top frame
+     nsIContent* topContent = mTopFrame->GetContent();
+     nsIContent* topParent = topContent->GetParent();
+-    int32_t contentIndex = topParent->IndexOf(topContent);
++    int32_t contentIndex = topParent->ComputeIndexOf(topContent);
+     contentIndex -= aOffset;
+     if (contentIndex < 0)
+       return nullptr;
+     startContent = topParent->GetChildAt_Deprecated(contentIndex - mRowsToPrepend);
+   } else {
+     // This will be the first item frame we create.  Use the content
+     // at the current index, which is the first index scrolled into view
+     GetListItemContentAt(mCurrentIndex+aOffset, getter_AddRefs(startContent));
+@@ -1212,17 +1212,17 @@ nsListBoxBodyFrame::GetNextItemBox(nsIFr
+ 
+   nsIFrame* result = aBox->GetNextSibling();
+ 
+   if (!result || result == mLinkupFrame || mRowsToPrepend > 0) {
+     // No result found. See if there's a content node that wants a frame.
+     nsIContent* prevContent = aBox->GetContent();
+     nsIContent* parentContent = prevContent->GetParent();
+ 
+-    int32_t i = parentContent->IndexOf(prevContent);
++    int32_t i = parentContent->ComputeIndexOf(prevContent);
+ 
+     uint32_t childCount = parentContent->GetChildCount();
+     if (((uint32_t)i + aOffset + 1) < childCount) {
+       // There is a content node that wants a frame.
+       nsIContent *nextContent = parentContent->GetChildAt_Deprecated(i + aOffset + 1);
+ 
+       nsIFrame* existingFrame;
+       if (!IsListItemChild(this, nextContent, &existingFrame)) {
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
+--- a/parser/html/nsHtml5TreeOperation.cpp
++++ b/parser/html/nsHtml5TreeOperation.cpp
+@@ -280,17 +280,17 @@ nsHtml5TreeOperation::FosterParent(nsICo
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsIContent* foster = aTable->GetParent();
+ 
+   if (IsElementOrTemplateContent(foster)) {
+ 
+     nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
+                                  aBuilder->GetDocument());
+ 
+-    uint32_t pos = foster->IndexOf(aTable);
++    uint32_t pos = foster->ComputeIndexOf(aTable);
+     nsresult rv = foster->InsertChildAt(aNode, pos, false);
+     NS_ENSURE_SUCCESS(rv, rv);
+     nsNodeUtils::ContentInserted(foster, aNode);
+     return rv;
+   }
+ 
+   return Append(aNode, aParent, aBuilder);
+ }
+@@ -675,17 +675,17 @@ nsHtml5TreeOperation::FosterParentText(n
+   MOZ_ASSERT(aBuilder->IsInDocUpdate());
+   nsresult rv = NS_OK;
+   nsIContent* foster = aTable->GetParent();
+ 
+   if (IsElementOrTemplateContent(foster)) {
+     nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
+                                  aBuilder->GetDocument());
+ 
+-    uint32_t pos = foster->IndexOf(aTable);
++    uint32_t pos = foster->ComputeIndexOf(aTable);
+ 
+     nsIContent* previousSibling = aTable->GetPreviousSibling();
+     if (previousSibling && previousSibling->IsNodeOfType(nsINode::eTEXT)) {
+       return AppendTextToTextNode(aBuffer,
+                                   aLength,
+                                   previousSibling,
+                                   aBuilder);
+     }

+ 43 - 0
mozilla-release/patches/1430997-2-60a1.patch

@@ -0,0 +1,43 @@
+# HG changeset patch
+# User Andrea Marchesini <amarchesini@mozilla.com>
+# Date 1516715676 -3600
+# Node ID 98c901dc8ae2062ab22200beafb21646fdc1eb09
+# Parent  c968f3886a02d9a2c4588837f2d8914b3f43e183
+Bug 1430997 - Rename nsINode::IndexOf to nsINode::ComputeIndexOf, r=me CLOSED TREE
+
+diff --git a/widget/cocoa/nsMenuBarX.mm b/widget/cocoa/nsMenuBarX.mm
+--- a/widget/cocoa/nsMenuBarX.mm
++++ b/widget/cocoa/nsMenuBarX.mm
+@@ -311,29 +311,29 @@ void nsMenuBarX::ObserveAttributeChanged
+ 
+ void nsMenuBarX::ObserveContentRemoved(nsIDocument* aDocument,
+                                        nsIContent* aContainer,
+                                        nsIContent* aChild,
+                                        nsIContent* aPreviousSibling)
+ {
+   nsINode* parent = NODE_FROM(aContainer, aDocument);
+   MOZ_ASSERT(parent);
+-  int32_t index = parent->IndexOf(aPreviousSibling) + 1;
++  int32_t index = parent->ComputeIndexOf(aPreviousSibling) + 1;
+   RemoveMenuAtIndex(index);
+ }
+ 
+ void nsMenuBarX::ObserveContentInserted(nsIDocument* aDocument,
+                                         nsIContent* aContainer,
+                                         nsIContent* aChild)
+ {
+   nsMenuX* newMenu = new nsMenuX();
+   if (newMenu) {
+     nsresult rv = newMenu->Create(this, this, aChild);
+     if (NS_SUCCEEDED(rv))
+-      InsertMenuAtIndex(newMenu, aContainer->IndexOf(aChild));
++      InsertMenuAtIndex(newMenu, aContainer->ComputeIndexOf(aChild));
+     else
+       delete newMenu;
+   }
+ }
+ 
+ void nsMenuBarX::ForceUpdateNativeMenuAt(const nsAString& indexString)
+ {
+   NSString* locationString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(indexString.BeginReading())
+

+ 37 - 0
mozilla-release/patches/series

@@ -7133,3 +7133,40 @@ TOP-1906540-mozdevice-removal-mozilla-25320.patch
 1559403-2-69a1.patch
 1566482-70a1.patch
 TOP-NOBUG-fixups-25320.patch
+1425321-1-59a1.patch
+1425321-2-59a1.patch
+1425321-3-59a1.patch
+1425440-01-59a1.patch
+1425440-02-59a1.patch
+1425440-03-59a1.patch
+1425440-04-59a1.patch
+1425440-05-59a1.patch
+1425440-06-59a1.patch
+1425440-07-59a1.patch
+1425440-08-59a1.patch
+1425440-09-59a1.patch
+1425440-10-59a1.patch
+1425440-11-59a1.patch
+1425440-12-59a1.patch
+1425440-13-59a1.patch
+1425440-14-59a1.patch
+1425440-15-59a1.patch
+1425440-16-59a1.patch
+1425440-17-59a1.patch
+1425440-18-59a1.patch
+1425440-19-59a1.patch
+1425440-20-59a1.patch
+1425440-21-59a1.patch
+1425440-22-59a1.patch
+1425440-23-59a1.patch
+1425440-24-59a1.patch
+1425440-25-59a1.patch
+1425440-26-59a1.patch
+1425440-27-59a1.patch
+1425440-28-59a1.patch
+1425440-29-59a1.patch
+1430516-59a1.patch
+1425440-30-59a1.patch
+1430997-1-60a1.patch
+1430997-2-60a1.patch
+1395973-60a1.patch