PRInt32& aStrLen)
PRInt32& aStrLen, nscoord& aNewWidth)
TextFrame::PrepareUnicodeText(PRInt32* aIndexes,                              PRUnichar* aBuffer, PRInt32 aBufSize,                              PRInt32& aStrLen){  PRUnichar* s = aBuffer;  PRUnichar* s0 = s;  // Get text content  PRInt32 textLength;  const PRUnichar* cp = GetText(mContent, textLength);  if (0 == textLength) {    aBuffer[0] = 0;    aStrLen = 0;    return aBuffer;  }  cp += mContentOffset;  const PRUnichar* end = cp + mContentLength;  // Skip leading space if necessary  PRInt32 mappingInx = 0;  PRInt32 strInx = mContentOffset;  if (0 != (mFlags & TEXT_SKIP_LEADING_WS)) {    while (cp < end) {      PRUnichar ch = *cp++;      if (!XP_IS_SPACE_W(ch)) {        cp--;        break;      } else {        if (nsnull != aIndexes) {          aIndexes[mappingInx++] = strInx;        }      }    }  }  PRInt32 length = 0;  if (0 != (TEXT_IS_PRE & mFlags)) {    PRIntn tabs = TEXT_GET_TAB_COUNT(mFlags);    // Make a copy of the text we are to render, translating tabs    // into whitespace.    PRInt32 maxLen = (end - cp) + 8*tabs;    if (maxLen > aBufSize) {      s0 = s = new PRUnichar[maxLen];    }    // Translate tabs into whitespace; translate other whitespace into    // spaces.    PRIntn col = (PRIntn) mColumn;    while (cp < end) {      PRUnichar ch = *cp++;      if (XP_IS_SPACE_W(ch)) {        if (ch == '\t') {          PRIntn spaces = 8 - (col & 7);          col += spaces;          while (--spaces >= 0) {            *s++ = ' ';            length++;          }          if (nsnull != aIndexes) {            aIndexes[mappingInx++] = strInx;            strInx++;/* XXX wrong? */          }          continue;        } else {          ch = ' ';        }      }      else if (ch == CH_NBSP) {        ch = ' ';      }      *s++ = ch;      length++;      if (nsnull != aIndexes) {        aIndexes[mappingInx++] = strInx;        strInx++;      }      col++;    }  } else {    // Make a copy of the text we are to render, compressing out    // whitespace; translating whitespace to literal spaces;    // eliminating trailing whitespace.    PRInt32 maxLen = end - cp;    if (maxLen > aBufSize) {      s0 = s = new PRUnichar[maxLen];    }    // Compress down the whitespace    while (cp < end) {      PRUnichar ch = *cp++;      if (XP_IS_SPACE_W(ch)) {        while (cp < end) {          ch = *cp++;          if (!XP_IS_SPACE_W(ch)) {            cp--;            break;          } else {            if (nsnull != aIndexes) {              aIndexes[mappingInx++] = strInx;            }          }        }        ch = ' ';      }      else if (ch == CH_NBSP) {        ch = ' ';      }      *s++ = ch;      length++;      if (nsnull != aIndexes) {        aIndexes[mappingInx++] = strInx;        strInx++;      }    }  }  aStrLen = length;  return s0;}