Skip to content

Commit 5386364

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Convert CGFLOAT_MAX to infinity
Summary: changelog: [internal] For embedded React Native screens, we need to calculate the intrinsic size. To do that, we need to pass Yoga value `YGUndefined`. However, if available size was `CGFLOAT_MAX` (which is not inifinity), we would pass it to Yoga and it would calculate layout with available height/width `CGFLOAT_MAX`. To fix this, we convert `CGFLOAT_MAX` to infinity. Which in YogaLayoutableShadowNode gets converted to YGUndefined. Reviewed By: ShikaSD Differential Revision: D34719047 fbshipit-source-id: e6fd40724f81abfba164e67efc9ca8fc74e9b235
1 parent bb8ff92 commit 5386364

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

React/Fabric/RCTConversions.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,17 @@ inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point)
173173
return {point.x, point.y};
174174
}
175175

176+
inline facebook::react::Float RCTFloatFromCGFloat(CGFloat value)
177+
{
178+
if (value == CGFLOAT_MAX) {
179+
return std::numeric_limits<facebook::react::Float>::infinity();
180+
}
181+
return value;
182+
}
183+
176184
inline facebook::react::Size RCTSizeFromCGSize(const CGSize &size)
177185
{
178-
return {size.width, size.height};
186+
return {RCTFloatFromCGFloat(size.width), RCTFloatFromCGFloat(size.height)};
179187
}
180188

181189
inline facebook::react::Rect RCTRectFromCGRect(const CGRect &rect)

0 commit comments

Comments
 (0)