diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index 283dcce8d776..b4534b13e7ea 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -3603,8 +3603,7 @@ XULDocument::OverlayForwardReference::Merge(Element* aTargetElement, if (attr == nsGkAtoms::removeelement && value.EqualsLiteral("true")) { nsCOMPtr parent = aTargetElement->GetParentNode(); if (!parent) return NS_ERROR_FAILURE; - rv = RemoveElement(parent, aTargetElement); - if (NS_FAILED(rv)) return rv; + parent->RemoveChildNode(aTargetElement, true); return NS_OK; } @@ -3671,13 +3670,19 @@ XULDocument::OverlayForwardReference::Merge(Element* aTargetElement, // non-null ID. rv = Merge(elementInDocument, currContent->AsElement(), aNotify); if (NS_FAILED(rv)) return rv; - aOverlayElement->RemoveChildAt_Deprecated(0, false); + nsIContent* firstChild = aOverlayElement->GetFirstChild(); + if (firstChild) { + aOverlayElement->RemoveChildNode(firstChild, false); + } continue; } } - aOverlayElement->RemoveChildAt_Deprecated(0, false); + nsIContent* firstChild = aOverlayElement->GetFirstChild(); + if (firstChild) { + aOverlayElement->RemoveChildNode(firstChild, false); + } rv = InsertElement(aTargetElement, currContent, aNotify); if (NS_FAILED(rv)) return rv; @@ -4037,15 +4042,6 @@ XULDocument::InsertElement(nsINode* aParent, nsIContent* aChild, bool aNotify) return NS_OK; } -nsresult -XULDocument::RemoveElement(nsINode* aParent, nsINode* aChild) -{ - int32_t nodeOffset = aParent->ComputeIndexOf(aChild); - - aParent->RemoveChildAt_Deprecated(nodeOffset, true); - return NS_OK; -} - //---------------------------------------------------------------------- // // CachedChromeStreamListener diff --git a/dom/xul/XULDocument.h b/dom/xul/XULDocument.h index 49384924aa12..1c57012e41c6 100644 --- a/dom/xul/XULDocument.h +++ b/dom/xul/XULDocument.h @@ -524,10 +524,6 @@ protected: nsresult InsertElement(nsINode* aParent, nsIContent* aChild, bool aNotify); - static - nsresult - RemoveElement(nsINode* aParent, nsINode* aChild); - /** * The current prototype that we are walking to construct the * content model.