PRInt32 numChildren = theNode->GetChildCount();
PRInt32 numChildren = 0;
nsSelection::GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset){  if (!aNode || !aReturnFrame || !aReturnOffset)    return NS_ERROR_NULL_POINTER;  if (aOffset < 0)    return NS_ERROR_FAILURE;  *aReturnOffset = aOffset;  nsresult result = NS_OK;  nsCOMPtr<nsIContent> theNode = aNode;  if (aNode->IsContentOfType(nsIContent::eELEMENT))  {    PRInt32 childIndex  = 0;    PRInt32 numChildren = theNode->GetChildCount();    if (numChildren == 0)    {      *aReturnOffset = 0;      return mShell->GetPrimaryFrameFor(theNode, aReturnFrame);    }        if (aHint == HINTLEFT)    {      if (aOffset > 0)        childIndex = aOffset - 1;      else        childIndex = aOffset;    }    else // HINTRIGHT    {      if (aOffset >= numChildren)        childIndex = numChildren - 1;      else        childIndex = aOffset;    }        nsCOMPtr<nsIContent> childNode = theNode->GetChildAt(childIndex);    if (!childNode)      return NS_ERROR_FAILURE;    theNode = childNode;#ifdef DONT_DO_THIS_YET    // XXX: We can't use this code yet because the hinting    //      can cause us to attatch to the wrong line frame.    // Now that we have the child node, check if it too    // can contain children. If so, call this method again!    if (theNode->IsContentOfType(nsIContent::eELEMENT))    {      PRInt32 newOffset = 0;      if (aOffset > childIndex)      {        numChildren = theNode->GetChildCount();        newOffset = numChildren;      }      return GetFrameForNodeOffset(theNode, newOffset, aHint, aReturnFrame,aReturnOffset);    }    else#endif // DONT_DO_THIS_YET    {      // Check to see if theNode is a text node. If it is, translate      // aOffset into an offset into the text node.      nsCOMPtr<nsIDOMText> textNode = do_QueryInterface(theNode);      if (textNode)      {        if (aOffset > childIndex)        {          PRUint32 textLength = 0;          result = textNode->GetLength(&textLength);          if (NS_FAILED(result))            return NS_ERROR_FAILURE;          *aReturnOffset = (PRInt32)textLength;        }        else          *aReturnOffset = 0;      }    }  }    result = mShell->GetPrimaryFrameFor(theNode, aReturnFrame);  if (NS_FAILED(result))    return result;  if (!*aReturnFrame)    return NS_ERROR_UNEXPECTED;  // find the child frame containing the offset we want  result = (*aReturnFrame)->GetChildFrameContainingOffset(*aReturnOffset, aHint, &aOffset, aReturnFrame);  return result;}