Skip to content

Commit

Permalink
Cleanup for cgFloatForYogaFloat (#1571)
Browse files Browse the repository at this point in the history
- Return CGFloat
- Proper check for YGUndefined
- Add YGUndefined default return value
  • Loading branch information
maicki authored and nguyenhuy committed Aug 12, 2019
1 parent 540f134 commit 0c78681
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/Layout/ASYogaUtilities.mm
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ float yogaFloatForCGFloat(CGFloat value)
}
}

float cgFloatForYogaFloat(float yogaFloat)
CGFloat cgFloatForYogaFloat(float yogaFloat, CGFloat undefinedDefault)
{
return (yogaFloat == YGUndefined) ? CGFLOAT_MAX : yogaFloat;
return YGFloatIsUndefined(yogaFloat) ? undefinedDefault : yogaFloat;
}

float yogaDimensionToPoints(ASDimension dimension)
Expand Down Expand Up @@ -213,8 +213,8 @@ YGSize ASLayoutElementYogaMeasureFunc(YGNodeRef yogaNode, float width, YGMeasure
id <ASLayoutElement> layoutElement = (__bridge id <ASLayoutElement>)YGNodeGetContext(yogaNode);
ASDisplayNodeCAssert([layoutElement conformsToProtocol:@protocol(ASLayoutElement)], @"Yoga context must be <ASLayoutElement>");

width = cgFloatForYogaFloat(width);
height = cgFloatForYogaFloat(height);
width = cgFloatForYogaFloat(width, CGFLOAT_MAX);
height = cgFloatForYogaFloat(height, CGFLOAT_MAX);

ASSizeRange sizeRange;
sizeRange.min = CGSizeZero;
Expand Down

0 comments on commit 0c78681

Please sign in to comment.