nsCOMPtr<nsIPresContext> presContext; mPresShell->GetPresContext(getter_AddRefs(presContext)); rootFrame->FirstChild(presContext, nsnull, &rootFrame);
rootFrame = rootFrame->GetFirstChild(nsnull);
nsPopupBoxObject::ShowPopup(nsIDOMElement* aSrcContent,                             nsIDOMElement* aPopupContent,                             PRInt32 aXPos, PRInt32 aYPos,                             const PRUnichar *aPopupType, const PRUnichar *anAnchorAlignment,                             const PRUnichar *aPopupAlignment){  nsIFrame* rootFrame;  mPresShell->GetRootFrame(&rootFrame);  if (!rootFrame)    return NS_OK;  if (rootFrame) {    nsCOMPtr<nsIPresContext> presContext;    mPresShell->GetPresContext(getter_AddRefs(presContext));    rootFrame->FirstChild(presContext, nsnull, &rootFrame);     }  nsCOMPtr<nsIRootBox> rootBox(do_QueryInterface(rootFrame));  if (!rootBox)    return NS_OK;  nsIFrame* popupSetFrame;  rootBox->GetPopupSetFrame(&popupSetFrame);  if (!popupSetFrame)    return NS_OK;  nsCOMPtr<nsIPopupSetFrame> popupSet(do_QueryInterface(popupSetFrame));  if (!popupSet)    return NS_OK;  nsCOMPtr<nsIContent> srcContent(do_QueryInterface(aSrcContent));  nsCOMPtr<nsIContent> popupContent(do_QueryInterface(aPopupContent));  nsAutoString popupType(aPopupType);  nsAutoString anchorAlign(anAnchorAlignment);  nsAutoString popupAlign(aPopupAlignment);  // Use |left| and |top| dimension attributes to position the popup if  // present, as they may have been persisted.   nsAutoString left, top;  popupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::left, left);  popupContent->GetAttr(kNameSpaceID_None, nsXULAtoms::top, top);    PRInt32 err;  if (!left.IsEmpty()) {    aXPos = left.ToInteger(&err);    if (NS_FAILED(err))      return err;  }  if (!top.IsEmpty()) {    aYPos = top.ToInteger(&err);    if (NS_FAILED(err))      return err;  }  return popupSet->ShowPopup(srcContent, popupContent, aXPos, aYPos,                              popupType, anchorAlign, popupAlign);}