Bug 394109 Inconsistent text-decoration positioning. r+sr+a=roc

This commit is contained in:
masayuki%d-toybox.com 2007-09-03 15:27:27 +00:00
Родитель 816a9d4b46
Коммит 8c920b846f
4 изменённых файлов: 30 добавлений и 23 удалений

Просмотреть файл

@ -37,7 +37,7 @@
#include "gfxRect.h"
#include <math.h>
#include "nsMathUtils.h"
gfxRect
gfxRect::Intersect(const gfxRect& aRect) const
@ -76,10 +76,10 @@ gfxRect::Union(const gfxRect& aRect) const
void
gfxRect::Round()
{
gfxFloat x0 = floor(X() + 0.5);
gfxFloat y0 = floor(Y() + 0.5);
gfxFloat x1 = floor(XMost() + 0.5);
gfxFloat y1 = floor(YMost() + 0.5);
gfxFloat x0 = NS_round(X());
gfxFloat y0 = NS_round(Y());
gfxFloat x1 = NS_round(XMost());
gfxFloat y1 = NS_round(YMost());
pos.x = x0;
pos.y = y0;

Просмотреть файл

@ -4437,7 +4437,7 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
// round to device pixels for suppressing the AA.
gfxFloat x = NS_round(aPt.x);
gfxFloat y = NS_round(aPt.y + aAscent - offset);
gfxFloat y = NS_round(aPt.y + aAscent) - NS_round(offset);
gfxFloat width = NS_round(aLineSize.width);
gfxFloat height = NS_round(aLineSize.height);
// The y position should be set to the middle of the line.

Просмотреть файл

@ -466,7 +466,9 @@ public:
const nsRect& aDirtyRect);
// helper: paint quirks-mode CSS text decorations
void PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
const gfxPoint& aFramePt, nsTextPaintStyle& aTextStyle,
const gfxPoint& aFramePt,
const gfxPoint& aTextBaselinePt,
nsTextPaintStyle& aTextStyle,
PropertyProvider& aProvider);
// helper: paint text frame when we're impacted by at least one selection.
// Return PR_FALSE if the text was not painted and we should continue with
@ -3732,6 +3734,7 @@ FillClippedRect(gfxContext* aCtx, nsPresContext* aPresContext,
void
nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
const gfxPoint& aFramePt,
const gfxPoint& aTextBaselinePt,
nsTextPaintStyle& aTextPaintStyle,
PropertyProvider& aProvider)
{
@ -3798,7 +3801,7 @@ nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
PRInt32 app = aTextPaintStyle.PresContext()->AppUnitsPerDevPixel();
// XXX aFramePt is in AppUnits, shouldn't it be nsFloatPoint?
gfxPoint pt(aFramePt.x / app, aFramePt.y / app);
gfxPoint pt(aFramePt.x / app, (aTextBaselinePt.y - mAscent) / app);
gfxSize size(GetRect().width / app, 0);
gfxFloat ascent = mAscent / app;
@ -4174,15 +4177,15 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
aProvider, mTextRun);
gfxFloat xOffset, hyphenWidth;
PRUint32 offset, length;
PRInt32 app = aTextPaintStyle.PresContext()->AppUnitsPerDevPixel();
// XXX aTextBaselinePt is in AppUnits, shouldn't it be nsFloatPoint?
gfxPoint pt(0.0, (aTextBaselinePt.y - mAscent) / app);
SelectionType type;
while (iterator.GetNextSegment(&xOffset, &offset, &length, &hyphenWidth, &type)) {
gfxFloat advance = hyphenWidth +
mTextRun->GetAdvanceWidth(offset, length, &aProvider);
if (type == aSelectionType) {
PRInt32 app = aTextPaintStyle.PresContext()->AppUnitsPerDevPixel();
// XXX aTextBaselinePt is in AppUnits, shouldn't it be nsFloatPoint?
gfxPoint pt((aTextBaselinePt.x + xOffset) / app,
(aTextBaselinePt.y - mAscent) / app);
pt.x = (aTextBaselinePt.x + xOffset) / app;
gfxFloat width = PR_ABS(advance) / app;
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
pt, width, mAscent / app, decorationMetrics,
@ -4205,7 +4208,8 @@ nsTextFrame::PaintTextWithSelection(gfxContext* aCtx,
SelectionType allTypes;
PaintTextWithSelectionColors(aCtx, aFramePt, aTextBaselinePt, aDirtyRect,
aProvider, aTextPaintStyle, details, &allTypes);
PaintTextDecorations(aCtx, aDirtyRect, aFramePt, aTextPaintStyle, aProvider);
PaintTextDecorations(aCtx, aDirtyRect, aFramePt, aTextBaselinePt,
aTextPaintStyle, aProvider);
PRInt32 i;
// Iterate through just the selection types that paint decorations and
// paint decorations for any that actually occur in this frame. Paint
@ -4297,7 +4301,8 @@ nsTextFrame::PaintText(nsIRenderingContext* aRenderingContext, nsPoint aPt,
0, hyphenTextRun->GetLength(), &dirtyRect, nsnull, nsnull);
}
}
PaintTextDecorations(ctx, dirtyRect, framePt, textPaintStyle, provider);
PaintTextDecorations(ctx, dirtyRect, framePt, textBaselinePt,
textPaintStyle, provider);
}
PRInt16

Просмотреть файл

@ -446,16 +446,18 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
nscoord offset;
nscoord size;
nscoord baseline;
fontMet->GetMaxAscent(baseline);
nscoord ascent;
fontMet->GetMaxAscent(ascent);
PRBool isRTL = vis->mDirection == NS_STYLE_DIRECTION_RTL;
nscoord baseline =
presContext->RoundAppUnitsToNearestDevPixels(textRect.y + ascent);
nsRefPtr<gfxContext> ctx = (gfxContext*)
aRenderingContext.GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
gfxPoint pt(presContext->AppUnitsToGfxUnits(textRect.x),
presContext->AppUnitsToGfxUnits(textRect.y));
gfxFloat width = presContext->AppUnitsToGfxUnits(textRect.width);
gfxFloat baselinePixel = presContext->AppUnitsToGfxUnits(baseline);
gfxFloat ascentPixel = presContext->AppUnitsToGfxUnits(ascent);
if (decorations & (NS_FONT_DECORATION_OVERLINE | NS_FONT_DECORATION_UNDERLINE)) {
fontMet->GetUnderline(offset, size);
gfxFloat offsetPixel = presContext->AppUnitsToGfxUnits(offset);
@ -463,7 +465,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
if (decorations & NS_FONT_DECORATION_OVERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, overColor,
pt, gfxSize(width, sizePixel),
baselinePixel, baselinePixel,
ascentPixel, ascentPixel,
sizePixel,
NS_STYLE_TEXT_DECORATION_OVERLINE,
NS_STYLE_BORDER_STYLE_SOLID,
@ -472,7 +474,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, underColor,
pt, gfxSize(width, sizePixel),
baselinePixel, offsetPixel,
ascentPixel, offsetPixel,
sizePixel,
NS_STYLE_TEXT_DECORATION_UNDERLINE,
NS_STYLE_BORDER_STYLE_SOLID,
@ -485,7 +487,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
gfxFloat sizePixel = presContext->AppUnitsToGfxUnits(size);
nsCSSRendering::PaintDecorationLine(ctx, underColor,
pt, gfxSize(width, sizePixel),
baselinePixel, offsetPixel,
ascentPixel, offsetPixel,
sizePixel,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
NS_STYLE_BORDER_STYLE_SOLID,
@ -515,7 +517,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
textRect.x, textRect.y + baseline,
textRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
@ -524,7 +526,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
{
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
textRect.x, textRect.y + baseline);
textRect.x, baseline);
}
}
}
@ -544,7 +546,7 @@ nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
mAccessKeyInfo->mBeforeWidth = 0;
}
aRenderingContext.DrawString(mCroppedTitle, textRect.x, textRect.y + baseline);
aRenderingContext.DrawString(mCroppedTitle, textRect.x, baseline);
}
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {