Remove the usage of YGUndefined for kYGValueAuto and fix setter and getter of dimensions

Reviewed By: emilsjolander

Differential Revision: D7302453

fbshipit-source-id: e002a1ddd75bfc6fe142a7275e7913c064972e16
This commit is contained in:
Pritesh Nandgaonkar 2018-04-03 14:56:27 -07:00 committed by Facebook Github Bot
parent 976712afa3
commit e5a4d59244
2 changed files with 18 additions and 14 deletions

View File

@ -9,7 +9,7 @@
const YGValue kYGValueUndefined = {0, YGUnitUndefined};
const YGValue kYGValueAuto = {YGUndefined, YGUnitAuto};
const YGValue kYGValueAuto = {0, YGUnitAuto};
const std::array<YGValue, YGEdgeCount> 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),

View File

@ -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) \