nsAutoString posStr; rv = child->GetAttribute(kNameSpaceID_None, kPositionAtom, posStr);
rv = InsertElement(aOriginalNode, child);
XULContentSinkImpl::Merge(nsIContent* aOriginalNode, nsIContent* aOverlayNode){    nsresult rv;    {        // Whack the attributes from aOverlayNode onto aOriginalNode        PRInt32 count;        rv = aOverlayNode->GetAttributeCount(count);        if (NS_FAILED(rv)) return rv;        for (PRInt32 i = 0; i < count; ++i) {            PRInt32 nameSpaceID;            nsCOMPtr<nsIAtom> tag;            rv = aOverlayNode->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(tag));            if (NS_FAILED(rv)) return rv;            nameSpaceID = kNameSpaceID_None;            if (nameSpaceID == kNameSpaceID_None && tag.get() == kIdAtom)                continue;            nsAutoString value;            rv = aOverlayNode->GetAttribute(nameSpaceID, tag, value);            if (NS_FAILED(rv)) return rv;            rv = aOriginalNode->SetAttribute(nameSpaceID, tag, value, PR_FALSE);            if (NS_FAILED(rv)) return rv;        }    }    {        // Now move any kids        PRInt32 count;        rv = aOverlayNode->ChildCount(count);        if (NS_FAILED(rv)) return rv;        for (PRInt32 i = 0; i < count; ++i) {            nsCOMPtr<nsIContent> child;            rv = aOverlayNode->ChildAt(i, *getter_AddRefs(child));            if (NS_FAILED(rv)) return rv;            nsAutoString posStr;            rv = child->GetAttribute(kNameSpaceID_None, kPositionAtom, posStr);            if (NS_FAILED(rv)) return rv;            PRBool wasInserted = PR_FALSE;            if (rv == NS_CONTENT_ATTR_HAS_VALUE) {                PRInt32 pos = posStr.ToInteger(NS_REINTERPRET_CAST(PRInt32*, &rv));                if (NS_SUCCEEDED(rv)) {                    rv = aOriginalNode->InsertChildAt(child, pos, PR_FALSE);                    if (NS_FAILED(rv)) return rv;                    wasInserted = PR_TRUE;                }            }            if (! wasInserted) {                rv = aOriginalNode->AppendChildTo(child, PR_FALSE);                if (NS_FAILED(rv)) return rv;            }        }        // Ok, now we _don't_ need to add these to the        // document-to-element map because normal construction of the        // nodes in OpenTag() will have done this.    }    return NS_OK;}