Correct the coordinates for selection decoration in right-to-left text. Bug 421042, r+sr=roc, a=beltzner

git-svn-id: svn://10.0.0.236/trunk@249680 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
smontagu%smontagu.org 2008-04-06 08:12:09 +00:00
parent 79bdfd8a9a
commit a64cd011a7
6 changed files with 23 additions and 44 deletions

View File

@ -4462,8 +4462,7 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
const gfxFloat aAscent,
const gfxFloat aOffset,
const PRUint8 aDecoration,
const PRUint8 aStyle,
const PRBool aIsRTL)
const PRUint8 aStyle)
{
gfxRect rect =
GetTextDecorationRectInternal(aPt, aLineSize, aAscent, aOffset,
@ -4545,13 +4544,8 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
case NS_STYLE_BORDER_STYLE_DOTTED:
case NS_STYLE_BORDER_STYLE_DASHED:
aGfxContext->NewPath();
if (aIsRTL) {
aGfxContext->MoveTo(rect.TopRight());
aGfxContext->LineTo(rect.TopLeft());
} else {
aGfxContext->MoveTo(rect.TopLeft());
aGfxContext->LineTo(rect.TopRight());
}
aGfxContext->LineTo(rect.TopLeft());
aGfxContext->MoveTo(rect.TopRight());
aGfxContext->Stroke();
break;
default:

View File

@ -223,7 +223,6 @@ public:
* NS_STYLE_BORDER_STYLE_DOTTED or
* NS_STYLE_BORDER_STYLE_DASHED or
* NS_STYLE_BORDER_STYLE_DOUBLE.
* @param aIsRTL when the text is RTL, it is true.
*/
static void PaintDecorationLine(gfxContext* aGfxContext,
const nscolor aColor,
@ -232,8 +231,7 @@ public:
const gfxFloat aAscent,
const gfxFloat aOffset,
const PRUint8 aDecoration,
const PRUint8 aStyle,
const PRBool aIsRTL);
const PRUint8 aStyle);
/**
* Function for getting the decoration line rect for the text.

View File

@ -5910,8 +5910,6 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
// Only paint if we have a positive width
if (width > 0) {
const nsStyleVisibility* visibility = GetStyleVisibility();
PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL;
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(start + aPt.x),
PresContext()->AppUnitsToGfxUnits(aLine->mBounds.y + aPt.y));
@ -5919,7 +5917,7 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
nsCSSRendering::PaintDecorationLine(
ctx, aColor, pt, size,
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
aOffset, aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
aOffset, aDecoration, NS_STYLE_BORDER_STYLE_SOLID);
}
}

View File

@ -221,16 +221,13 @@ nsHTMLContainerFrame::PaintTextDecorationLine(
bp.side(side) = 0;
}
}
const nsStyleVisibility* visibility = GetStyleVisibility();
PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord innerWidth = mRect.width - bp.left - bp.right;
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(bp.left + aPt.x),
PresContext()->AppUnitsToGfxUnits(bp.top + aPt.y));
gfxSize size(PresContext()->AppUnitsToGfxUnits(innerWidth), aSize);
nsCSSRendering::PaintDecorationLine(ctx, aColor, pt, size, aAscent, aOffset,
aDecoration, NS_STYLE_BORDER_STYLE_SOLID,
isRTL);
aDecoration, NS_STYLE_BORDER_STYLE_SOLID);
}
void

View File

@ -3710,24 +3710,21 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
size.height = fontMetrics.underlineSize;
nsCSSRendering::PaintDecorationLine(
aCtx, decorations.mOverColor, pt, size, ascent, ascent,
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID,
mTextRun->IsRightToLeft());
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID);
}
if (decorations.HasUnderline()) {
size.height = fontMetrics.underlineSize;
gfxFloat offset = aProvider.GetFontGroup()->GetUnderlineOffset();
nsCSSRendering::PaintDecorationLine(
aCtx, decorations.mUnderColor, pt, size, ascent, offset,
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
mTextRun->IsRightToLeft());
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID);
}
if (decorations.HasStrikeout()) {
size.height = fontMetrics.strikeoutSize;
gfxFloat offset = fontMetrics.strikeoutOffset;
nsCSSRendering::PaintDecorationLine(
aCtx, decorations.mStrikeColor, pt, size, ascent, offset,
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
mTextRun->IsRightToLeft());
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID);
}
}
@ -3741,7 +3738,7 @@ static const SelectionType SelectionTypesWithDecorations =
static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
nsTextPaintStyle& aTextPaintStyle, const gfxPoint& aPt, gfxFloat aWidth,
gfxFloat aAscent, gfxFloat aSize, gfxFloat aOffset, PRBool aIsRTL)
gfxFloat aAscent, gfxFloat aSize, gfxFloat aOffset)
{
nscolor color;
float relativeSize;
@ -3754,7 +3751,7 @@ static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
gfxPoint pt(aPt.x + 1.0, aPt.y);
nsCSSRendering::PaintDecorationLine(
aContext, color, pt, gfxSize(width, actualSize), aAscent, aOffset,
NS_STYLE_TEXT_DECORATION_UNDERLINE, style, aIsRTL);
NS_STYLE_TEXT_DECORATION_UNDERLINE, style);
}
/**
@ -3763,7 +3760,7 @@ static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
*/
static void DrawSelectionDecorations(gfxContext* aContext, SelectionType aType,
nsTextPaintStyle& aTextPaintStyle, const gfxPoint& aPt, gfxFloat aWidth,
gfxFloat aAscent, const gfxFont::Metrics& aFontMetrics, PRBool aIsRTL)
gfxFloat aAscent, const gfxFont::Metrics& aFontMetrics)
{
gfxSize size(aWidth, aFontMetrics.underlineSize);
@ -3772,30 +3769,29 @@ static void DrawSelectionDecorations(gfxContext* aContext, SelectionType aType,
nsCSSRendering::PaintDecorationLine(
aContext, NS_RGB(255,0,0),
aPt, size, aAscent, aFontMetrics.underlineOffset,
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED,
aIsRTL);
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED);
break;
}
case nsISelectionController::SELECTION_IME_RAWINPUT:
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexRawInput,
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
aFontMetrics.underlineOffset, aIsRTL);
aFontMetrics.underlineOffset);
break;
case nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT:
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelRawText,
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
aFontMetrics.underlineOffset, aIsRTL);
aFontMetrics.underlineOffset);
break;
case nsISelectionController::SELECTION_IME_CONVERTEDTEXT:
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexConvText,
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
aFontMetrics.underlineOffset, aIsRTL);
aFontMetrics.underlineOffset);
break;
case nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT:
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelConvText,
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
aFontMetrics.underlineOffset, aIsRTL);
aFontMetrics.underlineOffset);
break;
default:
@ -4089,11 +4085,11 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
gfxFloat advance = hyphenWidth +
mTextRun->GetAdvanceWidth(offset, length, &aProvider);
if (type == aSelectionType) {
pt.x = (aTextBaselinePt.x + xOffset) / app;
pt.x = (aFramePt.x + xOffset -
(mTextRun->IsRightToLeft() ? advance : 0)) / app;
gfxFloat width = PR_ABS(advance) / app;
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
pt, width, mAscent / app, decorationMetrics,
mTextRun->IsRightToLeft());
pt, width, mAscent / app, decorationMetrics);
}
iterator.UpdateWithAdvance(advance);
}

View File

@ -447,7 +447,6 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
nscoord size;
nscoord ascent;
fontMet->GetMaxAscent(ascent);
PRBool isRTL = vis->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord baseline =
presContext->RoundAppUnitsToNearestDevPixels(textRect.y + ascent);
@ -465,16 +464,14 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
pt, gfxSize(width, sizePixel),
ascentPixel, ascentPixel,
NS_STYLE_TEXT_DECORATION_OVERLINE,
NS_STYLE_BORDER_STYLE_SOLID,
isRTL);
NS_STYLE_BORDER_STYLE_SOLID);
}
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, underColor,
pt, gfxSize(width, sizePixel),
ascentPixel, offsetPixel,
NS_STYLE_TEXT_DECORATION_UNDERLINE,
NS_STYLE_BORDER_STYLE_SOLID,
isRTL);
NS_STYLE_BORDER_STYLE_SOLID);
}
}
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
@ -485,8 +482,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
pt, gfxSize(width, sizePixel),
ascentPixel, offsetPixel,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
NS_STYLE_BORDER_STYLE_SOLID,
isRTL);
NS_STYLE_BORDER_STYLE_SOLID);
}
aRenderingContext.SetFont(fontMet);