if (tag.get() == nsXULAtoms::Template)
if (tag.get() == nsXULAtoms::templateAtom)
nsXULTemplateBuilder::RemoveGeneratedContent(nsIContent* aElement){    // Keep a queue of "ungenerated" elements that we have to probe    // for generated content.    nsAutoVoidArray ungenerated;    ungenerated.AppendElement(aElement);    PRInt32 count;    while (0 != (count = ungenerated.Count())) {        // Pull the next "ungenerated" element off the queue.        PRInt32 last = count - 1;        nsIContent* element = NS_STATIC_CAST(nsIContent*, ungenerated[last]);        ungenerated.RemoveElementAt(last);        PRInt32 i = 0;        element->ChildCount(i);        while (--i >= 0) {            nsCOMPtr<nsIContent> child;            element->ChildAt(i, *getter_AddRefs(child));            NS_ASSERTION(child != nsnull, "huh? no child?");            if (! child)                continue;            // Optimize for the <template> element, because we *know*            // it won't have any generated content: there's no reason            // to even check this subtree.            nsCOMPtr<nsIAtom> tag;            element->GetTag(*getter_AddRefs(tag));            if (tag.get() == nsXULAtoms::Template)                continue;            // If the element is in the template map, then we            // assume it's been generated and nuke it.            nsCOMPtr<nsIContent> tmpl;            mTemplateMap.GetTemplateFor(child, getter_AddRefs(tmpl));            if (! tmpl) {                // Not in the template map, so this must not have been                // generated. We'll need to examine its kids.                ungenerated.AppendElement(child);                continue;            }            // If we get here, it's "generated". Bye bye!            element->RemoveChildAt(i, PR_TRUE);            child->SetDocument(nsnull, PR_TRUE, PR_TRUE);            // Remove element from the conflict set.            // XXXwaterson should this be moved into NoteGeneratedSubtreeRemoved?            MatchSet firings, retractions;            mConflictSet.Remove(ContentTestNode::Element(child), firings, retractions);            // Remove this and any children from the content support map.            mContentSupportMap.Remove(child);            // Remove from the template map            mTemplateMap.Remove(child);        }    }    return NS_OK;}