diff --git a/ReactCommon/yoga/yoga/YGStyle.cpp b/ReactCommon/yoga/yoga/YGStyle.cpp index 437b682d6..66e4d04cc 100644 --- a/ReactCommon/yoga/yoga/YGStyle.cpp +++ b/ReactCommon/yoga/yoga/YGStyle.cpp @@ -9,7 +9,7 @@ const YGValue kYGValueUndefined = {0, YGUnitUndefined}; -const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto}; +const YGValue kYGValueAuto = {0, YGUnitAuto}; const std::array kYGDefaultEdgeValuesUnit = { {kYGValueUndefined, @@ -42,7 +42,7 @@ YGStyle::YGStyle() flex(YGFloatOptional()), flexGrow(YGFloatOptional()), flexShrink(YGFloatOptional()), - flexBasis({0, YGUnitAuto}), + flexBasis(kYGValueAuto), margin(kYGDefaultEdgeValuesUnit), position(kYGDefaultEdgeValuesUnit), padding(kYGDefaultEdgeValuesUnit), diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 7518e8586..b13b28e1c 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -629,7 +629,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 && \ @@ -644,10 +644,10 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { \ void YGNodeStyleSet##name##Percent( \ const YGNodeRef node, const type paramName) { \ - if (node->getStyle().instanceName.value != paramName || \ + if (node->getStyle().instanceName.value != YGFloatSanitize(paramName) || \ node->getStyle().instanceName.unit != YGUnitPercent) { \ YGStyle style = node->getStyle(); \ - style.instanceName.value = paramName; \ + style.instanceName.value = YGFloatSanitize(paramName); \ style.instanceName.unit = \ YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \ node->setStyle(style); \ @@ -658,7 +658,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { void YGNodeStyleSet##name##Auto(const YGNodeRef node) { \ if (node->getStyle().instanceName.unit != YGUnitAuto) { \ YGStyle style = node->getStyle(); \ - style.instanceName.value = YGUndefined; \ + style.instanceName.value = 0; \ style.instanceName.unit = YGUnitAuto; \ node->setStyle(style); \ node->markDirtyAndPropogate(); \ @@ -678,19 +678,23 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) { \ type YGNodeStyleGet##name(const YGNodeRef node) { \ YGValue value = node->getStyle().instanceName; \ - if (value.unit == YGUndefined || value.unit == YGUnitAuto) { \ + if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \ value.value = YGUndefined; \ } \ return value; \ } -#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL( \ - type, name, paramName, instanceName) \ - YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \ - float, name, paramName, instanceName) \ - \ - type YGNodeStyleGet##name(const YGNodeRef node) { \ - return node->getStyle().instanceName; \ +#define YG_NODE_STYLE_PROPERTY_UNIT_AUTO_IMPL( \ + type, name, paramName, instanceName) \ + YG_NODE_STYLE_PROPERTY_SETTER_UNIT_AUTO_IMPL( \ + float, name, paramName, instanceName) \ + \ + type YGNodeStyleGet##name(const YGNodeRef node) { \ + YGValue value = node->getStyle().instanceName; \ + if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \ + value.value = YGUndefined; \ + } \ + return value; \ } #define YG_NODE_STYLE_EDGE_PROPERTY_UNIT_AUTO_IMPL(type, name, instanceName) \