if(mFrameSelection) { nsCOMPtr<nsIDOMNode> startNode; result = aRange->GetStartContainer(getter_AddRefs(startNode)); if (NS_SUCCEEDED(result)) { nsCOMPtr<nsIDOMNode> endNode; result = aRange->GetEndContainer(getter_AddRefs(endNode)); if (NS_SUCCEEDED(result)) { if (startNode == endNode) { nsCOMPtr<nsIContent> content(do_QueryInterface(startNode)); if (content) { nsIAtom *atom; if (NS_SUCCEEDED(content->GetTag(atom)) && atom == nsSelection::sRowAtom) { mFrameSelection->mSelectingTableCellMode = TABLESELECTION_CELL; } else { PRInt32 startOffset; PRInt32 endOffset; result = aRange->GetEndOffset(&endOffset); result &= aRange->GetStartOffset(&startOffset); if (NS_SUCCEEDED(result)) { if ((endOffset - startOffset) == 1) { nsCOMPtr<nsIContent> childAt; if (NS_SUCCEEDED(content->ChildAt(startOffset, *getter_AddRefs(childAt)))) { if ( (childAt) && (NS_SUCCEEDED(childAt->GetTag(atom)) && atom == nsSelection::sTableAtom) ) { mFrameSelection->mSelectingTableCellMode = TABLESELECTION_TABLE; } } } } } } } } } }
nsTypedSelection::AddRange(nsIDOMRange* aRange){  nsresult      result = AddItem(aRange);    if (NS_FAILED(result))    return result;  PRInt32 count;  result = GetRangeCount(&count);  if (NS_FAILED(result))    return result;  if (count <= 0)  {    NS_ASSERTION(0,"bad count after additem\n");    return NS_ERROR_FAILURE;  }  setAnchorFocusRange(count -1);  //TABLE CELL CHECK  if(mFrameSelection)// don't assume we have a FrameSelection  {    nsCOMPtr<nsIDOMNode> startNode;    result = aRange->GetStartContainer(getter_AddRefs(startNode));    if (NS_SUCCEEDED(result))    {      nsCOMPtr<nsIDOMNode> endNode;      result = aRange->GetEndContainer(getter_AddRefs(endNode));      if (NS_SUCCEEDED(result))      {        if (startNode == endNode)        {//check for table row          nsCOMPtr<nsIContent> content(do_QueryInterface(startNode));          if (content)          {            nsIAtom *atom;            if (NS_SUCCEEDED(content->GetTag(atom)) && atom == nsSelection::sRowAtom)            {//we are selecting a talble cell!              mFrameSelection->mSelectingTableCellMode = TABLESELECTION_CELL;            }            else //check to see if we are selecting a table            {              PRInt32 startOffset;              PRInt32 endOffset;              result = aRange->GetEndOffset(&endOffset);              result &= aRange->GetStartOffset(&startOffset);              if (NS_SUCCEEDED(result))              {                if ((endOffset - startOffset) == 1) //1 child selected                {                  nsCOMPtr<nsIContent> childAt;                  if (NS_SUCCEEDED(content->ChildAt(startOffset, *getter_AddRefs(childAt))))                  {                    if ( (childAt) &&                          (NS_SUCCEEDED(childAt->GetTag(atom)) && atom == nsSelection::sTableAtom) )                    {                      mFrameSelection->mSelectingTableCellMode = TABLESELECTION_TABLE;                    }                  }                }              }            }          }        }      }    }  }  nsCOMPtr<nsIPresContext>  presContext;  GetPresContext(getter_AddRefs(presContext));  selectFrames(presContext, aRange, PR_TRUE);          //ScrollIntoView(); this should not happen automatically  if (!mFrameSelection)    return NS_OK;//nothing to do  return mFrameSelection->NotifySelectionListeners(GetType());}