From a9e6edee5ad118362a0a202fc826d1a1516794d9 Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Thu, 21 Apr 2005 07:54:32 +0000 Subject: [PATCH] bug 290920 If an element has 'font-variant: small-caps', the selection color is broken r/sr=bzbarsky, a=dbaron git-svn-id: svn://10.0.0.236/trunk@172538 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsTextFrame.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index a495e0ed860..35bce97f512 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -687,6 +687,8 @@ public: TextPaintStyle& aStyle, nscoord aX, nscoord aY); + // The passed-in rendering context must have its color set to the color the + // text should be rendered in. void RenderString(nsIRenderingContext& aRenderingContext, nsStyleContext* aStyleContext, nsPresContext* aPresContext, @@ -2827,6 +2829,11 @@ nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext, PRUnichar* runStart = bp; nscoord charWidth, width = 0; PRInt32 countSoFar = 0; + // Save the color we want to use for the text, since calls to + // PaintTextDecorations in this method will call SetColor() on the rendering + // context. + nscolor textColor; + aRenderingContext.GetColor(textColor); for (; --aLength >= 0; aBuffer++) { nsIFontMetrics* nextFont; nscoord glyphWidth; @@ -2905,8 +2912,9 @@ nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext, if (nextFont != lastFont) { pendingCount = bp - runStart; if (0 != pendingCount) { + // Render the text with the color specified first. + aRenderingContext.SetColor(textColor); // Measure previous run of characters using the previous font - aRenderingContext.SetColor(aTextStyle.mColor->mColor); aRenderingContext.DrawString(runStart, pendingCount, aX, aY + mAscent, -1, spacing ? sp0 : nsnull); @@ -2933,6 +2941,8 @@ nsTextFrame::RenderString(nsIRenderingContext& aRenderingContext, } pendingCount = bp - runStart; if (0 != pendingCount) { + // Render the text with the color specified first. + aRenderingContext.SetColor(textColor); // Measure previous run of characters using the previous font aRenderingContext.DrawString(runStart, pendingCount, aX, aY + mAscent, -1, spacing ? sp0 : nsnull);