From bfe2436be6c6d05ecd4813573150d0d6c02f395f Mon Sep 17 00:00:00 2001 From: "masayuki@d-toybox.com" Date: Mon, 3 Sep 2007 04:03:49 -0700 Subject: [PATCH] Oops, backing-out previous checked-in, because tinderbox has RED. --- gfx/thebes/src/gfxRect.cpp | 10 +++++----- layout/base/nsCSSRendering.cpp | 2 +- layout/generic/nsTextFrameThebes.cpp | 21 ++++++++------------- layout/xul/base/src/nsTextBoxFrame.cpp | 20 +++++++++----------- 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/gfx/thebes/src/gfxRect.cpp b/gfx/thebes/src/gfxRect.cpp index b7ece07093f..7282be218e8 100644 --- a/gfx/thebes/src/gfxRect.cpp +++ b/gfx/thebes/src/gfxRect.cpp @@ -37,7 +37,7 @@ #include "gfxRect.h" -#include "nsMathUtils.h" +#include 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; diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 7aadced2899..d36e2f997c6 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -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. diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index 3a92b911cab..f1962e4f66a 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -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 diff --git a/layout/xul/base/src/nsTextBoxFrame.cpp b/layout/xul/base/src/nsTextBoxFrame.cpp index a42b648cdbd..eb35e04e094 100644 --- a/layout/xul/base/src/nsTextBoxFrame.cpp +++ b/layout/xul/base/src/nsTextBoxFrame.cpp @@ -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 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) {