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 draft
authorMilan Sreckovic <milan@mozilla.com>
Thu, 31 Aug 2017 16:00:44 -0400
changeset 656872 6a715faf2ab49a5727d20945b990c0ea715f02e5
parent 656783 4984da22242841a5d84c4e5fd866e93a450d9723
child 729273 d8f63d028ce68e3e50bb1039f50514e9467db28a
push id77356
push userbmo:milan@mozilla.com
push dateThu, 31 Aug 2017 20:01:08 +0000
reviewersxidorn
bugs1388892
milestone57.0a1
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
gfx/2d/BaseRect.h
layout/tables/TableArea.h
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -201,16 +201,21 @@ struct BaseRect {
   void SetRect(T aX, T aY, T aWidth, T aHeight)
   {
     x = aX; y = aY; width = aWidth; height = aHeight;
   }
   void SetRect(const Point& aPt, const SizeT& aSize)
   {
     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(const Point& aPoint) { x = aPoint.x; y = aPoint.y; }
   void MoveBy(T aDx, T aDy) { x += aDx; y += aDy; }
   void MoveBy(const Point& aPoint) { x += aPoint.x; y += aPoint.y; }
   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); }
--- a/layout/tables/TableArea.h
+++ b/layout/tables/TableArea.h
@@ -7,35 +7,45 @@
 #define mozilla_TableArea_h_
 
 #include "nsRect.h"
 
 namespace mozilla {
 
 struct TableArea
 {
-  TableArea() : mRect() { }
+  TableArea()
+    : mStartCol(0), mStartRow(0), mColCount(0), mRowCount(0) { }
   TableArea(int32_t aStartCol, int32_t aStartRow,
             int32_t aColCount, int32_t aRowCount)
-    : mRect(aStartCol, aStartRow, aColCount, aRowCount) { }
-
-  int32_t& StartCol() { return mRect.x; }
-  int32_t& StartRow() { return mRect.y; }
-  int32_t& ColCount() { return mRect.width; }
-  int32_t& RowCount() { return mRect.height; }
+    : mStartCol(aStartCol),
+      mStartRow(aStartRow),
+      mColCount(aColCount),
+      mRowCount(aRowCount) { }
 
-  int32_t StartCol() const { return mRect.x; }
-  int32_t StartRow() const { return mRect.y; }
-  int32_t ColCount() const { return mRect.width; }
-  int32_t RowCount() const { return mRect.height; }
-  int32_t EndCol() const { return mRect.XMost(); }
-  int32_t EndRow() const { return mRect.YMost(); }
+  int32_t& StartCol() { return mStartCol; }
+  int32_t& StartRow() { return mStartRow; }
+  int32_t& ColCount() { return mColCount; }
+  int32_t& RowCount() { return mRowCount; }
+
+  int32_t StartCol() const { return mStartCol; }
+  int32_t StartRow() const { return mStartRow; }
+  int32_t ColCount() const { return mColCount; }
+  int32_t RowCount() const { return mRowCount; }
+  int32_t EndCol() const { return mStartCol + mColCount; }
+  int32_t EndRow() const { return mStartRow + mRowCount; }
 
   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:
-  nsIntRect mRect;
+  int32_t mStartCol, mStartRow, mColCount, mRowCount;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_TableArea_h_