if (oldAnonymousElements) {     PRUint32 count; oldAnonymousElements->Count(&count);  while (PRInt32(--count) >= 0) { nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) ); nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) ); NS_ASSERTION(content != nsnull, "not an nsIContent"); if (! content) continue;  content->SetDocument(nsnull, PR_TRUE, PR_TRUE);
if (!oldAnonymousElements) { if (aAnonymousElements) { mAnonymousContentTable->Put(&key, aAnonymousElements); } } else { if (aAnonymousElements) { oldAnonymousElements->AppendElements(aAnonymousElements); } else {     PRUint32 count; oldAnonymousElements->Count(&count);  while (PRInt32(--count) >= 0) { nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) ); nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) ); NS_ASSERTION(content != nsnull, "not an nsIContent"); if (! content) continue;  content->SetDocument(nsnull, PR_TRUE, PR_TRUE); }
PresShell::SetAnonymousContentFor(nsIContent* aContent, nsISupportsArray* aAnonymousElements){  NS_PRECONDITION(aContent != nsnull, "null ptr");  if (! aContent)    return NS_ERROR_NULL_POINTER;  NS_PRECONDITION(aAnonymousElements != nsnull, "null ptr");  if (! aAnonymousElements)    return NS_ERROR_NULL_POINTER;  if (! mAnonymousContentTable) {    mAnonymousContentTable = new nsSupportsHashtable;    if (! mAnonymousContentTable)      return NS_ERROR_OUT_OF_MEMORY;  }  nsISupportsKey key(aContent);  nsCOMPtr<nsISupportsArray> oldAnonymousElements =    getter_AddRefs(NS_STATIC_CAST(nsISupportsArray*, mAnonymousContentTable->Get(&key)));  if (oldAnonymousElements) {    // If we're trying to set anonymous content for an element that    // already had anonymous content, then we need to be sure to clean    // up after the old content. (This can happen, for example, when a    // reframe occurs.)    PRUint32 count;    oldAnonymousElements->Count(&count);    while (PRInt32(--count) >= 0) {      nsCOMPtr<nsISupports> isupports( getter_AddRefs(oldAnonymousElements->ElementAt(count)) );      nsCOMPtr<nsIContent> content( do_QueryInterface(isupports) );      NS_ASSERTION(content != nsnull, "not an nsIContent");      if (! content)        continue;      content->SetDocument(nsnull, PR_TRUE, PR_TRUE);    }  }  mAnonymousContentTable->Put(&key, aAnonymousElements);  return NS_OK;}