aOffset = i;
aOffset = mContentOffset+mContentLength;
void TextFrame::CalcCursorPosition(nsIPresContext& aCX,                                   nsGUIEvent*     aEvent,                                   TextFrame *     aNewFrame,                                   PRInt32 &       aOffset,                                    PRInt32 &       aWidth) {    nsIStyleContext * styleContext;  aNewFrame->GetStyleContext(&aCX, styleContext);  const nsStyleFont *font      = (const nsStyleFont*)styleContext->GetStyleData(eStyleStruct_Font);  const nsStyleText *styleText = (const nsStyleText*)styleContext->GetStyleData(eStyleStruct_Text);  NS_RELEASE(styleContext);  nsIFontMetrics* fm   = aCX.GetMetricsFor(font->mFont);  nscoord width        = 0;  PRUint16        indexes[1024];  PRUint32        compressedStrLen;  PRBool          shouldDelete = PR_FALSE;  char            buf[128];  char *          compressedStr;  compressedStr = CompressWhiteSpace(buf, sizeof(buf), indexes, compressedStrLen, shouldDelete);  //compressedStr[compressedStrLen] = 0; // debug only  PRInt32 i;  char buffer[1024];  for (i=1;i<PRInt32(compressedStrLen);i++) {    strncpy(buffer, compressedStr, i);	  buffer[i] = 0;    width = fm->GetWidth(buffer);    //printf("%s %d %d\n", buf, i, width);    if (width >= aEvent->point.x) {      if (aEvent->message == NS_MOUSE_LEFT_BUTTON_DOWN) {        i--;        if (i < 0) {          i = 0;        }      }      aOffset = 0;      PRInt32 j;      for (j=0;j<PRInt32(mContentLength);j++) {        if (indexes[j] == i+mContentOffset) {          aOffset = j+mContentOffset;          //printf("Char pos %d  Offset is %d\n", i, aOffset);        }      }	    //aOffset = indexes[i];	    aWidth  = width;      aWidth = 0;	    return;    }  }  aOffset = i;  aWidth  = width;  if (shouldDelete) {    delete compressedStr;  }}