Bug 651120 - Remove index argument from content removed/appended/inserted notifications. r=peterv
authorCatalin Badea <catalin.badea392@gmail.com>
Thu, 27 Jul 2017 14:49:52 +0100
changeset 384142 4a8294c6b8e33ba08ef767bede8deeb28234b5b8
parent 384141 49820a586d6dec9f644f58b07a4770ba2697b1d3
child 384143 ba149aead55314a6b9094aef39dfd0c8b0439c5a
push id95708
push usercatalin.badea392@gmail.com
push dateTue, 03 Oct 2017 10:09:20 +0000
treeherdermozilla-inbound@4a8294c6b8e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs651120
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 651120 - Remove index argument from content removed/appended/inserted notifications. r=peterv
accessible/generic/DocAccessible.cpp
docshell/shistory/nsSHEntryShared.cpp
dom/base/NodeIterator.cpp
dom/base/ShadowRoot.cpp
dom/base/nsContentList.cpp
dom/base/nsContentSink.cpp
dom/base/nsDOMMutationObserver.cpp
dom/base/nsDocument.cpp
dom/base/nsIMutationObserver.h
dom/base/nsINode.cpp
dom/base/nsNodeUtils.cpp
dom/base/nsNodeUtils.h
dom/base/nsRange.cpp
dom/events/IMEContentObserver.cpp
dom/html/HTMLMediaElement.cpp
dom/html/HTMLOutputElement.cpp
dom/html/HTMLStyleElement.cpp
dom/html/HTMLTableElement.cpp
dom/html/HTMLTextAreaElement.cpp
dom/html/HTMLTitleElement.cpp
dom/html/nsHTMLContentSink.cpp
dom/script/ScriptElement.cpp
dom/svg/SVGStyleElement.cpp
dom/svg/SVGTitleElement.cpp
dom/svg/SVGUseElement.cpp
dom/xbl/nsBindingManager.cpp
dom/xbl/nsBindingManager.h
dom/xml/nsXMLContentSink.cpp
dom/xml/nsXMLPrettyPrinter.cpp
dom/xslt/xpath/XPathResult.cpp
dom/xslt/xslt/txMozillaXSLTProcessor.cpp
dom/xul/XULDocument.cpp
dom/xul/templates/nsXULContentBuilder.cpp
dom/xul/templates/nsXULTemplateBuilder.cpp
editor/libeditor/HTMLAnonymousNodeEditor.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditor.h
layout/base/PresShell.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/nsImageMap.cpp
layout/inspector/inDOMView.cpp
layout/svg/SVGObserverUtils.cpp
layout/svg/SVGTextFrame.cpp
layout/xul/tree/nsTreeContentView.cpp
parser/html/nsHtml5TreeOperation.cpp
toolkit/components/satchel/nsFormFillController.cpp
widget/cocoa/nsChangeObserver.h
widget/cocoa/nsMenuBarX.mm
widget/cocoa/nsMenuGroupOwnerX.mm
widget/cocoa/nsMenuItemX.mm
widget/cocoa/nsMenuX.mm
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -1091,18 +1091,17 @@ DocAccessible::ARIAActiveDescendantChang
       }
     }
   }
 }
 
 void
 DocAccessible::ContentAppended(nsIDocument* aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aFirstNewContent,
-                               int32_t /* unused */)
+                               nsIContent* aFirstNewContent)
 {
 }
 
 void
 DocAccessible::ContentStateChanged(nsIDocument* aDocument,
                                    nsIContent* aContent,
                                    EventStates aStateMask)
 {
@@ -1158,24 +1157,24 @@ void
 DocAccessible::CharacterDataChanged(nsIDocument* aDocument,
                                     nsIContent* aContent,
                                     CharacterDataChangeInfo* aInfo)
 {
 }
 
 void
 DocAccessible::ContentInserted(nsIDocument* aDocument, nsIContent* aContainer,
-                               nsIContent* aChild, int32_t /* unused */)
+                               nsIContent* aChild)
 {
 }
 
 void
 DocAccessible::ContentRemoved(nsIDocument* aDocument,
                               nsIContent* aContainerNode,
-                              nsIContent* aChildNode, int32_t /* unused */,
+                              nsIContent* aChildNode,
                               nsIContent* aPreviousSiblingNode)
 {
 #ifdef A11Y_LOG
   if (logging::IsEnabled(logging::eTree)) {
     logging::MsgBegin("TREE", "DOM content removed; doc: %p", this);
     logging::Node("container node", aContainerNode);
     logging::Node("content node", aChildNode);
     logging::MsgEnd();
--- a/docshell/shistory/nsSHEntryShared.cpp
+++ b/docshell/shistory/nsSHEntryShared.cpp
@@ -296,36 +296,33 @@ nsSHEntryShared::AttributeChanged(nsIDoc
                                   const nsAttrValue* aOldValue)
 {
   RemoveFromBFCacheAsync();
 }
 
 void
 nsSHEntryShared::ContentAppended(nsIDocument* aDocument,
                                  nsIContent* aContainer,
-                                 nsIContent* aFirstNewContent,
-                                 int32_t /* unused */)
+                                 nsIContent* aFirstNewContent)
 {
   RemoveFromBFCacheAsync();
 }
 
 void
 nsSHEntryShared::ContentInserted(nsIDocument* aDocument,
                                  nsIContent* aContainer,
-                                 nsIContent* aChild,
-                                 int32_t /* unused */)
+                                 nsIContent* aChild)
 {
   RemoveFromBFCacheAsync();
 }
 
 void
 nsSHEntryShared::ContentRemoved(nsIDocument* aDocument,
                                 nsIContent* aContainer,
                                 nsIContent* aChild,
-                                int32_t aIndexInContainer,
                                 nsIContent* aPreviousSibling)
 {
   RemoveFromBFCacheAsync();
 }
 
 void
 nsSHEntryShared::ParentChainChanged(nsIContent* aContent)
 {
--- a/dom/base/NodeIterator.cpp
+++ b/dom/base/NodeIterator.cpp
@@ -267,17 +267,16 @@ NS_IMETHODIMP NodeIterator::GetPointerBe
 
 /*
  * nsIMutationObserver interface
  */
 
 void NodeIterator::ContentRemoved(nsIDocument *aDocument,
                                   nsIContent *aContainer,
                                   nsIContent *aChild,
-                                  int32_t aIndexInContainer,
                                   nsIContent *aPreviousSibling)
 {
     nsINode *container = NODE_FROM(aContainer, aDocument);
 
     mPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
     mWorkingPointer.AdjustAfterRemoval(mRoot, container, aChild, aPreviousSibling);
 }
 
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -488,18 +488,17 @@ ShadowRoot::AttributeChanged(nsIDocument
   // Attributes may change insertion point matching, find its new distribution.
   RemoveDistributedNode(aElement);
   DistributeSingleNode(aElement);
 }
 
 void
 ShadowRoot::ContentAppended(nsIDocument* aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aFirstNewContent,
-                            int32_t aNewIndexInContainer)
+                            nsIContent* aFirstNewContent)
 {
   if (mInsertionPointChanged) {
     DistributeAllNodes();
     mInsertionPointChanged = false;
     return;
   }
 
   // Watch for new nodes added to the pool because the node
@@ -520,18 +519,17 @@ ShadowRoot::ContentAppended(nsIDocument*
 
     currentChild = currentChild->GetNextSibling();
   }
 }
 
 void
 ShadowRoot::ContentInserted(nsIDocument* aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aChild,
-                            int32_t aIndexInContainer)
+                            nsIContent* aChild)
 {
   if (mInsertionPointChanged) {
     DistributeAllNodes();
     mInsertionPointChanged = false;
     return;
   }
 
   // Watch for new nodes added to the pool because the node
@@ -548,17 +546,16 @@ ShadowRoot::ContentInserted(nsIDocument*
     DistributeSingleNode(aChild);
   }
 }
 
 void
 ShadowRoot::ContentRemoved(nsIDocument* aDocument,
                            nsIContent* aContainer,
                            nsIContent* aChild,
-                           int32_t aIndexInContainer,
                            nsIContent* aPreviousSibling)
 {
   if (mInsertionPointChanged) {
     DistributeAllNodes();
     mInsertionPointChanged = false;
     return;
   }
 
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -738,18 +738,17 @@ nsContentList::AttributeChanged(nsIDocum
     // expensive one).  Either way, no change of mState is required
     // here.
     mElements.RemoveElement(aElement);
   }
 }
 
 void
 nsContentList::ContentAppended(nsIDocument* aDocument, nsIContent* aContainer,
-                               nsIContent* aFirstNewContent,
-                               int32_t aNewIndexInContainer)
+                               nsIContent* aFirstNewContent)
 {
   NS_PRECONDITION(aContainer, "Can't get at the new content if no container!");
 
   /*
    * If the state is LIST_DIRTY then we have no useful information in our list
    * and we want to put off doing work as much as possible.
    *
    * Also, if aContainer is anonymous from our point of view, we know that we
@@ -842,18 +841,17 @@ nsContentList::ContentAppended(nsIDocume
 
     ASSERT_IN_SYNC;
   }
 }
 
 void
 nsContentList::ContentInserted(nsIDocument *aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aChild,
-                               int32_t aIndexInContainer)
+                               nsIContent* aChild)
 {
   // Note that aContainer can be null here if we are inserting into
   // the document itself; any attempted optimizations to this method
   // should deal with that.
   if (mState != LIST_DIRTY &&
       MayContainRelevantNodes(NODE_FROM(aContainer, aDocument)) &&
       nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild) &&
       MatchSelf(aChild)) {
@@ -862,17 +860,16 @@ nsContentList::ContentInserted(nsIDocume
 
   ASSERT_IN_SYNC;
 }
 
 void
 nsContentList::ContentRemoved(nsIDocument *aDocument,
                               nsIContent* aContainer,
                               nsIContent* aChild,
-                              int32_t aIndexInContainer,
                               nsIContent* aPreviousSibling)
 {
   // Note that aContainer can be null here if we are removing from
   // the document itself; any attempted optimizations to this method
   // should deal with that.
   if (mState != LIST_DIRTY &&
       MayContainRelevantNodes(NODE_FROM(aContainer, aDocument)) &&
       nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild) &&
@@ -1196,50 +1193,47 @@ nsLabelsNodeList::AttributeChanged(nsIDo
     SetDirty();
     return;
   }
 }
 
 void
 nsLabelsNodeList::ContentAppended(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aFirstNewContent,
-                                  int32_t aNewIndexInContainer)
+                                  nsIContent* aFirstNewContent)
 {
   // If a labelable element is moved to outside or inside of
   // nested associated labels, we're gonna have to modify
   // the content list.
   if (mState != LIST_DIRTY ||
       nsContentUtils::IsInSameAnonymousTree(mRootNode, aContainer)) {
     SetDirty();
     return;
   }
 }
 
 void
 nsLabelsNodeList::ContentInserted(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aChild,
-                                  int32_t aIndexInContainer)
+                                  nsIContent* aChild)
 {
   // If a labelable element is moved to outside or inside of
   // nested associated labels, we're gonna have to modify
   // the content list.
   if (mState != LIST_DIRTY ||
       nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild)) {
     SetDirty();
     return;
   }
 }
 
 void
 nsLabelsNodeList::ContentRemoved(nsIDocument* aDocument,
                                  nsIContent* aContainer,
                                  nsIContent* aChild,
-                                 int32_t aIndexInContainer,
                                  nsIContent* aPreviousSibling)
 {
   // If a labelable element is removed, we're gonna have to clean
   // the content list.
   if (mState != LIST_DIRTY ||
       nsContentUtils::IsInSameAnonymousTree(mRootNode, aChild)) {
     SetDirty();
     return;
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1305,18 +1305,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),
-                                 aStartIndex);
+                                 aContainer->GetChildAt(aStartIndex));
     mLastNotificationTime = PR_Now();
   }
 
   mInNotification--;
 }
 
 NS_IMETHODIMP
 nsContentSink::Notify(nsITimer *timer)
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -217,18 +217,17 @@ nsMutationReceiver::CharacterDataWillCha
   if (CharacterDataOldValue() && m->mPrevValue.IsVoid()) {
     aContent->GetText()->AppendTo(m->mPrevValue);
   }
 }
 
 void
 nsMutationReceiver::ContentAppended(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aFirstNewContent,
-                                    int32_t aNewIndexInContainer)
+                                    nsIContent* aFirstNewContent)
 {
   nsINode* parent = NODE_FROM(aContainer, aDocument);
   bool wantsChildList =
     ChildList() &&
     ((Subtree() && RegisterTarget()->SubtreeRoot() == parent->SubtreeRoot()) ||
      parent == Target());
   if (!wantsChildList || !IsObservable(aFirstNewContent)) {
     return;
@@ -258,18 +257,17 @@ nsMutationReceiver::ContentAppended(nsID
     n = n->GetNextSibling();
   }
   m->mPreviousSibling = aFirstNewContent->GetPreviousSibling();
 }
 
 void
 nsMutationReceiver::ContentInserted(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aChild,
-                                    int32_t aIndexInContainer)
+                                    nsIContent* aChild)
 {
   nsINode* parent = NODE_FROM(aContainer, aDocument);
   bool wantsChildList =
     ChildList() &&
     ((Subtree() && RegisterTarget()->SubtreeRoot() == parent->SubtreeRoot()) ||
      parent == Target());
   if (!wantsChildList || !IsObservable(aChild)) {
     return;
@@ -294,17 +292,16 @@ nsMutationReceiver::ContentInserted(nsID
   m->mPreviousSibling = aChild->GetPreviousSibling();
   m->mNextSibling = aChild->GetNextSibling();
 }
 
 void
 nsMutationReceiver::ContentRemoved(nsIDocument* aDocument,
                                    nsIContent* aContainer,
                                    nsIContent* aChild,
-                                   int32_t aIndexInContainer,
                                    nsIContent* aPreviousSibling)
 {
   if (!IsObservable(aChild)) {
     return;
   }
 
   nsINode* parent = NODE_FROM(aContainer, aDocument);
   if (Subtree() && parent->SubtreeRoot() != RegisterTarget()->SubtreeRoot()) {
@@ -366,21 +363,24 @@ nsMutationReceiver::ContentRemoved(nsIDo
 
   if (ChildList() && (Subtree() || parent == Target())) {
     nsDOMMutationRecord* m =
       Observer()->CurrentRecord(nsGkAtoms::childList);
     if (m->mTarget) {
       // Already handled case.
       return;
     }
+    MOZ_ASSERT(parent);
+
     m->mTarget = parent;
     m->mRemovedNodes = new nsSimpleContentList(parent);
     m->mRemovedNodes->AppendElement(aChild);
     m->mPreviousSibling = aPreviousSibling;
-    m->mNextSibling = parent->GetChildAt(aIndexInContainer);
+    m->mNextSibling = aPreviousSibling ?
+      aPreviousSibling->GetNextSibling() : parent->GetFirstChild();
   }
   // We need to schedule always, so that after microtask mTransientReceivers
   // can be cleared correctly.
   Observer()->ScheduleForRun();
 }
 
 void nsMutationReceiver::NodeWillBeDestroyed(const nsINode *aNode)
 {
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2346,17 +2346,17 @@ nsDocument::ResetToURI(nsIURI *aURI, nsI
       }
       mChildren.RemoveChildAt(i);
       if (content == mCachedRootElement) {
         // Immediately clear mCachedRootElement, now that it's been removed
         // from mChildren, so that GetRootElement() will stop returning this
         // now-stale value.
         mCachedRootElement = nullptr;
       }
-      nsNodeUtils::ContentRemoved(this, content, i, previousSibling);
+      nsNodeUtils::ContentRemoved(this, content, previousSibling);
       content->UnbindFromTree();
     }
     MOZ_ASSERT(!mCachedRootElement,
                "After removing all children, there should be no root elem");
   }
   mInUnlinkOrDeletion = oldVal;
 
   // Reset our stylesheets
--- a/dom/base/nsIMutationObserver.h
+++ b/dom/base/nsIMutationObserver.h
@@ -229,29 +229,26 @@ public:
   /**
    * Notification that one or more content nodes have been appended to the
    * child list of another node in the tree.
    *
    * @param aDocument  The owner-document of aContent. Can be null.
    * @param aContainer The container that had new children appended. Is never
    *                   null.
    * @param aFirstNewContent the node at aIndexInContainer in aContainer.
-   * @param aNewIndexInContainer the index in the container of the first
-   *                   new child
    *
    * @note Callers of this method might not hold a strong reference to the
    *       observer.  The observer is responsible for making sure it stays
    *       alive for the duration of the call as needed.  The observer may
    *       assume that this call will happen when there are script blockers on
    *       the stack.
    */
   virtual void ContentAppended(nsIDocument *aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aFirstNewContent,
-                               int32_t     aNewIndexInContainer) = 0;
+                               nsIContent* aFirstNewContent) = 0;
 
   /**
    * Notification that a content node has been inserted as child to another
    * node in the tree.
    *
    * @param aDocument  The owner-document of aContent, or, when aContainer
    *                   is null, the container that had the child inserted.
    *                   Can be null.
@@ -264,18 +261,17 @@ public:
    * @note Callers of this method might not hold a strong reference to the
    *       observer.  The observer is responsible for making sure it stays
    *       alive for the duration of the call as needed.  The observer may
    *       assume that this call will happen when there are script blockers on
    *       the stack.
    */
   virtual void ContentInserted(nsIDocument *aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aChild,
-                               int32_t aIndexInContainer) = 0;
+                               nsIContent* aChild) = 0;
 
   /**
    * Notification that a content node has been removed from the child list of
    * another node in the tree.
    *
    * @param aDocument  The owner-document of aContent, or, when aContainer
    *                   is null, the container that had the child removed.
    *                   Can be null.
@@ -292,17 +288,16 @@ public:
    *       observer.  The observer is responsible for making sure it stays
    *       alive for the duration of the call as needed.  The observer may
    *       assume that this call will happen when there are script blockers on
    *       the stack.
    */
   virtual void ContentRemoved(nsIDocument *aDocument,
                               nsIContent* aContainer,
                               nsIContent* aChild,
-                              int32_t aIndexInContainer,
                               nsIContent* aPreviousSibling) = 0;
 
  /**
    * The node is in the process of being destroyed. Calling QI on the node is
    * not supported, however it is possible to get children and flags through
    * nsINode as well as calling IsNodeOfType(eCONTENT) and casting to
    * nsIContent to get attributes.
    *
@@ -369,30 +364,27 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIMutatio
                                   int32_t aNameSpaceID,                      \
                                   nsIAtom* aAttribute,                       \
                                   int32_t aModType,                          \
                                   const nsAttrValue* aOldValue) override;
 
 #define NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED                          \
     virtual void ContentAppended(nsIDocument* aDocument,                     \
                                  nsIContent* aContainer,                     \
-                                 nsIContent* aFirstNewContent,               \
-                                 int32_t aNewIndexInContainer) override;
+                                 nsIContent* aFirstNewContent) override;
 
 #define NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED                          \
     virtual void ContentInserted(nsIDocument* aDocument,                     \
                                  nsIContent* aContainer,                     \
-                                 nsIContent* aChild,                         \
-                                 int32_t aIndexInContainer) override;
+                                 nsIContent* aChild) override;
 
 #define NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED                           \
     virtual void ContentRemoved(nsIDocument* aDocument,                      \
                                 nsIContent* aContainer,                      \
                                 nsIContent* aChild,                          \
-                                int32_t aIndexInContainer,                   \
                                 nsIContent* aPreviousSibling) override;
 
 #define NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED                      \
     virtual void NodeWillBeDestroyed(const nsINode* aNode) override;
 
 #define NS_DECL_NSIMUTATIONOBSERVER_PARENTCHAINCHANGED                       \
     virtual void ParentChainChanged(nsIContent *aContent) override;
 
@@ -449,32 +441,29 @@ void                                    
                          nsIAtom* aAttribute,                             \
                          int32_t aModType,                                \
                          const nsAttrValue* aOldValue)                    \
 {                                                                         \
 }                                                                         \
 void                                                                      \
 _class::ContentAppended(nsIDocument* aDocument,                           \
                         nsIContent* aContainer,                           \
-                        nsIContent* aFirstNewContent,                     \
-                        int32_t aNewIndexInContainer)                     \
+                        nsIContent* aFirstNewContent)                     \
 {                                                                         \
 }                                                                         \
 void                                                                      \
 _class::ContentInserted(nsIDocument* aDocument,                           \
                         nsIContent* aContainer,                           \
-                        nsIContent* aChild,                               \
-                        int32_t aIndexInContainer)                        \
+                        nsIContent* aChild)                               \
 {                                                                         \
 }                                                                         \
 void                                                                      \
 _class::ContentRemoved(nsIDocument* aDocument,                            \
                        nsIContent* aContainer,                            \
                        nsIContent* aChild,                                \
-                       int32_t aIndexInContainer,                         \
                        nsIContent* aPreviousSibling)                      \
 {                                                                         \
 }                                                                         \
 void                                                                      \
 _class::ParentChainChanged(nsIContent *aContent)                          \
 {                                                                         \
 }
 
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1626,19 +1626,19 @@ nsINode::doInsertChildAt(nsIContent* aKi
 
   NS_ASSERTION(aKid->GetParentNode() == this,
                "Did we run script inappropriately?");
 
   if (aNotify) {
     // Note that we always want to call ContentInserted when things are added
     // as kids to documents
     if (parent && isAppend) {
-      nsNodeUtils::ContentAppended(parent, aKid, aIndex);
+      nsNodeUtils::ContentAppended(parent, aKid);
     } else {
-      nsNodeUtils::ContentInserted(this, aKid, aIndex);
+      nsNodeUtils::ContentInserted(this, aKid);
     }
 
     if (nsContentUtils::HasMutationListeners(aKid,
           NS_EVENT_BITS_MUTATION_NODEINSERTED, this)) {
       InternalMutationEvent mutation(true, eLegacyNodeInserted);
       mutation.mRelatedNode = do_QueryInterface(this);
 
       mozAutoSubtreeModified subtree(OwnerDoc(), this);
@@ -1934,17 +1934,17 @@ nsINode::doRemoveChildAt(uint32_t aIndex
   nsSlots* slots = GetExistingSlots();
   if (slots && slots->mChildNodes) {
     auto childNodes =
       static_cast<nsParentNodeChildContentList*>(slots->mChildNodes.get());
     childNodes->InvalidateCache();
   }
 
   if (aNotify) {
-    nsNodeUtils::ContentRemoved(this, aKid, aIndex, previousSibling);
+    nsNodeUtils::ContentRemoved(this, aKid, previousSibling);
   }
 
   aKid->UnbindFromTree();
 }
 
 // When replacing, aRefChild is the content being replaced; when
 // inserting it's the content before which we're inserting.  In the
 // latter case it may be null.
@@ -2470,45 +2470,43 @@ nsINode::ReplaceOrInsertBefore(bool aRep
 
     uint32_t count = fragChildren->Length();
     if (!count) {
       return result;
     }
 
     bool appending =
       !IsNodeOfType(eDOCUMENT) && uint32_t(insPos) == GetChildCount();
-    int32_t firstInsPos = insPos;
     nsIContent* firstInsertedContent = fragChildren->ElementAt(0);
 
     // Iterate through the fragment's children, and insert them in the new
     // parent
     for (uint32_t i = 0; i < count; ++i, ++insPos) {
       // XXXbz how come no reparenting here?  That seems odd...
       // Insert the child.
       aError = InsertChildAt(fragChildren->ElementAt(i), insPos,
                              !appending);
       if (aError.Failed()) {
         // Make sure to notify on any children that we did succeed to insert
         if (appending && i != 0) {
           nsNodeUtils::ContentAppended(static_cast<nsIContent*>(this),
-                                       firstInsertedContent,
-                                       firstInsPos);
+                                       firstInsertedContent);
         }
         return nullptr;
       }
     }
 
     if (mutationBatch && !appending) {
       mutationBatch->NodesAdded();
     }
 
     // Notify and fire mutation events when appending
     if (appending) {
       nsNodeUtils::ContentAppended(static_cast<nsIContent*>(this),
-                                   firstInsertedContent, firstInsPos);
+                                   firstInsertedContent);
       if (mutationBatch) {
         mutationBatch->NodesAdded();
       }
       // Optimize for the case when there are no listeners
       if (nsContentUtils::
             HasMutationListeners(doc, NS_EVENT_BITS_MUTATION_NODEINSERTED)) {
         Element::FireNodeInserted(doc, this, *fragChildren);
       }
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -155,39 +155,36 @@ nsNodeUtils::AttributeSetToCurrentValue(
 {
   nsIDocument* doc = aElement->OwnerDoc();
   IMPL_MUTATION_NOTIFICATION(AttributeSetToCurrentValue, aElement,
                              (doc, aElement, aNameSpaceID, aAttribute));
 }
 
 void
 nsNodeUtils::ContentAppended(nsIContent* aContainer,
-                             nsIContent* aFirstNewContent,
-                             int32_t aNewIndexInContainer)
+                             nsIContent* aFirstNewContent)
 {
   nsIDocument* doc = aContainer->OwnerDoc();
 
   IMPL_MUTATION_NOTIFICATION(ContentAppended, aContainer,
-                             (doc, aContainer, aFirstNewContent,
-                              aNewIndexInContainer));
+                             (doc, aContainer, aFirstNewContent));
 }
 
 void
 nsNodeUtils::NativeAnonymousChildListChange(nsIContent* aContent,
                                             bool aIsRemove)
 {
   nsIDocument* doc = aContent->OwnerDoc();
   IMPL_MUTATION_NOTIFICATION(NativeAnonymousChildListChange, aContent,
                             (doc, aContent, aIsRemove));
 }
 
 void
 nsNodeUtils::ContentInserted(nsINode* aContainer,
-                             nsIContent* aChild,
-                             int32_t aIndexInContainer)
+                             nsIContent* aChild)
 {
   NS_PRECONDITION(aContainer->IsNodeOfType(nsINode::eCONTENT) ||
                   aContainer->IsNodeOfType(nsINode::eDOCUMENT),
                   "container must be an nsIContent or an nsIDocument");
   nsIContent* container;
   nsIDocument* doc = aContainer->OwnerDoc();
   nsIDocument* document;
   if (aContainer->IsNodeOfType(nsINode::eCONTENT)) {
@@ -195,23 +192,22 @@ nsNodeUtils::ContentInserted(nsINode* aC
     document = doc;
   }
   else {
     container = nullptr;
     document = static_cast<nsIDocument*>(aContainer);
   }
 
   IMPL_MUTATION_NOTIFICATION(ContentInserted, aContainer,
-                             (document, container, aChild, aIndexInContainer));
+                             (document, container, aChild));
 }
 
 void
 nsNodeUtils::ContentRemoved(nsINode* aContainer,
                             nsIContent* aChild,
-                            int32_t aIndexInContainer,
                             nsIContent* aPreviousSibling)
 {
   NS_PRECONDITION(aContainer->IsNodeOfType(nsINode::eCONTENT) ||
                   aContainer->IsNodeOfType(nsINode::eDOCUMENT),
                   "container must be an nsIContent or an nsIDocument");
   nsIContent* container;
   nsIDocument* doc = aContainer->OwnerDoc();
   nsIDocument* document;
@@ -220,18 +216,17 @@ nsNodeUtils::ContentRemoved(nsINode* aCo
     document = doc;
   }
   else {
     container = nullptr;
     document = static_cast<nsIDocument*>(aContainer);
   }
 
   IMPL_MUTATION_NOTIFICATION(ContentRemoved, aContainer,
-                             (document, container, aChild, aIndexInContainer,
-                              aPreviousSibling));
+                             (document, container, aChild, aPreviousSibling));
 }
 
 Maybe<NonOwningAnimationTarget>
 nsNodeUtils::GetTargetForAnimation(const Animation* aAnimation)
 {
   AnimationEffectReadOnly* effect = aAnimation->GetEffect();
   if (!effect || !effect->AsKeyframeEffect()) {
     return Nothing();
--- a/dom/base/nsNodeUtils.h
+++ b/dom/base/nsNodeUtils.h
@@ -87,52 +87,47 @@ public:
   static void AttributeSetToCurrentValue(mozilla::dom::Element* aElement,
                                          int32_t aNameSpaceID,
                                          nsIAtom* aAttribute);
 
   /**
    * Send ContentAppended notifications to nsIMutationObservers
    * @param aContainer           Node into which new child/children were added
    * @param aFirstNewContent     First new child
-   * @param aNewIndexInContainer Index of first new child
    * @see nsIMutationObserver::ContentAppended
    */
   static void ContentAppended(nsIContent* aContainer,
-                              nsIContent* aFirstNewContent,
-                              int32_t aNewIndexInContainer);
+                              nsIContent* aFirstNewContent);
 
   /**
    * Send NativeAnonymousChildList notifications to nsIMutationObservers
    * @param aContent             Anonymous node that's been added or removed
    * @param aIsRemove            True if it's a removal, false if an addition
    * @see nsIMutationObserver::NativeAnonymousChildListChange
    */
   static void NativeAnonymousChildListChange(nsIContent* aContent,
                                              bool aIsRemove);
 
   /**
    * Send ContentInserted notifications to nsIMutationObservers
    * @param aContainer        Node into which new child was inserted
    * @param aChild            Newly inserted child
-   * @param aIndexInContainer Index of new child
    * @see nsIMutationObserver::ContentInserted
    */
   static void ContentInserted(nsINode* aContainer,
-                              nsIContent* aChild,
-                              int32_t aIndexInContainer);
+                              nsIContent* aChild);
   /**
    * Send ContentRemoved notifications to nsIMutationObservers
    * @param aContainer        Node from which child was removed
    * @param aChild            Removed child
-   * @param aIndexInContainer Index of removed child
+   * @param aPreviousSibling  Previous sibling of the removed child
    * @see nsIMutationObserver::ContentRemoved
    */
   static void ContentRemoved(nsINode* aContainer,
                              nsIContent* aChild,
-                             int32_t aIndexInContainer,
                              nsIContent* aPreviousSibling);
   /**
    * Send ParentChainChanged notifications to nsIMutationObservers
    * @param aContent  The piece of content that had its parent changed.
    * @see nsIMutationObserver::ParentChainChanged
    */
   static inline void ParentChainChanged(nsIContent *aContent)
   {
--- a/dom/base/nsRange.cpp
+++ b/dom/base/nsRange.cpp
@@ -633,18 +633,17 @@ nsRange::CharacterDataChanged(nsIDocumen
                newRoot ? newRoot : mRoot.get(),
                !newEnd.Container()->GetParentNode() || !newStart.Container()->GetParentNode());
   }
 }
 
 void
 nsRange::ContentAppended(nsIDocument* aDocument,
                          nsIContent*  aContainer,
-                         nsIContent*  aFirstNewContent,
-                         int32_t      aNewIndexInContainer)
+                         nsIContent*  aFirstNewContent)
 {
   NS_ASSERTION(mIsPositioned, "shouldn't be notified if not positioned");
 
   nsINode* container = NODE_FROM(aContainer, aDocument);
   MOZ_ASSERT(container);
   MOZ_ASSERT(aFirstNewContent->GetParentNode() == container);
   if (container->IsSelectionDescendant() && IsInSelection()) {
     nsINode* child = aFirstNewContent;
@@ -672,18 +671,17 @@ nsRange::ContentAppended(nsIDocument* aD
     }
     DoSetRange(mStart.AsRaw(), mEnd.AsRaw(), mRoot, true);
   }
 }
 
 void
 nsRange::ContentInserted(nsIDocument* aDocument,
                          nsIContent* aContainer,
-                         nsIContent* aChild,
-                         int32_t /* aIndexInContainer */)
+                         nsIContent* aChild)
 {
   MOZ_ASSERT(mIsPositioned, "shouldn't be notified if not positioned");
 
   bool updateBoundaries = false;
   nsINode* container = NODE_FROM(aContainer, aDocument);
   MOZ_ASSERT(container);
   RawRangeBoundary newStart(mStart);
   RawRangeBoundary newEnd(mEnd);
@@ -726,17 +724,16 @@ nsRange::ContentInserted(nsIDocument* aD
     DoSetRange(newStart, newEnd, mRoot);
   }
 }
 
 void
 nsRange::ContentRemoved(nsIDocument* aDocument,
                         nsIContent* aContainer,
                         nsIContent* aChild,
-                        int32_t /* aIndexInContainer */,
                         nsIContent* aPreviousSibling)
 {
   MOZ_ASSERT(mIsPositioned, "shouldn't be notified if not positioned");
   nsINode* container = NODE_FROM(aContainer, aDocument);
   RawRangeBoundary newStart;
   RawRangeBoundary newEnd;
   Maybe<bool> gravitateStart;
   bool gravitateEnd;
--- a/dom/events/IMEContentObserver.cpp
+++ b/dom/events/IMEContentObserver.cpp
@@ -1116,49 +1116,49 @@ IMEContentObserver::NotifyContentAdded(n
                       IsEditorHandlingEventForComposition(),
                       IsEditorComposing());
   MaybeNotifyIMEOfTextChange(data);
 }
 
 void
 IMEContentObserver::ContentAppended(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aFirstNewContent,
-                                    int32_t /* unused */)
+                                    nsIContent* aFirstNewContent)
 {
   NotifyContentAdded(NODE_FROM(aContainer, aDocument),
                      aFirstNewContent, aContainer->GetLastChild());
 }
 
 void
 IMEContentObserver::ContentInserted(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aChild,
-                                    int32_t /* unused */)
+                                    nsIContent* aChild)
 {
+  MOZ_ASSERT(aChild);
   NotifyContentAdded(NODE_FROM(aContainer, aDocument),
                      aChild, aChild);
 }
 
 void
 IMEContentObserver::ContentRemoved(nsIDocument* aDocument,
                                    nsIContent* aContainer,
                                    nsIContent* aChild,
-                                   int32_t /* unused */,
                                    nsIContent* aPreviousSibling)
 {
   if (!NeedsTextChangeNotification()) {
     return;
   }
 
   mEndOfAddedTextCache.Clear();
   MaybeNotifyIMEOfAddedTextDuringDocumentChange();
 
   nsINode* containerNode = NODE_FROM(aContainer, aDocument);
 
+  MOZ_ASSERT(containerNode);
+
   uint32_t offset = 0;
   nsresult rv = NS_OK;
   if (!mStartOfRemovingTextRangeCache.Match(containerNode, aPreviousSibling)) {
     // At removing a child node of aContainer, we need the line break caused
     // by open tag of aContainer.  Be careful when aPreviousSibling is nullptr.
 
     rv = ContentEventHandler::GetFlatTextLengthInRange(
                                 NodePosition(mRootContent, 0),
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1522,20 +1522,19 @@ NS_IMPL_URI_ATTR(HTMLMediaElement, Src, 
 NS_IMPL_BOOL_ATTR(HTMLMediaElement, Controls, controls)
 NS_IMPL_BOOL_ATTR(HTMLMediaElement, Autoplay, autoplay)
 NS_IMPL_BOOL_ATTR(HTMLMediaElement, Loop, loop)
 NS_IMPL_BOOL_ATTR(HTMLMediaElement, DefaultMuted, muted)
 NS_IMPL_ENUM_ATTR_DEFAULT_VALUE(HTMLMediaElement, Preload, preload, nullptr)
 
 void
 HTMLMediaElement::ContentRemoved(nsIDocument* aDocument,
-                                 nsIContent*  aContainer,
-                                 nsIContent*  aChild,
-                                 int32_t /* aIndexInContainer */,
-                                 nsIContent*  aPreviousSibling)
+                                 nsIContent* aContainer,
+                                 nsIContent* aChild,
+                                 nsIContent* aPreviousSibling)
 {
   if (aChild == mSourcePointer) {
     mSourcePointer = aPreviousSibling;
   }
 }
 
 NS_IMETHODIMP_(bool)
 HTMLMediaElement::IsVideo()
--- a/dom/html/HTMLOutputElement.cpp
+++ b/dom/html/HTMLOutputElement.cpp
@@ -188,34 +188,31 @@ void HTMLOutputElement::CharacterDataCha
                                              nsIContent* aContent,
                                              CharacterDataChangeInfo* aInfo)
 {
   DescendantsChanged();
 }
 
 void HTMLOutputElement::ContentAppended(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aFirstNewContent,
-                                        int32_t aNewIndexInContainer)
+                                        nsIContent* aFirstNewContent)
 {
   DescendantsChanged();
 }
 
 void HTMLOutputElement::ContentInserted(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aChild,
-                                        int32_t aIndexInContainer)
+                                        nsIContent* aChild)
 {
   DescendantsChanged();
 }
 
 void HTMLOutputElement::ContentRemoved(nsIDocument* aDocument,
                                        nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       int32_t aIndexInContainer,
                                        nsIContent* aPreviousSibling)
 {
   DescendantsChanged();
 }
 
 JSObject*
 HTMLOutputElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
--- a/dom/html/HTMLStyleElement.cpp
+++ b/dom/html/HTMLStyleElement.cpp
@@ -70,36 +70,33 @@ HTMLStyleElement::CharacterDataChanged(n
                                        CharacterDataChangeInfo* aInfo)
 {
   ContentChanged(aContent);
 }
 
 void
 HTMLStyleElement::ContentAppended(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aFirstNewContent,
-                                  int32_t aNewIndexInContainer)
+                                  nsIContent* aFirstNewContent)
 {
   ContentChanged(aContainer);
 }
 
 void
 HTMLStyleElement::ContentInserted(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aChild,
-                                  int32_t aIndexInContainer)
+                                  nsIContent* aChild)
 {
   ContentChanged(aChild);
 }
 
 void
 HTMLStyleElement::ContentRemoved(nsIDocument* aDocument,
                                  nsIContent* aContainer,
                                  nsIContent* aChild,
-                                 int32_t aIndexInContainer,
                                  nsIContent* aPreviousSibling)
 {
   ContentChanged(aChild);
 }
 
 void
 HTMLStyleElement::ContentChanged(nsIContent* aContent)
 {
--- a/dom/html/HTMLTableElement.cpp
+++ b/dom/html/HTMLTableElement.cpp
@@ -474,18 +474,17 @@ TableRowsCollection::HandleInsert(nsICon
   return index + 1;
 }
 
 // nsIMutationObserver
 
 void
 TableRowsCollection::ContentAppended(nsIDocument* aDocument,
                                      nsIContent* aContainer,
-                                     nsIContent* aFirstNewContent,
-                                     int32_t aNewIndexInContainer)
+                                     nsIContent* aFirstNewContent)
 {
   if (!nsContentUtils::IsInSameAnonymousTree(mParent, aFirstNewContent) ||
       !InterestingContainer(aContainer)) {
     return;
   }
 
   // We usually can't guess where we need to start inserting, unless we're
   // appending into mParent, in which case we can provide the guess that we
@@ -499,32 +498,30 @@ TableRowsCollection::ContentAppended(nsI
        content; content = content->GetNextSibling()) {
     indexGuess = HandleInsert(aContainer, content, indexGuess);
   }
 }
 
 void
 TableRowsCollection::ContentInserted(nsIDocument* aDocument,
                                      nsIContent* aContainer,
-                                     nsIContent* aChild,
-                                     int32_t aIndexInContainer)
+                                     nsIContent* aChild)
 {
   if (!nsContentUtils::IsInSameAnonymousTree(mParent, aChild) ||
       !InterestingContainer(aContainer)) {
     return;
   }
 
   HandleInsert(aContainer, aChild);
 }
 
 void
 TableRowsCollection::ContentRemoved(nsIDocument* aDocument,
                                     nsIContent* aContainer,
                                     nsIContent* aChild,
-                                    int32_t aIndexInContainer,
                                     nsIContent* aPreviousSibling)
 {
   if (!nsContentUtils::IsInSameAnonymousTree(mParent, aChild) ||
       !InterestingContainer(aContainer)) {
     return;
   }
 
   // If the element being removed is a `tr`, we can just remove it from our
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -1030,36 +1030,33 @@ HTMLTextAreaElement::CharacterDataChange
                                           CharacterDataChangeInfo* aInfo)
 {
   ContentChanged(aContent);
 }
 
 void
 HTMLTextAreaElement::ContentAppended(nsIDocument* aDocument,
                                      nsIContent* aContainer,
-                                     nsIContent* aFirstNewContent,
-                                     int32_t /* unused */)
+                                     nsIContent* aFirstNewContent)
 {
   ContentChanged(aFirstNewContent);
 }
 
 void
 HTMLTextAreaElement::ContentInserted(nsIDocument* aDocument,
                                      nsIContent* aContainer,
-                                     nsIContent* aChild,
-                                     int32_t /* unused */)
+                                     nsIContent* aChild)
 {
   ContentChanged(aChild);
 }
 
 void
 HTMLTextAreaElement::ContentRemoved(nsIDocument* aDocument,
                                     nsIContent* aContainer,
                                     nsIContent* aChild,
-                                    int32_t aIndexInContainer,
                                     nsIContent* aPreviousSibling)
 {
   ContentChanged(aChild);
 }
 
 void
 HTMLTextAreaElement::ContentChanged(nsIContent* aContent)
 {
--- a/dom/html/HTMLTitleElement.cpp
+++ b/dom/html/HTMLTitleElement.cpp
@@ -59,36 +59,33 @@ HTMLTitleElement::CharacterDataChanged(n
                                        CharacterDataChangeInfo *aInfo)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 HTMLTitleElement::ContentAppended(nsIDocument *aDocument,
                                   nsIContent *aContainer,
-                                  nsIContent *aFirstNewContent,
-                                  int32_t aNewIndexInContainer)
+                                  nsIContent *aFirstNewContent)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 HTMLTitleElement::ContentInserted(nsIDocument *aDocument,
                                   nsIContent *aContainer,
-                                  nsIContent *aChild,
-                                  int32_t aIndexInContainer)
+                                  nsIContent *aChild)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 HTMLTitleElement::ContentRemoved(nsIDocument *aDocument,
                                  nsIContent *aContainer,
                                  nsIContent *aChild,
-                                 int32_t aIndexInContainer,
                                  nsIContent *aPreviousSibling)
 {
   SendTitleChangeEvent(false);
 }
 
 nsresult
 HTMLTitleElement::BindToTree(nsIDocument *aDocument,
                              nsIContent *aParent,
--- a/dom/html/nsHTMLContentSink.cpp
+++ b/dom/html/nsHTMLContentSink.cpp
@@ -1086,17 +1086,17 @@ HTMLContentSink::NotifyInsert(nsIContent
   }
 
   mInNotification++;
 
   {
     // Scope so we call EndUpdate before we decrease mInNotification
     MOZ_AUTO_DOC_UPDATE(mDocument, UPDATE_CONTENT_MODEL, !mBeganUpdate);
     nsNodeUtils::ContentInserted(NODE_FROM(aContent, mDocument),
-                                 aChildContent, aIndexInContainer);
+                                 aChildContent);
     mLastNotificationTime = PR_Now();
   }
 
   mInNotification--;
 }
 
 void
 HTMLContentSink::NotifyRootInsertion()
--- a/dom/script/ScriptElement.cpp
+++ b/dom/script/ScriptElement.cpp
@@ -94,27 +94,25 @@ ScriptElement::AttributeChanged(nsIDocum
                                 const nsAttrValue* aOldValue)
 {
   MaybeProcessScript();
 }
 
 void
 ScriptElement::ContentAppended(nsIDocument* aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aFirstNewContent,
-                               int32_t aNewIndexInContainer)
+                               nsIContent* aFirstNewContent)
 {
   MaybeProcessScript();
 }
 
 void
 ScriptElement::ContentInserted(nsIDocument* aDocument,
                                nsIContent* aContainer,
-                               nsIContent* aChild,
-                               int32_t aIndexInContainer)
+                               nsIContent* aChild)
 {
   MaybeProcessScript();
 }
 
 bool
 ScriptElement::MaybeProcessScript()
 {
   nsCOMPtr<nsIContent> cont =
--- a/dom/svg/SVGStyleElement.cpp
+++ b/dom/svg/SVGStyleElement.cpp
@@ -155,36 +155,33 @@ SVGStyleElement::CharacterDataChanged(ns
                                       CharacterDataChangeInfo* aInfo)
 {
   ContentChanged(aContent);
 }
 
 void
 SVGStyleElement::ContentAppended(nsIDocument* aDocument,
                                  nsIContent* aContainer,
-                                 nsIContent* aFirstNewContent,
-                                 int32_t aNewIndexInContainer)
+                                 nsIContent* aFirstNewContent)
 {
   ContentChanged(aContainer);
 }
 
 void
 SVGStyleElement::ContentInserted(nsIDocument* aDocument,
                                  nsIContent* aContainer,
-                                 nsIContent* aChild,
-                                 int32_t aIndexInContainer)
+                                 nsIContent* aChild)
 {
   ContentChanged(aChild);
 }
 
 void
 SVGStyleElement::ContentRemoved(nsIDocument* aDocument,
                                 nsIContent* aContainer,
                                 nsIContent* aChild,
-                                int32_t aIndexInContainer,
                                 nsIContent* aPreviousSibling)
 {
   ContentChanged(aChild);
 }
 
 void
 SVGStyleElement::ContentChanged(nsIContent* aContent)
 {
--- a/dom/svg/SVGTitleElement.cpp
+++ b/dom/svg/SVGTitleElement.cpp
@@ -45,36 +45,33 @@ SVGTitleElement::CharacterDataChanged(ns
                                       CharacterDataChangeInfo *aInfo)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 SVGTitleElement::ContentAppended(nsIDocument *aDocument,
                                  nsIContent *aContainer,
-                                 nsIContent *aFirstNewContent,
-                                 int32_t aNewIndexInContainer)
+                                 nsIContent *aFirstNewContent)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 SVGTitleElement::ContentInserted(nsIDocument *aDocument,
                                  nsIContent *aContainer,
-                                 nsIContent *aChild,
-                                 int32_t aIndexInContainer)
+                                 nsIContent *aChild)
 {
   SendTitleChangeEvent(false);
 }
 
 void
 SVGTitleElement::ContentRemoved(nsIDocument *aDocument,
                                 nsIContent *aContainer,
                                 nsIContent *aChild,
-                                int32_t aIndexInContainer,
                                 nsIContent *aPreviousSibling)
 {
   SendTitleChangeEvent(false);
 }
 
 nsresult
 SVGTitleElement::BindToTree(nsIDocument *aDocument,
                              nsIContent *aParent,
--- a/dom/svg/SVGUseElement.cpp
+++ b/dom/svg/SVGUseElement.cpp
@@ -165,40 +165,37 @@ SVGUseElement::AttributeChanged(nsIDocum
   if (nsContentUtils::IsInSameAnonymousTree(this, aElement)) {
     TriggerReclone();
   }
 }
 
 void
 SVGUseElement::ContentAppended(nsIDocument *aDocument,
                                nsIContent *aContainer,
-                               nsIContent *aFirstNewContent,
-                               int32_t aNewIndexInContainer)
+                               nsIContent *aFirstNewContent)
 {
   if (nsContentUtils::IsInSameAnonymousTree(this, aContainer)) {
     TriggerReclone();
   }
 }
 
 void
 SVGUseElement::ContentInserted(nsIDocument *aDocument,
                                nsIContent *aContainer,
-                               nsIContent *aChild,
-                               int32_t aIndexInContainer)
+                               nsIContent *aChild)
 {
   if (nsContentUtils::IsInSameAnonymousTree(this, aChild)) {
     TriggerReclone();
   }
 }
 
 void
 SVGUseElement::ContentRemoved(nsIDocument *aDocument,
                               nsIContent *aContainer,
                               nsIContent *aChild,
-                              int32_t aIndexInContainer,
                               nsIContent *aPreviousSibling)
 {
   if (nsContentUtils::IsInSameAnonymousTree(this, aChild)) {
     TriggerReclone();
   }
 }
 
 void
--- a/dom/xbl/nsBindingManager.cpp
+++ b/dom/xbl/nsBindingManager.cpp
@@ -833,23 +833,18 @@ InsertAppendedContent(XBLChildrenElement
        currentChild = currentChild->GetNextSibling()) {
     aPoint->InsertInsertedChildAt(currentChild, insertionIndex++);
   }
 }
 
 void
 nsBindingManager::ContentAppended(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aFirstNewContent,
-                                  int32_t     aNewIndexInContainer)
+                                  nsIContent* aFirstNewContent)
 {
-  if (aNewIndexInContainer == -1) {
-    return;
-  }
-
   // Try to find insertion points for all the new kids.
   XBLChildrenElement* point = nullptr;
   nsIContent* parent = aContainer;
 
   // Handle appending of default content.
   if (parent && parent->IsActiveChildrenElement()) {
     XBLChildrenElement* childrenEl = static_cast<XBLChildrenElement*>(parent);
     if (childrenEl->HasInsertedChildren()) {
@@ -869,21 +864,19 @@ nsBindingManager::ContentAppended(nsIDoc
     }
 
     if (binding->HasFilteredInsertionPoints()) {
       // There are filtered insertion points involved, handle each child
       // separately.
       // We could optimize this in the case when we've nested a few levels
       // deep already, without hitting bindings that have filtered insertion
       // points.
-      int32_t currentIndex = aNewIndexInContainer;
       for (nsIContent* currentChild = aFirstNewContent; currentChild;
            currentChild = currentChild->GetNextSibling()) {
-        HandleChildInsertion(aContainer, currentChild,
-                             currentIndex++, true);
+        HandleChildInsertion(aContainer, currentChild, true);
       }
 
       return;
     }
 
     point = binding->GetDefaultInsertionPoint();
     if (!point) {
       break;
@@ -908,31 +901,25 @@ nsBindingManager::ContentAppended(nsIDoc
     }
     parent = newParent;
   } while (parent);
 }
 
 void
 nsBindingManager::ContentInserted(nsIDocument* aDocument,
                                   nsIContent* aContainer,
-                                  nsIContent* aChild,
-                                  int32_t aIndexInContainer)
+                                  nsIContent* aChild)
 {
-  if (aIndexInContainer == -1) {
-    return;
-  }
-
-  HandleChildInsertion(aContainer, aChild, aIndexInContainer, false);
+  HandleChildInsertion(aContainer, aChild, false);
 }
 
 void
 nsBindingManager::ContentRemoved(nsIDocument* aDocument,
                                  nsIContent* aContainer,
                                  nsIContent* aChild,
-                                 int32_t aIndexInContainer,
                                  nsIContent* aPreviousSibling)
 {
   aChild->SetXBLInsertionParent(nullptr);
 
   XBLChildrenElement* point = nullptr;
   nsIContent* parent = aContainer;
 
   // Handle appending of default content.
@@ -1034,23 +1021,19 @@ nsBindingManager::Traverse(nsIContent *a
     NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "[via binding manager] mWrapperTable value");
     cb.NoteXPCOMChild(value);
   }
 }
 
 void
 nsBindingManager::HandleChildInsertion(nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       uint32_t aIndexInContainer,
                                        bool aAppend)
 {
-  NS_PRECONDITION(aChild, "Must have child");
-  NS_PRECONDITION(!aContainer ||
-                  uint32_t(aContainer->IndexOf(aChild)) == aIndexInContainer,
-                  "Child not at the right index?");
+  MOZ_ASSERT(aChild, "Must have child");
 
   XBLChildrenElement* point = nullptr;
   nsIContent* parent = aContainer;
 
   // Handle insertion of default content.
   if (parent && parent->IsActiveChildrenElement()) {
     XBLChildrenElement* childrenEl = static_cast<XBLChildrenElement*>(parent);
     if (childrenEl->HasInsertedChildren()) {
--- a/dom/xbl/nsBindingManager.h
+++ b/dom/xbl/nsBindingManager.h
@@ -176,20 +176,19 @@ public:
   nsIContent* FindNestedSingleInsertionPoint(nsIContent* aContainer, bool* aMulti);
 
 protected:
   nsIXPConnectWrappedJS* GetWrappedJS(nsIContent* aContent);
   nsresult SetWrappedJS(nsIContent* aContent, nsIXPConnectWrappedJS* aResult);
 
   // Called by ContentAppended and ContentInserted to handle a single child
   // insertion.  aChild must not be null.  aContainer may be null.
-  // aIndexInContainer is the index of the child in the parent.  aAppend is
-  // true if this child is being appended, not inserted.
+  // aAppend is true if this child is being appended, not inserted.
   void HandleChildInsertion(nsIContent* aContainer, nsIContent* aChild,
-                            uint32_t aIndexInContainer, bool aAppend);
+                            bool aAppend);
 
   // Same as ProcessAttachedQueue, but also nulls out
   // mProcessAttachedQueueEvent
   void DoProcessAttachedQueue();
 
   // Post an event to process the attached queue.
   void PostProcessAttachedQueueEvent();
 
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -396,18 +396,17 @@ nsXMLContentSink::OnTransformDone(nsresu
   // 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,
                  "rootElement not in doc?");
     mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
-    nsNodeUtils::ContentInserted(mDocument, rootElement,
-                                 mDocument->IndexOf(rootElement));
+    nsNodeUtils::ContentInserted(mDocument, rootElement);
     mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
   }
 
   // Start the layout process
   StartLayout(false);
 
   ScrollToRef();
 
--- a/dom/xml/nsXMLPrettyPrinter.cpp
+++ b/dom/xml/nsXMLPrettyPrinter.cpp
@@ -222,36 +222,33 @@ nsXMLPrettyPrinter::AttributeChanged(nsI
                                      const nsAttrValue* aOldValue)
 {
     MaybeUnhook(aElement);
 }
 
 void
 nsXMLPrettyPrinter::ContentAppended(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aFirstNewContent,
-                                    int32_t aNewIndexInContainer)
+                                    nsIContent* aFirstNewContent)
 {
     MaybeUnhook(aContainer);
 }
 
 void
 nsXMLPrettyPrinter::ContentInserted(nsIDocument* aDocument,
                                     nsIContent* aContainer,
-                                    nsIContent* aChild,
-                                    int32_t aIndexInContainer)
+                                    nsIContent* aChild)
 {
     MaybeUnhook(aContainer);
 }
 
 void
 nsXMLPrettyPrinter::ContentRemoved(nsIDocument* aDocument,
                                    nsIContent* aContainer,
                                    nsIContent* aChild,
-                                   int32_t aIndexInContainer,
                                    nsIContent* aPreviousSibling)
 {
     MaybeUnhook(aContainer);
 }
 
 void
 nsXMLPrettyPrinter::NodeWillBeDestroyed(const nsINode* aNode)
 {
--- a/dom/xslt/xpath/XPathResult.cpp
+++ b/dom/xslt/xpath/XPathResult.cpp
@@ -139,36 +139,33 @@ XPathResult::AttributeChanged(nsIDocumen
                               const nsAttrValue* aOldValue)
 {
     Invalidate(aElement);
 }
 
 void
 XPathResult::ContentAppended(nsIDocument* aDocument,
                              nsIContent* aContainer,
-                             nsIContent* aFirstNewContent,
-                             int32_t aNewIndexInContainer)
+                             nsIContent* aFirstNewContent)
 {
     Invalidate(aContainer);
 }
 
 void
 XPathResult::ContentInserted(nsIDocument* aDocument,
                              nsIContent* aContainer,
-                             nsIContent* aChild,
-                             int32_t aIndexInContainer)
+                             nsIContent* aChild)
 {
     Invalidate(aContainer);
 }
 
 void
 XPathResult::ContentRemoved(nsIDocument* aDocument,
                             nsIContent* aContainer,
                             nsIContent* aChild,
-                            int32_t aIndexInContainer,
                             nsIContent* aPreviousSibling)
 {
     Invalidate(aContainer);
 }
 
 nsresult
 XPathResult::SetExprResult(txAExprResult* aExprResult, uint16_t aResultType,
                            nsINode* aContextNode)
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -1227,36 +1227,33 @@ txMozillaXSLTProcessor::AttributeChanged
                                          const nsAttrValue* aOldValue)
 {
     mStylesheet = nullptr;
 }
 
 void
 txMozillaXSLTProcessor::ContentAppended(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aFirstNewContent,
-                                        int32_t /* unused */)
+                                        nsIContent* aFirstNewContent)
 {
     mStylesheet = nullptr;
 }
 
 void
 txMozillaXSLTProcessor::ContentInserted(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aChild,
-                                        int32_t /* unused */)
+                                        nsIContent* aChild)
 {
     mStylesheet = nullptr;
 }
 
 void
 txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument,
                                        nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       int32_t aIndexInContainer,
                                        nsIContent* aPreviousSibling)
 {
     mStylesheet = nullptr;
 }
 
 /* virtual */ JSObject*
 txMozillaXSLTProcessor::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
--- a/dom/xul/XULDocument.cpp
+++ b/dom/xul/XULDocument.cpp
@@ -1044,18 +1044,17 @@ XULDocument::AttributeChanged(nsIDocumen
           kNameSpaceID_None,
           aAttribute));
     }
 }
 
 void
 XULDocument::ContentAppended(nsIDocument* aDocument,
                              nsIContent* aContainer,
-                             nsIContent* aFirstNewContent,
-                             int32_t aNewIndexInContainer)
+                             nsIContent* aFirstNewContent)
 {
     NS_ASSERTION(aDocument == this, "unexpected doc");
 
     // Might not need this, but be safe for now.
     nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
     // Update our element map
     nsresult rv = NS_OK;
@@ -1063,32 +1062,30 @@ XULDocument::ContentAppended(nsIDocument
          cur = cur->GetNextSibling()) {
         rv = AddSubtreeToDocument(cur);
     }
 }
 
 void
 XULDocument::ContentInserted(nsIDocument* aDocument,
                              nsIContent* aContainer,
-                             nsIContent* aChild,
-                             int32_t aIndexInContainer)
+                             nsIContent* aChild)
 {
     NS_ASSERTION(aDocument == this, "unexpected doc");
 
     // Might not need this, but be safe for now.
     nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
     AddSubtreeToDocument(aChild);
 }
 
 void
 XULDocument::ContentRemoved(nsIDocument* aDocument,
                             nsIContent* aContainer,
                             nsIContent* aChild,
-                            int32_t aIndexInContainer,
                             nsIContent* aPreviousSibling)
 {
     NS_ASSERTION(aDocument == this, "unexpected doc");
 
     // Might not need this, but be safe for now.
     nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
 
     RemoveSubtreeFromDocument(aChild);
--- a/dom/xul/templates/nsXULContentBuilder.cpp
+++ b/dom/xul/templates/nsXULContentBuilder.cpp
@@ -1035,18 +1035,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),
-                                     newIndexInContainer);
+                                     container->GetChildAt(newIndexInContainer));
     }
 
     NS_IF_RELEASE(container);
 
     return NS_OK;
 }
 
 nsresult
--- a/dom/xul/templates/nsXULTemplateBuilder.cpp
+++ b/dom/xul/templates/nsXULTemplateBuilder.cpp
@@ -1208,17 +1208,16 @@ nsXULTemplateBuilder::AttributeChanged(n
         }
     }
 }
 
 void
 nsXULTemplateBuilder::ContentRemoved(nsIDocument* aDocument,
                                      nsIContent* aContainer,
                                      nsIContent* aChild,
-                                     int32_t aIndexInContainer,
                                      nsIContent* aPreviousSibling)
 {
     if (mRoot && nsContentUtils::ContentIsDescendantOf(mRoot, aChild)) {
         RefPtr<nsXULTemplateBuilder> kungFuDeathGrip(this);
 
         if (mQueryProcessor)
             mQueryProcessor->Done();
 
--- a/editor/libeditor/HTMLAnonymousNodeEditor.cpp
+++ b/editor/libeditor/HTMLAnonymousNodeEditor.cpp
@@ -302,21 +302,18 @@ HTMLEditor::DeleteRefToAnonymousNode(Man
     if (docObserver) {
       // Call BeginUpdate() so that the nsCSSFrameConstructor/PresShell
       // knows we're messing with the frame tree.
       nsCOMPtr<nsIDocument> document = GetDocument();
       if (document) {
         docObserver->BeginUpdate(document, UPDATE_CONTENT_MODEL);
       }
 
-      // XXX This is wrong (bug 439258).  Once it's fixed, the NS_WARNING
-      // in RestyleManager::RestyleForRemove should be changed back
-      // to an assertion.
       docObserver->ContentRemoved(aContent->GetComposedDoc(),
-                                  parentContent, aContent, -1,
+                                  parentContent, aContent,
                                   aContent->GetPreviousSibling());
       if (document) {
         docObserver->EndUpdate(document, UPDATE_CONTENT_MODEL);
       }
     }
   }
 
   // The ManualNACPtr destructor will invoke UnbindFromTree.
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3128,31 +3128,27 @@ HTMLEditor::InsertTextImpl(const nsAStri
 
   return EditorBase::InsertTextImpl(aStringToInsert, aInOutNode, aInOutOffset,
                                     aDoc);
 }
 
 void
 HTMLEditor::ContentAppended(nsIDocument* aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aFirstNewContent,
-                            int32_t aIndexInContainer)
+                            nsIContent* aFirstNewContent)
 {
-  DoContentInserted(aDocument, aContainer, aFirstNewContent, aIndexInContainer,
-                    eAppended);
+  DoContentInserted(aDocument, aContainer, aFirstNewContent, eAppended);
 }
 
 void
 HTMLEditor::ContentInserted(nsIDocument* aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aChild,
-                            int32_t aIndexInContainer)
+                            nsIContent* aChild)
 {
-  DoContentInserted(aDocument, aContainer, aChild, aIndexInContainer,
-                    eInserted);
+  DoContentInserted(aDocument, aContainer, aChild, eInserted);
 }
 
 bool
 HTMLEditor::IsInObservedSubtree(nsIDocument* aDocument,
                                 nsIContent* aContainer,
                                 nsIContent* aChild)
 {
   if (!aChild) {
@@ -3170,17 +3166,16 @@ HTMLEditor::IsInObservedSubtree(nsIDocum
 
   return !aChild->ChromeOnlyAccess() && !aChild->GetBindingParent();
 }
 
 void
 HTMLEditor::DoContentInserted(nsIDocument* aDocument,
                               nsIContent* aContainer,
                               nsIContent* aChild,
-                              int32_t /* aIndexInContainer */,
                               InsertedOrAppended aInsertedOrAppended)
 {
   MOZ_ASSERT(aChild);
   nsINode* container = NODE_FROM(aContainer, aDocument);
   MOZ_ASSERT(container);
 
   if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
     return;
@@ -3221,17 +3216,16 @@ HTMLEditor::DoContentInserted(nsIDocumen
     }
   }
 }
 
 void
 HTMLEditor::ContentRemoved(nsIDocument* aDocument,
                            nsIContent* aContainer,
                            nsIContent* aChild,
-                           int32_t aIndexInContainer,
                            nsIContent* aPreviousSibling)
 {
   if (!IsInObservedSubtree(aDocument, aContainer, aChild)) {
     return;
   }
 
   // XXX Why do we need to do this?  This method is a mutation observer's
   //     method.  Therefore, the caller should guarantee that this won't be
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -1071,17 +1071,17 @@ private:
                               const nsAString* aAttribute,
                               const nsAString* aValue);
   nsresult SetInlinePropertyOnNodeImpl(nsIContent& aNode,
                                        nsIAtom& aProperty,
                                        const nsAString* aAttribute,
                                        const nsAString& aValue);
   typedef enum { eInserted, eAppended } InsertedOrAppended;
   void DoContentInserted(nsIDocument* aDocument, nsIContent* aContainer,
-                         nsIContent* aChild, int32_t aIndexInContainer,
+                         nsIContent* aChild,
                          InsertedOrAppended aInsertedOrAppended);
   already_AddRefed<Element> GetElementOrParentByTagName(
                               const nsAString& aTagName, nsINode* aNode);
   already_AddRefed<Element> CreateElementWithDefaults(
                               const nsAString& aTagName);
   /**
    * Returns an anonymous Element of type aTag,
    * child of aParentContent. If aIsCreatedHidden is true, the class
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -4349,18 +4349,17 @@ RealContainer(nsIDocument* aDocument, ns
     return aDocument;
   }
   return aContainer;
 }
 
 void
 PresShell::ContentAppended(nsIDocument *aDocument,
                            nsIContent* aContainer,
-                           nsIContent* aFirstNewContent,
-                           int32_t     aNewIndexInContainer)
+                           nsIContent* aFirstNewContent)
 {
   NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentAppended");
   NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
 
   // We never call ContentAppended with a document as the container, so we can
   // assert that we have an nsIContent container.
   MOZ_ASSERT(aContainer);
   MOZ_ASSERT(aContainer->IsElement() ||
@@ -4382,18 +4381,17 @@ PresShell::ContentAppended(nsIDocument *
       nsCSSFrameConstructor::InsertionKind::Async);
 
   VERIFY_STYLE_TREE;
 }
 
 void
 PresShell::ContentInserted(nsIDocument* aDocument,
                            nsIContent*  aMaybeContainer,
-                           nsIContent*  aChild,
-                           int32_t      aIndexInContainer)
+                           nsIContent*  aChild)
 {
   NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentInserted");
   NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
   nsINode* container = RealContainer(aDocument, aMaybeContainer, aChild);
 
   if (!mDidInitialize) {
     return;
   }
@@ -4418,17 +4416,16 @@ PresShell::ContentInserted(nsIDocument* 
 
   VERIFY_STYLE_TREE;
 }
 
 void
 PresShell::ContentRemoved(nsIDocument *aDocument,
                           nsIContent* aMaybeContainer,
                           nsIContent* aChild,
-                          int32_t     aIndexInContainer,
                           nsIContent* aPreviousSibling)
 {
   NS_PRECONDITION(!mIsDocumentGone, "Unexpected ContentRemoved");
   NS_PRECONDITION(aDocument == mDocument, "Unexpected aDocument");
   nsINode* container = RealContainer(aDocument, aMaybeContainer, aChild);
 
   // Notify the ESM that the content has been removed, so that
   // it can clean up any state related to the content.
@@ -4441,17 +4438,19 @@ PresShell::ContentRemoved(nsIDocument *a
   mPresContext->EventStateManager()
     ->ContentRemoved(aDocument, aMaybeContainer, aChild);
 
   nsAutoCauseReflowNotifier crNotifier(this);
 
   // Call this here so it only happens for real content mutations and
   // not cases when the frame constructor calls its own methods to force
   // frame reconstruction.
-  nsIContent* oldNextSibling = container->GetChildAt(aIndexInContainer);
+  nsIContent* oldNextSibling = nullptr;
+  oldNextSibling = aPreviousSibling ?
+    aPreviousSibling->GetNextSibling() : container->GetFirstChild();
 
   mPresContext->RestyleManager()->ContentRemoved(container, aChild, oldNextSibling);
 
   // After removing aChild from tree we should save information about live ancestor
   if (mPointerEventTarget) {
     MOZ_ASSERT(PointerEventHandler::IsPointerEventEnabled());
     if (nsContentUtils::ContentIsDescendantOf(mPointerEventTarget, aChild)) {
       mPointerEventTarget = aMaybeContainer;
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -1472,34 +1472,31 @@ nsTextControlFrame::nsAnonDivObserver::C
 {
   mFrame.ClearCachedValue();
 }
 
 void
 nsTextControlFrame::nsAnonDivObserver::ContentAppended(
   nsIDocument* aDocument,
   nsIContent* aContainer,
-  nsIContent* aFirstNewContent,
-  int32_t /* unused */)
+  nsIContent* aFirstNewContent)
 {
   mFrame.ClearCachedValue();
 }
 
 void
 nsTextControlFrame::nsAnonDivObserver::ContentInserted(
   nsIDocument* aDocument,
   nsIContent* aContainer,
-  nsIContent* aChild,
-  int32_t /* unused */)
+  nsIContent* aChild)
 {
   mFrame.ClearCachedValue();
 }
 
 void
 nsTextControlFrame::nsAnonDivObserver::ContentRemoved(
   nsIDocument* aDocument,
   nsIContent* aContainer,
   nsIContent* aChild,
-  int32_t aIndexInContainer,
   nsIContent* aPreviousSibling)
 {
   mFrame.ClearCachedValue();
 }
--- a/layout/generic/nsImageMap.cpp
+++ b/layout/generic/nsImageMap.cpp
@@ -919,36 +919,33 @@ nsImageMap::AttributeChanged(nsIDocument
     // ID or name has changed. Let ImageFrame recreate ImageMap.
     mImageFrame->DisconnectMap();
   }
 }
 
 void
 nsImageMap::ContentAppended(nsIDocument *aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aFirstNewContent,
-                            int32_t     /* unused */)
+                            nsIContent* aFirstNewContent)
 {
   MaybeUpdateAreas(aContainer);
 }
 
 void
 nsImageMap::ContentInserted(nsIDocument *aDocument,
                             nsIContent* aContainer,
-                            nsIContent* aChild,
-                            int32_t /* unused */)
+                            nsIContent* aChild)
 {
   MaybeUpdateAreas(aContainer);
 }
 
 void
 nsImageMap::ContentRemoved(nsIDocument *aDocument,
                            nsIContent* aContainer,
                            nsIContent* aChild,
-                           int32_t aIndexInContainer,
                            nsIContent* aPreviousSibling)
 {
   MaybeUpdateAreas(aContainer);
 }
 
 void
 nsImageMap::ParentChainChanged(nsIContent* aContent)
 {
--- a/layout/inspector/inDOMView.cpp
+++ b/layout/inspector/inDOMView.cpp
@@ -758,32 +758,31 @@ inDOMView::AttributeChanged(nsIDocument*
     }
 
  }
 }
 
 void
 inDOMView::ContentAppended(nsIDocument *aDocument,
                            nsIContent* aContainer,
-                           nsIContent* aFirstNewContent,
-                           int32_t /* unused */)
+                           nsIContent* aFirstNewContent)
 {
   if (!mTree) {
     return;
   }
 
   for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) {
     // Our ContentInserted impl doesn't use the index
-    ContentInserted(aDocument, aContainer, cur, 0);
+    ContentInserted(aDocument, aContainer, cur);
   }
 }
 
 void
 inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer,
-                           nsIContent* aChild, int32_t /* unused */)
+                           nsIContent* aChild)
 {
   if (!mTree)
     return;
 
   nsresult rv;
   nsCOMPtr<nsIDOMNode> childDOMNode(do_QueryInterface(aChild));
   nsCOMPtr<nsIDOMNode> parent;
   if (!mDOMUtils) {
@@ -854,18 +853,17 @@ inDOMView::ContentInserted(nsIDocument *
   // insert new node
   InsertNode(newNode, row);
 
   mTree->RowCountChanged(row, 1);
 }
 
 void
 inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,
-                          nsIContent* aChild, int32_t aIndexInContainer,
-                          nsIContent* aPreviousSibling)
+                          nsIContent* aChild, nsIContent* aPreviousSibling)
 {
   if (!mTree)
     return;
 
   nsresult rv;
 
   // find the inDOMViewNode for the old child
   nsCOMPtr<nsIDOMNode> oldDOMNode(do_QueryInterface(aChild));
--- a/layout/svg/SVGObserverUtils.cpp
+++ b/layout/svg/SVGObserverUtils.cpp
@@ -133,36 +133,33 @@ nsSVGRenderingObserver::AttributeChanged
   // surely that is unnecessary.
 
   DoUpdate();
 }
 
 void
 nsSVGRenderingObserver::ContentAppended(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aFirstNewContent,
-                                        int32_t /* unused */)
+                                        nsIContent* aFirstNewContent)
 {
   DoUpdate();
 }
 
 void
 nsSVGRenderingObserver::ContentInserted(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aChild,
-                                        int32_t /* unused */)
+                                        nsIContent* aChild)
 {
   DoUpdate();
 }
 
 void
 nsSVGRenderingObserver::ContentRemoved(nsIDocument* aDocument,
                                        nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       int32_t aIndexInContainer,
                                        nsIContent* aPreviousSibling)
 {
   DoUpdate();
 }
 
 /**
  * Note that in the current setup there are two separate observer lists.
  *
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -3333,38 +3333,35 @@ SVGTextFrame::ScheduleReflowSVGNonDispla
   PresContext()->PresShell()->FrameNeedsReflow(f, aReason, NS_FRAME_IS_DIRTY);
 }
 
 NS_IMPL_ISUPPORTS(SVGTextFrame::MutationObserver, nsIMutationObserver)
 
 void
 SVGTextFrame::MutationObserver::ContentAppended(nsIDocument* aDocument,
                                                 nsIContent* aContainer,
-                                                nsIContent* aFirstNewContent,
-                                                int32_t aNewIndexInContainer)
+                                                nsIContent* aFirstNewContent)
 {
   mFrame->NotifyGlyphMetricsChange();
 }
 
 void
 SVGTextFrame::MutationObserver::ContentInserted(
                                         nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aChild,
-                                        int32_t aIndexInContainer)
+                                        nsIContent* aChild)
 {
   mFrame->NotifyGlyphMetricsChange();
 }
 
 void
 SVGTextFrame::MutationObserver::ContentRemoved(
                                        nsIDocument *aDocument,
                                        nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       int32_t aIndexInContainer,
                                        nsIContent* aPreviousSibling)
 {
   mFrame->NotifyGlyphMetricsChange();
 }
 
 void
 SVGTextFrame::MutationObserver::CharacterDataChanged(
                                                  nsIDocument* aDocument,
--- a/layout/xul/tree/nsTreeContentView.cpp
+++ b/layout/xul/tree/nsTreeContentView.cpp
@@ -1090,30 +1090,28 @@ nsTreeContentView::AttributeChanged(nsID
       }
     }
   }
 }
 
 void
 nsTreeContentView::ContentAppended(nsIDocument *aDocument,
                                    nsIContent* aContainer,
-                                   nsIContent* aFirstNewContent,
-                                   int32_t     /* unused */)
+                                   nsIContent* aFirstNewContent)
 {
   for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) {
     // Our contentinserted doesn't use the index
-    ContentInserted(aDocument, aContainer, cur, 0);
+    ContentInserted(aDocument, aContainer, cur);
   }
 }
 
 void
 nsTreeContentView::ContentInserted(nsIDocument *aDocument,
                                    nsIContent* aContainer,
-                                   nsIContent* aChild,
-                                   int32_t /* unused */)
+                                   nsIContent* aChild)
 {
   NS_ASSERTION(aChild, "null ptr");
 
   // Make sure this notification concerns us.
   // First check the tag to see if it's one that we care about.
 
   // Don't allow non-XUL nodes.
   if (!aChild->IsXULElement() || !aContainer->IsXULElement())
@@ -1172,17 +1170,16 @@ nsTreeContentView::ContentInserted(nsIDo
     }
   }
 }
 
 void
 nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
                                   nsIContent* aContainer,
                                   nsIContent* aChild,
-                                  int32_t aIndexInContainer,
                                   nsIContent* aPreviousSibling)
 {
   NS_ASSERTION(aChild, "null ptr");
 
   // Make sure this notification concerns us.
   // First check the tag to see if it's one that we care about.
 
   // We don't consider non-XUL nodes.
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -174,44 +174,42 @@ nsHtml5TreeOperation::Append(nsIContent*
                              nsIContent* aParent,
                              nsHtml5DocumentBuilder* aBuilder)
 {
   MOZ_ASSERT(aBuilder);
   MOZ_ASSERT(aBuilder->IsInDocUpdate());
   nsresult rv = NS_OK;
   nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
                                aBuilder->GetDocument());
-  uint32_t childCount = aParent->GetChildCount();
   rv = aParent->AppendChildTo(aNode, false);
   if (NS_SUCCEEDED(rv)) {
     aNode->SetParserHasNotified();
-    nsNodeUtils::ContentAppended(aParent, aNode, childCount);
+    nsNodeUtils::ContentAppended(aParent, aNode);
   }
   return rv;
 }
 
 nsresult
 nsHtml5TreeOperation::AppendToDocument(nsIContent* aNode,
                                        nsHtml5DocumentBuilder* aBuilder)
 {
   MOZ_ASSERT(aBuilder);
   MOZ_ASSERT(aBuilder->GetDocument() == aNode->OwnerDoc());
   MOZ_ASSERT(aBuilder->IsInDocUpdate());
   nsresult rv = NS_OK;
 
   nsIDocument* doc = aBuilder->GetDocument();
-  uint32_t childCount = doc->GetChildCount();
   rv = doc->AppendChildTo(aNode, false);
   if (rv == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR) {
     aNode->SetParserHasNotified();
     return NS_OK;
   }
   NS_ENSURE_SUCCESS(rv, rv);
   aNode->SetParserHasNotified();
-  nsNodeUtils::ContentInserted(doc, aNode, childCount);
+  nsNodeUtils::ContentInserted(doc, aNode);
 
   NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
                "Someone forgot to block scripts");
   if (aNode->IsElement()) {
     nsContentUtils::AddScriptRunner(
         new nsDocElementCreatedNotificationRunner(doc));
   }
   return rv;
@@ -255,28 +253,26 @@ nsHtml5TreeOperation::AppendChildrenToNe
                                                 nsIContent* aParent,
                                                 nsHtml5DocumentBuilder* aBuilder)
 {
   MOZ_ASSERT(aBuilder);
   MOZ_ASSERT(aBuilder->IsInDocUpdate());
   nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
                                aBuilder->GetDocument());
 
-  uint32_t childCount = aParent->GetChildCount();
   bool didAppend = false;
   while (aNode->HasChildren()) {
     nsCOMPtr<nsIContent> child = aNode->GetFirstChild();
     aNode->RemoveChildAt(0, true);
     nsresult rv = aParent->AppendChildTo(child, false);
     NS_ENSURE_SUCCESS(rv, rv);
     didAppend = true;
   }
   if (didAppend) {
-    nsNodeUtils::ContentAppended(aParent, aParent->GetChildAt(childCount),
-                                 childCount);
+    nsNodeUtils::ContentAppended(aParent, aParent->GetLastChild());
   }
   return NS_OK;
 }
 
 nsresult
 nsHtml5TreeOperation::FosterParent(nsIContent* aNode,
                                    nsIContent* aParent,
                                    nsIContent* aTable,
@@ -289,17 +285,17 @@ nsHtml5TreeOperation::FosterParent(nsICo
   if (IsElementOrTemplateContent(foster)) {
 
     nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
                                  aBuilder->GetDocument());
 
     uint32_t pos = foster->IndexOf(aTable);
     nsresult rv = foster->InsertChildAt(aNode, pos, false);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsNodeUtils::ContentInserted(foster, aNode, pos);
+    nsNodeUtils::ContentInserted(foster, aNode);
     return rv;
   }
 
   return Append(aNode, aParent, aBuilder);
 }
 
 nsresult
 nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
@@ -629,17 +625,17 @@ nsHtml5TreeOperation::FosterParentText(n
     nsNodeInfoManager* nodeInfoManager = aStackParent->OwnerDoc()->NodeInfoManager();
     RefPtr<nsTextNode> text = new nsTextNode(nodeInfoManager);
     NS_ASSERTION(text, "Infallible malloc failed?");
     rv = text->SetText(aBuffer, aLength, false);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = foster->InsertChildAt(text, pos, false);
     NS_ENSURE_SUCCESS(rv, rv);
-    nsNodeUtils::ContentInserted(foster, text, pos);
+    nsNodeUtils::ContentInserted(foster, text);
     return rv;
   }
 
   return AppendText(aBuffer, aLength, aStackParent, aBuilder);
 }
 
 nsresult
 nsHtml5TreeOperation::AppendComment(nsIContent* aParent,
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -165,40 +165,37 @@ nsFormFillController::AttributeChanged(n
   if (mListNode && mListNode->Contains(aElement)) {
     RevalidateDataList();
   }
 }
 
 void
 nsFormFillController::ContentAppended(nsIDocument* aDocument,
                                       nsIContent* aContainer,
-                                      nsIContent* aChild,
-                                      int32_t aIndexInContainer)
+                                      nsIContent* aChild)
 {
   if (mListNode && mListNode->Contains(aContainer)) {
     RevalidateDataList();
   }
 }
 
 void
 nsFormFillController::ContentInserted(nsIDocument* aDocument,
                                       nsIContent* aContainer,
-                                      nsIContent* aChild,
-                                      int32_t aIndexInContainer)
+                                      nsIContent* aChild)
 {
   if (mListNode && mListNode->Contains(aContainer)) {
     RevalidateDataList();
   }
 }
 
 void
 nsFormFillController::ContentRemoved(nsIDocument* aDocument,
                                      nsIContent* aContainer,
                                      nsIContent* aChild,
-                                     int32_t aIndexInContainer,
                                      nsIContent* aPreviousSibling)
 {
   if (mListNode && mListNode->Contains(aContainer)) {
     RevalidateDataList();
   }
 }
 
 void
--- a/widget/cocoa/nsChangeObserver.h
+++ b/widget/cocoa/nsChangeObserver.h
@@ -7,19 +7,20 @@
 #ifndef nsChangeObserver_h_
 #define nsChangeObserver_h_
 
 class nsIContent;
 class nsIDocument;
 class nsIAtom;
 
 #define NS_DECL_CHANGEOBSERVER \
-void ObserveAttributeChanged(nsIDocument *aDocument, nsIContent *aContent, nsIAtom *aAttribute) override; \
-void ObserveContentRemoved(nsIDocument *aDocument, nsIContent *aChild, int32_t aIndexInContainer) override; \
-void ObserveContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsIContent *aChild) override;
+void ObserveAttributeChanged(nsIDocument* aDocument, nsIContent* aContent, nsIAtom* aAttribute) override; \
+void ObserveContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, \
+                           nsIContent* aChild, nsIContent* aPreviousChild) override; \
+void ObserveContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild) override;
 
 // Something that wants to be alerted to changes in attributes or changes in
 // its corresponding content object.
 //
 // This interface is used by our menu code so we only have to have one
 // nsIDocumentObserver.
 //
 // Any class that implements this interface must take care to unregister itself
@@ -28,17 +29,18 @@ class nsChangeObserver
 {
 public:
   // XXX use dom::Element
   virtual void ObserveAttributeChanged(nsIDocument* aDocument,
                                        nsIContent* aContent,
                                        nsIAtom* aAttribute)=0;
 
   virtual void ObserveContentRemoved(nsIDocument* aDocument,
-                                     nsIContent* aChild, 
-                                     int32_t aIndexInContainer)=0;
+                                     nsIContent* aContainer,
+                                     nsIContent* aChild,
+                                     nsIContent* aPreviousSibling)=0;
 
   virtual void ObserveContentInserted(nsIDocument* aDocument,
                                       nsIContent* aContainer,
                                       nsIContent* aChild)=0;
 };
 
 #endif // nsChangeObserver_h_
--- a/widget/cocoa/nsMenuBarX.mm
+++ b/widget/cocoa/nsMenuBarX.mm
@@ -304,20 +304,24 @@ void nsMenuBarX::RemoveMenuAtIndex(uint3
 
 void nsMenuBarX::ObserveAttributeChanged(nsIDocument* aDocument,
                                          nsIContent* aContent,
                                          nsIAtom* aAttribute)
 {
 }
 
 void nsMenuBarX::ObserveContentRemoved(nsIDocument* aDocument,
+                                       nsIContent* aContainer,
                                        nsIContent* aChild,
-                                       int32_t aIndexInContainer)
+                                       nsIContent* aPreviousSibling)
 {
-  RemoveMenuAtIndex(aIndexInContainer);
+  nsINode* parent = NODE_FROM(aContainer, aDocument);
+  MOZ_ASSERT(parent);
+  int32_t index = parent->IndexOf(aPreviousSibling) + 1;
+  RemoveMenuAtIndex(index);
 }
 
 void nsMenuBarX::ObserveContentInserted(nsIDocument* aDocument,
                                         nsIContent* aContainer,
                                         nsIContent* aChild)
 {
   nsMenuX* newMenu = new nsMenuX();
   if (newMenu) {
--- a/widget/cocoa/nsMenuGroupOwnerX.mm
+++ b/widget/cocoa/nsMenuGroupOwnerX.mm
@@ -78,21 +78,20 @@ void nsMenuGroupOwnerX::CharacterDataCha
                                              nsIContent* aContent,
                                              CharacterDataChangeInfo* aInfo)
 {
 }
 
 
 void nsMenuGroupOwnerX::ContentAppended(nsIDocument* aDocument,
                                         nsIContent* aContainer,
-                                        nsIContent* aFirstNewContent,
-                                        int32_t /* unused */)
+                                        nsIContent* aFirstNewContent)
 {
   for (nsIContent* cur = aFirstNewContent; cur; cur = cur->GetNextSibling()) {
-    ContentInserted(aDocument, aContainer, cur, 0);
+    ContentInserted(aDocument, aContainer, cur);
   }
 }
 
 
 void nsMenuGroupOwnerX::NodeWillBeDestroyed(const nsINode * aNode)
 {
 }
 
@@ -124,45 +123,43 @@ void nsMenuGroupOwnerX::AttributeChanged
   if (obs)
     obs->ObserveAttributeChanged(aDocument, aElement, aAttribute);
 }
 
 
 void nsMenuGroupOwnerX::ContentRemoved(nsIDocument * aDocument,
                                        nsIContent * aContainer,
                                        nsIContent * aChild,
-                                       int32_t aIndexInContainer,
                                        nsIContent * aPreviousSibling)
 {
   if (!aContainer) {
     return;
   }
 
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
   nsChangeObserver* obs = LookupContentChangeObserver(aContainer);
   if (obs)
-    obs->ObserveContentRemoved(aDocument, aChild, aIndexInContainer);
+    obs->ObserveContentRemoved(aDocument, aContainer, aChild, aPreviousSibling);
   else if (aContainer != mContent) {
     // We do a lookup on the parent container in case things were removed
     // under a "menupopup" item. That is basically a wrapper for the contents
     // of a "menu" node.
     nsCOMPtr<nsIContent> parent = aContainer->GetParent();
     if (parent) {
       obs = LookupContentChangeObserver(parent);
       if (obs)
-        obs->ObserveContentRemoved(aDocument, aChild, aIndexInContainer);
+        obs->ObserveContentRemoved(aDocument, aContainer, aChild, aPreviousSibling);
     }
   }
 }
 
 
 void nsMenuGroupOwnerX::ContentInserted(nsIDocument * aDocument,
                                         nsIContent * aContainer,
-                                        nsIContent * aChild,
-                                        int32_t /* unused */)
+                                        nsIContent * aChild)
 {
   if (!aContainer) {
     return;
   }
 
   nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
   nsChangeObserver* obs = LookupContentChangeObserver(aContainer);
   if (obs)
--- a/widget/cocoa/nsMenuItemX.mm
+++ b/widget/cocoa/nsMenuItemX.mm
@@ -341,17 +341,20 @@ nsMenuItemX::ObserveAttributeChanged(nsI
       else
         [mNativeMenuItem setEnabled:YES];
     }
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-void nsMenuItemX::ObserveContentRemoved(nsIDocument *aDocument, nsIContent *aChild, int32_t aIndexInContainer)
+void nsMenuItemX::ObserveContentRemoved(nsIDocument* aDocument,
+                                        nsIContent* aContainer,
+                                        nsIContent* aChild,
+                                        nsIContent* aPreviousSibling)
 {
   if (aChild == mCommandContent) {
     mMenuGroupOwner->UnregisterForContentChanges(mCommandContent);
     mCommandContent = nullptr;
   }
 
   mMenuParent->SetRebuild(true);
 }
--- a/widget/cocoa/nsMenuX.mm
+++ b/widget/cocoa/nsMenuX.mm
@@ -756,18 +756,20 @@ void nsMenuX::ObserveAttributeChanged(ns
   }
   else if (aAttribute == nsGkAtoms::image) {
     SetupIcon();
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
-void nsMenuX::ObserveContentRemoved(nsIDocument *aDocument, nsIContent *aChild,
-                                    int32_t aIndexInContainer)
+void nsMenuX::ObserveContentRemoved(nsIDocument* aDocument,
+                                    nsIContent* aContainer,
+                                    nsIContent* aChild,
+                                    nsIContent* aPreviousSibling)
 {
   if (gConstructingMenu)
     return;
 
   SetRebuild(true);
   mMenuGroupOwner->UnregisterForContentChanges(aChild);
 }