Bug 1388892: TableArea doesn't really need to own the rectangle, except for the union call. Especially since we're exposing the addresses of the members. r=xidorn
MozReview-Commit-ID: BAjQ20ngkIM
This commit is contained in:
@@ -206,6 +206,11 @@ struct BaseRect {
|
|||||||
{
|
{
|
||||||
SetRect(aPt.x, aPt.y, aSize.width, aSize.height);
|
SetRect(aPt.x, aPt.y, aSize.width, aSize.height);
|
||||||
}
|
}
|
||||||
|
void GetRect(T* aX, T* aY, T* aWidth, T* aHeight)
|
||||||
|
{
|
||||||
|
*aX = x; *aY = y; *aWidth = width; *aHeight = height;
|
||||||
|
}
|
||||||
|
|
||||||
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
void MoveTo(T aX, T aY) { x = aX; y = aY; }
|
||||||
void MoveTo(const Point& aPoint) { x = aPoint.x; y = aPoint.y; }
|
void MoveTo(const Point& aPoint) { x = aPoint.x; y = aPoint.y; }
|
||||||
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
|
||||||
|
|||||||
@@ -12,28 +12,38 @@ namespace mozilla {
|
|||||||
|
|
||||||
struct TableArea
|
struct TableArea
|
||||||
{
|
{
|
||||||
TableArea() : mRect() { }
|
TableArea()
|
||||||
|
: mStartCol(0), mStartRow(0), mColCount(0), mRowCount(0) { }
|
||||||
TableArea(int32_t aStartCol, int32_t aStartRow,
|
TableArea(int32_t aStartCol, int32_t aStartRow,
|
||||||
int32_t aColCount, int32_t aRowCount)
|
int32_t aColCount, int32_t aRowCount)
|
||||||
: mRect(aStartCol, aStartRow, aColCount, aRowCount) { }
|
: mStartCol(aStartCol),
|
||||||
|
mStartRow(aStartRow),
|
||||||
|
mColCount(aColCount),
|
||||||
|
mRowCount(aRowCount) { }
|
||||||
|
|
||||||
int32_t& StartCol() { return mRect.x; }
|
int32_t& StartCol() { return mStartCol; }
|
||||||
int32_t& StartRow() { return mRect.y; }
|
int32_t& StartRow() { return mStartRow; }
|
||||||
int32_t& ColCount() { return mRect.width; }
|
int32_t& ColCount() { return mColCount; }
|
||||||
int32_t& RowCount() { return mRect.height; }
|
int32_t& RowCount() { return mRowCount; }
|
||||||
|
|
||||||
int32_t StartCol() const { return mRect.x; }
|
int32_t StartCol() const { return mStartCol; }
|
||||||
int32_t StartRow() const { return mRect.y; }
|
int32_t StartRow() const { return mStartRow; }
|
||||||
int32_t ColCount() const { return mRect.width; }
|
int32_t ColCount() const { return mColCount; }
|
||||||
int32_t RowCount() const { return mRect.height; }
|
int32_t RowCount() const { return mRowCount; }
|
||||||
int32_t EndCol() const { return mRect.XMost(); }
|
int32_t EndCol() const { return mStartCol + mColCount; }
|
||||||
int32_t EndRow() const { return mRect.YMost(); }
|
int32_t EndRow() const { return mStartRow + mRowCount; }
|
||||||
|
|
||||||
void UnionArea(const TableArea& aArea1, const TableArea& aArea2)
|
void UnionArea(const TableArea& aArea1, const TableArea& aArea2)
|
||||||
{ mRect.UnionRect(aArea1.mRect, aArea2.mRect); }
|
{
|
||||||
|
nsIntRect rect(aArea1.mStartCol, aArea1.mStartRow,
|
||||||
|
aArea1.mColCount, aArea1.mRowCount);
|
||||||
|
rect.UnionRect(rect, nsIntRect(aArea2.mStartCol, aArea2.mStartRow,
|
||||||
|
aArea2.mColCount, aArea2.mRowCount));
|
||||||
|
rect.GetRect(&mStartCol, &mStartRow, &mColCount, &mRowCount);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsIntRect mRect;
|
int32_t mStartCol, mStartRow, mColCount, mRowCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|||||||
Reference in New Issue
Block a user