Oops, backing-out previous checked-in, because tinderbox has RED.

This commit is contained in:
masayuki@d-toybox.com 2007-09-03 04:03:49 -07:00
parent 8541f8f7f0
commit bfe2436be6
4 changed files with 23 additions and 30 deletions

View File

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

View File

@ -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) - NS_round(offset);
gfxFloat y = NS_round(aPt.y + aAscent - 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.

View File

@ -466,9 +466,7 @@ public:
const nsRect& aDirtyRect);
// helper: paint quirks-mode CSS text decorations
void PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
const gfxPoint& aFramePt,
const gfxPoint& aTextBaselinePt,
nsTextPaintStyle& aTextStyle,
const gfxPoint& aFramePt, 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
@ -3734,7 +3732,6 @@ FillClippedRect(gfxContext* aCtx, nsPresContext* aPresContext,
void
nsTextFrame::PaintTextDecorations(gfxContext* aCtx, const gfxRect& aDirtyRect,
const gfxPoint& aFramePt,
const gfxPoint& aTextBaselinePt,
nsTextPaintStyle& aTextPaintStyle,
PropertyProvider& aProvider)
{
@ -3801,7 +3798,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, (aTextBaselinePt.y - mAscent) / app);
gfxPoint pt(aFramePt.x / app, aFramePt.y / app);
gfxSize size(GetRect().width / app, 0);
gfxFloat ascent = mAscent / app;
@ -4177,15 +4174,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) {
pt.x = (aTextBaselinePt.x + xOffset) / app;
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);
gfxFloat width = PR_ABS(advance) / app;
DrawSelectionDecorations(aCtx, aSelectionType, aTextPaintStyle,
pt, width, mAscent / app, decorationMetrics,
@ -4208,8 +4205,7 @@ nsTextFrame::PaintTextWithSelection(gfxContext* aCtx,
SelectionType allTypes;
PaintTextWithSelectionColors(aCtx, aFramePt, aTextBaselinePt, aDirtyRect,
aProvider, aTextPaintStyle, details, &allTypes);
PaintTextDecorations(aCtx, aDirtyRect, aFramePt, aTextBaselinePt,
aTextPaintStyle, aProvider);
PaintTextDecorations(aCtx, aDirtyRect, aFramePt, 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
@ -4301,8 +4297,7 @@ nsTextFrame::PaintText(nsIRenderingContext* aRenderingContext, nsPoint aPt,
0, hyphenTextRun->GetLength(), &dirtyRect, nsnull, nsnull);
}
}
PaintTextDecorations(ctx, dirtyRect, framePt, textBaselinePt,
textPaintStyle, provider);
PaintTextDecorations(ctx, dirtyRect, framePt, textPaintStyle, provider);
}
PRInt16

View File

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