From 3e398f42065e372b3a2ddf8d4446f055729ed65a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 21 Jul 2010 11:33:32 -0400 Subject: [PATCH] Bug 578696 part 10. Stop holding strong refs when calling ContentInserted. r=sicking --- content/base/public/nsIMutationObserver.h | 6 ++++++ content/base/src/nsNodeUtils.cpp | 2 +- content/xul/document/src/nsXULDocument.cpp | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/content/base/public/nsIMutationObserver.h b/content/base/public/nsIMutationObserver.h index 1e7386c9b6e6..7af99050d673 100644 --- a/content/base/public/nsIMutationObserver.h +++ b/content/base/public/nsIMutationObserver.h @@ -234,6 +234,12 @@ public: * aDocument * @param aChild The newly inserted child. * @param aIndexInContainer The index in the container of the new child. + * + * @note Callers of this method might not hold a strong reference to the + * observer. The observer is responsible for making sure it stays + * alive for the duration of the call as needed. The observer may + * assume that this call will happen when there are script blockers on + * the stack. */ virtual void ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, diff --git a/content/base/src/nsNodeUtils.cpp b/content/base/src/nsNodeUtils.cpp index 1b94de4fe802..83cca24353d4 100644 --- a/content/base/src/nsNodeUtils.cpp +++ b/content/base/src/nsNodeUtils.cpp @@ -183,7 +183,7 @@ nsNodeUtils::ContentInserted(nsINode* aContainer, document = static_cast(aContainer); } - IMPL_STRONGREF_MUTATION_NOTIFICATION(ContentInserted, aContainer, + IMPL_MUTATION_NOTIFICATION(ContentInserted, aContainer, (document, container, aChild, aIndexInContainer)); } diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 04d0c1ebfc6b..498a536893bf 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1121,6 +1121,9 @@ nsXULDocument::ContentInserted(nsIDocument* aDocument, { NS_ASSERTION(aDocument == this, "unexpected doc"); + // Might not need this, but be safe for now. + nsCOMPtr kungFuDeathGrip(this); + AddSubtreeToDocument(aChild); }