nsISupportsKey key(ins); nsCOMPtr<nsIDOMNodeList> nodeList = getter_AddRefs(NS_STATIC_CAST(nsIDOMNodeList*, mContentListTable->Get(&key))); if (nodeList) { nsCOMPtr<nsIAnonymousContentList> contentList(do_QueryInterface(nodeList)); if (contentList) {   PRUint32 count; contentList->GetInsertionPointCount(&count); for (PRUint32 i =0; i < count; i++) { nsCOMPtr<nsIXBLInsertionPoint> point; contentList->GetInsertionPointAt(i, getter_AddRefs(point)); PRInt32 index; point->GetInsertionIndex(&index); if (index != -1) {   point->InsertChildAt(aIndexInContainer, aChild); SetInsertionParent(aChild, ins); break;
nsCOMPtr<nsIDOMNodeList> nodeList; PRBool isAnonymousContentList; GetXBLChildNodesInternal(ins, getter_AddRefs(nodeList), &isAnonymousContentList);  if (nodeList && isAnonymousContentList) {   nsAnonymousContentList* contentList = NS_STATIC_CAST(nsAnonymousContentList*, NS_STATIC_CAST(nsIDOMNodeList*, nodeList.get()));  PRInt32 count = contentList->GetInsertionPointCount(); for (PRInt32 i = 0; i < count; i++) { nsXBLInsertionPoint* point = contentList->GetInsertionPointAt(i); if (point->GetInsertionIndex() != -1) {         PRInt32 pointSize = point->ChildCount(); PRBool inserted = PR_FALSE; for (PRInt32 parentIndex = aIndexInContainer - 1; parentIndex >= 0 && !inserted; --parentIndex) { nsIContent* currentSibling = aContainer->GetChildAt(parentIndex); for (PRInt32 pointIndex = pointSize - 1; pointIndex >= 0; --pointIndex) { nsCOMPtr<nsIContent> currContent = point->ChildAt(pointIndex); if (currContent == currentSibling) { point->InsertChildAt(pointIndex + 1, aChild); inserted = PR_TRUE; break; } }
nsBindingManager::ContentInserted(nsIDocument* aDocument,			                     nsIContent* aContainer,                           nsIContent* aChild,                           PRInt32 aIndexInContainer){// XXX This is hacked just to make menus work again.  if (aIndexInContainer == -1 || !mContentListTable)    // It's anonymous.    return NS_OK;   nsCOMPtr<nsIContent> ins;  GetNestedInsertionPoint(aContainer, aChild, getter_AddRefs(ins));  if (ins) {    nsISupportsKey key(ins);    nsCOMPtr<nsIDOMNodeList> nodeList = getter_AddRefs(NS_STATIC_CAST(nsIDOMNodeList*, mContentListTable->Get(&key)));    if (nodeList) {      nsCOMPtr<nsIAnonymousContentList> contentList(do_QueryInterface(nodeList));      if (contentList) {        // Find a non-pseudo-insertion point and just jam ourselves in.        // This is not 100% correct.  Hack city, baby.        PRUint32 count;        contentList->GetInsertionPointCount(&count);        for (PRUint32 i =0; i < count; i++) {          nsCOMPtr<nsIXBLInsertionPoint> point;          contentList->GetInsertionPointAt(i, getter_AddRefs(point));          PRInt32 index;          point->GetInsertionIndex(&index);          if (index != -1) {            // We're real. Jam the kid in.            // XXX Check the filters to find the correct points.            point->InsertChildAt(aIndexInContainer, aChild);            SetInsertionParent(aChild, ins);            break;          }        }      }    }  }   return NS_OK;}