Correct the coordinates for selection decoration in right-to-left text. Bug 421042, r+sr=roc, a=beltzner
This commit is contained in:
@@ -4462,8 +4462,7 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
|||||||
const gfxFloat aAscent,
|
const gfxFloat aAscent,
|
||||||
const gfxFloat aOffset,
|
const gfxFloat aOffset,
|
||||||
const PRUint8 aDecoration,
|
const PRUint8 aDecoration,
|
||||||
const PRUint8 aStyle,
|
const PRUint8 aStyle)
|
||||||
const PRBool aIsRTL)
|
|
||||||
{
|
{
|
||||||
gfxRect rect =
|
gfxRect rect =
|
||||||
GetTextDecorationRectInternal(aPt, aLineSize, aAscent, aOffset,
|
GetTextDecorationRectInternal(aPt, aLineSize, aAscent, aOffset,
|
||||||
@@ -4545,13 +4544,8 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
|
|||||||
case NS_STYLE_BORDER_STYLE_DOTTED:
|
case NS_STYLE_BORDER_STYLE_DOTTED:
|
||||||
case NS_STYLE_BORDER_STYLE_DASHED:
|
case NS_STYLE_BORDER_STYLE_DASHED:
|
||||||
aGfxContext->NewPath();
|
aGfxContext->NewPath();
|
||||||
if (aIsRTL) {
|
|
||||||
aGfxContext->MoveTo(rect.TopRight());
|
|
||||||
aGfxContext->LineTo(rect.TopLeft());
|
aGfxContext->LineTo(rect.TopLeft());
|
||||||
} else {
|
aGfxContext->MoveTo(rect.TopRight());
|
||||||
aGfxContext->MoveTo(rect.TopLeft());
|
|
||||||
aGfxContext->LineTo(rect.TopRight());
|
|
||||||
}
|
|
||||||
aGfxContext->Stroke();
|
aGfxContext->Stroke();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ public:
|
|||||||
* NS_STYLE_BORDER_STYLE_DOTTED or
|
* NS_STYLE_BORDER_STYLE_DOTTED or
|
||||||
* NS_STYLE_BORDER_STYLE_DASHED or
|
* NS_STYLE_BORDER_STYLE_DASHED or
|
||||||
* NS_STYLE_BORDER_STYLE_DOUBLE.
|
* NS_STYLE_BORDER_STYLE_DOUBLE.
|
||||||
* @param aIsRTL when the text is RTL, it is true.
|
|
||||||
*/
|
*/
|
||||||
static void PaintDecorationLine(gfxContext* aGfxContext,
|
static void PaintDecorationLine(gfxContext* aGfxContext,
|
||||||
const nscolor aColor,
|
const nscolor aColor,
|
||||||
@@ -232,8 +231,7 @@ public:
|
|||||||
const gfxFloat aAscent,
|
const gfxFloat aAscent,
|
||||||
const gfxFloat aOffset,
|
const gfxFloat aOffset,
|
||||||
const PRUint8 aDecoration,
|
const PRUint8 aDecoration,
|
||||||
const PRUint8 aStyle,
|
const PRUint8 aStyle);
|
||||||
const PRBool aIsRTL);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for getting the decoration line rect for the text.
|
* Function for getting the decoration line rect for the text.
|
||||||
|
|||||||
@@ -5910,8 +5910,6 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
|
|||||||
|
|
||||||
// Only paint if we have a positive width
|
// Only paint if we have a positive width
|
||||||
if (width > 0) {
|
if (width > 0) {
|
||||||
const nsStyleVisibility* visibility = GetStyleVisibility();
|
|
||||||
PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
||||||
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
|
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
|
||||||
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(start + aPt.x),
|
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(start + aPt.x),
|
||||||
PresContext()->AppUnitsToGfxUnits(aLine->mBounds.y + aPt.y));
|
PresContext()->AppUnitsToGfxUnits(aLine->mBounds.y + aPt.y));
|
||||||
@@ -5919,7 +5917,7 @@ nsBlockFrame::PaintTextDecorationLine(nsIRenderingContext& aRenderingContext,
|
|||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
ctx, aColor, pt, size,
|
ctx, aColor, pt, size,
|
||||||
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
|
PresContext()->AppUnitsToGfxUnits(aLine->GetAscent()),
|
||||||
aOffset, aDecoration, NS_STYLE_BORDER_STYLE_SOLID, isRTL);
|
aOffset, aDecoration, NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -221,16 +221,13 @@ nsHTMLContainerFrame::PaintTextDecorationLine(
|
|||||||
bp.side(side) = 0;
|
bp.side(side) = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const nsStyleVisibility* visibility = GetStyleVisibility();
|
|
||||||
PRBool isRTL = visibility->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
||||||
nscoord innerWidth = mRect.width - bp.left - bp.right;
|
nscoord innerWidth = mRect.width - bp.left - bp.right;
|
||||||
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
|
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
|
||||||
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(bp.left + aPt.x),
|
gfxPoint pt(PresContext()->AppUnitsToGfxUnits(bp.left + aPt.x),
|
||||||
PresContext()->AppUnitsToGfxUnits(bp.top + aPt.y));
|
PresContext()->AppUnitsToGfxUnits(bp.top + aPt.y));
|
||||||
gfxSize size(PresContext()->AppUnitsToGfxUnits(innerWidth), aSize);
|
gfxSize size(PresContext()->AppUnitsToGfxUnits(innerWidth), aSize);
|
||||||
nsCSSRendering::PaintDecorationLine(ctx, aColor, pt, size, aAscent, aOffset,
|
nsCSSRendering::PaintDecorationLine(ctx, aColor, pt, size, aAscent, aOffset,
|
||||||
aDecoration, NS_STYLE_BORDER_STYLE_SOLID,
|
aDecoration, NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
isRTL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -3710,24 +3710,21 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
|
|||||||
size.height = fontMetrics.underlineSize;
|
size.height = fontMetrics.underlineSize;
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mOverColor, pt, size, ascent, ascent,
|
aCtx, decorations.mOverColor, pt, size, ascent, ascent,
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_OVERLINE, NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
mTextRun->IsRightToLeft());
|
|
||||||
}
|
}
|
||||||
if (decorations.HasUnderline()) {
|
if (decorations.HasUnderline()) {
|
||||||
size.height = fontMetrics.underlineSize;
|
size.height = fontMetrics.underlineSize;
|
||||||
gfxFloat offset = aProvider.GetFontGroup()->GetUnderlineOffset();
|
gfxFloat offset = aProvider.GetFontGroup()->GetUnderlineOffset();
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mUnderColor, pt, size, ascent, offset,
|
aCtx, decorations.mUnderColor, pt, size, ascent, offset,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
mTextRun->IsRightToLeft());
|
|
||||||
}
|
}
|
||||||
if (decorations.HasStrikeout()) {
|
if (decorations.HasStrikeout()) {
|
||||||
size.height = fontMetrics.strikeoutSize;
|
size.height = fontMetrics.strikeoutSize;
|
||||||
gfxFloat offset = fontMetrics.strikeoutOffset;
|
gfxFloat offset = fontMetrics.strikeoutOffset;
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aCtx, decorations.mStrikeColor, pt, size, ascent, offset,
|
aCtx, decorations.mStrikeColor, pt, size, ascent, offset,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
mTextRun->IsRightToLeft());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3741,7 +3738,7 @@ static const SelectionType SelectionTypesWithDecorations =
|
|||||||
|
|
||||||
static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
|
static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
|
||||||
nsTextPaintStyle& aTextPaintStyle, const gfxPoint& aPt, gfxFloat aWidth,
|
nsTextPaintStyle& aTextPaintStyle, const gfxPoint& aPt, gfxFloat aWidth,
|
||||||
gfxFloat aAscent, gfxFloat aSize, gfxFloat aOffset, PRBool aIsRTL)
|
gfxFloat aAscent, gfxFloat aSize, gfxFloat aOffset)
|
||||||
{
|
{
|
||||||
nscolor color;
|
nscolor color;
|
||||||
float relativeSize;
|
float relativeSize;
|
||||||
@@ -3754,7 +3751,7 @@ static void DrawIMEUnderline(gfxContext* aContext, PRInt32 aIndex,
|
|||||||
gfxPoint pt(aPt.x + 1.0, aPt.y);
|
gfxPoint pt(aPt.x + 1.0, aPt.y);
|
||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aContext, color, pt, gfxSize(width, actualSize), aAscent, aOffset,
|
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,
|
static void DrawSelectionDecorations(gfxContext* aContext, SelectionType aType,
|
||||||
nsTextPaintStyle& aTextPaintStyle, const gfxPoint& aPt, gfxFloat aWidth,
|
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);
|
gfxSize size(aWidth, aFontMetrics.underlineSize);
|
||||||
|
|
||||||
@@ -3772,30 +3769,29 @@ static void DrawSelectionDecorations(gfxContext* aContext, SelectionType aType,
|
|||||||
nsCSSRendering::PaintDecorationLine(
|
nsCSSRendering::PaintDecorationLine(
|
||||||
aContext, NS_RGB(255,0,0),
|
aContext, NS_RGB(255,0,0),
|
||||||
aPt, size, aAscent, aFontMetrics.underlineOffset,
|
aPt, size, aAscent, aFontMetrics.underlineOffset,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE, NS_STYLE_BORDER_STYLE_DOTTED);
|
||||||
aIsRTL);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case nsISelectionController::SELECTION_IME_RAWINPUT:
|
case nsISelectionController::SELECTION_IME_RAWINPUT:
|
||||||
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexRawInput,
|
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexRawInput,
|
||||||
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
||||||
aFontMetrics.underlineOffset, aIsRTL);
|
aFontMetrics.underlineOffset);
|
||||||
break;
|
break;
|
||||||
case nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT:
|
case nsISelectionController::SELECTION_IME_SELECTEDRAWTEXT:
|
||||||
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelRawText,
|
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelRawText,
|
||||||
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
||||||
aFontMetrics.underlineOffset, aIsRTL);
|
aFontMetrics.underlineOffset);
|
||||||
break;
|
break;
|
||||||
case nsISelectionController::SELECTION_IME_CONVERTEDTEXT:
|
case nsISelectionController::SELECTION_IME_CONVERTEDTEXT:
|
||||||
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexConvText,
|
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexConvText,
|
||||||
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
||||||
aFontMetrics.underlineOffset, aIsRTL);
|
aFontMetrics.underlineOffset);
|
||||||
break;
|
break;
|
||||||
case nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT:
|
case nsISelectionController::SELECTION_IME_SELECTEDCONVERTEDTEXT:
|
||||||
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelConvText,
|
DrawIMEUnderline(aContext, nsTextPaintStyle::eIndexSelConvText,
|
||||||
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
aTextPaintStyle, aPt, aWidth, aAscent, size.height,
|
||||||
aFontMetrics.underlineOffset, aIsRTL);
|
aFontMetrics.underlineOffset);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -4089,11 +4085,11 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
|
|||||||
gfxFloat advance = hyphenWidth +
|
gfxFloat advance = hyphenWidth +
|
||||||
mTextRun->GetAdvanceWidth(offset, length, &aProvider);
|
mTextRun->GetAdvanceWidth(offset, length, &aProvider);
|
||||||
if (type == aSelectionType) {
|
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;
|
gfxFloat width = PR_ABS(advance) / app;
|
||||||
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
|
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
|
||||||
pt, width, mAscent / app, decorationMetrics,
|
pt, width, mAscent / app, decorationMetrics);
|
||||||
mTextRun->IsRightToLeft());
|
|
||||||
}
|
}
|
||||||
iterator.UpdateWithAdvance(advance);
|
iterator.UpdateWithAdvance(advance);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -447,7 +447,6 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
|||||||
nscoord size;
|
nscoord size;
|
||||||
nscoord ascent;
|
nscoord ascent;
|
||||||
fontMet->GetMaxAscent(ascent);
|
fontMet->GetMaxAscent(ascent);
|
||||||
PRBool isRTL = vis->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
||||||
|
|
||||||
nscoord baseline =
|
nscoord baseline =
|
||||||
presContext->RoundAppUnitsToNearestDevPixels(textRect.y + ascent);
|
presContext->RoundAppUnitsToNearestDevPixels(textRect.y + ascent);
|
||||||
@@ -465,16 +464,14 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
|||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, ascentPixel,
|
ascentPixel, ascentPixel,
|
||||||
NS_STYLE_TEXT_DECORATION_OVERLINE,
|
NS_STYLE_TEXT_DECORATION_OVERLINE,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
isRTL);
|
|
||||||
}
|
}
|
||||||
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
|
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
|
||||||
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
nsCSSRendering::PaintDecorationLine(ctx, underColor,
|
||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, offsetPixel,
|
ascentPixel, offsetPixel,
|
||||||
NS_STYLE_TEXT_DECORATION_UNDERLINE,
|
NS_STYLE_TEXT_DECORATION_UNDERLINE,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
isRTL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
|
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
|
||||||
@@ -485,8 +482,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
|
|||||||
pt, gfxSize(width, sizePixel),
|
pt, gfxSize(width, sizePixel),
|
||||||
ascentPixel, offsetPixel,
|
ascentPixel, offsetPixel,
|
||||||
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
|
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
|
||||||
NS_STYLE_BORDER_STYLE_SOLID,
|
NS_STYLE_BORDER_STYLE_SOLID);
|
||||||
isRTL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aRenderingContext.SetFont(fontMet);
|
aRenderingContext.SetFont(fontMet);
|
||||||
|
|||||||
Reference in New Issue
Block a user