aRenderingContext.DrawString(text, textLength, dx, dy, mRect.width); PaintTextDecorations(aRenderingContext, aDecorations, dx, dy, mRect.width);
aRenderingContext.DrawString(text, textLength, dx, dy, width); PaintTextDecorations(aRenderingContext, aDecorations, dx, dy, width);
TextFrame::PaintAsciiText(nsIPresContext& aPresContext,                          nsIRenderingContext& aRenderingContext,                          nscolor aTextColor,                          PRUint8 aDecorations,                          nscolor aSelectionTextColor,                          nscolor aSelectionBGColor,                          nscoord dx, nscoord dy){  nsIPresShell* shell = aPresContext.GetShell();  nsIDocument* doc = shell->GetDocument();  PRBool displaySelection;  displaySelection = doc->GetDisplaySelection();  PRInt32 textLength;  PRInt32 indicies[500];  PRInt32* ip = indicies;  if (mContentLength > 500) {    ip = new PRInt32[mContentLength];  }  char buf[500];  char* text = PrepareAsciiText(displaySelection ? ip : nsnull,                                buf, 500, textLength);  if (0 != textLength) {    if (!displaySelection) {      // When there is no selection showing, use the fastest and      // simplest rendering approach      aRenderingContext.DrawString(text, textLength, dx, dy, mRect.width);      PaintTextDecorations(aRenderingContext, aDecorations, dx, dy, mRect.width);    }    else {      SelectionInfo si;      ComputeSelectionInfo(aRenderingContext, doc, ip, textLength, si);      nscoord textWidth;      nsIFontMetrics * fm = aRenderingContext.GetFontMetrics();      if (si.mEmptySelection) {        aRenderingContext.DrawString(text, textLength, dx, dy, mRect.width);        PaintTextDecorations(aRenderingContext, aDecorations, dx, dy, mRect.width);        aRenderingContext.GetWidth(text, PRUint32(si.mStartOffset), textWidth);        RenderSelectionCursor(aRenderingContext,                              dx + textWidth, dy, mRect.height,                              CURSOR_COLOR);      }      else {        nscoord x = dx;        if (0 != si.mStartOffset) {          // Render first (unselected) section          aRenderingContext.GetWidth(text, PRUint32(si.mStartOffset), textWidth);          aRenderingContext.DrawString(text, si.mStartOffset,                                       x, dy, textWidth);          PaintTextDecorations(aRenderingContext, aDecorations, x, dy, textWidth);          x += textWidth;        }        PRInt32 secondLen = si.mEndOffset - si.mStartOffset;        if (0 != secondLen) {          // Get the width of the second (selected) section          aRenderingContext.GetWidth(text + si.mStartOffset, PRUint32(secondLen), textWidth);          // Render second (selected) section          aRenderingContext.SetColor(aSelectionBGColor);          aRenderingContext.FillRect(x, dy, textWidth, mRect.height);          aRenderingContext.SetColor(aSelectionTextColor);          aRenderingContext.DrawString(text + si.mStartOffset, secondLen,                                       x, dy, textWidth);          PaintTextDecorations(aRenderingContext, aDecorations, x, dy, textWidth);          aRenderingContext.SetColor(aTextColor);          x += textWidth;        }        if (textLength != si.mEndOffset) {          PRInt32 thirdLen = textLength - si.mEndOffset;          // Render third (unselected) section          aRenderingContext.GetWidth(text + si.mEndOffset, PRUint32(thirdLen), textWidth);          aRenderingContext.DrawString(text + si.mEndOffset,                                       thirdLen, x, dy, textWidth);          PaintTextDecorations(aRenderingContext, aDecorations, x, dy, textWidth);        }      }      NS_RELEASE(fm);    }  }  // Cleanup  if (text != buf) {    delete [] text;  }  if (ip != indicies) {    delete [] ip;  }  NS_RELEASE(shell);  NS_RELEASE(doc);}