diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index ae9511c71fe..6df7f051e4a 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -180,18 +180,6 @@ public: virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument) = 0; - /** - * Remove a child and replace it with another. - * - * @param aKid the content to replace with - * @param aIndex the index of the content to replace - * @param aNotify whether to notify the document that the replace has - * occurred - * @param aDeepSetDocument whether to set document on all children of aKid - */ - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) = 0; - /** * Append a content node to the end of the child list. * diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 6dc762b3dcb..9d4f8fa3974 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -492,10 +492,6 @@ public: virtual void ContentInserted(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) = 0; - virtual void ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) = 0; virtual void ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) = 0; diff --git a/mozilla/content/base/public/nsIDocumentObserver.h b/mozilla/content/base/public/nsIDocumentObserver.h index 6281a8e9540..824bc8a8b11 100644 --- a/mozilla/content/base/public/nsIDocumentObserver.h +++ b/mozilla/content/base/public/nsIDocumentObserver.h @@ -202,26 +202,6 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer) = 0; - /** - * Notification that content has been replaced. This method is called - * automatically by the content container objects when a content object - * is replaced in the container (therefore there is normally no need to - * invoke this method directly). The notification is passed on to all - * of the document observers. - * - * @param aDocument The document being observed - * @param aContainer the container that now contains aChild - * @param aOldChild the child that was replaced - * @param aNewChild the child that replaced aOldChild - * @param aIndexInContainer the index of the old and new child in the - * container - */ - virtual void ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) = 0; - /** * Content has just been removed. This method is called automatically * by content container objects when a content object has just been @@ -376,11 +356,6 @@ public: nsIContent* aContainer, \ nsIContent* aChild, \ PRInt32 aIndexInContainer); \ - virtual void ContentReplaced(nsIDocument* aDocument, \ - nsIContent* aContainer, \ - nsIContent* aOldChild, \ - nsIContent* aNewChild, \ - PRInt32 aIndexInContainer); \ virtual void ContentRemoved(nsIDocument* aDocument, \ nsIContent* aContainer, \ nsIContent* aChild, \ @@ -479,14 +454,6 @@ _class::ContentInserted(nsIDocument* aDocument, \ { \ } \ void \ -_class::ContentReplaced(nsIDocument* aDocument, \ - nsIContent* aContainer, \ - nsIContent* aOldChild, \ - nsIContent* aNewChild, \ - PRInt32 aIndexInContainer) \ -{ \ -} \ -void \ _class::ContentRemoved(nsIDocument* aDocument, \ nsIContent* aContainer, \ nsIContent* aChild, \ diff --git a/mozilla/content/base/src/nsAttrAndChildArray.cpp b/mozilla/content/base/src/nsAttrAndChildArray.cpp index c52ac40ca55..d9c582dc19e 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.cpp +++ b/mozilla/content/base/src/nsAttrAndChildArray.cpp @@ -161,19 +161,6 @@ nsAttrAndChildArray::RemoveChildAt(PRUint32 aPos) SetChildCount(childCount - 1); } -void -nsAttrAndChildArray::ReplaceChildAt(nsIContent* aChild, PRUint32 aPos) -{ - NS_ASSERTION(aPos < ChildCount(), "out-of-bounds"); - void** pos = mImpl->mBuffer + AttrSlotsSize() + aPos; - nsIContent* child = NS_STATIC_CAST(nsIContent*, *pos); - *pos = aChild; - - // Make sure to addref first, in case aChild == child - NS_ADDREF(aChild); - NS_RELEASE(child); -} - PRInt32 nsAttrAndChildArray::IndexOfChild(nsIContent* aPossibleChild) const { diff --git a/mozilla/content/base/src/nsAttrAndChildArray.h b/mozilla/content/base/src/nsAttrAndChildArray.h index 20fb7ae9c76..9488e562a17 100644 --- a/mozilla/content/base/src/nsAttrAndChildArray.h +++ b/mozilla/content/base/src/nsAttrAndChildArray.h @@ -88,7 +88,6 @@ public: } nsresult InsertChildAt(nsIContent* aChild, PRUint32 aPos); void RemoveChildAt(PRUint32 aPos); - void ReplaceChildAt(nsIContent* aChild, PRUint32 aPos); PRInt32 IndexOfChild(nsIContent* aPossibleChild) const; PRUint32 AttrCount() const; diff --git a/mozilla/content/base/src/nsContentList.cpp b/mozilla/content/base/src/nsContentList.cpp index 219595421ef..74388fbedbf 100644 --- a/mozilla/content/base/src/nsContentList.cpp +++ b/mozilla/content/base/src/nsContentList.cpp @@ -614,26 +614,6 @@ nsContentList::ContentInserted(nsIDocument *aDocument, mState = LIST_DIRTY; } -void -nsContentList::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - if (mState == LIST_DIRTY) - return; - - if (IsDescendantOfRoot(aContainer)) { - if (MatchSelf(aOldChild) || MatchSelf(aNewChild)) { - mState = LIST_DIRTY; - } - } - else if (ContainsRoot(aOldChild)) { - DisconnectFromDocument(); - } -} - void nsContentList::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/content/base/src/nsContentList.h b/mozilla/content/base/src/nsContentList.h index 9367038e64f..f01cb5f732d 100644 --- a/mozilla/content/base/src/nsContentList.h +++ b/mozilla/content/base/src/nsContentList.h @@ -183,9 +183,6 @@ public: PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument *aDocument, nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); virtual void DocumentWillBeDestroyed(nsIDocument *aDocument); diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 3fd12f1769e..33c2bb21f8c 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -1945,23 +1945,6 @@ nsDocument::ContentInserted(nsIContent* aContainer, nsIContent* aChild, } } -void -nsDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, - nsIContent* aNewChild, PRInt32 aIndexInContainer) -{ - NS_ABORT_IF_FALSE(aOldChild && aNewChild, "Null old or new child child!"); - - PRInt32 i; - // XXXdwh There is a hacky ordering dependency between the binding - // manager and the frame constructor that forces us to walk the - // observer list in a reverse order - for (i = mObservers.Count() - 1; i >= 0; --i) { - nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i]; - observer->ContentReplaced(this, aContainer, aOldChild, aNewChild, - aIndexInContainer); - } -} - void nsDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index 7f96a685d71..f9b75251be2 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -385,10 +385,6 @@ public: virtual void ContentInserted(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 7c0ca069714..81cfcd7b80b 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -820,13 +820,6 @@ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, return NS_OK; } -nsresult -nsGenericDOMDataNode::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - return NS_OK; -} - nsresult nsGenericDOMDataNode::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 3df9151b33e..12984f19a8e 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -218,8 +218,6 @@ public: virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const; virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 9b70e0e3fd9..84d94c7f6ae 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2505,44 +2505,6 @@ nsGenericElement::InsertChildAt(nsIContent* aKid, return NS_OK; } -nsresult -nsGenericElement::ReplaceChildAt(nsIContent* aKid, - PRUint32 aIndex, - PRBool aNotify, - PRBool aDeepSetDocument) -{ - NS_PRECONDITION(aKid, "null ptr"); - nsCOMPtr oldKid = GetChildAt(aIndex); - mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify); - - nsRange::OwnerChildReplaced(this, aIndex, oldKid); - mAttrsAndChildren.ReplaceChildAt(aKid, aIndex); - - aKid->SetParent(this); - - if (mDocument) { - aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE); - if (aNotify) { - mDocument->ContentReplaced(this, oldKid, aKid, aIndex); - } - if (HasMutationListeners(this, NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) { - nsMutationEvent mutation(NS_MUTATION_SUBTREEMODIFIED, this); - mutation.mRelatedNode = do_QueryInterface(oldKid); - - nsEventStatus status = nsEventStatus_eIgnore; - HandleDOMEvent(nsnull, &mutation, nsnull, - NS_EVENT_FLAG_INIT, &status); - } - } - - if (oldKid) { - oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); - oldKid->SetParent(nsnull); - } - - return NS_OK; -} - nsresult nsGenericElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) @@ -2884,18 +2846,11 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, nsresult res = NS_OK; PRInt32 oldPos = 0; - nsCOMPtr oldContent(do_QueryInterface(aOldChild, &res)); - - if (NS_FAILED(res)) { - /* - * If aOldChild doesn't support the nsIContent interface it can't be - * an existing child of this node. - */ - return NS_ERROR_DOM_NOT_FOUND_ERR; - } + nsCOMPtr oldContent = do_QueryInterface(aOldChild); + // if oldContent is null IndexOf will return < 0, which is what we want + // since aOldChild couldn't be a child. oldPos = aElement->IndexOf(oldContent); - if (oldPos < 0) { return NS_ERROR_DOM_NOT_FOUND_ERR; } @@ -2933,8 +2888,10 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } + nsIDocument* elemDoc = aElement->GetDocument(); + nsCOMPtr old_doc = newContent->GetDocument(); - if (old_doc && old_doc != aElement->GetDocument() && + if (old_doc && old_doc != elemDoc && !nsContentUtils::CanCallerAccess(aNewChild)) { return NS_ERROR_DOM_SECURITY_ERR; } @@ -2948,6 +2905,9 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } + // We're ready to start inserting children, so let's start a batch + mozAutoDocUpdate updateBatch(elemDoc, UPDATE_CONTENT_MODEL, PR_TRUE); + /* * Check if this is a document fragment. If it is, we need * to remove the children of the document fragment and add them @@ -2956,6 +2916,8 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, if (nodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) { nsCOMPtr childContent; PRUint32 i, count = newContent->GetChildCount(); + res = aElement->RemoveChildAt(oldPos, PR_TRUE); + NS_ENSURE_SUCCESS(res, res); /* * Iterate through the fragments children, removing each from @@ -2966,33 +2928,19 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, // Always get and remove the first child, since the child indexes // change as we go along. childContent = newContent->GetChildAt(0); - res = newContent->RemoveChildAt(0, PR_FALSE); - - if (NS_FAILED(res)) { - return res; - } + NS_ENSURE_SUCCESS(res, res); // Insert the child and increment the insertion position - if (i) { - res = aElement->InsertChildAt(childContent, oldPos++, PR_TRUE, - PR_TRUE); - } else { - res = aElement->ReplaceChildAt(childContent, oldPos++, PR_TRUE, - PR_TRUE); - } - - if (NS_FAILED(res)) { - return res; - } + res = aElement->InsertChildAt(childContent, oldPos++, PR_TRUE, + PR_TRUE); + NS_ENSURE_SUCCESS(res, res); } - } else { + } + else { nsCOMPtr oldParent; res = aNewChild->GetParentNode(getter_AddRefs(oldParent)); - - if (NS_FAILED(res)) { - return res; - } + NS_ENSURE_SUCCESS(res, res); /* * Remove the element from the old parent if one exists, since oldParent @@ -3001,13 +2949,12 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, * new child is alleady a child of this node-- jst@citec.fi */ if (oldParent) { - nsCOMPtr tmpNode; - PRUint32 origChildCount = aElement->GetChildCount(); /* * We don't care here if the return fails or not. */ + nsCOMPtr tmpNode; oldParent->RemoveChild(aNewChild, getter_AddRefs(tmpNode)); PRUint32 newChildCount = aElement->GetChildCount(); @@ -3035,21 +2982,15 @@ nsGenericElement::doReplaceChild(nsIContent* aElement, nsIDOMNode* aNewChild, aElement->GetDocument(), old_doc); } - if (aNewChild == aOldChild) { - // We're replacing a child with itself. In this case the child - // has already been removed from this element once we get here - // so we can't call ReplaceChildAt() (since aOldChild is no - // longer at oldPos). In stead we'll call InsertChildAt() to put - // the child back where it was. - - res = aElement->InsertChildAt(newContent, oldPos, PR_TRUE, PR_TRUE); - } else { - res = aElement->ReplaceChildAt(newContent, oldPos, PR_TRUE, PR_TRUE); + // If we're replacing a child with itself the child + // has already been removed from this element once we get here. + if (aNewChild != aOldChild) { + res = aElement->RemoveChildAt(oldPos, PR_TRUE); + NS_ENSURE_SUCCESS(res, res); } - if (NS_FAILED(res)) { - return res; - } + res = aElement->InsertChildAt(newContent, oldPos, PR_TRUE, PR_TRUE); + NS_ENSURE_SUCCESS(res, res); } return CallQueryInterface(replacedChild, aReturn); diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 86b306b5663..6460fea9208 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -376,8 +376,6 @@ public: virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const; virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); diff --git a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp index a9dee0550d5..b7a00c120ce 100644 --- a/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptGroupElement.cpp @@ -77,8 +77,6 @@ public: // nsIContent virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); @@ -254,21 +252,6 @@ nsHTMLOptGroupElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, aDeepSetDocument); } -nsresult -nsHTMLOptGroupElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - nsCOMPtr sel; - GetSelect(getter_AddRefs(sel)); - if (sel) { - sel->WillRemoveOptions(this, aIndex); - sel->WillAddOptions(aKid, this, aIndex); - } - - return nsGenericHTMLElement::ReplaceChildAt(aKid, aIndex, aNotify, - aDeepSetDocument); -} - nsresult nsHTMLOptGroupElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index 9d5f4ba1c96..74ac533e2fc 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -124,8 +124,6 @@ public: PRBool aNotify); virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); @@ -532,16 +530,6 @@ nsHTMLOptionElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, return rv; } -nsresult -nsHTMLOptionElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - nsresult rv = nsGenericHTMLElement::ReplaceChildAt(aKid, aIndex, aNotify, - aDeepSetDocument); - NotifyTextChanged(); - return rv; -} - nsresult nsHTMLOptionElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) { diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 67ec5c072d3..04f26512c28 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -214,8 +214,6 @@ public: // nsIContent virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); @@ -546,17 +544,6 @@ nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, aDeepSetDocument); } -nsresult -nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - WillRemoveOptions(this, aIndex); - WillAddOptions(aKid, this, aIndex); - - return nsGenericHTMLFormElement::ReplaceChildAt(aKid, aIndex, aNotify, - aDeepSetDocument); -} - nsresult nsHTMLSelectElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) { diff --git a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp index 7d28dd14192..769798a6882 100644 --- a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp @@ -78,8 +78,6 @@ public: virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); @@ -237,20 +235,6 @@ nsHTMLStyleElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, return rv; } -nsresult -nsHTMLStyleElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - nsresult rv = - nsGenericHTMLElement::ReplaceChildAt(aKid, aIndex, aNotify, - aDeepSetDocument); - if (NS_SUCCEEDED(rv)) { - UpdateStyleSheet(); - } - - return rv; -} - nsresult nsHTMLStyleElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) diff --git a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp index 16a7b604ac6..3b47fa4b18b 100644 --- a/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -120,8 +120,6 @@ public: // nsIContent virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); @@ -531,19 +529,6 @@ nsHTMLTextAreaElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, return rv; } -nsresult -nsHTMLTextAreaElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument) -{ - nsresult rv; - rv = nsGenericHTMLFormElement::ReplaceChildAt(aKid, aIndex, aNotify, - aDeepSetDocument); - if (!mValueChanged) { - Reset(); - } - return rv; -} - nsresult nsHTMLTextAreaElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 457aa7a6695..5af446e6d77 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -1234,29 +1234,6 @@ nsHTMLDocument::ContentInserted(nsIContent* aContainer, nsIContent* aContent, nsDocument::ContentInserted(aContainer, aContent, aIndexInContainer); } -void -nsHTMLDocument::ContentReplaced(nsIContent* aContainer, nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - NS_ABORT_IF_FALSE(aOldChild && aNewChild, "Null new or old child!"); - - nsresult rv = UnregisterNamedItems(aOldChild); - - if (NS_FAILED(rv)) { - return; - } - - rv = RegisterNamedItems(aNewChild); - - if (NS_FAILED(rv)) { - return; - } - - nsDocument::ContentReplaced(aContainer, aOldChild, - aNewChild, aIndexInContainer); -} - void nsHTMLDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aContent, PRInt32 aIndexInContainer) diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 3b8a6d163f0..425358008b2 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -125,10 +125,6 @@ public: virtual void ContentInserted(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 8ae5fedd59f..cbf675e7d82 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -375,11 +375,6 @@ public: nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); protected: nsresult GetXBLChildNodesInternal(nsIContent* aContent, @@ -1481,16 +1476,6 @@ nsBindingManager::ContentRemoved(nsIDocument* aDocument, } } -void nsBindingManager::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - ContentRemoved(aDocument, aContainer, aOldChild, aIndexInContainer); - ContentInserted(aDocument, aContainer, aNewChild, aIndexInContainer); -} - // Creation Routine /////////////////////////////////////////////////////////////////////// diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp index c9c85eeda2f..6a4030d456c 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.cpp @@ -271,16 +271,6 @@ nsXMLPrettyPrinter::ContentInserted(nsIDocument* aDocument, MaybeUnhook(aContainer); } -void -nsXMLPrettyPrinter::ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - MaybeUnhook(aContainer); -} - void nsXMLPrettyPrinter::ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, diff --git a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h index 55e42754dc1..356ee980799 100644 --- a/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h +++ b/mozilla/content/xml/document/src/nsXMLPrettyPrinter.h @@ -63,10 +63,6 @@ public: virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); virtual void DocumentWillBeDestroyed(nsIDocument* aDocument); diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 83ddc62cbf9..f0ce89522ac 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1772,60 +1772,6 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, return NS_OK; } -nsresult -nsXULElement::ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, - PRBool aDeepSetDocument) -{ - nsresult rv = EnsureContentsGenerated(); - NS_ENSURE_SUCCESS(rv, rv); - - NS_PRECONDITION(nsnull != aKid, "null ptr"); - if (!aKid) - return NS_ERROR_NULL_POINTER; - - nsCOMPtr oldKid = mAttrsAndChildren.GetSafeChildAt(aIndex); - NS_ASSERTION(oldKid != nsnull, "out-of-bounds"); - if (!oldKid) { - return NS_ERROR_FAILURE; - } - - if (oldKid == aKid) - return NS_OK; - - mozAutoDocUpdate updateBatch(mDocument, UPDATE_CONTENT_MODEL, aNotify); - - mAttrsAndChildren.ReplaceChildAt(aKid, aIndex); - - aKid->SetParent(this); - //nsRange::OwnerChildReplaced(this, aIndex, oldKid); - - if (mDocument) { - aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE); - - if (aNotify) { - mDocument->ContentReplaced(this, oldKid, aKid, aIndex); - } - if (HasMutationListeners(this, - NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED)) { - nsMutationEvent mutation(NS_MUTATION_SUBTREEMODIFIED, this); - mutation.mRelatedNode = do_QueryInterface(oldKid); - - nsEventStatus status = nsEventStatus_eIgnore; - HandleDOMEvent(nsnull, &mutation, nsnull, - NS_EVENT_FLAG_INIT, &status); - } - } - - // This will cause the script object to be unrooted for each - // element in the subtree. - oldKid->SetDocument(nsnull, PR_TRUE, PR_TRUE); - - // We've got no mo' parent. - oldKid->SetParent(nsnull); - - return NS_OK; -} - nsresult nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 18cbcf0a547..61b731105af 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -446,8 +446,6 @@ public: virtual PRInt32 IndexOf(nsIContent* aPossibleChild) const; virtual nsresult InsertChildAt(nsIContent* aKid, PRUint32 aIndex, PRBool aNotify, PRBool aDeepSetDocument); - virtual nsresult ReplaceChildAt(nsIContent* aKid, PRUint32 aIndex, - PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument); virtual nsresult RemoveChildAt(PRUint32 aIndex, PRBool aNotify); diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 76dd329fbcf..0c0386a35ee 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1176,25 +1176,6 @@ nsXULDocument::ContentInserted(nsIContent* aContainer, aIndexInContainer); } -void -nsXULDocument::ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - nsresult rv; - rv = RemoveSubtreeFromDocument(aOldChild); - if (NS_FAILED(rv)) - return; - - rv = AddSubtreeToDocument(aNewChild); - if (NS_FAILED(rv)) - return; - - nsXMLDocument::ContentReplaced(aContainer, aOldChild, aNewChild, - aIndexInContainer); -} - void nsXULDocument::ContentRemoved(nsIContent* aContainer, nsIContent* aChild, diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index ea32f280fe0..6c3854e2aa6 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -119,11 +119,6 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); - virtual void ContentRemoved(nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); diff --git a/mozilla/extensions/inspector/base/src/inDOMView.cpp b/mozilla/extensions/inspector/base/src/inDOMView.cpp index 21bf5984d6c..b7159ccc164 100644 --- a/mozilla/extensions/inspector/base/src/inDOMView.cpp +++ b/mozilla/extensions/inspector/base/src/inDOMView.cpp @@ -841,37 +841,6 @@ inDOMView::ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, mTree->RowCountChanged(row, 1); } -void -inDOMView::ContentReplaced(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aOldChild, nsIContent* aNewChild, PRInt32 aIndexInContainer) -{ - if (!mTree) - return; - - nsresult rv; - - // find the inDOMViewNode for the old child - nsCOMPtr oldDOMNode(do_QueryInterface(aOldChild)); - nsCOMPtr newDOMNode(do_QueryInterface(aNewChild)); - PRInt32 row = 0; - if (NS_FAILED(rv = NodeToRow(oldDOMNode, &row))) - return; - inDOMViewNode* oldNode; - if (NS_FAILED(rv = RowToNode(row, &oldNode))) - return; - - PRInt32 oldRowCount = GetRowCount(); - if (oldNode->isOpen) - CollapseNode(row); - - inDOMViewNode* newNode = CreateNode(newDOMNode, oldNode->parent); - ReplaceLink(newNode, oldNode); - - ReplaceNode(newNode, row); - - // XXX can this go into ReplaceNode? - mTree->InvalidateRange(row, oldRowCount-1); -} - void inDOMView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer) { diff --git a/mozilla/extensions/transformiix/source/xpath/nsXPathResult.cpp b/mozilla/extensions/transformiix/source/xpath/nsXPathResult.cpp index 075b0980cc8..c58ace27e48 100644 --- a/mozilla/extensions/transformiix/source/xpath/nsXPathResult.cpp +++ b/mozilla/extensions/transformiix/source/xpath/nsXPathResult.cpp @@ -237,16 +237,6 @@ nsXPathResult::ContentInserted(nsIDocument* aDocument, Invalidate(); } -void -nsXPathResult::ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - Invalidate(); -} - void nsXPathResult::ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, diff --git a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp index 7e9ecdac0c6..f607d834510 100644 --- a/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp +++ b/mozilla/extensions/transformiix/source/xslt/txMozillaXSLTProcessor.cpp @@ -880,16 +880,6 @@ txMozillaXSLTProcessor::ContentInserted(nsIDocument* aDocument, mStylesheet = nsnull; } -void -txMozillaXSLTProcessor::ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - mStylesheet = nsnull; -} - void txMozillaXSLTProcessor::ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index c306b85ea59..416e8033fcc 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -8608,7 +8608,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aIndexInContainer, nsILayoutHistoryState* aFrameState, - PRBool aInContentReplaced) + PRBool aInReinsertContent) { // XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and // the :empty pseudo-class? @@ -8733,7 +8733,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, : FindNextAnonymousSibling(shell, mDocument, aContainer, aChild); } - PRBool handleSpecialFrame = IsFrameSpecial(parentFrame) && !aInContentReplaced; + PRBool handleSpecialFrame = IsFrameSpecial(parentFrame) && !aInReinsertContent; // Now, find the geometric parent so that we can handle // continuations properly. Use the prev sibling if we have it; @@ -8763,7 +8763,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } // If the frame we are manipulating is a special frame then see if we need to reframe - // NOTE: if we are in ContentReplaced, then don't reframe as we are already doing just that! + // NOTE: if we are in ReinsertContent, then don't reframe as we are already doing just that! if (handleSpecialFrame) { // a special inline frame has propagated some of its children upward to be children // of the block and those frames may need to move around. Sometimes we may need to reframe @@ -8848,8 +8848,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } #endif if (parentContainer) { - PRInt32 ix = parentContainer->IndexOf(blockContent); - ContentReplaced(aPresContext, parentContainer, blockContent, blockContent, ix); + ReinsertContent(aPresContext, parentContainer, blockContent); } else { // XXX uh oh. the block that needs reworking has no parent... @@ -8967,19 +8966,18 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } nsresult -nsCSSFrameConstructor::ContentReplaced(nsIPresContext* aPresContext, +nsCSSFrameConstructor::ReinsertContent(nsIPresContext* aPresContext, nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) + nsIContent* aChild) { + PRInt32 ix = aContainer->IndexOf(aChild); // XXX For now, do a brute force remove and insert. nsresult res = ContentRemoved(aPresContext, aContainer, - aOldChild, aIndexInContainer, PR_TRUE); + aChild, ix, PR_TRUE); if (NS_SUCCEEDED(res)) { res = ContentInserted(aPresContext, aContainer, nsnull, - aNewChild, aIndexInContainer, nsnull, PR_TRUE); + aChild, ix, nsnull, PR_TRUE); } return res; @@ -9183,7 +9181,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer, - PRBool aInContentReplaced) + PRBool aInReinsertContent) { // XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and // the :empty pseudo-class? @@ -9246,9 +9244,9 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, // If the frame we are manipulating is a special frame then do // something different instead of just inserting newly created // frames. - // NOTE: if we are in ContentReplaced, + // NOTE: if we are in ReinsertContent, // then do not reframe as we are already doing just that! - if (IsFrameSpecial(childFrame) && !aInContentReplaced) { + if (IsFrameSpecial(childFrame) && !aInReinsertContent) { // We are pretty harsh here (and definitely not optimal) -- we // wipe out the entire containing block and recreate it from // scratch. The reason is that because we know that a special @@ -9704,7 +9702,7 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext, // first-letter text but isn't currently). // // To deal with both of these we make a simple change: map a - // CharacterDataChanged into a ContentReplaced when we are changing text + // CharacterDataChanged into a ReinsertContent when we are changing text // that is part of a first-letter situation. PRBool doCharacterDataChanged = PR_TRUE; nsCOMPtr textContent(do_QueryInterface(aContent)); @@ -9722,10 +9720,8 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext, // repair the blocks frame structure properly. nsCOMPtr container = aContent->GetParent(); if (container) { - PRInt32 ix = container->IndexOf(aContent); doCharacterDataChanged = PR_FALSE; - rv = ContentReplaced(aPresContext, container, - aContent, aContent, ix); + rv = ReinsertContent(aPresContext, container, aContent); } } } @@ -12907,8 +12903,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, } #endif if (parentContainer) { - PRInt32 ix = parentContainer->IndexOf(aBlockContent); - ContentReplaced(aPresContext, parentContainer, aBlockContent, aBlockContent, ix); + ReinsertContent(aPresContext, parentContainer, aBlockContent); } else { NS_ERROR("uh oh. the block we need to reframe has no parent!"); @@ -13229,8 +13224,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF NS_STATIC_CAST(void*, parentContainer)); } #endif - PRInt32 ix = parentContainer->IndexOf(blockContent); - return ContentReplaced(aPresContext, parentContainer, blockContent, blockContent, ix); + return ReinsertContent(aPresContext, parentContainer, blockContent); } } } diff --git a/mozilla/layout/base/nsCSSFrameConstructor.h b/mozilla/layout/base/nsCSSFrameConstructor.h index 030fa675a54..0aea22ada04 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.h +++ b/mozilla/layout/base/nsCSSFrameConstructor.h @@ -102,19 +102,13 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer, nsILayoutHistoryState* aFrameState, - PRBool aInContentReplaced); - - nsresult ContentReplaced(nsIPresContext* aPresContext, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); + PRBool aInReinsertContent); nsresult ContentRemoved(nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer, - PRBool aInContentReplaced); + PRBool aInReinsertContent); nsresult CharacterDataChanged(nsIPresContext* aPresContext, nsIContent* aContent, @@ -183,6 +177,10 @@ public: private: + nsresult ReinsertContent(nsIPresContext* aPresContext, + nsIContent* aContainer, + nsIContent* aChild); + nsresult ConstructPageFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame* aParentFrame, diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index f5bbbff3250..12e4c510247 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -1224,9 +1224,6 @@ public: PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); virtual void StyleSheetAdded(nsIDocument* aDocument, @@ -5233,24 +5230,6 @@ PresShell::ContentInserted(nsIDocument* aDocument, DidCauseReflow(); } -void -PresShell::ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - // Notify the ESM that the content has been removed, so that - // it can clean up any state related to the content. - mPresContext->EventStateManager()->ContentRemoved(aOldChild); - - WillCauseReflow(); - mFrameConstructor->ContentReplaced(mPresContext, aContainer, aOldChild, - aNewChild, aIndexInContainer); - VERIFY_STYLE_TREE; - DidCauseReflow(); -} - void PresShell::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index f9a7cf2aed9..3d861373cc8 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -986,16 +986,6 @@ nsImageMap::ContentInserted(nsIDocument *aDocument, MaybeUpdateAreas(aContainer); } -void -nsImageMap::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - MaybeUpdateAreas(aContainer); -} - void nsImageMap::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/generic/nsImageMap.h b/mozilla/layout/generic/nsImageMap.h index c65c48f3725..ec85744c802 100644 --- a/mozilla/layout/generic/nsImageMap.h +++ b/mozilla/layout/generic/nsImageMap.h @@ -96,9 +96,6 @@ public: PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index f9a7cf2aed9..3d861373cc8 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -986,16 +986,6 @@ nsImageMap::ContentInserted(nsIDocument *aDocument, MaybeUpdateAreas(aContainer); } -void -nsImageMap::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - MaybeUpdateAreas(aContainer); -} - void nsImageMap::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/html/base/src/nsImageMap.h b/mozilla/layout/html/base/src/nsImageMap.h index c65c48f3725..ec85744c802 100644 --- a/mozilla/layout/html/base/src/nsImageMap.h +++ b/mozilla/layout/html/base/src/nsImageMap.h @@ -96,9 +96,6 @@ public: PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index f5bbbff3250..12e4c510247 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -1224,9 +1224,6 @@ public: PRInt32 aNewIndexInContainer); virtual void ContentInserted(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument* aDocument, nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument* aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); virtual void StyleSheetAdded(nsIDocument* aDocument, @@ -5233,24 +5230,6 @@ PresShell::ContentInserted(nsIDocument* aDocument, DidCauseReflow(); } -void -PresShell::ContentReplaced(nsIDocument* aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - // Notify the ESM that the content has been removed, so that - // it can clean up any state related to the content. - mPresContext->EventStateManager()->ContentRemoved(aOldChild); - - WillCauseReflow(); - mFrameConstructor->ContentReplaced(mPresContext, aContainer, aOldChild, - aNewChild, aIndexInContainer); - VERIFY_STYLE_TREE; - DidCauseReflow(); -} - void PresShell::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index c306b85ea59..416e8033fcc 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -8608,7 +8608,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, nsIContent* aChild, PRInt32 aIndexInContainer, nsILayoutHistoryState* aFrameState, - PRBool aInContentReplaced) + PRBool aInReinsertContent) { // XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and // the :empty pseudo-class? @@ -8733,7 +8733,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, : FindNextAnonymousSibling(shell, mDocument, aContainer, aChild); } - PRBool handleSpecialFrame = IsFrameSpecial(parentFrame) && !aInContentReplaced; + PRBool handleSpecialFrame = IsFrameSpecial(parentFrame) && !aInReinsertContent; // Now, find the geometric parent so that we can handle // continuations properly. Use the prev sibling if we have it; @@ -8763,7 +8763,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } // If the frame we are manipulating is a special frame then see if we need to reframe - // NOTE: if we are in ContentReplaced, then don't reframe as we are already doing just that! + // NOTE: if we are in ReinsertContent, then don't reframe as we are already doing just that! if (handleSpecialFrame) { // a special inline frame has propagated some of its children upward to be children // of the block and those frames may need to move around. Sometimes we may need to reframe @@ -8848,8 +8848,7 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } #endif if (parentContainer) { - PRInt32 ix = parentContainer->IndexOf(blockContent); - ContentReplaced(aPresContext, parentContainer, blockContent, blockContent, ix); + ReinsertContent(aPresContext, parentContainer, blockContent); } else { // XXX uh oh. the block that needs reworking has no parent... @@ -8967,19 +8966,18 @@ nsCSSFrameConstructor::ContentInserted(nsIPresContext* aPresContext, } nsresult -nsCSSFrameConstructor::ContentReplaced(nsIPresContext* aPresContext, +nsCSSFrameConstructor::ReinsertContent(nsIPresContext* aPresContext, nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) + nsIContent* aChild) { + PRInt32 ix = aContainer->IndexOf(aChild); // XXX For now, do a brute force remove and insert. nsresult res = ContentRemoved(aPresContext, aContainer, - aOldChild, aIndexInContainer, PR_TRUE); + aChild, ix, PR_TRUE); if (NS_SUCCEEDED(res)) { res = ContentInserted(aPresContext, aContainer, nsnull, - aNewChild, aIndexInContainer, nsnull, PR_TRUE); + aChild, ix, nsnull, PR_TRUE); } return res; @@ -9183,7 +9181,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer, - PRBool aInContentReplaced) + PRBool aInReinsertContent) { // XXXldb Do we need to re-resolve style to handle the CSS2 + combinator and // the :empty pseudo-class? @@ -9246,9 +9244,9 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext, // If the frame we are manipulating is a special frame then do // something different instead of just inserting newly created // frames. - // NOTE: if we are in ContentReplaced, + // NOTE: if we are in ReinsertContent, // then do not reframe as we are already doing just that! - if (IsFrameSpecial(childFrame) && !aInContentReplaced) { + if (IsFrameSpecial(childFrame) && !aInReinsertContent) { // We are pretty harsh here (and definitely not optimal) -- we // wipe out the entire containing block and recreate it from // scratch. The reason is that because we know that a special @@ -9704,7 +9702,7 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext, // first-letter text but isn't currently). // // To deal with both of these we make a simple change: map a - // CharacterDataChanged into a ContentReplaced when we are changing text + // CharacterDataChanged into a ReinsertContent when we are changing text // that is part of a first-letter situation. PRBool doCharacterDataChanged = PR_TRUE; nsCOMPtr textContent(do_QueryInterface(aContent)); @@ -9722,10 +9720,8 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext, // repair the blocks frame structure properly. nsCOMPtr container = aContent->GetParent(); if (container) { - PRInt32 ix = container->IndexOf(aContent); doCharacterDataChanged = PR_FALSE; - rv = ContentReplaced(aPresContext, container, - aContent, aContent, ix); + rv = ReinsertContent(aPresContext, container, aContent); } } } @@ -12907,8 +12903,7 @@ nsCSSFrameConstructor::WipeContainingBlock(nsIPresContext* aPresContext, } #endif if (parentContainer) { - PRInt32 ix = parentContainer->IndexOf(aBlockContent); - ContentReplaced(aPresContext, parentContainer, aBlockContent, aBlockContent, ix); + ReinsertContent(aPresContext, parentContainer, aBlockContent); } else { NS_ERROR("uh oh. the block we need to reframe has no parent!"); @@ -13229,8 +13224,7 @@ nsCSSFrameConstructor::ReframeContainingBlock(nsIPresContext* aPresContext, nsIF NS_STATIC_CAST(void*, parentContainer)); } #endif - PRInt32 ix = parentContainer->IndexOf(blockContent); - return ContentReplaced(aPresContext, parentContainer, blockContent, blockContent, ix); + return ReinsertContent(aPresContext, parentContainer, blockContent); } } } diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h index 030fa675a54..0aea22ada04 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.h +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.h @@ -102,19 +102,13 @@ public: nsIContent* aChild, PRInt32 aIndexInContainer, nsILayoutHistoryState* aFrameState, - PRBool aInContentReplaced); - - nsresult ContentReplaced(nsIPresContext* aPresContext, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer); + PRBool aInReinsertContent); nsresult ContentRemoved(nsIPresContext* aPresContext, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer, - PRBool aInContentReplaced); + PRBool aInReinsertContent); nsresult CharacterDataChanged(nsIPresContext* aPresContext, nsIContent* aContent, @@ -183,6 +177,10 @@ public: private: + nsresult ReinsertContent(nsIPresContext* aPresContext, + nsIContent* aContainer, + nsIContent* aChild); + nsresult ConstructPageFrame(nsIPresShell* aPresShell, nsIPresContext* aPresContext, nsIFrame* aParentFrame, diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp index 3d8439543c1..37f32ef3ffc 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.cpp @@ -941,17 +941,6 @@ nsTreeContentView::ContentInserted(nsIDocument *aDocument, } } -void -nsTreeContentView::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ - ContentRemoved(aDocument, aContainer, aOldChild, aIndexInContainer); - ContentInserted(aDocument, aContainer, aNewChild, aIndexInContainer); -} - void nsTreeContentView::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h index 847bcffb2a8..172b85c2279 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeContentView.h @@ -88,10 +88,6 @@ class nsTreeContentView : public nsITreeView, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); - virtual void ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, nsIContent* aNewChild, - PRInt32 aIndexInContainer); virtual void ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aChild, PRInt32 aIndexInContainer); virtual void DocumentWillBeDestroyed(nsIDocument *aDocument); diff --git a/mozilla/widget/src/cocoa/nsMenuBarX.cpp b/mozilla/widget/src/cocoa/nsMenuBarX.cpp index 15c9c63a3bf..76ba3a6e17a 100644 --- a/mozilla/widget/src/cocoa/nsMenuBarX.cpp +++ b/mozilla/widget/src/cocoa/nsMenuBarX.cpp @@ -761,12 +761,6 @@ nsMenuBarX::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer, } } -void -nsMenuBarX::ContentReplaced( nsIDocument * aDocument, nsIContent * aContainer, nsIContent * aOldChild, - nsIContent * aNewChild, PRInt32 aIndexInContainer) -{ -} - void nsMenuBarX::DocumentWillBeDestroyed( nsIDocument * aDocument ) { diff --git a/mozilla/widget/src/mac/nsMenuBar.cpp b/mozilla/widget/src/mac/nsMenuBar.cpp index c8b0e07e8f5..48f4a03c904 100644 --- a/mozilla/widget/src/mac/nsMenuBar.cpp +++ b/mozilla/widget/src/mac/nsMenuBar.cpp @@ -661,13 +661,6 @@ nsMenuBar::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer, return NS_OK; } -NS_IMETHODIMP -nsMenuBar::ContentReplaced( nsIDocument * aDocument, nsIContent * aContainer, nsIContent * aOldChild, - nsIContent * aNewChild, PRInt32 aIndexInContainer) -{ - return NS_OK; -} - NS_IMETHODIMP nsMenuBar::DocumentWillBeDestroyed( nsIDocument * aDocument ) { diff --git a/mozilla/widget/src/mac/nsMenuBarX.cpp b/mozilla/widget/src/mac/nsMenuBarX.cpp index 5f7d2f3908a..d891762715d 100644 --- a/mozilla/widget/src/mac/nsMenuBarX.cpp +++ b/mozilla/widget/src/mac/nsMenuBarX.cpp @@ -771,13 +771,6 @@ nsMenuBarX::ContentAppended( nsIDocument * aDocument, nsIContent * aContainer, } } -void -nsMenuBarX::ContentReplaced( nsIDocument * aDocument, nsIContent * aContainer, - nsIContent * aOldChild, nsIContent * aNewChild, - PRInt32 aIndexInContainer) -{ -} - void nsMenuBarX::DocumentWillBeDestroyed( nsIDocument * aDocument ) { diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index df3b2b4af18..142238a1f94 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1578,15 +1578,6 @@ nsWebShellWindow::ContentInserted(nsIDocument *aDocument, { } -void -nsWebShellWindow::ContentReplaced(nsIDocument *aDocument, - nsIContent* aContainer, - nsIContent* aOldChild, - nsIContent* aNewChild, - PRInt32 aIndexInContainer) -{ -} - void nsWebShellWindow::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer,