if (!aInnerIter) return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIContentIterator> iter = do_CreateInstance(
nsTypedSelection::selectFrames(nsIPresContext* aPresContext,                             nsIContentIterator *aInnerIter,                             nsIContent *aContent,                             nsIDOMRange *aRange,                             nsIPresShell *aPresShell,                             PRBool aFlags){  if (!mFrameSelection)    return NS_OK;//nothing to do  nsresult result;  if (!aInnerIter)    return NS_ERROR_NULL_POINTER;#ifdef USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE  nsCOMPtr<nsIGeneratedContentIterator> genericiter = do_QueryInterface(aInnerIter);  if (genericiter && aPresShell)  {    result = genericiter->Init(aPresShell,aContent);  }  else#endif // USE_SELECTION_GENERATED_CONTENT_ITERATOR_CODE    result = aInnerIter->Init(aContent);  nsIFrame *frame;  if (NS_SUCCEEDED(result))  {    // First select frame of content passed in    result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(aContent, &frame);    if (NS_SUCCEEDED(result) && frame)    {      //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame      frame->SetSelected(aPresContext, nsnull, aFlags, eSpreadDown);#ifndef OLD_TABLE_SELECTION      PRBool tablesel;      mFrameSelection->GetTableCellSelection(&tablesel);      if (tablesel)      {        nsITableCellLayout *tcl;        if (NS_SUCCEEDED(frame->QueryInterface(NS_GET_IID(nsITableCellLayout),(void **)&tcl)) && tcl)        {          return NS_OK;        }      }#endif //OLD_TABLE_SELECTION    }    // Now iterated through the child frames and set them    nsCOMPtr<nsIContent> innercontent;    nsRect frameRect;     while (NS_ENUMERATOR_FALSE == aInnerIter->IsDone())    {      result = aInnerIter->CurrentNode(getter_AddRefs(innercontent));      if (NS_SUCCEEDED(result) && innercontent)      {        result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(innercontent, &frame);        if (NS_SUCCEEDED(result) && frame)        {          //NOTE: eSpreadDown is now IGNORED. Selected state is set only for given frame          frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);//spread from here to hit all frames in flow          frame->GetRect(frameRect);                    //if a rect is 0 height/width then try to notify next available in flow of selection status.          while (!frameRect.width || !frameRect.height)          {            //try to notify next in flow that its content is selected.            if (NS_SUCCEEDED(frame->GetNextInFlow(&frame)) && frame)            {              frame->GetRect(frameRect);              frame->SetSelected(aPresContext, nsnull,aFlags,eSpreadDown);            }            else              break;          }        //if the frame is splittable and this frame is 0,0 then set the next in flow frame to be selected also        }      }      result = aInnerIter->Next();      if (NS_FAILED(result))        return result;    }#if 0    result = mFrameSelection->GetTracker()->GetPrimaryFrameFor(content, &frame);    if (NS_SUCCEEDED(result) && frame)      frame->SetSelected(aRange,aFlags,eSpreadDown);//spread from here to hit all frames in flow#endif    return NS_OK;  }  return NS_ERROR_FAILURE;}