Bug 489008. Destroy anonymous content off a script-runner. r=bzbarsky

This commit is contained in:
Robert O'Callahan 2009-05-18 10:08:08 +12:00
Родитель 43aa3fca5b
Коммит 466a59cbb1
1 изменённых файлов: 20 добавлений и 2 удалений

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

@ -3878,13 +3878,31 @@ nsContentUtils::IsInSameAnonymousTree(nsINode* aNode,
}
class AnonymousContentDestroyer : public nsRunnable {
public:
AnonymousContentDestroyer(nsCOMPtr<nsIContent>* aContent) {
mContent.swap(*aContent);
mParent = mContent->GetParent();
mDoc = mContent->GetOwnerDoc();
}
NS_IMETHOD Run() {
mContent->UnbindFromTree();
return NS_OK;
}
private:
nsCOMPtr<nsIContent> mContent;
// Hold strong refs to the parent content and document so that they
// don't die unexpectedly
nsCOMPtr<nsIDocument> mDoc;
nsCOMPtr<nsIContent> mParent;
};
/* static */
void
nsContentUtils::DestroyAnonymousContent(nsCOMPtr<nsIContent>* aContent)
{
if (*aContent) {
(*aContent)->UnbindFromTree();
*aContent = nsnull;
AddScriptRunner(new AnonymousContentDestroyer(aContent));
}
}