diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 8e757c48e79..1c69271fc1b 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -1792,8 +1792,7 @@ nsCanvasRenderingContext2D::ShadowInitialize(const gfxRect& extents, gfxAlphaBox mThebes->SetMatrix(matrix); // outset by the blur radius so that blurs can leak onto the canvas even // when the shape is outside the clipping area - clipExtents.Outset(blurRadius.height, blurRadius.width, - blurRadius.height, blurRadius.width); + clipExtents.Inflate(blurRadius.width, blurRadius.height); drawExtents = drawExtents.Intersect(clipExtents - CurrentState().shadowOffset); gfxContext* ctx = blur.Init(drawExtents, gfxIntSize(0,0), blurRadius, nsnull, nsnull); @@ -2795,7 +2794,7 @@ nsCanvasRenderingContext2D::DrawOrMeasureText(const nsAString& aRawText, if (doDrawShadow) { // for some reason the box is too tight, probably rounding error - processor.mBoundingBox.Outset(2.0); + processor.mBoundingBox.Inflate(2.0); // this is unnecessarily big is max-width scaling is involved, but it // will still produce correct output diff --git a/gfx/src/BaseRect.h b/gfx/src/BaseRect.h index 42516878732..09f9cdc9b4c 100644 --- a/gfx/src/BaseRect.h +++ b/gfx/src/BaseRect.h @@ -201,6 +201,7 @@ struct BaseRect { void SizeTo(T aWidth, T aHeight) { width = aWidth; height = aHeight; } void SizeTo(const SizeT& aSize) { width = aSize.width; height = aSize.height; } + void Inflate(T aD) { Inflate(aD, aD); } void Inflate(T aDx, T aDy) { x -= aDx; @@ -215,7 +216,9 @@ struct BaseRect { width += aMargin.LeftRight(); height += aMargin.TopBottom(); } + void Inflate(const SizeT& aSize) { Inflate(aSize.width, aSize.height); } + void Deflate(T aD) { Deflate(aD, aD); } void Deflate(T aDx, T aDy) { x += aDx; @@ -230,6 +233,7 @@ struct BaseRect { width = NS_MAX(T(0), width - aMargin.LeftRight()); height = NS_MAX(T(0), height - aMargin.TopBottom()); } + void Deflate(const SizeT& aSize) { Deflate(aSize.width, aSize.height); } // Return true if the rectangles contain the same set of points, including // points on the edges. diff --git a/gfx/thebes/gfxBlur.cpp b/gfx/thebes/gfxBlur.cpp index 952fd1e6e1e..613c6957e3e 100644 --- a/gfx/thebes/gfxBlur.cpp +++ b/gfx/thebes/gfxBlur.cpp @@ -63,7 +63,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect, mBlurRadius = aBlurRadius; gfxRect rect(aRect); - rect.Outset(aBlurRadius + aSpreadRadius); + rect.Inflate(aBlurRadius + aSpreadRadius); rect.RoundOut(); if (aDirtyRect) { @@ -72,7 +72,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect, mHasDirtyRect = PR_TRUE; mDirtyRect = *aDirtyRect; gfxRect requiredBlurArea = mDirtyRect.Intersect(rect); - requiredBlurArea.Outset(aBlurRadius + aSpreadRadius); + requiredBlurArea.Inflate(aBlurRadius + aSpreadRadius); rect = requiredBlurArea.Intersect(rect); } else { mHasDirtyRect = PR_FALSE; @@ -90,7 +90,7 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect, // expensive int<->float conversions if we were to use gfxRect instead. gfxRect skipRect = *aSkipRect; skipRect.RoundIn(); - skipRect.Inset(aBlurRadius + aSpreadRadius); + skipRect.Deflate(aBlurRadius + aSpreadRadius); gfxUtils::GfxRectToIntRect(skipRect, &mSkipRect); nsIntRect shadowIntRect; gfxUtils::GfxRectToIntRect(rect, &shadowIntRect); diff --git a/gfx/thebes/gfxRect.h b/gfx/thebes/gfxRect.h index a7b5e9f39aa..ed376e41a39 100644 --- a/gfx/thebes/gfxRect.h +++ b/gfx/thebes/gfxRect.h @@ -44,6 +44,7 @@ #include "nsDebug.h" #include "mozilla/BaseMargin.h" #include "mozilla/BaseRect.h" +#include "nsRect.h" struct gfxMargin : public mozilla::BaseMargin { typedef mozilla::BaseMargin Super; @@ -94,6 +95,8 @@ struct THEBES_API gfxRect : Super(aPos, aSize) {} gfxRect(gfxFloat aX, gfxFloat aY, gfxFloat aWidth, gfxFloat aHeight) : Super(aX, aY, aWidth, aHeight) {} + gfxRect(const nsIntRect& aRect) : + Super(aRect.x, aRect.y, aRect.width, aRect.height) {} /** * Return true if all components of this rect are within @@ -103,34 +106,6 @@ struct THEBES_API gfxRect : */ PRBool WithinEpsilonOfIntegerPixels(gfxFloat aEpsilon) const; - void Inset(gfxFloat k) { - Deflate(k, k); - } - - void Inset(gfxFloat top, gfxFloat right, gfxFloat bottom, gfxFloat left) { - Deflate(gfxMargin(left, top, right, bottom)); - } - - void Inset(const gfxFloat *sides) { - Inset(sides[0], sides[1], sides[2], sides[3]); - } - - void Inset(const gfxIntSize& aSize) { - Deflate(aSize.width, aSize.height); - } - - void Outset(gfxFloat k) { - Inflate(k, k); - } - - void Outset(gfxFloat top, gfxFloat right, gfxFloat bottom, gfxFloat left) { - Inflate(gfxMargin(left, top, right, bottom)); - } - - void Outset(const gfxIntSize& aSize) { - Outset(aSize.height, aSize.width, aSize.height, aSize.width); - } - // Round the rectangle edges to integer coordinates, such that the rounded // rectangle has the same set of pixel centers as the original rectangle. // Edges at offset 0.5 round up. diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 2daf7e49ef8..74e5b27e97c 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -251,7 +251,7 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable, aUserSpaceToImageSpace.TransformBounds(userSpaceClipExtents); // Inflate by one pixel because bilinear filtering will sample at most // one pixel beyond the computed image pixel coordinate. - imageSpaceClipExtents.Outset(1.0); + imageSpaceClipExtents.Inflate(1.0); gfxRect needed = imageSpaceClipExtents.Intersect(aSourceRect); needed = needed.Intersect(aSubimage); diff --git a/gfx/thebes/gfxXlibNativeRenderer.cpp b/gfx/thebes/gfxXlibNativeRenderer.cpp index b7dfcbab5de..d6bc3230b08 100644 --- a/gfx/thebes/gfxXlibNativeRenderer.cpp +++ b/gfx/thebes/gfxXlibNativeRenderer.cpp @@ -502,7 +502,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, if (!matrixIsIntegerTranslation) { // The filter footprint means that the affected rectangle is a // little larger than the drawingRect; - affectedRect.Outset(filterRadius); + affectedRect.Inflate(filterRadius); NATIVE_DRAWING_NOTE("FALLBACK: matrix not integer translation"); } else if (!canDrawOverBackground) { @@ -531,7 +531,7 @@ gfxXlibNativeRenderer::Draw(gfxContext* ctx, nsIntSize size, if (!matrixIsIntegerTranslation) { // The source surface may need to be a little larger than the clip // extents due to the filter footprint. - clipExtents.Outset(filterRadius); + clipExtents.Inflate(filterRadius); } clipExtents.RoundOut(); diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 621b4060b89..1329ba78d9b 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -1127,9 +1127,9 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext, aForFrame->GetPaddingRect() - aForFrame->GetPosition() + aFrameArea.TopLeft(); skipGfxRect = nsLayoutUtils::RectToGfxRect(paddingRect, twipsPerPixel); } else if (hasBorderRadius) { - skipGfxRect.Inset( - PR_MAX(borderRadii[C_TL].height, borderRadii[C_TR].height), 0, - PR_MAX(borderRadii[C_BL].height, borderRadii[C_BR].height), 0); + skipGfxRect.Deflate(gfxMargin( + 0, PR_MAX(borderRadii[C_TL].height, borderRadii[C_TR].height), + 0, PR_MAX(borderRadii[C_BL].height, borderRadii[C_BR].height))); } for (PRUint32 i = shadows->Length(); i > 0; --i) { @@ -1366,8 +1366,9 @@ nsCSSRendering::PaintBoxShadowInner(nsPresContext* aPresContext, skipRect.Deflate(blurMargin); gfxRect skipGfxRect = nsLayoutUtils::RectToGfxRect(skipRect, twipsPerPixel); if (hasBorderRadius) { - skipGfxRect.Inset(PR_MAX(clipRectRadii[C_TL].height, clipRectRadii[C_TR].height), 0, - PR_MAX(clipRectRadii[C_BL].height, clipRectRadii[C_BR].height), 0); + skipGfxRect.Deflate( + gfxMargin(0, PR_MAX(clipRectRadii[C_TL].height, clipRectRadii[C_TR].height), + 0, PR_MAX(clipRectRadii[C_BL].height, clipRectRadii[C_BR].height))); } // When there's a blur radius, gfxAlphaBoxBlur leaves the skiprect area diff --git a/layout/base/nsCSSRenderingBorders.cpp b/layout/base/nsCSSRenderingBorders.cpp index f16c7295ccf..d9581913abf 100644 --- a/layout/base/nsCSSRenderingBorders.cpp +++ b/layout/base/nsCSSRenderingBorders.cpp @@ -188,10 +188,11 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(PRInt32 aAppUnitsPerPixel, } mInnerRect = mOuterRect; - mInnerRect.Inset(mBorderStyles[0] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[0] : 0, - mBorderStyles[1] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[1] : 0, - mBorderStyles[2] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[2] : 0, - mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0); + mInnerRect.Deflate( + gfxMargin(mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0, + mBorderStyles[0] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[0] : 0, + mBorderStyles[1] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[1] : 0, + mBorderStyles[2] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[2] : 0)); ComputeBorderCornerDimensions(mOuterRect, mInnerRect, mBorderRadii, &mBorderCornerDimensions); @@ -563,7 +564,7 @@ nsCSSBorderRenderer::FillSolidBorder(const gfxRect& aOuterRect, CheckFourFloatsEqual(aBorderSizes, aBorderSizes[0])) { gfxRect r(aOuterRect); - r.Inset(aBorderSizes[0] / 2.0); + r.Deflate(aBorderSizes[0] / 2.0); mContext->SetLineWidth(aBorderSizes[0]); mContext->NewPath(); @@ -707,7 +708,7 @@ nsCSSBorderRenderer::DrawBorderSidesCompositeColors(PRIntn aSides, const nsBorde gfxRGBA lineColor = ComputeCompositeColorForLine(i, aCompositeColors); gfxRect siRect = soRect; - siRect.Inset(1.0, 1.0, 1.0, 1.0); + siRect.Deflate(1.0); // now cap the rects to the real mInnerRect gfxPoint tl = siRect.TopLeft(); @@ -904,7 +905,8 @@ nsCSSBorderRenderer::DrawBorderSides(PRIntn aSides) for (unsigned int i = 0; i < borderColorStyleCount; i++) { // walk siRect inwards at the start of the loop to get the // correct inner rect. - siRect.Inset(borderWidths[i]); + siRect.Deflate(gfxMargin(borderWidths[i][3], borderWidths[i][0], + borderWidths[i][1], borderWidths[i][2])); if (borderColorStyle[i] != BorderColorStyleNone) { gfxRGBA color = ComputeColorForLine(i, @@ -1113,7 +1115,7 @@ nsCSSBorderRenderer::DrawSingleWidthSolidBorder() // Easy enough to deal with. mContext->SetLineWidth(1); gfxRect rect = mOuterRect; - rect.Inset(0.5); + rect.Deflate(0.5); const twoFloats cornerAdjusts[4] = { { +0.5, 0 }, { 0, +0.5 }, @@ -1158,8 +1160,8 @@ nsCSSBorderRenderer::DrawNoCompositeColorSolidBorder() ComputeInnerRadii(mBorderRadii, mBorderWidths, &innerRadii); gfxRect strokeRect = mOuterRect; - strokeRect.Inset(mBorderWidths[0] / 2.0, mBorderWidths[1] / 2.0, - mBorderWidths[2] / 2.0, mBorderWidths[3] / 2.0); + strokeRect.Deflate(gfxMargin(mBorderWidths[3] / 2.0, mBorderWidths[0] / 2.0, + mBorderWidths[1] / 2.0, mBorderWidths[2] / 2.0)); NS_FOR_CSS_CORNERS(i) { // the corner index -- either 1 2 3 0 (cw) or 0 3 2 1 (ccw) @@ -1292,7 +1294,7 @@ nsCSSBorderRenderer::DrawRectangularCompositeColors() mContext->SetLineWidth(1); memcpy(currentColors, mCompositeColors, sizeof(nsBorderColors*) * 4); gfxRect rect = mOuterRect; - rect.Inset(0.5); + rect.Deflate(0.5); const twoFloats cornerAdjusts[4] = { { +0.5, 0 }, { 0, +0.5 }, @@ -1347,7 +1349,7 @@ nsCSSBorderRenderer::DrawRectangularCompositeColors() if (currentColors[0] && currentColors[0]->mNext) { currentColors[0] = currentColors[0]->mNext; } - rect.Inset(1); + rect.Deflate(1); } } @@ -1419,7 +1421,7 @@ nsCSSBorderRenderer::DrawBorders() // Very simple case. SetupStrokeStyle(NS_SIDE_TOP); gfxRect rect = mOuterRect; - rect.Inset(mBorderWidths[0] / 2.0); + rect.Deflate(mBorderWidths[0] / 2.0); mContext->NewPath(); mContext->Rectangle(rect); mContext->Stroke(); @@ -1441,7 +1443,7 @@ nsCSSBorderRenderer::DrawBorders() mContext->SetDash(&dash, 1, 0.5); mContext->SetAntialiasMode(gfxContext::MODE_ALIASED); gfxRect rect = mOuterRect; - rect.Inset(mBorderWidths[0] / 2.0); + rect.Deflate(mBorderWidths[0] / 2.0); mContext->NewPath(); mContext->Rectangle(rect); mContext->Stroke(); @@ -1469,7 +1471,7 @@ nsCSSBorderRenderer::DrawBorders() if (noCornerOutsideCenter) { // Relatively simple case. SetupStrokeStyle(NS_SIDE_TOP); - mOuterRect.Inset(mBorderWidths[0] / 2.0); + mOuterRect.Deflate(mBorderWidths[0] / 2.0); NS_FOR_CSS_CORNERS(corner) { if (mBorderRadii.sizes[corner].height == 0 || mBorderRadii.sizes[corner].width == 0) { continue; diff --git a/layout/mathml/nsMathMLmencloseFrame.cpp b/layout/mathml/nsMathMLmencloseFrame.cpp index 23ff471dcc5..4b8d4e9ebf0 100644 --- a/layout/mathml/nsMathMLmencloseFrame.cpp +++ b/layout/mathml/nsMathMLmencloseFrame.cpp @@ -777,7 +777,7 @@ void nsDisplayNotation::Paint(nsDisplayListBuilder* aBuilder, gfxFloat e = presContext->AppUnitsToGfxUnits(mThickness); gfxCtx->SetLineWidth(e); - rect.Inset(e / 2.0); + rect.Deflate(e / 2.0); gfxCtx->NewPath(); diff --git a/layout/svg/base/src/nsSVGUtils.cpp b/layout/svg/base/src/nsSVGUtils.cpp index 2eeab42b2be..c0344788219 100644 --- a/layout/svg/base/src/nsSVGUtils.cpp +++ b/layout/svg/base/src/nsSVGUtils.cpp @@ -1438,7 +1438,7 @@ nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, double dy = style_expansion * (fabs(ctm.yy) + fabs(ctm.yx)); gfxRect strokeExtents = aPathExtents; - strokeExtents.Outset(dy, dx, dy, dx); + strokeExtents.Inflate(dx, dy); return strokeExtents; }