newWordBufSize);
newWordBufSize, aIsBreakable);
nsTextFrame::ComputeTotalWordDimensions(nsIPresContext* aPresContext,                                   nsILineBreaker* aLineBreaker,                                   nsLineLayout& aLineLayout,                                   const nsHTMLReflowState& aReflowState,                                   nsIFrame* aNextFrame,                                   const nsTextDimensions& aBaseDimensions,                                   PRUnichar* aWordBuf,                                   PRUint32 aWordLen,                                   PRUint32 aWordBufSize){  // Before we get going, convert any spaces in the current word back  // to nbsp's. This keeps the breaking logic happy.  RevertSpacesToNBSP(aWordBuf, (PRInt32) aWordLen);  nsTextDimensions addedDimensions;  PRUnichar *newWordBuf = aWordBuf;  PRUint32 newWordBufSize = aWordBufSize;  while (nsnull != aNextFrame) {    nsIContent* content = nsnull;    if ((NS_OK == aNextFrame->GetContent(&content)) && (nsnull != content)) {#ifdef DEBUG_WORD_WRAPPING      printf("  next textRun=");      nsFrame::ListTag(stdout, aNextFrame);      printf("\n");#endif      nsITextContent* tc;      if (NS_OK == content->QueryInterface(kITextContentIID, (void**)&tc)) {        PRBool stop = PR_FALSE;        nsTextDimensions moreDimensions;        moreDimensions = ComputeWordFragmentDimensions(aPresContext,                                                   aLineBreaker,                                                   aLineLayout,                                                   aReflowState,                                                   aNextFrame, content, tc,                                                   &stop,                                                   newWordBuf,                                                   aWordLen,                                                   newWordBufSize);        if (moreDimensions.width < 0) {          PRUint32 moreSize = -moreDimensions.width;          //Oh, wordBuf is too small, we have to grow it          newWordBufSize += moreSize;          if (newWordBuf != aWordBuf) {            newWordBuf = (PRUnichar*)nsMemory::Realloc(newWordBuf, sizeof(PRUnichar)*newWordBufSize);            NS_ASSERTION(newWordBuf, "not enough memory");          } else {            newWordBuf = (PRUnichar*)nsMemory::Alloc(sizeof(PRUnichar)*newWordBufSize);            NS_ASSERTION(newWordBuf, "not enough memory");            if(newWordBuf)  {                memcpy((void*)newWordBuf, aWordBuf, sizeof(PRUnichar)*(newWordBufSize-moreSize));            }          }          if(newWordBuf)  {            moreDimensions = ComputeWordFragmentDimensions(aPresContext,                                                 aLineBreaker,                                                 aLineLayout,                                                 aReflowState,                                                 aNextFrame, content, tc,                                                 &stop,                                                 newWordBuf,                                                 aWordLen,                                                 newWordBufSize);            NS_ASSERTION((moreDimensions.width >= 0), "ComputeWordFragmentWidth is returning negative");          } else {            stop = PR_TRUE;            moreDimensions.Clear();          }          }        NS_RELEASE(tc);        NS_RELEASE(content);        addedDimensions.Combine(moreDimensions);#ifdef DEBUG_WORD_WRAPPING        printf("  moreWidth=%d (addedWidth=%d) stop=%c\n", moreDimensions.width,               addedDimensions.width, stop?'T':'F');#endif        if (stop) {          goto done;        }      }      else {        // It claimed it was text but it doesn't implement the        // nsITextContent API. Therefore I don't know what to do with it        // and can't look inside it. Oh well.        NS_RELEASE(content);        goto done;      }    }    // Move on to the next frame in the text-run    aNextFrame = aLineLayout.FindNextText(aPresContext, aNextFrame);  } done:;#ifdef DEBUG_WORD_WRAPPING  printf("  total word width=%d\n", aBaseDimensions.width + addedDimensions.width);#endif  if (newWordBuf && (newWordBuf != aWordBuf)) {    nsMemory::Free(newWordBuf);  }  addedDimensions.Combine(aBaseDimensions);  return addedDimensions;}