From fa3ab5c65382b5c8dab0bcf2bd6fcc643fae7918 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 13 Nov 2019 14:19:59 -0800 Subject: [PATCH] Fabric: Add and subtract operations for RectangleEdges Summary: We will use it soon for `EdgeInsets` Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D18444732 fbshipit-source-id: f03aa2a8889d426095a954d88f9cb6172c3e376e --- ReactCommon/fabric/graphics/Geometry.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ReactCommon/fabric/graphics/Geometry.h b/ReactCommon/fabric/graphics/Geometry.h index d3a3846961c..b1c05ab7a95 100644 --- a/ReactCommon/fabric/graphics/Geometry.h +++ b/ReactCommon/fabric/graphics/Geometry.h @@ -141,6 +141,26 @@ struct RectangleEdges { } }; +template +RectangleEdges operator+( + RectangleEdges const &lhs, + RectangleEdges const &rhs) { + return RectangleEdges{lhs.left + rhs.left, + lhs.top + rhs.top, + lhs.right + rhs.right, + lhs.bottom + rhs.bottom}; +} + +template +RectangleEdges operator-( + RectangleEdges const &lhs, + RectangleEdges const &rhs) { + return RectangleEdges{lhs.left - rhs.left, + lhs.top - rhs.top, + lhs.right - rhs.right, + lhs.bottom - rhs.bottom}; +} + /* * Generic data structure describes some values associated with *corners* * of a rectangle.