Bug 1086708 - Rename the snapping variant of NSRectToRect to NSRectToSnappedRect. r=mattwoodrow

This commit is contained in:
Jonathan Watt
2014-10-22 12:29:06 +01:00
parent d6447d468c
commit 3b52cf43ad
24 changed files with 82 additions and 64 deletions

View File

@@ -684,9 +684,9 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
// We're drawing borders around the joined continuation boxes so we need
// to clip that to the slice that we want for this frame.
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(aBorderArea,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
Clip(NSRectToSnappedRect(aBorderArea,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
}
} else {
MOZ_ASSERT(joinedBorderArea.IsEqualEdges(aBorderArea),
@@ -1372,9 +1372,9 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
}
}
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(fragmentClip,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
Clip(NSRectToSnappedRect(fragmentClip,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
gfxCornerSizes clipRectRadii;
if (hasBorderRadius) {
@@ -3293,8 +3293,9 @@ DrawBorderImage(nsPresContext* aPresContext,
clip.Inflate(imageOutset);
autoSR.EnsureSaved(aRenderingContext.ThebesContext());
aRenderingContext.ThebesContext()->
Clip(NSRectToRect(clip, aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
Clip(NSRectToSnappedRect(clip,
aForFrame->PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
}
} else {
borderImgArea = aBorderArea;
@@ -3598,7 +3599,8 @@ DrawSolidBorderSegment(nsRenderingContext& aContext,
aAppUnitsPerDevPixel, *drawTarget,
color, StrokeOptions(), drawOptions);
else
drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
drawTarget->FillRect(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel,
*drawTarget),
color, drawOptions);
}
else {
@@ -3607,14 +3609,16 @@ DrawSolidBorderSegment(nsRenderingContext& aContext,
aAppUnitsPerDevPixel, *drawTarget,
color, StrokeOptions(), drawOptions);
else
drawTarget->FillRect(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
drawTarget->FillRect(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel,
*drawTarget),
color, drawOptions);
}
}
else {
// polygon with beveling
Point poly[4];
SetPoly(NSRectToRect(aRect, aAppUnitsPerDevPixel, *drawTarget), poly);
SetPoly(NSRectToSnappedRect(aRect, aAppUnitsPerDevPixel, *drawTarget),
poly);
Float startBevelOffset =
NSAppUnitsToFloatPixels(aStartBevelOffset, aAppUnitsPerDevPixel);

View File

@@ -532,9 +532,9 @@ void nsCaret::PaintCaret(nsDisplayListBuilder *aBuilder,
ComputeCaretRects(frame, contentOffset, &caretRect, &hookRect);
Rect devPxCaretRect =
NSRectToRect(caretRect + aOffset, appUnitsPerDevPixel, *drawTarget);
NSRectToSnappedRect(caretRect + aOffset, appUnitsPerDevPixel, *drawTarget);
Rect devPxHookRect =
NSRectToRect(hookRect + aOffset, appUnitsPerDevPixel, *drawTarget);
NSRectToSnappedRect(hookRect + aOffset, appUnitsPerDevPixel, *drawTarget);
ColorPattern color(ToDeviceColor(frame->GetCaretColorAt(contentOffset)));
drawTarget->FillRect(devPxCaretRect, color);

View File

@@ -1840,7 +1840,8 @@ nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder,
{
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
DrawTarget* drawTarget = aCtx->GetDrawTarget();
Rect rect = NSRectToRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
Rect rect =
NSRectToSnappedRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(rect, ColorPattern(ToDeviceColor(mColor)));
}
@@ -3118,7 +3119,7 @@ nsDisplayBoxShadowInner::Paint(nsDisplayListBuilder* aBuilder,
for (uint32_t i = 0; i < rects.Length(); ++i) {
gfx->Save();
gfx->Clip(NSRectToRect(rects[i], appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(rects[i], appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBoxShadowInner(presContext, *aCtx, mFrame,
borderRect, rects[i]);
gfx->Restore();

View File

@@ -7049,8 +7049,8 @@ Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel)
Float(aRect.height / aAppUnitsPerPixel));
}
Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT)
Rect NSRectToSnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT)
{
// Note that by making aAppUnitsPerPixel a double we're doing floating-point
// division using a larger type and avoiding rounding error.

View File

@@ -2423,8 +2423,8 @@ gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel);
* MaybeSnapToDevicePixels helper, which this function calls to do any
* snapping).
*/
gfx::Rect NSRectToRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT);
gfx::Rect NSRectToSnappedRect(const nsRect& aRect, double aAppUnitsPerPixel,
const gfx::DrawTarget& aSnapDT);
void StrokeLineWithSnapping(const nsPoint& aP1, const nsPoint& aP2,
int32_t aAppUnitsPerDevPixel,

View File

@@ -10133,7 +10133,8 @@ void ReflowCountMgr::PaintCount(const char* aName,
}
nsRect rect(0,0, width+15, height+15);
Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f)));
drawTarget->FillRect(devPxRect, black);

View File

@@ -1509,9 +1509,9 @@ void nsComboboxControlFrame::PaintFocus(nsRenderingContext& aRenderingContext,
gfx->Save();
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
gfx->Clip(NSRectToRect(clipRect,
PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
gfx->Clip(NSRectToSnappedRect(clipRect,
PresContext()->AppUnitsPerDevPixel(),
*aRenderingContext.GetDrawTarget()));
// REVIEW: Why does the old code paint mDisplayFrame again? We've
// already painted it in the children above. So clipping it here won't do

View File

@@ -227,7 +227,7 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
int32_t appUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
gfx->Restore();
@@ -240,7 +240,7 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.height = topBorder;
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
gfx->Restore();
@@ -252,7 +252,7 @@ nsFieldSetFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.height = mRect.height - (yoff + topBorder);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext);
gfx->Restore();

View File

@@ -70,7 +70,7 @@ PaintIndeterminateMark(nsIFrame* aFrame,
rect.y += (rect.height - rect.height/4) / 2;
rect.height /= 4;
Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect = NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect,
ColorPattern(ToDeviceColor(aFrame->StyleColor()->mColor)));

View File

@@ -335,7 +335,8 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
padding.top + aPt.y,
mRect.width - (padding.left + padding.right),
mRect.height - (padding.top + padding.bottom));
Rect devPxRect = NSRectToRect(rect, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(rect, appUnitsPerDevPixel, *drawTarget);
RefPtr<PathBuilder> builder = drawTarget->CreatePathBuilder();
AppendEllipseToPath(builder, devPxRect.Center(), devPxRect.Size());
RefPtr<Path> ellipse = builder->Finish();
@@ -364,7 +365,8 @@ nsBulletFrame::PaintBullet(nsRenderingContext& aRenderingContext, nsPoint aPt,
pc->RoundAppUnitsToNearestDevPixels(rect.height));
snapRect.MoveBy((rect.width - snapRect.width) / 2,
(rect.height - snapRect.height) / 2);
Rect devPxRect = NSRectToRect(snapRect, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(snapRect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, color);
}
break;

View File

@@ -246,7 +246,8 @@ nsDisplayCanvasBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
if (NS_GET_A(mColor) > 0) {
DrawTarget* drawTarget = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
Rect devPxRect = NSRectToRect(bgClipRect, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(bgClipRect, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, ColorPattern(ToDeviceColor(mColor)));
}
}

View File

@@ -1700,7 +1700,8 @@ void nsDisplayFramesetBlank::Paint(nsDisplayListBuilder* aBuilder,
{
DrawTarget* drawTarget = aCtx->GetDrawTarget();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
Rect rect = NSRectToRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
Rect rect =
NSRectToSnappedRect(mVisibleRect, appUnitsPerDevPixel, *drawTarget);
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
drawTarget->FillRect(rect, white);
}

View File

@@ -1225,8 +1225,8 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
// Clip so we don't render outside the inner rect
gfx->Save();
gfx->Clip(NSRectToRect(inner, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->Clip(NSRectToSnappedRect(inner, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
// Check if we should display image placeholders
if (gIconLoad->mPrefShowPlaceholders) {

View File

@@ -382,8 +382,8 @@ nsPageFrame::DrawHeaderFooter(nsRenderingContext& aRenderingContext,
// set up new clip and draw the text
gfx->Save();
gfx->Clip(NSRectToRect(aRect, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->Clip(NSRectToSnappedRect(aRect, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
aRenderingContext.ThebesContext()->SetColor(NS_RGB(0,0,0));
nsLayoutUtils::DrawString(this, &aRenderingContext, str.get(), str.Length(), nsPoint(x, y + aAscent));
gfx->Restore();

View File

@@ -1834,9 +1834,9 @@ void nsDisplayMathMLSelectionRect::Paint(nsDisplayListBuilder* aBuilder,
nsRenderingContext* aCtx)
{
DrawTarget* drawTarget = aCtx->GetDrawTarget();
Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
mFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
Rect rect = NSRectToSnappedRect(mRect + ToReferenceFrame(),
mFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
// get color to use for selection from the look&feel object
nscolor bgColor =
LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground,

View File

@@ -101,8 +101,9 @@ void nsDisplayMathMLError::Paint(nsDisplayListBuilder* aBuilder,
nsPoint pt = ToReferenceFrame();
int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel();
DrawTarget* drawTarget = aCtx->GetDrawTarget();
Rect rect = NSRectToRect(nsRect(pt, mFrame->GetSize()), appUnitsPerDevPixel,
*drawTarget);
Rect rect = NSRectToSnappedRect(nsRect(pt, mFrame->GetSize()),
appUnitsPerDevPixel,
*drawTarget);
ColorPattern red(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
drawTarget->FillRect(rect, red);

View File

@@ -366,9 +366,9 @@ void nsDisplayMathMLBar::Paint(nsDisplayListBuilder* aBuilder,
{
// paint the bar with the current text color
DrawTarget* drawTarget = aCtx->GetDrawTarget();
Rect rect = NSRectToRect(mRect + ToReferenceFrame(),
mFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
Rect rect = NSRectToSnappedRect(mRect + ToReferenceFrame(),
mFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget);
ColorPattern color(ToDeviceColor(
mFrame->GetVisitedDependentColor(eCSSProperty_color)));
drawTarget->FillRect(rect, color);

View File

@@ -522,9 +522,9 @@ nsSVGIntegrationUtils::PaintFramesWithEffects(nsRenderingContext* aCtx,
gfx->Save();
nsRect clipRect =
aFrame->GetVisualOverflowRectRelativeToSelf() + toUserSpace;
gfx->Clip(NSRectToRect(clipRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
}

View File

@@ -589,9 +589,9 @@ nsSVGUtils::PaintFrameWithEffects(nsIFrame *aFrame,
// GetCanvasTM().
overflowRect = overflowRect + aFrame->GetPosition();
}
gfx->Clip(NSRectToRect(overflowRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->Clip(NSRectToSnappedRect(overflowRect,
aFrame->PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
}
gfx->PushGroup(gfxContentType::COLOR_ALPHA);
}

View File

@@ -348,7 +348,8 @@ nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
//middle
nsRect r(onePixel, onePixel,
mRect.width - onePixel, mRect.height - onePixel);
Rect devPixelRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
Rect devPixelRect =
NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->StrokeRect(devPixelRect, color);
//shading
StrokeLineWithSnapping(nsPoint(2*onePixel, mRect.height-2*onePixel),

View File

@@ -1612,10 +1612,10 @@ nsBoxFrame::DrawLine(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x1, nsco
void
nsBoxFrame::FillRect(DrawTarget& aDrawTarget, bool aHorizontal, nscoord x, nscoord y, nscoord width, nscoord height)
{
Rect rect = NSRectToRect(aHorizontal ? nsRect(x, y, width, height) :
nsRect(y, x, height, width),
PresContext()->AppUnitsPerDevPixel(),
aDrawTarget);
Rect rect = NSRectToSnappedRect(aHorizontal ? nsRect(x, y, width, height) :
nsRect(y, x, height, width),
PresContext()->AppUnitsPerDevPixel(),
aDrawTarget);
ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
aDrawTarget.FillRect(rect, white);
}

View File

@@ -173,7 +173,7 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.height = border.top;
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
gfx->Restore();
@@ -185,7 +185,7 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.height = border.top;
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
gfx->Restore();
@@ -197,7 +197,7 @@ nsGroupBoxFrame::PaintBorderBackground(nsRenderingContext& aRenderingContext,
clipRect.height = mRect.height - (yoff + border.top);
gfx->Save();
gfx->Clip(NSRectToRect(clipRect, appUnitsPerDevPixel, *drawTarget));
gfx->Clip(NSRectToSnappedRect(clipRect, appUnitsPerDevPixel, *drawTarget));
nsCSSRendering::PaintBorder(presContext, aRenderingContext, this,
aDirtyRect, rect, mStyleContext, skipSides);
gfx->Restore();

View File

@@ -561,7 +561,8 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
aTextRect.y + mAccessKeyInfo->mAccessOffset,
mAccessKeyInfo->mAccessWidth,
mAccessKeyInfo->mAccessUnderlineSize);
Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, color);
}

View File

@@ -2802,8 +2802,9 @@ nsTreeBodyFrame::PaintTreeBody(nsRenderingContext& aRenderingContext,
gfxContext* gfx = aRenderingContext.ThebesContext();
gfx->Save();
gfx->Clip(NSRectToRect(mInnerBox + aPt, PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
gfx->Clip(NSRectToSnappedRect(mInnerBox + aPt,
PresContext()->AppUnitsPerDevPixel(),
*drawTarget));
int32_t oldPageCount = mPageLength;
if (!mHasFixedRowCount)
mPageLength = mInnerBox.height/mRowHeight;
@@ -3628,20 +3629,23 @@ nsTreeBodyFrame::PaintText(int32_t aRowIndex,
fontMet->GetUnderline(offset, size);
if (decorations & NS_FONT_DECORATION_OVERLINE) {
nsRect r(textRect.x, textRect.y, textRect.width, size);
Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, color);
}
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
nsRect r(textRect.x, textRect.y + baseline - offset,
textRect.width, size);
Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, color);
}
}
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
fontMet->GetStrikeout(offset, size);
nsRect r(textRect.x, textRect.y + baseline - offset, textRect.width, size);
Rect devPxRect = NSRectToRect(r, appUnitsPerDevPixel, *drawTarget);
Rect devPxRect =
NSRectToSnappedRect(r, appUnitsPerDevPixel, *drawTarget);
drawTarget->FillRect(devPxRect, color);
}
nsStyleContext* cellContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecell);
@@ -3788,7 +3792,8 @@ nsTreeBodyFrame::PaintProgressMeter(int32_t aRowIndex,
} else {
DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
int32_t appUnitsPerDevPixel = PresContext()->AppUnitsPerDevPixel();
Rect rect = NSRectToRect(meterRect, appUnitsPerDevPixel, *drawTarget);
Rect rect =
NSRectToSnappedRect(meterRect, appUnitsPerDevPixel, *drawTarget);
ColorPattern color(ToDeviceColor(
GetVisitedDependentColor(eCSSProperty_color)));
drawTarget->FillRect(rect, color);