nsILookAndFeel* look = nsnull; if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) { look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, mSelectionBGColor); look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, mSelectionTextColor); NS_RELEASE(look); }
nsILookAndFeel* look = aPresContext->LookAndFeel(); look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, mSelectionBGColor); look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, mSelectionTextColor);
    TextStyle(nsIPresContext* aPresContext,              nsIRenderingContext& aRenderingContext,              nsStyleContext* sc)    {      mNormalFont = nsnull;      mSmallFont = nsnull;      mLastFont = nsnull;      // Get style data      mColor = sc->GetStyleColor();      mFont = sc->GetStyleFont();      mText = sc->GetStyleText();      mVisibility = sc->GetStyleVisibility();      // Cache the original decorations and reuse the current font      // to query metrics, rather than creating a new font which is expensive.      nsFont* plainFont = (nsFont *)&mFont->mFont; //XXX: Change to use a CONST_CAST macro.      NS_ASSERTION(plainFont, "null plainFont: font problems in TextStyle::TextStyle");      PRUint8 originalDecorations = plainFont->decorations;      plainFont->decorations = NS_FONT_DECORATION_NONE;      mAveCharWidth = 0;      SetFontFromStyle(&aRenderingContext, sc); // some users of the struct expect this state      aRenderingContext.GetFontMetrics(mNormalFont);      mNormalFont->GetSpaceWidth(mSpaceWidth);      mNormalFont->GetAveCharWidth(mAveCharWidth);      mLastFont = mNormalFont;      // Get the small-caps font if needed      mSmallCaps = NS_STYLE_FONT_VARIANT_SMALL_CAPS == plainFont->variant;      if (mSmallCaps) {        nscoord originalSize = plainFont->size;        plainFont->size = nscoord(0.8 * plainFont->size);        aPresContext->GetMetricsFor(*plainFont, &mSmallFont);        // Reset to the size value saved earlier.        plainFont->size = originalSize;      }      else {        mSmallFont = nsnull;      }      // Reset to the decoration saved earlier      plainFont->decorations = originalDecorations;       // Get colors from look&feel      mSelectionBGColor = NS_RGB(0, 0, 0);      mSelectionTextColor = NS_RGB(255, 255, 255);	    nsILookAndFeel* look = nsnull;	    if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {	      look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, mSelectionBGColor);	      look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, mSelectionTextColor);	      NS_RELEASE(look);	    }      // Get the word and letter spacing      mWordSpacing = 0;      PRIntn unit = mText->mWordSpacing.GetUnit();      if (eStyleUnit_Coord == unit) {        mWordSpacing = mText->mWordSpacing.GetCoordValue();      }      mLetterSpacing = 0;      unit = mText->mLetterSpacing.GetUnit();      if (eStyleUnit_Coord == unit) {        mLetterSpacing = mText->mLetterSpacing.GetCoordValue();      }      mNumSpacesToRender = 0;      mNumSpacesToMeasure = 0;      mNumSpacesReceivingExtraJot = 0;      mExtraSpacePerSpace = 0;      mPreformatted = (NS_STYLE_WHITESPACE_PRE == mText->mWhiteSpace) ||        (NS_STYLE_WHITESPACE_MOZ_PRE_WRAP == mText->mWhiteSpace);      mJustifying = (NS_STYLE_TEXT_ALIGN_JUSTIFY == mText->mTextAlign) &&        !mPreformatted;    }