mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 237566: Remove nsIContent::ReplaceChildAt and supportive codepaths.
r=bz sr=jst
This commit is contained in:
parent
ad1a26ddf7
commit
386382d6ab
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
|
@ -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, \
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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<nsIContent> 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<nsIContent> 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<nsIContent> 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<nsIDocument> 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<nsIContent> 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<nsIDOMNode> 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<nsIDOMNode> tmpNode;
|
||||
|
||||
PRUint32 origChildCount = aElement->GetChildCount();
|
||||
|
||||
/*
|
||||
* We don't care here if the return fails or not.
|
||||
*/
|
||||
nsCOMPtr<nsIDOMNode> 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);
|
||||
|
@ -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);
|
||||
|
@ -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<nsISelectElement> 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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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 ///////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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<nsIContent> 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)
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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<nsIDOMNode> oldDOMNode(do_QueryInterface(aOldChild));
|
||||
nsCOMPtr<nsIDOMNode> 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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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<nsITextContent> textContent(do_QueryInterface(aContent));
|
||||
@ -9722,10 +9720,8 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext,
|
||||
// repair the blocks frame structure properly.
|
||||
nsCOMPtr<nsIContent> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<nsITextContent> textContent(do_QueryInterface(aContent));
|
||||
@ -9722,10 +9720,8 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIPresContext* aPresContext,
|
||||
// repair the blocks frame structure properly.
|
||||
nsCOMPtr<nsIContent> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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 )
|
||||
{
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user