diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index c0538a919d2..f7a6e6d32b3 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1338,32 +1338,10 @@ nsGenericElement::GetParent(nsIContent*& aResult) const return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - nsresult nsGenericElement::SetParent(nsIContent* aParent) { mParent = aParent; - - if (mParent) { - // Get the binding parent. - nsCOMPtr bindingParent; - mParent->GetBindingParent(getter_AddRefs(bindingParent)); - nsIContent* par = mDOMSlots ? mDOMSlots->mBindingParent : nsnull; - if (bindingParent && (bindingParent.get() != par)) - UpdateBindingParent(mContent, bindingParent); - } - return NS_OK; } @@ -1565,6 +1543,17 @@ nsGenericElement::SetBindingParent(nsIContent* aParent) GetDOMSlots(); mDOMSlots->mBindingParent = aParent; // Weak, so no addref happens. + + if (aParent) { + PRInt32 count; + mContent->ChildCount(count); + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr child; + mContent->ChildAt(i, *getter_AddRefs(child)); + child->SetBindingParent(aParent); + } + } + return NS_OK; } diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index 1cc5d8fdcab..afb98ca7028 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -396,18 +396,6 @@ nsXBLBinding::GetAnonymousContent(nsIContent** aResult) return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - NS_IMETHODIMP nsXBLBinding::SetAnonymousContent(nsIContent* aParent) { @@ -430,7 +418,7 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent) nsCOMPtr child; mContent->ChildAt(i, *getter_AddRefs(child)); child->SetParent(mBoundElement); - UpdateBindingParent(child, mBoundElement); + child->SetBindingParent(mBoundElement); } // (3) We need to insert entries into our attribute table for any elements diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index f72cf347800..bbd7f9a04b8 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -2318,31 +2318,10 @@ nsXULElement::GetParent(nsIContent*& aResult) const return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - NS_IMETHODIMP nsXULElement::SetParent(nsIContent* aParent) { mParent = aParent; // no refcount - - if (mParent) { - // Get the binding parent. - nsCOMPtr bindingParent; - mParent->GetBindingParent(getter_AddRefs(bindingParent)); - if (bindingParent && (bindingParent.get() != mBindingParent)) - UpdateBindingParent((nsIStyledContent*)this, bindingParent); - } - return NS_OK; } @@ -4222,6 +4201,15 @@ NS_IMETHODIMP nsXULElement::SetBindingParent(nsIContent* aParent) { mBindingParent = aParent; // [Weak] no addref + if (mBindingParent) { + PRInt32 count; + ChildCount(count); + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr child; + ChildAt(i, *getter_AddRefs(child)); + child->SetBindingParent(aParent); + } + } return NS_OK; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 5622744d597..2fec33bafad 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -5435,14 +5435,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, content->SetParent(aParent); content->SetDocument(aDocument, PR_TRUE, PR_TRUE); content->SetBindingParent(content); - nsCOMPtr child; - PRInt32 childCount; - content->ChildCount(childCount); - for (PRInt32 j = 0; j < childCount; j++) { - content->ChildAt(j, *getter_AddRefs(child)); - child->SetParent(content); - } - + nsIFrame * newFrame = nsnull; nsresult rv = creator->CreateFrameFor(aPresContext, content, &newFrame); if (NS_SUCCEEDED(rv) && newFrame != nsnull) { diff --git a/layout/base/src/nsGenericElement.cpp b/layout/base/src/nsGenericElement.cpp index c0538a919d2..f7a6e6d32b3 100644 --- a/layout/base/src/nsGenericElement.cpp +++ b/layout/base/src/nsGenericElement.cpp @@ -1338,32 +1338,10 @@ nsGenericElement::GetParent(nsIContent*& aResult) const return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - nsresult nsGenericElement::SetParent(nsIContent* aParent) { mParent = aParent; - - if (mParent) { - // Get the binding parent. - nsCOMPtr bindingParent; - mParent->GetBindingParent(getter_AddRefs(bindingParent)); - nsIContent* par = mDOMSlots ? mDOMSlots->mBindingParent : nsnull; - if (bindingParent && (bindingParent.get() != par)) - UpdateBindingParent(mContent, bindingParent); - } - return NS_OK; } @@ -1565,6 +1543,17 @@ nsGenericElement::SetBindingParent(nsIContent* aParent) GetDOMSlots(); mDOMSlots->mBindingParent = aParent; // Weak, so no addref happens. + + if (aParent) { + PRInt32 count; + mContent->ChildCount(count); + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr child; + mContent->ChildAt(i, *getter_AddRefs(child)); + child->SetBindingParent(aParent); + } + } + return NS_OK; } diff --git a/layout/html/style/src/nsCSSFrameConstructor.cpp b/layout/html/style/src/nsCSSFrameConstructor.cpp index 5622744d597..2fec33bafad 100644 --- a/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -5435,14 +5435,7 @@ nsCSSFrameConstructor::CreateAnonymousFrames(nsIPresShell* aPresShell, content->SetParent(aParent); content->SetDocument(aDocument, PR_TRUE, PR_TRUE); content->SetBindingParent(content); - nsCOMPtr child; - PRInt32 childCount; - content->ChildCount(childCount); - for (PRInt32 j = 0; j < childCount; j++) { - content->ChildAt(j, *getter_AddRefs(child)); - child->SetParent(content); - } - + nsIFrame * newFrame = nsnull; nsresult rv = creator->CreateFrameFor(aPresContext, content, &newFrame); if (NS_SUCCEEDED(rv) && newFrame != nsnull) { diff --git a/layout/xbl/src/nsXBLBinding.cpp b/layout/xbl/src/nsXBLBinding.cpp index 1cc5d8fdcab..afb98ca7028 100644 --- a/layout/xbl/src/nsXBLBinding.cpp +++ b/layout/xbl/src/nsXBLBinding.cpp @@ -396,18 +396,6 @@ nsXBLBinding::GetAnonymousContent(nsIContent** aResult) return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - NS_IMETHODIMP nsXBLBinding::SetAnonymousContent(nsIContent* aParent) { @@ -430,7 +418,7 @@ nsXBLBinding::SetAnonymousContent(nsIContent* aParent) nsCOMPtr child; mContent->ChildAt(i, *getter_AddRefs(child)); child->SetParent(mBoundElement); - UpdateBindingParent(child, mBoundElement); + child->SetBindingParent(mBoundElement); } // (3) We need to insert entries into our attribute table for any elements diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index f72cf347800..bbd7f9a04b8 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -2318,31 +2318,10 @@ nsXULElement::GetParent(nsIContent*& aResult) const return NS_OK; } -static void UpdateBindingParent(nsIContent* aContent, nsIContent* aBindingParent) -{ - aContent->SetBindingParent(aBindingParent); - PRInt32 count; - aContent->ChildCount(count); - for (PRInt32 i = 0; i < count; i++) { - nsCOMPtr child; - aContent->ChildAt(i, *getter_AddRefs(child)); - UpdateBindingParent(child, aBindingParent); - } -} - NS_IMETHODIMP nsXULElement::SetParent(nsIContent* aParent) { mParent = aParent; // no refcount - - if (mParent) { - // Get the binding parent. - nsCOMPtr bindingParent; - mParent->GetBindingParent(getter_AddRefs(bindingParent)); - if (bindingParent && (bindingParent.get() != mBindingParent)) - UpdateBindingParent((nsIStyledContent*)this, bindingParent); - } - return NS_OK; } @@ -4222,6 +4201,15 @@ NS_IMETHODIMP nsXULElement::SetBindingParent(nsIContent* aParent) { mBindingParent = aParent; // [Weak] no addref + if (mBindingParent) { + PRInt32 count; + ChildCount(count); + for (PRInt32 i = 0; i < count; i++) { + nsCOMPtr child; + ChildAt(i, *getter_AddRefs(child)); + child->SetBindingParent(aParent); + } + } return NS_OK; }