Make nsContentSink, instead of subclasses, be responsible for making sure RemoveObserver is called (bug 420835). r+sr=sicking, a=blocking1.9+.

This commit is contained in:
jruderman@hmc.edu 2008-03-04 20:54:21 -08:00
Родитель f4abad427c
Коммит 7344700153
3 изменённых файлов: 24 добавлений и 24 удалений

Просмотреть файл

@ -154,10 +154,25 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsContentSink)
NS_INTERFACE_MAP_ENTRY(nsICSSLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsIScriptLoaderObserver)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptLoaderObserver)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_2(nsContentSink, mDocument, mParser)
NS_IMPL_CYCLE_COLLECTION_CLASS(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsContentSink)
if (tmp->mDocument) {
tmp->mDocument->RemoveObserver(tmp);
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsContentSink)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
nsContentSink::nsContentSink()
{
@ -181,6 +196,11 @@ nsContentSink::nsContentSink()
nsContentSink::~nsContentSink()
{
if (mDocument) {
// Remove ourselves just to be safe, though we really should have
// been removed in DidBuildModel if everything worked right.
mDocument->RemoveObserver(this);
}
}
nsresult

Просмотреть файл

@ -1570,11 +1570,6 @@ HTMLContentSink::~HTMLContentSink()
NS_IF_RELEASE(mBody);
NS_IF_RELEASE(mRoot);
if (mDocument) {
// Remove ourselves just to be safe, though we really should have
// been removed in DidBuildModel if everything worked right.
mDocument->RemoveObserver(this);
}
NS_IF_RELEASE(mHTMLDocument);
if (mNotificationTimer) {
@ -1615,22 +1610,16 @@ HTMLContentSink::~HTMLContentSink()
}
#if DEBUG
NS_IMPL_ISUPPORTS_INHERITED6(HTMLContentSink,
NS_IMPL_ISUPPORTS_INHERITED3(HTMLContentSink,
nsContentSink,
nsIContentSink,
nsIHTMLContentSink,
nsITimerCallback,
nsIDocumentObserver,
nsIMutationObserver,
nsIDebugDumpContent)
#else
NS_IMPL_ISUPPORTS_INHERITED5(HTMLContentSink,
NS_IMPL_ISUPPORTS_INHERITED2(HTMLContentSink,
nsContentSink,
nsIContentSink,
nsIHTMLContentSink,
nsITimerCallback,
nsIDocumentObserver,
nsIMutationObserver)
nsIHTMLContentSink)
#endif
static PRBool

Просмотреть файл

@ -145,12 +145,6 @@ nsXMLContentSink::nsXMLContentSink()
nsXMLContentSink::~nsXMLContentSink()
{
if (mDocument) {
// Remove ourselves just to be safe, though we really should have
// been removed in DidBuildModel if everything worked right.
mDocument->RemoveObserver(this);
}
NS_IF_RELEASE(mDocElement);
if (mText) {
PR_Free(mText); // Doesn't null out, unlike PR_FREEIF
@ -189,9 +183,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsXMLContentSink)
NS_INTERFACE_MAP_ENTRY(nsIContentSink)
NS_INTERFACE_MAP_ENTRY(nsIXMLContentSink)
NS_INTERFACE_MAP_ENTRY(nsIExpatSink)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY(nsITransformObserver)
NS_INTERFACE_MAP_END_INHERITING(nsContentSink)