Bug 641426. Part 2: Remove a bunch of direct gfxRect::pos/size usage. r=joe

This commit is contained in:
Robert O'Callahan 2011-04-19 15:07:21 +12:00
Родитель 3c866720cc
Коммит 629c1b7e18
30 изменённых файлов: 164 добавлений и 170 удалений

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

@ -1965,7 +1965,7 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
nsresult
nsCanvasRenderingContext2D::DrawRect(const gfxRect& rect, Style style)
{
if (!FloatValidate(rect.pos.x, rect.pos.y, rect.size.width, rect.size.height))
if (!FloatValidate(rect.X(), rect.Y(), rect.Width(), rect.Height()))
return NS_OK;
PathAutoSaveRestore pathSR(this);

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

@ -2812,7 +2812,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
nsRefPtr<gfxImageSurface> blackImage;
gfxRect targetRect(rect.x, rect.y, rect.width, rect.height);
gfxIntSize targetSize(rect.width, rect.height);
gfxPoint deviceOffset = -targetRect.pos;
gfxPoint deviceOffset = -targetRect.TopLeft();
// We always use a temporary "white image"
whiteImage = new gfxImageSurface(targetSize, gfxASurface::ImageFormatRGB24);
@ -2831,7 +2831,7 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
// background and copy the result
PaintRectToSurface(rect, aSurface, gfxRGBA(1.0, 1.0, 1.0));
{
gfxRect copyRect(gfxPoint(0, 0), targetRect.size);
gfxRect copyRect(gfxPoint(0, 0), targetRect.Size());
nsRefPtr<gfxContext> ctx = new gfxContext(whiteImage);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->SetSource(aSurface, deviceOffset);

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

@ -290,8 +290,8 @@ Layer::SnapTransform(const gfx3DMatrix& aTransform,
}
// compute translation factors that will move aSnapRect to the snapped rect
// given those scale factors
snappedMatrix.x0 = topLeft.x - aSnapRect.pos.x*snappedMatrix.xx;
snappedMatrix.y0 = topLeft.y - aSnapRect.pos.y*snappedMatrix.yy;
snappedMatrix.x0 = topLeft.x - aSnapRect.X()*snappedMatrix.xx;
snappedMatrix.y0 = topLeft.y - aSnapRect.Y()*snappedMatrix.yy;
result = gfx3DMatrix::From2D(snappedMatrix);
if (aResidualTransform && !snappedMatrix.IsSingular()) {
// set aResidualTransform so that aResidual * snappedMatrix == matrix2D.

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

@ -55,7 +55,7 @@ ScaledSize(const nsIntSize& aSize, float aXScale, float aYScale)
gfxRect rect(0, 0, aSize.width, aSize.height);
rect.Scale(aXScale, aYScale);
rect.RoundOut();
return nsIntSize(rect.size.width, rect.size.height);
return nsIntSize(rect.Width(), rect.Height());
}
nsIntRect
@ -201,9 +201,9 @@ MovePixels(gfxASurface* aBuffer,
src.Round();
dest.Round();
aBuffer->MovePixels(nsIntRect(src.pos.x, src.pos.y,
src.size.width, src.size.height),
nsIntPoint(dest.pos.x, dest.pos.y));
aBuffer->MovePixels(nsIntRect(src.X(), src.Y(),
src.Width(), src.Height()),
nsIntPoint(dest.X(), dest.Y()));
}
static void

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

@ -1059,7 +1059,7 @@ ToOutsideIntRect(const gfxRect &aRect)
{
gfxRect r = aRect;
r.RoundOut();
return nsIntRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
return nsIntRect(r.X(), r.Y(), r.Width(), r.Height());
}
static nsIntRect
@ -1067,7 +1067,7 @@ ToInsideIntRect(const gfxRect& aRect)
{
gfxRect r = aRect;
r.RoundIn();
return nsIntRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
return nsIntRect(r.X(), r.Y(), r.Width(), r.Height());
}
/**
@ -1194,11 +1194,11 @@ BasicLayerManager::PushGroupWithCachedSurface(gfxContext *aTarget,
nsRefPtr<gfxContext> ctx =
mCachedSurface.Get(aContent,
gfxIntSize(clip.size.width, clip.size.height),
gfxIntSize(clip.Width(), clip.Height()),
currentSurf);
/* Align our buffer for the original surface */
ctx->Translate(-clip.pos);
*aSavedOffset = clip.pos;
ctx->Translate(-clip.TopLeft());
*aSavedOffset = clip.TopLeft();
ctx->Multiply(saveMatrix.Matrix());
return ctx.forget();
}

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

@ -712,7 +712,7 @@ LayerManagerOGL::WorldTransformRect(nsIntRect& aRect)
{
gfxRect grect(aRect.x, aRect.y, aRect.width, aRect.height);
grect = mWorldMatrix.TransformBounds(grect);
aRect.SetRect(grect.pos.x, grect.pos.y, grect.size.width, grect.size.height);
aRect.SetRect(grect.X(), grect.Y(), grect.Width(), grect.Height());
}
void

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

@ -918,8 +918,8 @@ ShadowBufferOGL::Upload(gfxASurface* aUpdate, const nsIntRegion& aUpdated,
destRect.RoundOut();
// NB: this gfxContext must not escape EndUpdate() below
nsIntRegion scaledDestRegion(nsIntRect(destRect.pos.x, destRect.pos.y,
destRect.size.width, destRect.size.height));
nsIntRegion scaledDestRegion(nsIntRect(destRect.X(), destRect.Y(),
destRect.Width(), destRect.Height()));
mTexImage->DirectUpdate(aUpdate, scaledDestRegion);
mBufferRect = aRect;

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

@ -304,30 +304,30 @@ static PRBool
ConditionRect(gfxRect& r) {
// if either x or y is way out of bounds;
// note that we don't handle negative w/h here
if (r.pos.x > CAIRO_COORD_MAX || r.pos.y > CAIRO_COORD_MAX)
if (r.X() > CAIRO_COORD_MAX || r.Y() > CAIRO_COORD_MAX)
return PR_FALSE;
if (r.pos.x < 0.0) {
r.size.width += r.pos.x;
if (r.X() < 0.0) {
r.size.width += r.X();
if (r.size.width < 0.0)
return PR_FALSE;
r.pos.x = 0.0;
}
if (r.pos.x + r.size.width > CAIRO_COORD_MAX) {
r.size.width = CAIRO_COORD_MAX - r.pos.x;
if (r.XMost() > CAIRO_COORD_MAX) {
r.size.width = CAIRO_COORD_MAX - r.X();
}
if (r.pos.y < 0.0) {
r.size.height += r.pos.y;
if (r.size.height < 0.0)
if (r.Y() < 0.0) {
r.size.height += r.Y();
if (r.Height() < 0.0)
return PR_FALSE;
r.pos.y = 0.0;
}
if (r.pos.y + r.size.height > CAIRO_COORD_MAX) {
r.size.height = CAIRO_COORD_MAX - r.pos.y;
if (r.YMost() > CAIRO_COORD_MAX) {
r.size.height = CAIRO_COORD_MAX - r.Y();
}
return PR_TRUE;
}

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

@ -290,8 +290,8 @@ void
gfxASurface::MarkDirty(const gfxRect& r)
{
cairo_surface_mark_dirty_rectangle(mSurface,
(int) r.pos.x, (int) r.pos.y,
(int) r.size.width, (int) r.size.height);
(int) r.X(), (int) r.Y(),
(int) r.Width(), (int) r.Height());
}
void

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

@ -247,7 +247,7 @@ gfxContext::Rectangle(const gfxRect& rect, PRBool snapToPixels)
}
}
cairo_rectangle(mCairo, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
}
void
@ -386,11 +386,7 @@ gfxContext::UserToDevice(const gfxSize& size) const
gfxRect
gfxContext::UserToDevice(const gfxRect& rect) const
{
double xmin, ymin, xmax, ymax;
xmin = rect.pos.x;
ymin = rect.pos.y;
xmax = rect.pos.x + rect.size.width;
ymax = rect.pos.y + rect.size.height;
double xmin = rect.X(), ymin = rect.Y(), xmax = rect.XMost(), ymax = rect.YMost();
double x[3], y[3];
x[0] = xmin; y[0] = ymax;
@ -444,9 +440,9 @@ gfxContext::UserToDevicePixelSnapped(gfxRect& rect, PRBool ignoreScale) const
p1.Round();
p3.Round();
rect.pos = gfxPoint(NS_MIN(p1.x, p3.x), NS_MIN(p1.y, p3.y));
rect.size = gfxSize(NS_MAX(p1.x, p3.x) - rect.pos.x,
NS_MAX(p1.y, p3.y) - rect.pos.y);
rect.MoveTo(gfxPoint(NS_MIN(p1.x, p3.x), NS_MIN(p1.y, p3.y)));
rect.SizeTo(gfxSize(NS_MAX(p1.x, p3.x) - rect.X(),
NS_MAX(p1.y, p3.y) - rect.Y()));
return PR_TRUE;
}
@ -497,8 +493,8 @@ gfxContext::PixelSnappedRectangleAndSetPattern(const gfxRect& rect,
IdentityMatrix();
}
Translate(r.pos);
r.pos.x = r.pos.y = 0;
Translate(r.TopLeft());
r.MoveTo(gfxPoint(0, 0));
Rectangle(r);
SetPattern(pattern);
@ -635,7 +631,7 @@ void
gfxContext::Clip(const gfxRect& rect)
{
cairo_new_path(mCairo);
cairo_rectangle(mCairo, rect.pos.x, rect.pos.y, rect.size.width, rect.size.height);
cairo_rectangle(mCairo, rect.X(), rect.Y(), rect.Width(), rect.Height());
cairo_clip(mCairo);
}
@ -977,9 +973,9 @@ gfxContext::RoundedRectangle(const gfxRect& rect,
gfxPoint pc, p0, p1, p2, p3;
if (draw_clockwise)
cairo_move_to(mCairo, rect.pos.x + corners[NS_CORNER_TOP_LEFT].width, rect.pos.y);
cairo_move_to(mCairo, rect.X() + corners[NS_CORNER_TOP_LEFT].width, rect.Y());
else
cairo_move_to(mCairo, rect.pos.x + rect.size.width - corners[NS_CORNER_TOP_RIGHT].width, rect.pos.y);
cairo_move_to(mCairo, rect.X() + rect.Width() - corners[NS_CORNER_TOP_RIGHT].width, rect.Y());
NS_FOR_CSS_CORNERS(i) {
// the corner index -- either 1 2 3 0 (cw) or 0 3 2 1 (ccw)

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

@ -1360,9 +1360,9 @@ gfxFont::Measure(gfxTextRun *aTextRun,
advance, metrics.mBoundingBox.Height());
}
if (isRTL) {
glyphRect.pos.x -= advance;
glyphRect -= gfxPoint(advance, 0);
}
glyphRect.pos.x += x;
glyphRect += gfxPoint(x, 0);
metrics.mBoundingBox = metrics.mBoundingBox.Union(glyphRect);
}
}
@ -1389,9 +1389,9 @@ gfxFont::Measure(gfxTextRun *aTextRun,
advance, metrics.mAscent + metrics.mDescent);
}
if (isRTL) {
glyphRect.pos.x -= advance;
glyphRect -= gfxPoint(advance, 0);
}
glyphRect.pos.x += x;
glyphRect += gfxPoint(x, 0);
metrics.mBoundingBox = metrics.mBoundingBox.Union(glyphRect);
x += direction*advance;
}
@ -1414,7 +1414,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
metrics.mBoundingBox = metrics.mBoundingBox.Union(fontBox);
}
if (isRTL) {
metrics.mBoundingBox.pos.x -= x;
metrics.mBoundingBox -= gfxPoint(x, 0);
}
metrics.mAdvanceWidth = x*direction;
@ -1943,10 +1943,10 @@ gfxGlyphExtents::SetTightGlyphExtents(PRUint32 aGlyphID, const gfxRect& aExtents
HashEntry *entry = mTightGlyphExtents.PutEntry(aGlyphID);
if (!entry)
return;
entry->x = aExtentsAppUnits.pos.x;
entry->y = aExtentsAppUnits.pos.y;
entry->width = aExtentsAppUnits.size.width;
entry->height = aExtentsAppUnits.size.height;
entry->x = aExtentsAppUnits.X();
entry->y = aExtentsAppUnits.Y();
entry->width = aExtentsAppUnits.Width();
entry->height = aExtentsAppUnits.Height();
}
gfxFontGroup::gfxFontGroup(const nsAString& aFamilies, const gfxFontStyle *aStyle, gfxUserFontSet *aUserFontSet)

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

@ -110,7 +110,7 @@ gfxMatrix::Transform(const gfxSize& size) const
gfxRect
gfxMatrix::Transform(const gfxRect& rect) const
{
return gfxRect(Transform(rect.pos), Transform(rect.size));
return gfxRect(Transform(rect.TopLeft()), Transform(rect.Size()));
}
gfxRect
@ -122,20 +122,20 @@ gfxMatrix::TransformBounds(const gfxRect& rect) const
double min_x, max_x;
double min_y, max_y;
quad_x[0] = rect.pos.x;
quad_y[0] = rect.pos.y;
quad_x[0] = rect.X();
quad_y[0] = rect.Y();
cairo_matrix_transform_point (CONST_CAIRO_MATRIX(this), &quad_x[0], &quad_y[0]);
quad_x[1] = rect.pos.x + rect.size.width;
quad_y[1] = rect.pos.y;
quad_x[1] = rect.XMost();
quad_y[1] = rect.Y();
cairo_matrix_transform_point (CONST_CAIRO_MATRIX(this), &quad_x[1], &quad_y[1]);
quad_x[2] = rect.pos.x;
quad_y[2] = rect.pos.y + rect.size.height;
quad_x[2] = rect.X();
quad_y[2] = rect.YMost();
cairo_matrix_transform_point (CONST_CAIRO_MATRIX(this), &quad_x[2], &quad_y[2]);
quad_x[3] = rect.pos.x + rect.size.width;
quad_y[3] = rect.pos.y + rect.size.height;
quad_x[3] = rect.XMost();
quad_y[3] = rect.YMost();
cairo_matrix_transform_point (CONST_CAIRO_MATRIX(this), &quad_x[3], &quad_y[3]);
min_x = max_x = quad_x[0];
@ -153,24 +153,6 @@ gfxMatrix::TransformBounds(const gfxRect& rect) const
max_y = quad_y[i];
}
// we don't compute this now
#if 0
if (is_tight) {
/* it's tight if and only if the four corner points form an axis-aligned
rectangle.
And that's true if and only if we can derive corners 0 and 3 from
corners 1 and 2 in one of two straightforward ways...
We could use a tolerance here but for now we'll fall back to FALSE in the case
of floating point error.
*/
*is_tight =
(quad_x[1] == quad_x[0] && quad_y[1] == quad_y[3] &&
quad_x[2] == quad_x[3] && quad_y[2] == quad_y[0]) ||
(quad_x[1] == quad_x[3] && quad_y[1] == quad_y[0] &&
quad_x[2] == quad_x[0] && quad_y[2] == quad_y[3]);
}
#endif
return gfxRect(min_x, min_y, max_x - min_x, max_y - min_y);
}

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

@ -107,7 +107,7 @@ gfxQuartzNativeDrawing::BeginNativeDrawing()
// bug 382049 - need to explicity set the composite operation to sourceOver
CGContextSetCompositeOperation(mCGContext, kPrivateCGCompositeSourceOver);
} else {
mQuartzSurface = new gfxQuartzSurface(mNativeRect.size,
mQuartzSurface = new gfxQuartzSurface(mNativeRect.Size(),
gfxASurface::ImageFormatARGB32);
if (mQuartzSurface->CairoStatus())
return nsnull;
@ -133,6 +133,6 @@ gfxQuartzNativeDrawing::EndNativeDrawing()
// Copy back to destination
mContext->Translate(mNativeRect.TopLeft());
mContext->DrawSurface(mQuartzSurface, mNativeRect.size);
mContext->DrawSurface(mQuartzSurface, mNativeRect.Size());
}
}

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

@ -90,16 +90,45 @@ struct THEBES_API gfxRect {
return (pos != s.pos) || (size != s.size);
}
void MoveTo(const gfxPoint& aPt) { pos = aPt; }
const gfxRect& MoveBy(const gfxPoint& aPt) {
pos = pos + aPt;
return *this;
}
void SizeTo(const gfxSize& aSize) { size = aSize; }
gfxRect operator+(const gfxPoint& aPt) const {
return gfxRect(pos + aPt, size);
}
gfxRect operator-(const gfxPoint& aPt) const {
return gfxRect(pos - aPt, size);
}
gfxRect operator+(const gfxSize& aSize) const {
return gfxRect(pos + gfxPoint(aSize.width, aSize.height), size);
}
gfxRect operator-(const gfxSize& aSize) const {
return gfxRect(pos - gfxPoint(aSize.width, aSize.height), size);
}
gfxRect operator*(const gfxFloat aScale) const {
return gfxRect(pos * aScale, size * aScale);
}
const gfxRect& operator+=(const gfxPoint& aPt) {
pos += aPt;
return *this;
}
const gfxRect& operator-=(const gfxPoint& aPt) {
pos -= aPt;
return *this;
}
const gfxRect& operator+=(const gfxSize& aSize) {
pos += gfxPoint(aSize.width, aSize.height);
return *this;
}
const gfxRect& operator-=(const gfxSize& aSize) {
pos -= gfxPoint(aSize.width, aSize.height);
return *this;
}
gfxFloat Width() const { return size.width; }
gfxFloat Height() const { return size.height; }
@ -122,8 +151,7 @@ struct THEBES_API gfxRect {
*/
PRBool WithinEpsilonOfIntegerPixels(gfxFloat aEpsilon) const;
gfxPoint TopLeft() { return pos; }
gfxPoint BottomRight() { return gfxPoint(XMost(), YMost()); }
gfxSize Size() const { return size; }
void Inset(gfxFloat k) {
pos.x += k;

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

@ -272,15 +272,15 @@ CreateSamplingRestrictedDrawable(gfxDrawable* aDrawable,
nsRefPtr<gfxContext> tmpCtx = new gfxContext(temp);
tmpCtx->SetOperator(OptimalFillOperator());
aDrawable->Draw(tmpCtx, needed - needed.pos, PR_TRUE,
gfxPattern::FILTER_FAST, gfxMatrix().Translate(needed.pos));
aDrawable->Draw(tmpCtx, needed - needed.TopLeft(), PR_TRUE,
gfxPattern::FILTER_FAST, gfxMatrix().Translate(needed.TopLeft()));
nsRefPtr<gfxPattern> resultPattern = new gfxPattern(temp);
if (!resultPattern)
return nsnull;
nsRefPtr<gfxDrawable> drawable =
new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.pos));
new gfxSurfaceDrawable(temp, size, gfxMatrix().Translate(-needed.TopLeft()));
return drawable.forget();
}

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

@ -137,8 +137,9 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
// and it fixes bug 382458
// There's probably a better fix, but I haven't figured out
// the root cause of the problem.
mTempSurfaceSize.width = (PRInt32) NS_ceil(mNativeRect.size.width + 1);
mTempSurfaceSize.height = (PRInt32) NS_ceil(mNativeRect.size.height + 1);
mTempSurfaceSize =
gfxIntSize((PRInt32) NS_ceil(mNativeRect.Width() + 1),
(PRInt32) NS_ceil(mNativeRect.Height() + 1));
} else {
// figure out the scale factors
mScale = m.ScaleFactors(PR_TRUE);
@ -151,8 +152,9 @@ gfxWindowsNativeDrawing::BeginNativeDrawing()
mWorldTransform.eDy = 0.0f;
// See comment above about "+1"
mTempSurfaceSize.width = (PRInt32) NS_ceil(mNativeRect.size.width * mScale.width + 1);
mTempSurfaceSize.height = (PRInt32) NS_ceil(mNativeRect.size.height * mScale.height + 1);
mTempSurfaceSize =
gfxIntSize((PRInt32) NS_ceil(mNativeRect.Width() * mScale.width + 1),
(PRInt32) NS_ceil(mNativeRect.Height() * mScale.height + 1));
}
}
}
@ -294,9 +296,9 @@ gfxWindowsNativeDrawing::PaintToContext()
gfxASurface::ImageFormatARGB32);
mContext->Save();
mContext->Translate(mNativeRect.pos);
mContext->Translate(mNativeRect.TopLeft());
mContext->NewPath();
mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.size));
mContext->Rectangle(gfxRect(gfxPoint(0.0, 0.0), mNativeRect.Size()));
nsRefPtr<gfxPattern> pat = new gfxPattern(alphaSurface);
@ -334,7 +336,7 @@ gfxWindowsNativeDrawing::TransformToNativeRect(const gfxRect& r,
roundedRect.MoveBy(mTranslation);
}
} else {
roundedRect.MoveBy(- mNativeRect.pos);
roundedRect.MoveBy(-mNativeRect.TopLeft());
}
roundedRect.Round();

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

@ -1617,7 +1617,7 @@ SetupBackgroundClip(BackgroundClipState& aClipState, gfxContext *aCtx,
// http://hg.mozilla.org/mozilla-central/rev/50e934e4979b landed.
NS_WARNING("converted background area should not be empty");
// Make our caller not do anything.
aClipState.mDirtyRectGfx.size.SizeTo(0.0, 0.0);
aClipState.mDirtyRectGfx.SizeTo(gfxSize(0.0, 0.0));
return;
}
@ -1657,7 +1657,7 @@ DrawBackgroundColor(BackgroundClipState& aClipState, gfxContext *aCtx,
// http://hg.mozilla.org/mozilla-central/rev/50e934e4979b landed.
NS_WARNING("converted background area should not be empty");
// Make our caller not do anything.
aClipState.mDirtyRectGfx.size.SizeTo(0.0, 0.0);
aClipState.mDirtyRectGfx.SizeTo(gfxSize(0.0, 0.0));
return;
}
@ -1942,10 +1942,10 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext,
gfxPoint lineStart, lineEnd;
double radiusX = 0, radiusY = 0; // for radial gradients only
if (aGradient->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR) {
ComputeLinearGradientLine(aPresContext, aGradient, oneCellArea.size,
ComputeLinearGradientLine(aPresContext, aGradient, oneCellArea.Size(),
&lineStart, &lineEnd);
} else {
ComputeRadialGradientLine(aPresContext, aGradient, oneCellArea.size,
ComputeRadialGradientLine(aPresContext, aGradient, oneCellArea.Size(),
&lineStart, &lineEnd, &radiusX, &radiusY);
}
gfxFloat lineLength = NS_hypot(lineEnd.x - lineStart.x,
@ -2192,9 +2192,9 @@ nsCSSRendering::PaintGradient(nsPresContext* aPresContext,
// tile with the overall area we're supposed to be filling
gfxRect fillRect = tileRect.Intersect(areaToFill);
ctx->NewPath();
ctx->Translate(tileRect.pos);
ctx->Translate(tileRect.TopLeft());
ctx->SetPattern(gradientPattern);
ctx->Rectangle(fillRect - tileRect.pos, PR_TRUE);
ctx->Rectangle(fillRect - tileRect.TopLeft(), PR_TRUE);
ctx->Fill();
ctx->SetMatrix(ctm);
}
@ -3560,7 +3560,7 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
rect.pos.x += lineHeight / 2.0;
aGfxContext->NewPath();
gfxPoint pt(rect.pos);
gfxPoint pt(rect.TopLeft());
gfxFloat rightMost = pt.x + rect.Width() + lineHeight;
gfxFloat adv = rect.Height() - lineHeight;
gfxFloat flatLengthAtVertex = NS_MAX((lineHeight - 1.0) * 2.0, 1.0);
@ -3568,7 +3568,7 @@ nsCSSRendering::PaintDecorationLine(gfxContext* aGfxContext,
pt.x -= lineHeight;
aGfxContext->MoveTo(pt); // 1
pt.x = rect.pos.x;
pt.x = rect.X();
aGfxContext->LineTo(pt); // 2
PRBool goDown = PR_TRUE;
@ -3640,9 +3640,7 @@ nsCSSRendering::GetTextDecorationRectInternal(const gfxPoint& aPt,
PRBool canLiftUnderline = aDescentLimit >= 0.0;
gfxRect r;
r.pos.x = NS_floor(aPt.x + 0.5);
r.size.width = NS_round(aLineSize.width);
gfxRect r(NS_floor(aPt.x + 0.5), 0, NS_round(aLineSize.width), 0);
gfxFloat lineHeight = NS_round(aLineSize.height);
lineHeight = NS_MAX(lineHeight, 1.0);

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

@ -225,10 +225,10 @@ ComputeBorderCornerDimensions(const gfxRect& aOuterRect,
const gfxCornerSizes& aRadii,
gfxCornerSizes *aDimsRet)
{
gfxFloat topWidth = aInnerRect.pos.y - aOuterRect.pos.y;
gfxFloat leftWidth = aInnerRect.pos.x - aOuterRect.pos.x;
gfxFloat rightWidth = aOuterRect.size.width - aInnerRect.size.width - leftWidth;
gfxFloat bottomWidth = aOuterRect.size.height - aInnerRect.size.height - topWidth;
gfxFloat leftWidth = aInnerRect.X() - aOuterRect.X();
gfxFloat topWidth = aInnerRect.Y() - aOuterRect.Y();
gfxFloat rightWidth = aOuterRect.Width() - aInnerRect.Width() - leftWidth;
gfxFloat bottomWidth = aOuterRect.Height() - aInnerRect.Height() - topWidth;
if (AllCornersZeroSize(aRadii)) {
// These will always be in pixel units from CSS
@ -354,11 +354,11 @@ nsCSSBorderRenderer::DoCornerSubPath(mozilla::css::Corner aCorner)
gfxPoint offset(0.0, 0.0);
if (aCorner == C_TR || aCorner == C_BR)
offset.x = mOuterRect.size.width - mBorderCornerDimensions[aCorner].width;
offset.x = mOuterRect.Width() - mBorderCornerDimensions[aCorner].width;
if (aCorner == C_BR || aCorner == C_BL)
offset.y = mOuterRect.size.height - mBorderCornerDimensions[aCorner].height;
offset.y = mOuterRect.Height() - mBorderCornerDimensions[aCorner].height;
mContext->Rectangle(gfxRect(mOuterRect.pos + offset,
mContext->Rectangle(gfxRect(mOuterRect.TopLeft() + offset,
mBorderCornerDimensions[aCorner]));
}
@ -375,11 +375,11 @@ nsCSSBorderRenderer::DoSideClipWithoutCornersSubPath(mozilla::css::Side aSide)
if (aSide == NS_SIDE_TOP) {
offset.x = mBorderCornerDimensions[C_TL].width;
} else if (aSide == NS_SIDE_RIGHT) {
offset.x = mOuterRect.size.width - mBorderWidths[NS_SIDE_RIGHT];
offset.x = mOuterRect.Width() - mBorderWidths[NS_SIDE_RIGHT];
offset.y = mBorderCornerDimensions[C_TR].height;
} else if (aSide == NS_SIDE_BOTTOM) {
offset.x = mBorderCornerDimensions[C_BL].width;
offset.y = mOuterRect.size.height - mBorderWidths[NS_SIDE_BOTTOM];
offset.y = mOuterRect.Height() - mBorderWidths[NS_SIDE_BOTTOM];
} else if (aSide == NS_SIDE_LEFT) {
offset.y = mBorderCornerDimensions[C_TL].height;
}
@ -390,8 +390,8 @@ nsCSSBorderRenderer::DoSideClipWithoutCornersSubPath(mozilla::css::Side aSide)
// with both proceeding clockwise.
gfxSize sideCornerSum = mBorderCornerDimensions[mozilla::css::Corner(aSide)]
+ mBorderCornerDimensions[mozilla::css::Corner(NEXT_SIDE(aSide))];
gfxRect rect(mOuterRect.pos + offset,
mOuterRect.size - sideCornerSum);
gfxRect rect(mOuterRect.TopLeft() + offset,
mOuterRect.Size() - sideCornerSum);
if (aSide == NS_SIDE_TOP || aSide == NS_SIDE_BOTTOM)
rect.size.height = mBorderWidths[aSide];
@ -581,29 +581,27 @@ nsCSSBorderRenderer::FillSolidBorder(const gfxRect& aOuterRect,
// compute base rects for each side
if (aSides & SIDE_BIT_TOP) {
r[NS_SIDE_TOP].pos = aOuterRect.TopLeft();
r[NS_SIDE_TOP].size.width = aOuterRect.size.width;
r[NS_SIDE_TOP].size.height = aBorderSizes[NS_SIDE_TOP];
r[NS_SIDE_TOP] =
gfxRect(aOuterRect.X(), aOuterRect.Y(),
aOuterRect.Width(), aBorderSizes[NS_SIDE_TOP]);
}
if (aSides & SIDE_BIT_BOTTOM) {
r[NS_SIDE_BOTTOM].pos = aOuterRect.BottomLeft();
r[NS_SIDE_BOTTOM].pos.y -= aBorderSizes[NS_SIDE_BOTTOM];
r[NS_SIDE_BOTTOM].size.width = aOuterRect.size.width;
r[NS_SIDE_BOTTOM].size.height = aBorderSizes[NS_SIDE_BOTTOM];
r[NS_SIDE_BOTTOM] =
gfxRect(aOuterRect.X(), aOuterRect.YMost() - aBorderSizes[NS_SIDE_BOTTOM],
aOuterRect.Width(), aBorderSizes[NS_SIDE_BOTTOM]);
}
if (aSides & SIDE_BIT_LEFT) {
r[NS_SIDE_LEFT].pos = aOuterRect.TopLeft();
r[NS_SIDE_LEFT].size.width = aBorderSizes[NS_SIDE_LEFT];
r[NS_SIDE_LEFT].size.height = aOuterRect.size.height;
r[NS_SIDE_LEFT] =
gfxRect(aOuterRect.X(), aOuterRect.Y(),
aBorderSizes[NS_SIDE_LEFT], aOuterRect.Height());
}
if (aSides & SIDE_BIT_RIGHT) {
r[NS_SIDE_RIGHT].pos = aOuterRect.TopRight();
r[NS_SIDE_RIGHT].pos.x -= aBorderSizes[NS_SIDE_RIGHT];
r[NS_SIDE_RIGHT].size.width = aBorderSizes[NS_SIDE_RIGHT];
r[NS_SIDE_RIGHT].size.height = aOuterRect.size.height;
r[NS_SIDE_RIGHT] =
gfxRect(aOuterRect.XMost() - aBorderSizes[NS_SIDE_RIGHT], aOuterRect.Y(),
aBorderSizes[NS_SIDE_RIGHT], aOuterRect.Height());
}
// If two sides meet at a corner that we're rendering, then
@ -695,7 +693,6 @@ nsCSSBorderRenderer::DrawBorderSidesCompositeColors(PRIntn aSides, const nsBorde
// the generic composite colors path; each border is 1px in size
gfxRect soRect = mOuterRect;
gfxRect siRect;
gfxFloat maxBorderWidth = 0;
NS_FOR_CSS_SIDES (i) {
maxBorderWidth = NS_MAX(maxBorderWidth, mBorderWidths[i]);
@ -703,21 +700,18 @@ nsCSSBorderRenderer::DrawBorderSidesCompositeColors(PRIntn aSides, const nsBorde
gfxFloat fakeBorderSizes[4];
gfxRGBA lineColor;
gfxPoint tl, br;
gfxPoint itl = mInnerRect.TopLeft();
gfxPoint ibr = mInnerRect.BottomRight();
for (PRUint32 i = 0; i < PRUint32(maxBorderWidth); i++) {
lineColor = ComputeCompositeColorForLine(i, aCompositeColors);
gfxRGBA lineColor = ComputeCompositeColorForLine(i, aCompositeColors);
siRect = soRect;
gfxRect siRect = soRect;
siRect.Inset(1.0, 1.0, 1.0, 1.0);
// now cap the rects to the real mInnerRect
tl = siRect.TopLeft();
br = siRect.BottomRight();
gfxPoint tl = siRect.TopLeft();
gfxPoint br = siRect.BottomRight();
tl.x = NS_MIN(tl.x, itl.x);
tl.y = NS_MIN(tl.y, itl.y);
@ -725,9 +719,7 @@ nsCSSBorderRenderer::DrawBorderSidesCompositeColors(PRIntn aSides, const nsBorde
br.x = NS_MAX(br.x, ibr.x);
br.y = NS_MAX(br.y, ibr.y);
siRect.pos = tl;
siRect.size.width = br.x - tl.x;
siRect.size.height = br.y - tl.y;
siRect = gfxRect(tl.x, tl.y, br.x - tl.x , br.y - tl.y);
fakeBorderSizes[NS_SIDE_TOP] = siRect.TopLeft().y - soRect.TopLeft().y;
fakeBorderSizes[NS_SIDE_RIGHT] = soRect.TopRight().x - siRect.TopRight().x;

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

@ -1009,9 +1009,7 @@ nsRect
nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
{
/* Get a new gfxRect whose units are app units by scaling by the specified factor. */
gfxRect scaledRect(aRect.pos.x * aFactor, aRect.pos.y * aFactor,
aRect.size.width * aFactor,
aRect.size.height * aFactor);
gfxRect scaledRect = aRect * aFactor;
/* Round outward. */
scaledRect.RoundOut();
@ -1023,8 +1021,8 @@ nsLayoutUtils::RoundGfxRectToAppRect(const gfxRect &aRect, float aFactor)
ConstrainToCoordValues(scaledRect.size.height);
/* Now typecast everything back. This is guaranteed to be safe. */
return nsRect(nscoord(scaledRect.pos.x), nscoord(scaledRect.pos.y),
nscoord(scaledRect.size.width), nscoord(scaledRect.size.height));
return nsRect(nscoord(scaledRect.X()), nscoord(scaledRect.Y()),
nscoord(scaledRect.Width()), nscoord(scaledRect.Height()));
}
@ -3088,8 +3086,8 @@ static gfxPoint
MapToFloatImagePixels(const gfxSize& aSize,
const gfxRect& aDest, const gfxPoint& aPt)
{
return gfxPoint(((aPt.x - aDest.pos.x)*aSize.width)/aDest.size.width,
((aPt.y - aDest.pos.y)*aSize.height)/aDest.size.height);
return gfxPoint(((aPt.x - aDest.X())*aSize.width)/aDest.Width(),
((aPt.y - aDest.Y())*aSize.height)/aDest.Height());
}
/**
@ -3104,8 +3102,8 @@ static gfxPoint
MapToFloatUserPixels(const gfxSize& aSize,
const gfxRect& aDest, const gfxPoint& aPt)
{
return gfxPoint(aPt.x*aDest.size.width/aSize.width + aDest.pos.x,
aPt.y*aDest.size.height/aSize.height + aDest.pos.y);
return gfxPoint(aPt.x*aDest.Width()/aSize.width + aDest.X(),
aPt.y*aDest.Height()/aSize.height + aDest.Y());
}
/* static */ gfxRect

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

@ -287,7 +287,7 @@ nsHTMLCanvasFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// Transform the canvas into the right place
gfxMatrix transform;
transform.Translate(r.pos);
transform.Translate(r.TopLeft());
transform.Scale(r.Width()/canvasSize.width, r.Height()/canvasSize.height);
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));

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

@ -1223,9 +1223,9 @@ nsDisplayImage::ConfigureLayer(ImageLayer* aLayer)
mImage->GetHeight(&imageHeight);
gfxMatrix transform;
transform.Translate(destRect.pos);
transform.Scale(destRect.size.width/imageWidth,
destRect.size.height/imageHeight);
transform.Translate(destRect.TopLeft());
transform.Scale(destRect.Width()/imageWidth,
destRect.Height()/imageHeight);
aLayer->SetTransform(gfx3DMatrix::From2D(transform));
aLayer->SetVisibleRegion(nsIntRect(0, 0, imageWidth, imageHeight));

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

@ -2185,7 +2185,7 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
// Set a transform on the layer to draw the plugin in the right place
gfxMatrix transform;
transform.Translate(r.pos);
transform.Translate(r.TopLeft());
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetVisibleRegion(nsIntRect(0, 0, size.width, size.height));

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

@ -5050,7 +5050,7 @@ nsTextFrame::GetSnappedBaselineY(gfxContext* aContext, gfxFloat aY)
gfxRect putativeRect(0, baseline/appUnitsPerDevUnit, 1, 1);
if (!aContext->UserToDevicePixelSnapped(putativeRect))
return baseline;
return aContext->DeviceToUser(putativeRect.pos).y*appUnitsPerDevUnit;
return aContext->DeviceToUser(putativeRect.TopLeft()).y*appUnitsPerDevUnit;
}
void

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

@ -278,7 +278,7 @@ nsVideoFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
layer->SetContentFlags(Layer::CONTENT_OPAQUE);
// Set a transform on the layer to draw the video in the right place
gfxMatrix transform;
transform.Translate(r.pos);
transform.Translate(r.TopLeft());
transform.Scale(r.Width()/frameSize.width, r.Height()/frameSize.height);
layer->SetTransform(gfx3DMatrix::From2D(transform));
layer->SetVisibleRegion(nsIntRect(0, 0, videoSize.width, videoSize.height));

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

@ -488,8 +488,8 @@ BuildBackgroundPatternFor(ContainerLayer* aContainer,
gfxRect localContentVis(t.Transform(contentVis));
// Round *in* here because this area is punched out of the background
localContentVis.RoundIn();
nsIntRect localIntContentVis(localContentVis.pos.x, localContentVis.pos.y,
localContentVis.size.width, localContentVis.size.height);
nsIntRect localIntContentVis(localContentVis.X(), localContentVis.Y(),
localContentVis.Width(), localContentVis.Height());
// Get the frame's rect
nscoord auPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();

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

@ -169,7 +169,7 @@ nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
// We don't care if this overflows, because we can handle upscaling/
// downscaling to filterRes
PRBool overflow;
filterRes = nsSVGUtils::ConvertToSurfaceSize(filterRegion.size * scale,
filterRes = nsSVGUtils::ConvertToSurfaceSize(filterRegion.Size() * scale,
&overflow);
}

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

@ -112,7 +112,7 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
new gfxImageSurface(surfaceSize, gfxASurface::ImageFormatARGB32);
if (!image || image->CairoStatus())
return nsnull;
image->SetDeviceOffset(-clipExtents.pos);
image->SetDeviceOffset(-clipExtents.TopLeft());
nsSVGRenderState tmpState(image);

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

@ -275,10 +275,8 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
// GetUserStrokeExtent gets the extents wrong we can still use it
// to get the device space position of zero length stroked paths.
extent = context->GetUserStrokeExtent();
extent.pos.x += extent.size.width / 2;
extent.pos.y += extent.size.height / 2;
extent.size.width = 0;
extent.size.height = 0;
extent += extent.Size()/2;
extent.SizeTo(gfxSize(0, 0));
}
extent = nsSVGUtils::PathExtentsToMaxStrokeExtents(extent, this);
} else if (GetStyleSVG()->mFill.mType == eStyleSVGPaintType_None) {

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

@ -788,7 +788,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
}
// Translate the dirty rect so that it is wrt the widget top-left.
dirtyRect.MoveBy(-rect.pos);
dirtyRect.MoveBy(-rect.TopLeft());
// Round out the dirty rect to gdk pixels to ensure that gtk draws
// enough pixels for interpolation to device pixels.
dirtyRect.RoundOut();
@ -837,7 +837,7 @@ nsNativeThemeGTK::DrawWidgetBackground(nsRenderingContext* aContext,
// Rects are in device coords.
ctx->IdentityMatrix();
}
ctx->Translate(rect.pos + gfxPoint(drawingRect.x, drawingRect.y));
ctx->Translate(rect.TopLeft() + gfxPoint(drawingRect.x, drawingRect.y));
NS_ASSERTION(!IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType),
"Trying to render an unsafe widget!");

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

@ -1544,12 +1544,12 @@ RENDER_AGAIN:
// are because we might have drawn something above them (like a background-image).
ctx->Save();
ctx->ResetClip();
ctx->Translate(dr.pos);
ctx->Translate(dr.TopLeft());
// Create a rounded rectangle to follow the buttons' look.
gfxRect buttonbox1(0.0, 0.0, dr.size.width, dr.size.height - 2.0);
gfxRect buttonbox2(1.0, dr.size.height - 2.0, dr.size.width - 1.0, 1.0);
gfxRect buttonbox3(2.0, dr.size.height - 1.0, dr.size.width - 3.0, 1.0);
gfxRect buttonbox1(0.0, 0.0, dr.Width(), dr.Height() - 2.0);
gfxRect buttonbox2(1.0, dr.Height() - 2.0, dr.Width() - 1.0, 1.0);
gfxRect buttonbox3(2.0, dr.Height() - 1.0, dr.Width() - 3.0, 1.0);
gfxContext::GraphicsOperator currentOp = ctx->CurrentOperator();
ctx->SetOperator(gfxContext::OPERATOR_CLEAR);