if (tc.get()) { tc->GetText(&frag); } if (!frag) { return NS_ERROR_FAILURE;
if (tc) { frag = tc->Text(); if (!frag) { return NS_ERROR_FAILURE; }
nsTextFrame::Paint(nsIPresContext*      aPresContext,                   nsIRenderingContext& aRenderingContext,                   const nsRect&        aDirtyRect,                   nsFramePaintLayer    aWhichLayer,                   PRUint32             aFlags){  if (NS_FRAME_PAINT_LAYER_FOREGROUND != aWhichLayer) {    return NS_OK;  }  if ((0 != (mState & TEXT_BLINK_ON)) && nsBlinkTimer::GetBlinkIsOff()) {    return NS_OK;  }  nsStyleContext* sc = mStyleContext;  PRBool isVisible;  if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {    TextStyle ts(aPresContext, aRenderingContext, mStyleContext);    if (ts.mSmallCaps || (0 != ts.mWordSpacing) || (0 != ts.mLetterSpacing)      || ts.mJustifying) {      PaintTextSlowly(aPresContext, aRenderingContext, sc, ts, 0, 0);    }    else {      // Get the text fragment      nsCOMPtr<nsITextContent> tc = do_QueryInterface(mContent);      const nsTextFragment* frag = nsnull;      if (tc.get()) {        tc->GetText(&frag);      }      if (!frag) {        return NS_ERROR_FAILURE;      }      // Choose rendering pathway based on rendering context performance      // hint, whether it needs to be transformed, and whether it's      // multi-byte      PRBool   hasMultiByteChars = (0 != (mState & TEXT_HAS_MULTIBYTE));      PRUint32 hints = 0;      aRenderingContext.GetHints(hints);#ifdef IBMBIDI      PRBool bidiEnabled = aPresContext->BidiEnabled();#else      const PRBool bidiEnabled = PR_FALSE;#endif // IBMBIDI      // * BiDi text or text with multi-byte characters must always be      //   rendered as Unicode.      // * Non-transformed, 1-byte text should always be rendered as      //   ASCII.      // * Other transformed or 2-byte text should be rendered according      //   to the preference of the hint from the rendering context.      if (bidiEnabled || hasMultiByteChars ||          ((0 == (hints & NS_RENDERING_HINT_FAST_8BIT_TEXT)) &&           (frag->Is2b() || (0 != (mState & TEXT_WAS_TRANSFORMED))))) {        PaintUnicodeText(aPresContext, aRenderingContext, sc, ts, 0, 0);      }      else {        PaintAsciiText(aPresContext, aRenderingContext, sc, ts, 0, 0);      }    }  }  DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame", &aRenderingContext);  return NS_OK;}