if (mAnchorNode && mFocusNode){ anchorContent =  mAnchorNode; frameContent = mFocusNode;
if (getAnchorNode() && getFocusNode()){ anchorContent =  getAnchorNode(); frameContent = getFocusNode();
nsRangeList::ResetSelection(nsIFocusTracker *aTracker, nsIFrame *aStartFrame){  nsCOMPtr<nsIDOMNode> startNode;  nsCOMPtr<nsIDOMNode> endNode;  PRInt32 startOffset;  PRInt32 endOffset;  nsIFrame *result;  nsCOMPtr<nsIDOMRange> range;  //we will need to check if any "side" is the anchor and send a direction order to the frames.  if (!mRangeArray)    return NS_ERROR_FAILURE;  //reset the focus and anchor points.  nsCOMPtr<nsIContent> anchorContent;  nsCOMPtr<nsIContent> frameContent;  if (mAnchorNode && mFocusNode){    anchorContent =  mAnchorNode;    frameContent = mFocusNode;  }  for (PRInt32 i =0; i<mRangeArray->Count(); i++){    //end content and start content do NOT necessarily mean anchor and focus frame respectively    PRInt32 anchorOffset = -1; //the frames themselves can talk to the presentation manager.  we will tell them    PRInt32 frameOffset = -1;  // where we would "like" to have the anchor pt.  actually we count on it.    range = (nsISupports *)mRangeArray->ElementAt(i);    DEBUG_OUT_RANGE(range);    range->GetStartParent(getter_AddRefs(startNode));    range->GetStartOffset(&startOffset);    range->GetEndParent(getter_AddRefs(endNode));    range->GetEndOffset(&endOffset);    nsCOMPtr<nsIContent> startContent(startNode);    result = findFrameFromContent(aStartFrame, startContent,PR_TRUE);    if (result){      nsCOMPtr<nsIContent> endContent(endNode);      if (endContent == startContent){        if (startContent == frameContent)          frameOffset = mFocusOffset;        if ( startContent == anchorContent )           anchorOffset = mAnchorOffset;         result->SetSelectedContentOffsets(PR_TRUE, startOffset, endOffset, anchorOffset, frameOffset, PR_FALSE,                                           aTracker, &result);      }      else{        if (startContent == frameContent)          frameOffset = mFocusOffset;        if ( startContent == anchorContent )           anchorOffset = mAnchorOffset;         result->SetSelectedContentOffsets(PR_TRUE, startOffset, -1 , anchorOffset, frameOffset, PR_FALSE,                                           aTracker, &result);//select from start to end        //now we keep selecting until we hit the last content, or the end of the page.        anchorOffset = -1;        frameOffset = -1;        while(result = getNextFrame(result)){          nsCOMPtr<nsIContent> content;          result->GetContent(*getter_AddRefs(content));          if (content == endContent){            if (endContent == frameContent)              frameOffset = mFocusOffset;            if ( endContent == anchorContent )               anchorOffset = mAnchorOffset;             result->SetSelectedContentOffsets(PR_TRUE, 0, endOffset, anchorOffset, frameOffset, PR_FALSE,                                               aTracker, &result);//select from beginning to endOffset            return NS_OK;          }          else            result->SetSelected(PR_TRUE, 0 , -1, PR_FALSE);        }      }    }  }  return NS_OK;}