nsCOMPtr<nsIAtom> tag; element->GetTag(getter_AddRefs(tag)); if (tag.get() == nsXULAtoms::templateAtom)
nsINodeInfo *ni = element->GetNodeInfo(); if (!ni || ni->Equals(nsXULAtoms::templateAtom, kNameSpaceID_XUL))
nsXULContentBuilder::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);        PRUint32 i = element->GetChildCount();        while (i-- > 0) {            nsCOMPtr<nsIContent> child = element->GetChildAt(i);            // 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::templateAtom)                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) {                // No 'template' attribute, 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);            // Remove element from the conflict set.            // XXXwaterson should this be moved into NoteGeneratedSubtreeRemoved?            nsTemplateMatchSet firings(mConflictSet.GetPool());            nsTemplateMatchSet retractions(mConflictSet.GetPool());            mConflictSet.Remove(nsContentTestNode::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;}