PRUnichar* text = PrepareUnicodeText(ip, buf, kNumIndices, textLength);
nscoord width = 0; PRUnichar* text = PrepareUnicodeText(*aRendContext, ip, buf, kNumIndices, textLength, width);
TextFrame::GetPosition(nsIPresContext& aCX,                       nsIRenderingContext * aRendContext,                       nsGUIEvent*     aEvent,                       nsIFrame*       aNewFrame,                       PRUint32&       aAcutalContentOffset,                       PRInt32&        aOffset){  const PRInt16 kNumIndices = 512;  // Get the rendered form of the text  PRInt32 textLength;  PRInt32  indicies[kNumIndices];  PRInt32* ip = indicies;  if (mContentLength > kNumIndices) {    ip = new PRInt32[mContentLength+1];  }  PRUnichar buf[kNumIndices];  PRUnichar* text = PrepareUnicodeText(ip, buf, kNumIndices, textLength);  ip[mContentLength] = ip[mContentLength-1]+1;  // Find the font metrics for this text  nsIStyleContext* styleContext;  aNewFrame->GetStyleContext(&aCX, styleContext);  const nsStyleFont *font = (const nsStyleFont*) styleContext->GetStyleData(eStyleStruct_Font);  NS_RELEASE(styleContext);  nsIFontMetrics* fm = aCX.GetMetricsFor(font->mFont);  PRInt32 offset = mContentOffset + mContentLength;  PRInt32 index;  PRInt32 textWidth;  aRendContext->SetFont(fm);  PRBool found = BinarySearchForPosition(aRendContext, text, 0, 0, 0, PRInt32(textLength), PRInt32(aEvent->point.x), index, textWidth);  if (found) {    PRInt32 charWidth;    aRendContext->GetWidth(text[index], charWidth);    charWidth /= 2;    if (PRInt32(aEvent->point.x) > textWidth+charWidth) {      index++;    }    offset = 0;    PRInt32 j;    PRInt32* ptr = ip; // We will use pointer math to make it fast, instead of indexing into ip    for (j=0;j<=PRInt32(mContentLength);j++) {      if (*ptr == index+mContentOffset) {        offset = j+mContentOffset;        break;      }      ptr++;    }        }  NS_RELEASE(fm);  if (ip != indicies) {    delete [] ip;  }  if (text != buf) {    delete [] text;  }  aAcutalContentOffset = ((TextFrame *)aNewFrame)->mContentOffset;  aOffset = offset;  return NS_OK;}