File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -517,6 +517,18 @@ static CGFloat YGRoundPixelValue(CGFloat value) {
517517 return roundf (value * scale) / scale;
518518}
519519
520+ static CGPoint YGPointReplacingNanWithZero (CGPoint const value) {
521+ CGPoint result = value;
522+
523+ if (isnan (result.x )) {
524+ result.x = 0 ;
525+ }
526+ if (isnan (result.y )) {
527+ result.y = 0 ;
528+ }
529+ return result;
530+ }
531+
520532static void YGApplyLayoutToViewHierarchy (UIView* view, BOOL preserveOrigin) {
521533 NSCAssert (
522534 [NSThread isMainThread ],
@@ -529,22 +541,15 @@ static void YGApplyLayoutToViewHierarchy(UIView* view, BOOL preserveOrigin) {
529541 }
530542
531543 YGNodeRef node = yoga.node ;
532- const CGPoint topLeft = {
544+ const CGPoint topLeft = YGPointReplacingNanWithZero ( {
533545 YGNodeLayoutGetLeft (node),
534546 YGNodeLayoutGetTop (node),
535- };
547+ }) ;
536548
537- CGPoint bottomRight = {
549+ const CGPoint bottomRight = YGPointReplacingNanWithZero ( {
538550 topLeft.x + YGNodeLayoutGetWidth (node),
539551 topLeft.y + YGNodeLayoutGetHeight (node),
540- };
541-
542- if (isnan (bottomRight.x )) {
543- bottomRight.x = 0 ;
544- }
545- if (isnan (bottomRight.y )) {
546- bottomRight.y = 0 ;
547- }
552+ });
548553
549554 const CGPoint origin = preserveOrigin ? view.frame .origin : CGPointZero;
550555 view.frame = (CGRect){
You can’t perform that action at this time.
0 commit comments