diff --git a/ReactCommon/fabric/graphics/Geometry.h b/ReactCommon/fabric/graphics/Geometry.h index 0bd5448791..6349938d5e 100644 --- a/ReactCommon/fabric/graphics/Geometry.h +++ b/ReactCommon/fabric/graphics/Geometry.h @@ -110,21 +110,23 @@ struct Rect { }; /* - * EdgeInsets + * Generic data structure describes some values associated with *edges* + * of a rectangle. */ -struct EdgeInsets { - Float left {0}; - Float top {0}; - Float right {0}; - Float bottom {0}; +template +struct RectangleEdges { + T left {}; + T top {}; + T right {}; + T bottom {}; - bool operator==(const EdgeInsets &rhs) const { + bool operator==(const RectangleEdges &rhs) const { return std::tie(this->left, this->top, this->right, this->bottom) == std::tie(rhs.left, rhs.top, rhs.right, rhs.bottom); } - bool operator!=(const EdgeInsets &rhs) const { + bool operator!=(const RectangleEdges &rhs) const { return !(*this == rhs); } @@ -136,21 +138,23 @@ struct EdgeInsets { }; /* - * CornerInsets + * Generic data structure describes some values associated with *corners* + * of a rectangle. */ -struct CornerInsets { - Float topLeft {0}; - Float topRight {0}; - Float bottomLeft {0}; - Float bottomRight {0}; +template +struct RectangleCorners { + T topLeft {}; + T topRight {}; + T bottomLeft {}; + T bottomRight {}; - bool operator==(const CornerInsets &rhs) const { + bool operator==(const RectangleCorners &rhs) const { return - std::tie(this->topLeft, this->topRight, this->bottomLeft, this->bottomRight) == - std::tie(rhs.topLeft, rhs.topRight, rhs.bottomLeft, rhs.bottomRight); + std::tie(this->topLeft, this->topRight, this->bottomLeft, this->bottomRight) == + std::tie(rhs.topLeft, rhs.topRight, rhs.bottomLeft, rhs.bottomRight); } - bool operator!=(const CornerInsets &rhs) const { + bool operator!=(const RectangleCorners &rhs) const { return !(*this == rhs); } @@ -161,5 +165,15 @@ struct CornerInsets { } }; +/* + * EdgeInsets + */ +using EdgeInsets = RectangleEdges; + +/* + * CornerInsets + */ +using CornerInsets = RectangleCorners; + } // namespace react } // namespace facebook