*aReturnDetails = nsnull; PRInt8 j; for (j = (PRInt8) 0; j < (PRInt8)nsISelectionController::NUM_SELECTIONTYPES; j++){ if (mDomSelections[j]) mDomSelections[j]->LookUpSelection(aContent, aContentOffset, aContentLength, aReturnDetails, (SelectionType)(1<<j), aSlowCheck);
for (i =0; i<cnt; i++){ nsCOMPtr<nsIDOMRange> range = mRangeArray[i]; if (range){ nsCOMPtr<nsIDOMNode> startNode; nsCOMPtr<nsIDOMNode> endNode; PRInt32 startOffset; PRInt32 endOffset; range->GetStartContainer(getter_AddRefs(startNode)); range->GetStartOffset(&startOffset); range->GetEndContainer(getter_AddRefs(endNode)); range->GetEndOffset(&endOffset); if (passedInNode == startNode && passedInNode == endNode){ if (startOffset < (aContentOffset + aContentLength)  && endOffset > aContentOffset){ if (!details){ details = new SelectionDetails;  newDetails = details; } else{ newDetails->mNext = new SelectionDetails; newDetails = newDetails->mNext; } if (!newDetails) return NS_ERROR_OUT_OF_MEMORY; newDetails->mNext = nsnull; newDetails->mStart = PR_MAX(0,startOffset - aContentOffset); newDetails->mEnd = PR_MIN(aContentLength, endOffset - aContentOffset); newDetails->mType = aType; } } else if (passedInNode == startNode){ if (startOffset < (aContentOffset + aContentLength)){ if (!details){ details = new SelectionDetails; newDetails = details; } else{ newDetails->mNext = new SelectionDetails; newDetails = newDetails->mNext; } if (!newDetails) return NS_ERROR_OUT_OF_MEMORY; newDetails->mNext = nsnull; newDetails->mStart = PR_MAX(0,startOffset - aContentOffset); newDetails->mEnd = aContentLength; newDetails->mType = aType; } } else if (passedInNode == endNode){ if (endOffset > aContentOffset){ if (!details){ details = new SelectionDetails; newDetails = details; } else{ newDetails->mNext = new SelectionDetails; newDetails = newDetails->mNext; } if (!newDetails) return NS_ERROR_OUT_OF_MEMORY; newDetails->mNext = nsnull; newDetails->mStart = 0; newDetails->mEnd = PR_MIN(aContentLength, endOffset - aContentOffset); newDetails->mType = aType; } } else {  if (cnt > 1 || aSlowCheck){  PRInt32 resultnum = ComparePoints(startNode, startOffset ,passedInNode, aContentOffset); if (resultnum > 0) continue; resultnum = ComparePoints(endNode, endOffset, passedInNode, aContentOffset ); if (resultnum <0) continue; }  if (!details){ details = new SelectionDetails; newDetails = details; } else{ newDetails->mNext = new SelectionDetails; newDetails = newDetails->mNext; } if (!newDetails) return NS_ERROR_OUT_OF_MEMORY; newDetails->mNext = nsnull; newDetails->mStart = 0; newDetails->mEnd = aContentLength; newDetails->mType = aType; } } else continue;
nsSelection::LookUpSelection(nsIContent *aContent, PRInt32 aContentOffset, PRInt32 aContentLength,                             SelectionDetails **aReturnDetails, PRBool aSlowCheck){  if (!aContent || !aReturnDetails)    return NS_ERROR_NULL_POINTER;  STATUS_CHECK_RETURN_MACRO();  *aReturnDetails = nsnull;  PRInt8 j;  for (j = (PRInt8) 0; j < (PRInt8)nsISelectionController::NUM_SELECTIONTYPES; j++){    if (mDomSelections[j])     mDomSelections[j]->LookUpSelection(aContent, aContentOffset, aContentLength, aReturnDetails, (SelectionType)(1<<j), aSlowCheck);  }  return NS_OK;}