Skip to content

Commit ea8b7e0

Browse files
Emil Sjolanderfacebook-github-bot
authored andcommitted
Fix up some small issues with YGUnitAuto
Summary: There are still some pieces of RN which does not handle YGUnitAuto and makes use of either the value being nan or the unit being undefined. This diff makes this more robust to those kinds of situations. Reviewed By: wwjholmes Differential Revision: D4567045 fbshipit-source-id: ace5fd89bd534a6bb5ec7dba0c3afbf13d62d7c9
1 parent 6928957 commit ea8b7e0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

yoga/Yoga.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ inline float YGNodeStyleGetFlexShrink(const YGNodeRef node) {
434434
}
435435

436436
static inline const YGValue *YGNodeStyleGetFlexBasisPtr(const YGNodeRef node) {
437-
if (node->style.flexBasis.unit != YGUnitAuto) {
437+
if (node->style.flexBasis.unit != YGUnitAuto && node->style.flexBasis.unit != YGUnitUndefined) {
438438
return &node->style.flexBasis;
439439
}
440440
if (!YGFloatIsUndefined(node->style.flex) && node->style.flex > 0.0f) {
@@ -477,7 +477,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
477477
node->style.instanceName.unit != YGUnitPoint) { \
478478
node->style.instanceName.value = paramName; \
479479
node->style.instanceName.unit = \
480-
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPoint; \
480+
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPoint; \
481481
YGNodeMarkDirtyInternal(node); \
482482
} \
483483
} \
@@ -487,7 +487,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
487487
node->style.instanceName.unit != YGUnitPercent) { \
488488
node->style.instanceName.value = paramName; \
489489
node->style.instanceName.unit = \
490-
YGFloatIsUndefined(paramName) ? YGUnitUndefined : YGUnitPercent; \
490+
YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
491491
YGNodeMarkDirtyInternal(node); \
492492
} \
493493
}
@@ -496,7 +496,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
496496
void YGNodeStyleSet##name(const YGNodeRef node, const type paramName) { \
497497
if (node->style.instanceName.value != paramName || \
498498
node->style.instanceName.unit != YGUnitPoint) { \
499-
node->style.instanceName.value = YGFloatIsUndefined(paramName) ? YGUndefined : paramName; \
499+
node->style.instanceName.value = paramName; \
500500
node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPoint; \
501501
YGNodeMarkDirtyInternal(node); \
502502
} \
@@ -505,7 +505,7 @@ void YGNodeStyleSetFlex(const YGNodeRef node, const float flex) {
505505
void YGNodeStyleSet##name##Percent(const YGNodeRef node, const type paramName) { \
506506
if (node->style.instanceName.value != paramName || \
507507
node->style.instanceName.unit != YGUnitPercent) { \
508-
node->style.instanceName.value = YGFloatIsUndefined(paramName) ? YGUndefined : paramName; \
508+
node->style.instanceName.value = paramName; \
509509
node->style.instanceName.unit = YGFloatIsUndefined(paramName) ? YGUnitAuto : YGUnitPercent; \
510510
YGNodeMarkDirtyInternal(node); \
511511
} \

yoga/Yoga.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct YGValue {
4444
} YGValue;
4545

4646
static const YGValue YGValueUndefined = {YGUndefined, YGUnitUndefined};
47-
static const YGValue YGValueAuto = {0, YGUnitAuto};
47+
static const YGValue YGValueAuto = {YGUndefined, YGUnitAuto};
4848

4949
typedef struct YGNode *YGNodeRef;
5050
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,

0 commit comments

Comments
 (0)