Fix setter and getter of margin, position, border and padding
Summary: This diff fixes the setter and getter of margin, position, border and padding to the previous behaviour of yoga, before floatoptional change This diff also removes the unrequired `#define` Reviewed By: emilsjolander Differential Revision: D7274115 fbshipit-source-id: 942a91e6562ef789ae79102a828f397889468fa7
This commit is contained in:
committed by
Facebook Github Bot
parent
cfb9eeca20
commit
369c9ad12a
@@ -72,7 +72,10 @@ appendNumberIfNotAuto(string* base, const string& key, const YGValue number) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
appendNumberIfNotZero(string* base, const string& str, const YGValue number) {
|
||||||
if (!YGFloatsEqual(number.value, 0)) {
|
|
||||||
|
if (number.unit == YGUnitAuto) {
|
||||||
|
base->append(str + ": auto; ");
|
||||||
|
} else if (!YGFloatsEqual(number.value, 0)) {
|
||||||
appendNumberIfNotUndefined(base, str, number);
|
appendNumberIfNotUndefined(base, str, number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -637,7 +637,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
|
void YGNodeStyleSet##name##Auto(const YGNodeRef node, const YGEdge edge) { \
|
||||||
if (node->getStyle().instanceName[edge].unit != YGUnitAuto) { \
|
if (node->getStyle().instanceName[edge].unit != YGUnitAuto) { \
|
||||||
YGStyle style = node->getStyle(); \
|
YGStyle style = node->getStyle(); \
|
||||||
style.instanceName[edge].value = YGUndefined; \
|
style.instanceName[edge].value = 0; \
|
||||||
style.instanceName[edge].unit = YGUnitAuto; \
|
style.instanceName[edge].unit = YGUnitAuto; \
|
||||||
node->setStyle(style); \
|
node->setStyle(style); \
|
||||||
node->markDirtyAndPropogate(); \
|
node->markDirtyAndPropogate(); \
|
||||||
@@ -649,7 +649,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
void YGNodeStyleSet##name( \
|
void YGNodeStyleSet##name( \
|
||||||
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = paramName, \
|
.value = YGFloatSanitize(paramName), \
|
||||||
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
||||||
}; \
|
}; \
|
||||||
if ((node->getStyle().instanceName[edge].value != value.value && \
|
if ((node->getStyle().instanceName[edge].value != value.value && \
|
||||||
@@ -665,7 +665,7 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
void YGNodeStyleSet##name##Percent( \
|
void YGNodeStyleSet##name##Percent( \
|
||||||
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
||||||
YGValue value = { \
|
YGValue value = { \
|
||||||
.value = paramName, \
|
.value = YGFloatSanitize(paramName), \
|
||||||
.unit = \
|
.unit = \
|
||||||
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent, \
|
||||||
}; \
|
}; \
|
||||||
@@ -681,28 +681,11 @@ float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
|
|||||||
\
|
\
|
||||||
WIN_STRUCT(type) \
|
WIN_STRUCT(type) \
|
||||||
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
||||||
return WIN_STRUCT_REF(node->getStyle().instanceName[edge]); \
|
YGValue value = node->getStyle().instanceName[edge]; \
|
||||||
}
|
if (value.unit == YGUnitUndefined || value.unit == YGUnitAuto) { \
|
||||||
|
value.value = YGUndefined; \
|
||||||
#define YG_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
|
||||||
void YGNodeStyleSet##name( \
|
|
||||||
const YGNodeRef node, const YGEdge edge, const float paramName) { \
|
|
||||||
YGValue value = { \
|
|
||||||
.value = paramName, \
|
|
||||||
.unit = YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint, \
|
|
||||||
}; \
|
|
||||||
if ((node->getStyle().instanceName[edge].value != value.value && \
|
|
||||||
value.unit != YGUnitUndefined) || \
|
|
||||||
node->getStyle().instanceName[edge].unit != value.unit) { \
|
|
||||||
YGStyle style = node->getStyle(); \
|
|
||||||
style.instanceName[edge] = value; \
|
|
||||||
node->setStyle(style); \
|
|
||||||
node->markDirtyAndPropogate(); \
|
|
||||||
} \
|
} \
|
||||||
} \
|
return WIN_STRUCT_REF(value); \
|
||||||
\
|
|
||||||
float YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge) { \
|
|
||||||
return node->getStyle().instanceName[edge].value; \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
#define YG_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||||
@@ -873,7 +856,8 @@ void YGNodeStyleSetBorder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
float YGNodeStyleGetBorder(const YGNodeRef node, const YGEdge edge) {
|
||||||
if (node->getStyle().border[edge].unit == YGUnitUndefined) {
|
if (node->getStyle().border[edge].unit == YGUnitUndefined ||
|
||||||
|
node->getStyle().border[edge].unit == YGUnitAuto) {
|
||||||
// TODO(T26792433): Rather than returning YGUndefined, change the api to
|
// TODO(T26792433): Rather than returning YGUndefined, change the api to
|
||||||
// return YGFloatOptional.
|
// return YGFloatOptional.
|
||||||
return YGUndefined;
|
return YGUndefined;
|
||||||
|
Reference in New Issue
Block a user