nsCOMPtr<nsIContent> parentContent; header->GetParent(getter_AddRefs(parentContent));
nsIContent* parentContent = header->GetParent();
nsXULTreeBuilder::Sort(nsIDOMElement* aElement){    nsCOMPtr<nsIContent> header = do_QueryInterface(aElement);    if (! header)        return NS_ERROR_FAILURE;    nsAutoString sortLocked;    header->GetAttr(kNameSpaceID_None, nsXULAtoms::sortLocked, sortLocked);    if (sortLocked.Equals(NS_LITERAL_STRING("true")))        return NS_OK;    nsAutoString sort;    header->GetAttr(kNameSpaceID_None, nsXULAtoms::sort, sort);    if (sort.IsEmpty())        return NS_OK;    // Grab the new sort variable    mSortVariable = mRules.LookupSymbol(sort.get());    // Cycle the sort direction    nsAutoString dir;    header->GetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, dir);    if (dir == NS_LITERAL_STRING("ascending")) {        dir = NS_LITERAL_STRING("descending");        mSortDirection = eDirection_Descending;    }    else if (dir == NS_LITERAL_STRING("descending")) {        dir = NS_LITERAL_STRING("natural");        mSortDirection = eDirection_Natural;    }    else {        dir = NS_LITERAL_STRING("ascending");        mSortDirection = eDirection_Ascending;    }    // Sort it.    SortSubtree(mRows.GetRoot());    mRows.InvalidateCachedRow();    if (mBoxObject)         mBoxObject->Invalidate();    header->SetAttr(kNameSpaceID_None, nsXULAtoms::sortDirection, dir, PR_TRUE);    header->SetAttr(kNameSpaceID_None, nsXULAtoms::sortActive, NS_LITERAL_STRING("true"), PR_TRUE);    // Unset sort attribute(s) on the other columns    nsCOMPtr<nsIContent> parentContent;    header->GetParent(getter_AddRefs(parentContent));    if (parentContent) {        nsCOMPtr<nsIAtom> parentTag;        parentContent->GetTag(getter_AddRefs(parentTag));        if (parentTag == nsXULAtoms::treecols) {            PRInt32 numChildren;            parentContent->ChildCount(numChildren);            for (int i = 0; i < numChildren; ++i) {                nsCOMPtr<nsIContent> childContent;                nsCOMPtr<nsIAtom> childTag;                parentContent->ChildAt(i, getter_AddRefs(childContent));                if (childContent) {                    childContent->GetTag(getter_AddRefs(childTag));                    if (childTag == nsXULAtoms::treecol && childContent != header) {                        childContent->UnsetAttr(kNameSpaceID_None,                                                nsXULAtoms::sortDirection, PR_TRUE);                        childContent->UnsetAttr(kNameSpaceID_None,                                                nsXULAtoms::sortActive, PR_TRUE);                    }                }            }        }    }    return NS_OK;}