From da2d410122fd2072497f55a9934325f38cfcbba7 Mon Sep 17 00:00:00 2001 From: Pritesh Nandgaonkar Date: Thu, 15 Mar 2018 07:13:03 -0700 Subject: [PATCH] Fix getters and setters if min and max Dimension Reviewed By: emilsjolander Differential Revision: D7274807 fbshipit-source-id: 7c1a4c19e8d0552b089a410c3330392cb26a6a47 --- ReactCommon/yoga/yoga/Yoga.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 5ccb6b1eff3..e38ff26870c 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -538,7 +538,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { type, name, paramName, instanceName) \ void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \ YGValue value = { \ - .value = paramName, \ + .value = YGFloatSanitize(paramName), \ .unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \ }; \ if ((node->getStyle().instanceName.value != value.value && \ @@ -554,7 +554,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { void YGNodeStyleSet##name##Percent( \ const YGNodeRef node, const type paramName) { \ YGValue value = { \ - .value = paramName, \ + .value = YGFloatSanitize(paramName), \ .unit = \ YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \ }; \ @@ -621,7 +621,11 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { float, name, paramName, instanceName) \ \ type YGNodeStyleGet##name(const YGNodeRef node) { \ - return node->getStyle().instanceName; \ + YGValue value = node->getStyle().instanceName; \ + if (value.unit == YGUndefined || value.unit == YGUnitAuto) { \ + value.value = YGUndefined; \ + } \ + return value; \ } #define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL( \