From fa49d4105216e4cda39087177ff9aba434523c0c Mon Sep 17 00:00:00 2001 From: "pollmann%netscape.com" Date: Mon, 2 Apr 2001 00:45:52 +0000 Subject: [PATCH] Bug 65609: (DOM) Allow form elements inside a subtree to find their parent when the subtree is appended/inserted. r=nisheeth@netscape.com, sr=jst@netscape.com git-svn-id: svn://10.0.0.236/trunk@91014 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIContent.h | 7 ++- mozilla/content/base/src/nsCommentNode.cpp | 13 +++-- mozilla/content/base/src/nsDocumentViewer.cpp | 4 +- .../content/base/src/nsGenericDOMDataNode.cpp | 2 +- .../content/base/src/nsGenericDOMDataNode.h | 22 +++++--- mozilla/content/base/src/nsGenericElement.cpp | 35 +++++------- mozilla/content/base/src/nsGenericElement.h | 9 ++- .../html/content/src/nsAttributeContent.cpp | 9 ++- .../html/content/src/nsGenericHTMLElement.cpp | 17 +++--- .../html/content/src/nsGenericHTMLElement.h | 18 ++++-- .../html/content/src/nsHTMLOptionElement.cpp | 6 +- .../html/content/src/nsHTMLScriptElement.cpp | 2 +- .../html/content/src/nsHTMLSelectElement.cpp | 27 +++++---- .../html/content/src/nsHTMLTableElement.cpp | 6 +- .../html/document/src/nsHTMLContentSink.cpp | 52 ++++++++--------- .../src/nsHTMLFragmentContentSink.cpp | 12 ++-- .../html/document/src/nsImageDocument.cpp | 6 +- .../xml/document/src/nsXMLContentSink.cpp | 21 +++---- .../content/xul/content/src/nsXULElement.cpp | 56 ++++++------------- .../content/xul/content/src/nsXULElement.h | 9 ++- .../xul/document/src/nsXULDocument.cpp | 22 ++------ .../xul/templates/src/nsXULContentBuilder.cpp | 7 ++- .../xul/templates/src/nsXULContentUtils.cpp | 3 +- .../xul/templates/src/nsXULSortService.cpp | 26 +++------ mozilla/layout/base/nsDocumentViewer.cpp | 4 +- .../layout/forms/nsComboboxControlFrame.cpp | 7 +-- .../html/forms/src/nsComboboxControlFrame.cpp | 7 +-- mozilla/layout/html/tests/TestAttributes.cpp | 2 +- 28 files changed, 194 insertions(+), 217 deletions(-) diff --git a/mozilla/content/base/public/nsIContent.h b/mozilla/content/base/public/nsIContent.h index be917981ab8..93bd841a7c9 100644 --- a/mozilla/content/base/public/nsIContent.h +++ b/mozilla/content/base/public/nsIContent.h @@ -77,12 +77,13 @@ public: NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aIndex) const = 0; NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) = 0; + PRBool aNotify, PRBool aDeepSetDocument) = 0; NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) = 0; + PRBool aNotify, PRBool aDeepSetDocument) = 0; - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) = 0; + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) = 0; NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) = 0; diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 379e9b4a679..9a51676c387 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -82,15 +82,16 @@ public: return mInner.IndexOf(aPossibleChild, aResult); } NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) { - return mInner.InsertChildAt(aKid, aIndex, aNotify); + PRBool aNotify, PRBool aDeepSetDocument) { + return mInner.InsertChildAt(aKid, aIndex, aNotify, aDeepSetDocument); } NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) { - return mInner.ReplaceChildAt(aKid, aIndex, aNotify); + PRBool aNotify, PRBool aDeepSetDocument) { + return mInner.ReplaceChildAt(aKid, aIndex, aNotify, aDeepSetDocument); } - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { - return mInner.AppendChildTo(aKid, aNotify); + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { + return mInner.AppendChildTo(aKid, aNotify, aDeepSetDocument); } NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { return mInner.RemoveChildAt(aIndex, aNotify); diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 2fc7be6194f..1966b1ed844 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -2609,9 +2609,9 @@ nsresult DocumentViewerImpl::GetSelectionDocument(nsIDeviceContextSpec * aDevSpe if (!bodyElement) { return NS_ERROR_NULL_POINTER; } bodyElement->SetDocument(doc, PR_FALSE, PR_TRUE); // put the head and body into the root - rv = htmlElement->AppendChildTo(headElement, PR_FALSE); + rv = htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) { return rv; } - rv = htmlElement->AppendChildTo(bodyElement, PR_FALSE); + rv = htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) { return rv; } // load the document into the docshell diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 31c1497224f..60425b7d1d9 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -889,7 +889,7 @@ nsGenericDOMDataNode::SplitText(nsIContent *aOuterContent, PRUint32 aOffset, if (NS_SUCCEEDED(rv)) { nsCOMPtr content(do_QueryInterface(newNode)); - rv = parentNode->InsertChildAt(content, index+1, PR_TRUE); + rv = parentNode->InsertChildAt(content, index+1, PR_TRUE, PR_FALSE); } } diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.h b/mozilla/content/base/src/nsGenericDOMDataNode.h index 2e1aebf11b7..40d6ba3546e 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.h +++ b/mozilla/content/base/src/nsGenericDOMDataNode.h @@ -223,13 +223,16 @@ struct nsGenericDOMDataNode { aResult = -1; return NS_OK; } - nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + nsresult InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } - nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + nsresult ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } - nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify) { + nsresult AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } nsresult RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { @@ -461,15 +464,16 @@ struct nsGenericDOMDataNode { return _g.IndexOf(aPossibleChild, aResult); \ } \ NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, \ - PRBool aNotify) { \ - return _g.InsertChildAt(aKid, aIndex, aNotify); \ + PRBool aNotify, PRBool aDeepSetDocument) { \ + return _g.InsertChildAt(aKid, aIndex, aNotify, aDeepSetDocument); \ } \ NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, \ - PRBool aNotify) { \ - return _g.ReplaceChildAt(aKid, aIndex, aNotify); \ + PRBool aNotify, PRBool aDeepSetDocument) { \ + return _g.ReplaceChildAt(aKid, aIndex, aNotify, aDeepSetDocument); \ } \ - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { \ - return _g.AppendChildTo(aKid, aNotify); \ + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, \ + PRBool aDeepSetDocument) { \ + return _g.AppendChildTo(aKid, aNotify, aDeepSetDocument); \ } \ NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { \ return _g.RemoveChildAt(aIndex, aNotify); \ diff --git a/mozilla/content/base/src/nsGenericElement.cpp b/mozilla/content/base/src/nsGenericElement.cpp index 1748a6a89b0..2519914ae29 100644 --- a/mozilla/content/base/src/nsGenericElement.cpp +++ b/mozilla/content/base/src/nsGenericElement.cpp @@ -2235,10 +2235,8 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); - // Insert the child and increment the insertion position - res = InsertChildAt(childContent, refPos++, PR_TRUE); + res = InsertChildAt(childContent, refPos++, PR_TRUE, PR_TRUE); if (NS_FAILED(res)) { return res; @@ -2300,9 +2298,7 @@ nsGenericElement::doInsertBefore(nsIDOMNode* aNewChild, } } - newContent->SetDocument(mDocument, PR_TRUE, PR_TRUE); - - res = InsertChildAt(newContent, refPos, PR_TRUE); + res = InsertChildAt(newContent, refPos, PR_TRUE, PR_TRUE); if (NS_FAILED(res)) { return res; @@ -2428,13 +2424,11 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, return res; } - childContent->SetDocument(document, PR_TRUE, PR_TRUE); - // Insert the child and increment the insertion position if (i) { - res = InsertChildAt(childContent, oldPos++, PR_TRUE); + res = InsertChildAt(childContent, oldPos++, PR_TRUE, PR_TRUE); } else { - res = ReplaceChildAt(childContent, oldPos++, PR_TRUE); + res = ReplaceChildAt(childContent, oldPos++, PR_TRUE, PR_TRUE); } if (NS_FAILED(res)) { @@ -2489,9 +2483,7 @@ nsGenericElement::doReplaceChild(nsIDOMNode* aNewChild, } } - newContent->SetDocument(document, PR_TRUE, PR_TRUE); - - res = ReplaceChildAt(newContent, oldPos, PR_TRUE); + res = ReplaceChildAt(newContent, oldPos, PR_TRUE, PR_TRUE); if (NS_FAILED(res)) { return res; @@ -2834,7 +2826,7 @@ nsGenericContainerElement::CopyInnerTo(nsIContent* aSrcContent, result = newNode->QueryInterface(NS_GET_IID(nsIContent), (void**)&newContent); if (NS_OK == result) { - result = aDst->AppendChildTo(newContent, PR_FALSE); + result = aDst->AppendChildTo(newContent, PR_FALSE, PR_FALSE); NS_RELEASE(newContent); } NS_RELEASE(newNode); @@ -3357,7 +3349,8 @@ nsGenericContainerElement::IndexOf(nsIContent* aPossibleChild, nsresult nsGenericContainerElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; @@ -3370,7 +3363,7 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(this); nsRange::OwnerChildInserted(this, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentInserted(this, aKid, aIndex); } @@ -3401,7 +3394,8 @@ nsGenericContainerElement::InsertChildAt(nsIContent* aKid, nsresult nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; @@ -3415,7 +3409,7 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(this); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentReplaced(this, oldKid, aKid, aIndex); } @@ -3431,7 +3425,8 @@ nsGenericContainerElement::ReplaceChildAt(nsIContent* aKid, } nsresult -nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) +nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; @@ -3444,7 +3439,7 @@ nsGenericContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(this); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentAppended(this, mChildren.Count() - 1); } diff --git a/mozilla/content/base/src/nsGenericElement.h b/mozilla/content/base/src/nsGenericElement.h index 8dac32d4a0d..0f09eaa534a 100644 --- a/mozilla/content/base/src/nsGenericElement.h +++ b/mozilla/content/base/src/nsGenericElement.h @@ -432,9 +432,12 @@ public: NS_IMETHOD ChildCount(PRInt32& aResult) const; NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const; NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const; - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify); + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument); NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify); void ListAttributes(FILE* out) const; diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index 7b696ee5e9e..a8b4a74e7fa 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -161,9 +161,12 @@ public: NS_IMETHOD ChildCount(PRInt32& aResult) const { aResult = 0; return NS_OK; } NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const { aResult = nsnull; return NS_OK; } NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const { aResult = -1; return NS_OK; } - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { return NS_OK; } - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { return NS_OK; } - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { return NS_OK; } + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { return NS_OK; } NS_IMETHOD SplitText(PRUint32 aOffset, nsIDOMText** aReturn){ return NS_OK; } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp index 88142887651..53e499a8307 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.cpp +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.cpp @@ -3297,7 +3297,7 @@ nsGenericHTMLContainerElement::CopyInnerTo(nsIContent* aSrcContent, result = newNode->QueryInterface(NS_GET_IID(nsIContent), (void**)&newContent); if (NS_OK == result) { - result = aDst->AppendChildTo(newContent, PR_FALSE); + result = aDst->AppendChildTo(newContent, PR_FALSE, PR_FALSE); NS_RELEASE(newContent); } NS_RELEASE(newNode); @@ -3415,7 +3415,8 @@ nsGenericHTMLContainerElement::IndexOf(nsIContent* aPossibleChild, NS_IMETHODIMP nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIDocument* doc = mDocument; @@ -3428,7 +3429,7 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, aKid->SetParent(this); nsRange::OwnerChildInserted(this, aIndex); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentInserted(this, aKid, aIndex); } @@ -3458,7 +3459,8 @@ nsGenericHTMLContainerElement::InsertChildAt(nsIContent* aKid, NS_IMETHODIMP nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid, "null ptr"); nsIContent* oldKid = (nsIContent *)mChildren.ElementAt(aIndex); @@ -3472,7 +3474,7 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, NS_ADDREF(aKid); aKid->SetParent(this); if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentReplaced(this, oldKid, aKid, aIndex); } @@ -3488,7 +3490,8 @@ nsGenericHTMLContainerElement::ReplaceChildAt(nsIContent* aKid, } NS_IMETHODIMP -nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) +nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { NS_PRECONDITION(nsnull != aKid && this != aKid, "null ptr"); nsIDocument* doc = mDocument; @@ -3501,7 +3504,7 @@ nsGenericHTMLContainerElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(this); // ranges don't need adjustment since new child is at end of list if (nsnull != doc) { - aKid->SetDocument(doc, PR_FALSE, PR_TRUE); + aKid->SetDocument(doc, aDeepSetDocument, PR_TRUE); if (aNotify) { doc->ContentAppended(this, mChildren.Count() - 1); } diff --git a/mozilla/content/html/content/src/nsGenericHTMLElement.h b/mozilla/content/html/content/src/nsGenericHTMLElement.h index 1fd39df0f3d..870df32a9a5 100644 --- a/mozilla/content/html/content/src/nsGenericHTMLElement.h +++ b/mozilla/content/html/content/src/nsGenericHTMLElement.h @@ -416,13 +416,16 @@ public: aResult = -1; return NS_OK; } - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) { + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify) { + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { return NS_OK; } NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify) { @@ -473,9 +476,12 @@ public: NS_IMETHOD ChildCount(PRInt32& aResult) const; NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const; NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const; - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify); + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument); NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify); nsCheapVoidArray mChildren; diff --git a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp index b806d5900a4..fc43ab8e6c9 100644 --- a/mozilla/content/html/content/src/nsHTMLOptionElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLOptionElement.cpp @@ -556,8 +556,8 @@ nsHTMLOptionElement::SetText(const nsAReadableString& aText) if (domtext) { result = domtext->SetData(aText); - if (NS_SUCCEEDED(result)) { - result = AppendChildTo(text, PR_TRUE); + if (NS_SUCCEEDED(result)) { + result = AppendChildTo(text, PR_TRUE, PR_FALSE); if (NS_SUCCEEDED(result)) { nsCOMPtr doc; @@ -695,7 +695,7 @@ nsHTMLOptionElement::Initialize(JSContext* aContext, } // this addrefs textNode: - result = AppendChildTo(content, PR_FALSE); + result = AppendChildTo(content, PR_FALSE, PR_FALSE); if (NS_FAILED(result)) { return result; } diff --git a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp index 68549e68fa0..94c22bc7b01 100644 --- a/mozilla/content/html/content/src/nsHTMLScriptElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLScriptElement.cpp @@ -178,7 +178,7 @@ nsHTMLScriptElement::SetText(const nsAReadableString& aValue) rv = NS_NewTextNode(getter_AddRefs(content)); NS_ENSURE_SUCCESS(rv, rv); - rv = InsertChildAt(content, 0, PR_FALSE); + rv = InsertChildAt(content, 0, PR_FALSE, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp index 5bcde7c4601..6e27e890c94 100644 --- a/mozilla/content/html/content/src/nsHTMLSelectElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLSelectElement.cpp @@ -140,9 +140,12 @@ public: // nsIDOMNSHTMLSelectElement NS_DECL_IDOMNSHTMLSELECTELEMENT - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify); + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument); NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify); NS_IMETHOD HandleDOMEvent(nsIPresContext* aPresContext, @@ -293,10 +296,12 @@ nsHTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm) // nsIContent NS_IMETHODIMP -nsHTMLSelectElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) +nsHTMLSelectElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument) { nsresult res = nsGenericHTMLContainerFormElement::AppendChildTo(aKid, - aNotify); + aNotify, + aDeepSetDocument); if (NS_SUCCEEDED(res)) { AddOption(aKid); } @@ -306,10 +311,11 @@ nsHTMLSelectElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) NS_IMETHODIMP nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, PRBool aDeepSetDocument) { nsresult res = nsGenericHTMLContainerFormElement::InsertChildAt(aKid, aIndex, - aNotify); + aNotify, + aDeepSetDocument); if (NS_SUCCEEDED(res)) { // No index is necessary // It dirties list and the list automatically @@ -322,7 +328,7 @@ nsHTMLSelectElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, NS_IMETHODIMP nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, - PRBool aNotify) + PRBool aNotify, PRBool aDeepSetDocument) { nsCOMPtr content; if (NS_SUCCEEDED(ChildAt(aIndex, *getter_AddRefs(content)))) { @@ -331,7 +337,8 @@ nsHTMLSelectElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, nsresult res = nsGenericHTMLContainerFormElement::ReplaceChildAt(aKid, aIndex, - aNotify); + aNotify, + aDeepSetDocument); if (NS_SUCCEEDED(res)) { AddOption(aKid); @@ -485,7 +492,7 @@ nsHTMLSelectElement::SetLength(PRUint32 aLength) rv = NS_NewTextNode(getter_AddRefs(text)); NS_ENSURE_SUCCESS(rv, rv); - rv = element->AppendChildTo(text, PR_FALSE); + rv = element->AppendChildTo(text, PR_FALSE, PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr node(do_QueryInterface(element)); diff --git a/mozilla/content/html/content/src/nsHTMLTableElement.cpp b/mozilla/content/html/content/src/nsHTMLTableElement.cpp index 686d1b2f09f..894a0e288f2 100644 --- a/mozilla/content/html/content/src/nsHTMLTableElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLTableElement.cpp @@ -653,7 +653,7 @@ nsHTMLTableElement::CreateTFoot(nsIDOMHTMLElement** aValue) rv = NS_NewHTMLTableSectionElement(getter_AddRefs(newFoot),nodeInfo); if (NS_SUCCEEDED(rv) && newFoot) { - rv = AppendChildTo(newFoot, PR_TRUE); + rv = AppendChildTo(newFoot, PR_TRUE, PR_FALSE); newFoot->QueryInterface(NS_GET_IID(nsIDOMHTMLElement), (void **)aValue); } } @@ -700,7 +700,7 @@ nsHTMLTableElement::CreateCaption(nsIDOMHTMLElement** aValue) rv = NS_NewHTMLTableCaptionElement(getter_AddRefs(newCaption),nodeInfo); if (NS_SUCCEEDED(rv) && newCaption) { - rv = AppendChildTo(newCaption, PR_TRUE); + rv = AppendChildTo(newCaption, PR_TRUE, PR_FALSE); newCaption->QueryInterface(NS_GET_IID(nsIDOMHTMLElement), (void **)aValue); } @@ -842,7 +842,7 @@ nsHTMLTableElement::InsertRow(PRInt32 aIndex, nsIDOMHTMLElement** aValue) nodeInfo); if (NS_SUCCEEDED(rv) && newRowGroup) { - rv = AppendChildTo(newRowGroup, PR_TRUE); + rv = AppendChildTo(newRowGroup, PR_TRUE, PR_FALSE); rowGroup = do_QueryInterface(newRowGroup); } diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 8a28ccc3276..5e6c462fe6f 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1403,10 +1403,10 @@ SinkContext::OpenContainer(const nsIParserNode& aNode) if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } mStack[mStackPos].mFlags |= APPENDED; } @@ -1489,10 +1489,10 @@ SinkContext::CloseContainer(const nsIParserNode& aNode) if (mStack[mStackPos-1].mInsertionPoint != -1) { result = parent->InsertChildAt(content, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - result = parent->AppendChildTo(content, PR_FALSE); + result = parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } } @@ -1648,7 +1648,7 @@ SinkContext::DemoteContainer(const nsIParserNode& aNode) // notification (it the container hasn't already been appended) else if (!(mStack[stackPos].mFlags & APPENDED)) { mSink->mInNotification++; - parent->AppendChildTo(container, PR_FALSE); + parent->AppendChildTo(container, PR_FALSE, PR_FALSE); mSink->mInNotification--; } @@ -1692,7 +1692,7 @@ SinkContext::DemoteContainer(const nsIParserNode& aNode) // since we already did notifications for all content // that's come through with the FlushTags() call so far. mSink->mInNotification++; - result = parent->AppendChildTo(child, sync); + result = parent->AppendChildTo(child, sync, PR_FALSE); mSink->mInNotification--; } NS_RELEASE(child); @@ -1815,10 +1815,10 @@ SinkContext::AddLeaf(nsIHTMLContent* aContent) if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(aContent, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(aContent, PR_FALSE); + parent->AppendChildTo(aContent, PR_FALSE, PR_FALSE); } DidAddContent(aContent, PR_FALSE); @@ -1867,10 +1867,10 @@ SinkContext::AddComment(const nsIParserNode& aNode) if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(comment, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(comment, PR_FALSE); + parent->AppendChildTo(comment, PR_FALSE, PR_FALSE); } DidAddContent(comment, PR_FALSE); @@ -2001,10 +2001,10 @@ SinkContext::FlushTags(PRBool aNotify) if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } mStack[stackPos].mFlags |= APPENDED; @@ -2134,10 +2134,10 @@ SinkContext::FlushText(PRBool* aDidFlush, PRBool aReleaseLast) if (mStack[mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(content, mStack[mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } mLastTextNode = content; @@ -2377,7 +2377,7 @@ HTMLContentSink::Init(nsIDocument* aDoc, MOZ_TIMER_STOP(mWatch); return rv; } - mRoot->AppendChildTo(mHead, PR_FALSE); + mRoot->AppendChildTo(mHead, PR_FALSE, PR_FALSE); mCurrentContext = new SinkContext(this); mCurrentContext->Begin(eHTMLTag_html, mRoot, 0, -1); @@ -2717,11 +2717,11 @@ HTMLContentSink::SetTitle(const nsString& aValue) tc->SetData(*mTitle); NS_RELEASE(tc); } - it->AppendChildTo(text, PR_FALSE); + it->AppendChildTo(text, PR_FALSE, PR_FALSE); text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } - mHead->AppendChildTo(it, PR_FALSE); + mHead->AppendChildTo(it, PR_FALSE, PR_FALSE); NS_RELEASE(it); } @@ -3721,7 +3721,7 @@ HTMLContentSink::ProcessAREATag(const nsIParserNode& aNode) AddBaseTagInfo(area); // basehref or basetarget. Fix. Bug: 30617 // Add AREA object to the current map - mCurrentMap->AppendChildTo(area, PR_FALSE); + mCurrentMap->AppendChildTo(area, PR_FALSE, PR_FALSE); NS_RELEASE(area); } return NS_OK; @@ -3810,7 +3810,7 @@ HTMLContentSink::ProcessBASETag(const nsIParserNode& aNode) element->SetDocument(mDocument, PR_FALSE, PR_TRUE); result = AddAttributes(aNode, element); if (NS_SUCCEEDED(result)) { - parent->AppendChildTo(element, PR_FALSE); + parent->AppendChildTo(element, PR_FALSE, PR_FALSE); if(!mInsideNoXXXTag) { nsAutoString value; if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, value)) { @@ -4173,7 +4173,7 @@ HTMLContentSink::ProcessLINKTag(const nsIParserNode& aNode) NS_RELEASE(element); return result; } - parent->AppendChildTo(element, PR_FALSE); + parent->AppendChildTo(element, PR_FALSE, PR_FALSE); } else { return result; @@ -4291,7 +4291,7 @@ HTMLContentSink::ProcessMETATag(const nsIParserNode& aNode) NS_RELEASE(it); return rv; } - parent->AppendChildTo(it, PR_FALSE); + parent->AppendChildTo(it, PR_FALSE, PR_FALSE); // XXX It's just not sufficient to check if the parent is head. Also check for // the preference. @@ -4974,10 +4974,10 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) if (mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint != -1) { parent->InsertChildAt(element, mCurrentContext->mStack[mCurrentContext->mStackPos-1].mInsertionPoint++, - PR_FALSE); + PR_FALSE, PR_FALSE); } else { - parent->AppendChildTo(element, PR_FALSE); + parent->AppendChildTo(element, PR_FALSE, PR_FALSE); } } else { @@ -4999,7 +4999,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode) tc->SetData(script); NS_RELEASE(tc); } - element->AppendChildTo(text, PR_FALSE); + element->AppendChildTo(text, PR_FALSE, PR_FALSE); text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } @@ -5141,7 +5141,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) NS_RELEASE(element); return rv; } - parent->AppendChildTo(element, PR_FALSE); + parent->AppendChildTo(element, PR_FALSE, PR_FALSE); } if(!mInsideNoXXXTag && NS_SUCCEEDED(rv)) { @@ -5207,7 +5207,7 @@ HTMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) tc->SetData(content); NS_RELEASE(tc); } - element->AppendChildTo(text, PR_FALSE); + element->AppendChildTo(text, PR_FALSE, PR_FALSE); text->SetDocument(mDocument, PR_FALSE, PR_TRUE); NS_RELEASE(text); } diff --git a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp index 2f8e17eeab7..fd68f474d6d 100644 --- a/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLFragmentContentSink.cpp @@ -330,7 +330,7 @@ nsHTMLFragmentContentSink::SetTitle(const nsString& aValue) parent = mRoot; } - result=parent->AppendChildTo(content, PR_FALSE); + result=parent->AppendChildTo(content, PR_FALSE, PR_FALSE); if (NS_SUCCEEDED(result)) { result=AddTextToContent(content,aValue); @@ -508,7 +508,7 @@ nsHTMLFragmentContentSink::OpenContainer(const nsIParserNode& aNode) parent = mRoot; } - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); PushContent(content); } } @@ -586,7 +586,7 @@ nsHTMLFragmentContentSink::AddLeaf(const nsIParserNode& aNode) parent = mRoot; } - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } } @@ -659,7 +659,7 @@ nsHTMLFragmentContentSink::AddComment(const nsIParserNode& aNode) parent = mRoot; } - parent->AppendChildTo(comment, PR_FALSE); + parent->AppendChildTo(comment, PR_FALSE, PR_FALSE); } NS_RELEASE(comment); } @@ -793,7 +793,7 @@ nsHTMLFragmentContentSink::AddTextToContent(nsIHTMLContent* aContent,const nsStr if (NS_SUCCEEDED(result)) { tc->SetData(aText); } - result=aContent->AppendChildTo(text, PR_FALSE); + result=aContent->AppendChildTo(text, PR_FALSE, PR_FALSE); } } } @@ -822,7 +822,7 @@ nsHTMLFragmentContentSink::FlushText() parent = mRoot; } - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); NS_RELEASE(content); } diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 405a64cb0d4..5f4604ef1df 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -375,9 +375,9 @@ nsImageDocument::CreateSyntheticDocument() image->SetHTMLAttribute(nsHTMLAtoms::src, val, PR_FALSE); image->SetHTMLAttribute(nsHTMLAtoms::alt, val, PR_FALSE); - root->AppendChildTo(body, PR_FALSE); - center->AppendChildTo(image, PR_FALSE); - body->AppendChildTo(center, PR_FALSE); + root->AppendChildTo(body, PR_FALSE, PR_FALSE); + center->AppendChildTo(image, PR_FALSE, PR_FALSE); + body->AppendChildTo(center, PR_FALSE, PR_FALSE); NS_RELEASE(image); NS_RELEASE(center); diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index c9b6303ce9c..185535b3c2b 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -661,7 +661,7 @@ nsXMLContentSink::OpenContainer(const nsIParserNode& aNode) else { nsCOMPtr parent = getter_AddRefs(GetCurrentContent()); - parent->AppendChildTo(content, PR_FALSE); + parent->AppendChildTo(content, PR_FALSE, PR_FALSE); } if (pushContent) { PushContent(content); @@ -814,8 +814,8 @@ nsXMLContentSink::AddContentAsLeaf(nsIContent *aContent) else { nsCOMPtr parent = getter_AddRefs(GetCurrentContent()); - if (nsnull != parent) { - result = parent->AppendChildTo(aContent, PR_FALSE); + if (parent) { + result = parent->AppendChildTo(aContent, PR_FALSE, PR_FALSE); } } @@ -1147,18 +1147,15 @@ nsXMLContentSink::ProcessSTYLETag(const nsIParserNode& aNode) if (0 == src.Length()) { // Create a text node holding the content - nsIContent* text; - rv = NS_NewTextNode(&text); - if (NS_OK == rv) { - nsIDOMText* tc; - rv = text->QueryInterface(NS_GET_IID(nsIDOMText), (void**)&tc); - if (NS_OK == rv) { + nsCOMPtr text; + rv = NS_NewTextNode(getter_AddRefs(text)); + if (text) { + nsCOMPtr tc(do_QueryInterface(text)); + if (tc) { tc->SetData(mStyleText); - NS_RELEASE(tc); } - mStyleElement->AppendChildTo(text, PR_FALSE); + mStyleElement->AppendChildTo(text, PR_FALSE, PR_FALSE); text->SetDocument(mDocument, PR_FALSE, PR_TRUE); - NS_RELEASE(text); } // Create a string to hold the data and wrap it up in a unicode diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp index 7f5c4beb765..ac5966afcc0 100644 --- a/mozilla/content/xul/content/src/nsXULElement.cpp +++ b/mozilla/content/xul/content/src/nsXULElement.cpp @@ -1097,15 +1097,9 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, if (NS_FAILED(rv)) return rv; if (pos >= 0) { - // Because InsertChildAt() only does a "shallow" - // SetDocument(), we need to ensure that a "deep" one is - // done now. We do it -before- inserting into the content - // model, because some frames assume that the document - // will have been set. - rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); - if (NS_FAILED(rv)) return rv; - - rv = InsertChildAt(newcontent, pos, PR_TRUE); + // Some frames assume that the document will have been set, + // so pass in PR_TRUE for aDeepSetDocument here. + rv = InsertChildAt(newcontent, pos, PR_TRUE, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert aNewChild"); if (NS_FAILED(rv)) return rv; } @@ -1116,15 +1110,9 @@ nsXULElement::InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, // just append it? } else { - // Because AppendChildTo() only does a "shallow" - // SetDocument(), we need to ensure that a "deep" one is done - // now. We do it -before- appending to the content model, - // because some frames assume that they can get to the - // document right away. - rv = newcontent->SetDocument(mDocument, PR_TRUE, PR_TRUE); - if (NS_FAILED(rv)) return rv; - - rv = AppendChildTo(newcontent, PR_TRUE); + // Some frames assume that the document will have been set, + // so pass in PR_TRUE for aDeepSetDocument here. + rv = AppendChildTo(newcontent, PR_TRUE, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to append a aNewChild"); if (NS_FAILED(rv)) return rv; } @@ -1162,15 +1150,9 @@ nsXULElement::ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, NS_ASSERTION(newelement != nsnull, "not an nsIContent"); if (newelement) { - // Because ReplaceChildAt() only does a "shallow" - // SetDocument(), we need to ensure that a "deep" one - // is done now. We do it -before- replacing the nodein - // the content model, because some frames assume that - // the document will have been set. - rv = newelement->SetDocument(mDocument, PR_TRUE, PR_TRUE); - if (NS_FAILED(rv)) return rv; - - rv = ReplaceChildAt(newelement, pos, PR_TRUE); + // Some frames assume that the document will have been set, + // so pass in PR_TRUE for aDeepSetDocument here. + rv = ReplaceChildAt(newelement, pos, PR_TRUE, PR_TRUE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to replace old child"); } } @@ -1329,7 +1311,7 @@ nsXULElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn) if (! newchild) return NS_ERROR_UNEXPECTED; - rv = result->AppendChildTo(newchild, PR_FALSE); + rv = result->AppendChildTo(newchild, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) return rv; } } @@ -2592,7 +2574,8 @@ nsXULElement::IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const } NS_IMETHODIMP -nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) +nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { nsresult rv; if (NS_FAILED(rv = EnsureContentsGenerated())) @@ -2611,8 +2594,7 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this)); //nsRange::OwnerChildInserted(this, aIndex); - // N.B. that this is "shallow"! - aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); + aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE); if (mDocument && HasMutationListeners(NS_STATIC_CAST(nsIStyledContent*,this), NS_EVENT_BITS_MUTATION_NODEINSERTED)) { @@ -2638,7 +2620,8 @@ nsXULElement::InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) } NS_IMETHODIMP -nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) +nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument) { nsresult rv; if (NS_FAILED(rv = EnsureContentsGenerated())) @@ -2662,9 +2645,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this)); //nsRange::OwnerChildReplaced(this, aIndex, oldKid); - // N.B. that we only do a "shallow" SetDocument() - // here. Callers beware! - aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); + aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE); if (aNotify && mDocument) { mDocument->ContentReplaced(NS_STATIC_CAST(nsIStyledContent*, this), oldKid, aKid, aIndex); @@ -2682,7 +2663,7 @@ nsXULElement::ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify) } NS_IMETHODIMP -nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) +nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify, PRBool aDeepSetDocument) { nsresult rv; if (NS_FAILED(rv = EnsureContentsGenerated())) @@ -2696,8 +2677,7 @@ nsXULElement::AppendChildTo(nsIContent* aKid, PRBool aNotify) aKid->SetParent(NS_STATIC_CAST(nsIStyledContent*, this)); // ranges don't need adjustment since new child is at end of list - // N.B. that this is only "shallow". Callers beware! - aKid->SetDocument(mDocument, PR_FALSE, PR_TRUE); + aKid->SetDocument(mDocument, aDeepSetDocument, PR_TRUE); if (mDocument && HasMutationListeners(NS_STATIC_CAST(nsIStyledContent*,this), NS_EVENT_BITS_MUTATION_NODEINSERTED)) { diff --git a/mozilla/content/xul/content/src/nsXULElement.h b/mozilla/content/xul/content/src/nsXULElement.h index 6a5d2fda060..392ef842318 100644 --- a/mozilla/content/xul/content/src/nsXULElement.h +++ b/mozilla/content/xul/content/src/nsXULElement.h @@ -347,9 +347,12 @@ public: NS_IMETHOD ChildCount(PRInt32& aResult) const; NS_IMETHOD ChildAt(PRInt32 aIndex, nsIContent*& aResult) const; NS_IMETHOD IndexOf(nsIContent* aPossibleChild, PRInt32& aResult) const; - NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify); - NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify); + NS_IMETHOD InsertChildAt(nsIContent* aKid, PRInt32 aIndex, PRBool aNotify, + PRBool aDeepSetDocument); + NS_IMETHOD ReplaceChildAt(nsIContent* aKid, PRInt32 aIndex, + PRBool aNotify, PRBool aDeepSetDocument); + NS_IMETHOD AppendChildTo(nsIContent* aKid, PRBool aNotify, + PRBool aDeepSetDocument); NS_IMETHOD RemoveChildAt(PRInt32 aIndex, PRBool aNotify); NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpeceID) const; NS_IMETHOD GetTag(nsIAtom*& aResult) const; diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 463f19f2e94..bef0acafd5f 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -4809,7 +4809,7 @@ nsXULDocument::ResumeWalk() if (NS_FAILED(rv)) return rv; // ...and append it to the content model. - rv = element->AppendChildTo(child, PR_FALSE); + rv = element->AppendChildTo(child, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) return rv; // do pre-order document-level hookup, but only if @@ -4898,7 +4898,7 @@ nsXULDocument::ResumeWalk() if (! child) return NS_ERROR_UNEXPECTED; - rv = element->AppendChildTo(child, PR_FALSE); + rv = element->AppendChildTo(child, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) return rv; } } @@ -5945,7 +5945,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) if (pos != -1) { pos = isInsertAfter ? pos + 1 : pos; - rv = aParent->InsertChildAt(aChild, pos, PR_FALSE); + rv = aParent->InsertChildAt(aChild, pos, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; wasInserted = PR_TRUE; @@ -5962,7 +5962,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) // Positions are one-indexed. PRInt32 pos = posStr.ToInteger(NS_REINTERPRET_CAST(PRInt32*, &rv)); if (NS_SUCCEEDED(rv)) { - rv = aParent->InsertChildAt(aChild, pos - 1, PR_FALSE); + rv = aParent->InsertChildAt(aChild, pos - 1, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; wasInserted = PR_TRUE; @@ -5971,21 +5971,9 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) } if (! wasInserted) { - rv = aParent->AppendChildTo(aChild, PR_FALSE); + rv = aParent->AppendChildTo(aChild, PR_FALSE, PR_TRUE); if (NS_FAILED(rv)) return rv; } - - // Both InsertChildAt() and AppendChildTo() only do a "shallow" - // SetDocument(); make sure that we do a "deep" one now... - nsCOMPtr doc; - rv = aParent->GetDocument(*getter_AddRefs(doc)); - if (NS_FAILED(rv)) return rv; - - NS_ASSERTION(doc != nsnull, "merging into null document"); - - rv = aChild->SetDocument(doc, PR_TRUE, PR_TRUE); - if (NS_FAILED(rv)) return rv; - return NS_OK; } diff --git a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp index 911d3164eb3..fc83c862068 100644 --- a/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentBuilder.cpp @@ -694,7 +694,8 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, rv = content->SetText(value.GetUnicode(), value.Length(), PR_FALSE); if (NS_FAILED(rv)) return rv; - rv = aRealNode->AppendChildTo(nsCOMPtr( do_QueryInterface(content) ), aNotify); + rv = aRealNode->AppendChildTo(nsCOMPtr( do_QueryInterface(content) ), + aNotify, PR_FALSE); if (NS_FAILED(rv)) return rv; // XXX Don't bother remembering text nodes as the @@ -828,7 +829,7 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode, } if (NS_FAILED(rv)) { - rv = aRealNode->AppendChildTo(realKid, aNotify); + rv = aRealNode->AppendChildTo(realKid, aNotify, PR_FALSE); NS_ASSERTION(NS_SUCCEEDED(rv), "unable to insert element"); } } @@ -1368,7 +1369,7 @@ nsXULContentBuilder::EnsureElementHasGenericChild(nsIContent* parent, if (NS_FAILED(rv)) return rv; // XXX Note that the notification ensures we won't batch insertions! This could be bad! - Dave - rv = parent->AppendChildTo(element, aNotify); + rv = parent->AppendChildTo(element, aNotify, PR_FALSE); if (NS_FAILED(rv)) return rv; *result = element; diff --git a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp index 6081e74a969..882fd83cf40 100644 --- a/mozilla/content/xul/templates/src/nsXULContentUtils.cpp +++ b/mozilla/content/xul/templates/src/nsXULContentUtils.cpp @@ -186,7 +186,8 @@ nsXULContentUtils::AttachTextNode(nsIContent* parent, nsIRDFNode* value) if (NS_FAILED(rv)) return rv; // hook it up to the child - rv = parent->AppendChildTo(nsCOMPtr( do_QueryInterface(text) ), PR_FALSE); + rv = parent->AppendChildTo(nsCOMPtr( do_QueryInterface(text) ), + PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) return rv; return NS_OK; diff --git a/mozilla/content/xul/templates/src/nsXULSortService.cpp b/mozilla/content/xul/templates/src/nsXULSortService.cpp index b15c171f5f7..df6b2e8c059 100644 --- a/mozilla/content/xul/templates/src/nsXULSortService.cpp +++ b/mozilla/content/xul/templates/src/nsXULSortService.cpp @@ -1877,12 +1877,7 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo, PR { nsIContent* kid = NS_STATIC_CAST(nsIContent*, contentSortInfoArray[loop]->content); - // Because InsertChildAt() only does a - // "shallow" SetDocument(), we need to do a - // "deep" one now... - kid->SetDocument(doc, PR_TRUE, PR_TRUE); - - container->InsertChildAt(kid, childPos++, PR_FALSE); + container->InsertChildAt(kid, childPos++, PR_FALSE, PR_TRUE); parentNode = (nsIContent *)contentSortInfoArray[loop]->content; @@ -2222,7 +2217,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort direction = inplaceSortCallback(&node, &temp, &sortInfo); if (direction < 0) { - container->InsertChildAt(node, staticCount, aNotify); + container->InsertChildAt(node, staticCount, aNotify, PR_FALSE); childAdded = PR_TRUE; } else @@ -2237,7 +2232,8 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort direction = inplaceSortCallback(&node, &temp, &sortInfo); if (direction > 0) { - container->InsertChildAt(node, staticCount+numChildren, aNotify); + container->InsertChildAt(node, staticCount+numChildren, aNotify, + PR_FALSE); childAdded = PR_TRUE; } else @@ -2260,7 +2256,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort if (((x == left) && (direction < 0)) || (((x == right)) && (direction > 0)) || (left == right)) { PRInt32 thePos = ((direction > 0) ? x : x-1); - container->InsertChildAt(node, thePos, aNotify); + container->InsertChildAt(node, thePos, aNotify, PR_FALSE); childAdded = PR_TRUE; sortState->lastWasFirst = (thePos == 0) ? PR_TRUE: PR_FALSE; @@ -2276,7 +2272,7 @@ XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSort if (childAdded == PR_FALSE) { - container->InsertChildAt(node, numChildren, aNotify); + container->InsertChildAt(node, numChildren, aNotify, PR_FALSE); } if ((!sortState->mCache) && (sortInfo.mInner)) @@ -2432,14 +2428,8 @@ XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource, if (NS_FAILED(rv = treeBody->GetParent(*getter_AddRefs(treeParent)))) return(rv); if (NS_FAILED(rv = treeParent->IndexOf(treeBody, treeBodyIndex))) return(rv); if (NS_FAILED(rv = treeParent->RemoveChildAt(treeBodyIndex, PR_TRUE))) return(rv); - - // We need to do a deep SetDocument(), because AppendChildTo() - // only does a shallow one. - nsCOMPtr doc; - treeParent->GetDocument(*getter_AddRefs(doc)); - treeBody->SetDocument(doc, PR_TRUE, PR_TRUE); - - if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE))) return(rv); + if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE, PR_TRUE))) + return(rv); return(NS_OK); } diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 2fc7be6194f..1966b1ed844 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -2609,9 +2609,9 @@ nsresult DocumentViewerImpl::GetSelectionDocument(nsIDeviceContextSpec * aDevSpe if (!bodyElement) { return NS_ERROR_NULL_POINTER; } bodyElement->SetDocument(doc, PR_FALSE, PR_TRUE); // put the head and body into the root - rv = htmlElement->AppendChildTo(headElement, PR_FALSE); + rv = htmlElement->AppendChildTo(headElement, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) { return rv; } - rv = htmlElement->AppendChildTo(bodyElement, PR_FALSE); + rv = htmlElement->AppendChildTo(bodyElement, PR_FALSE, PR_FALSE); if (NS_FAILED(rv)) { return rv; } // load the document into the docshell diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 8bb51cd5a7b..5042a5a6f06 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -256,7 +256,7 @@ nsComboboxControlFrame::nsComboboxControlFrame() mGoodToGo = PR_FALSE; - //Shrink the area around it's contents + //Shrink the area around it's contents //SetFlags(NS_BLOCK_SHRINK_WRAP); REFLOW_COUNTER_INIT() @@ -2261,10 +2261,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); - /* - labelContent->SetDocument(doc, PR_FALSE, PR_TRUE); - mContent->AppendChildTo(labelContent, PR_FALSE); - */ + // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); nsCOMPtr nimgr; result = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 8bb51cd5a7b..5042a5a6f06 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -256,7 +256,7 @@ nsComboboxControlFrame::nsComboboxControlFrame() mGoodToGo = PR_FALSE; - //Shrink the area around it's contents + //Shrink the area around it's contents //SetFlags(NS_BLOCK_SHRINK_WRAP); REFLOW_COUNTER_INIT() @@ -2261,10 +2261,7 @@ nsComboboxControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext, nsCOMPtr doc; mContent->GetDocument(*getter_AddRefs(doc)); - /* - labelContent->SetDocument(doc, PR_FALSE, PR_TRUE); - mContent->AppendChildTo(labelContent, PR_FALSE); - */ + // mContent->AppendChildTo(labelContent, PR_FALSE, PR_FALSE); nsCOMPtr nimgr; result = doc->GetNodeInfoManager(*getter_AddRefs(nimgr)); diff --git a/mozilla/layout/html/tests/TestAttributes.cpp b/mozilla/layout/html/tests/TestAttributes.cpp index 9afec5ec26b..88da65c0643 100644 --- a/mozilla/layout/html/tests/TestAttributes.cpp +++ b/mozilla/layout/html/tests/TestAttributes.cpp @@ -300,7 +300,7 @@ int main(int argc, char** argv) NS_ASSERTION(canHaveKids,""); container->SetDocument(myDoc, PR_FALSE, PR_TRUE); - container->AppendChildTo(text, PR_FALSE); + container->AppendChildTo(text, PR_FALSE, PR_FALSE); PRInt32 nk; container->ChildCount(nk); if (nk != 1) {