[ASDisplayNode] Ensure that nil can never be returned from -measureWithSizeRange: (#2014)

* [ASDisplayNode] Ensure that nil can never be returned from -measureWithSizeRange:

This can happen in rare cases when multiple relayouts occur while a transition is being measured.

* [ASDisplayNode] Use ternary operator style for nil check.
This commit is contained in:
appleguy
2016-07-30 18:04:08 -07:00
committed by GitHub
parent e0ada479a0
commit 965fe05c11
2 changed files with 8 additions and 2 deletions

View File

@@ -28,7 +28,9 @@ static ASLayout *crossChildLayout(const id<ASLayoutable> child,
// stretched children will have a cross dimension of at least crossMin
const CGFloat childCrossMin = alignItems == ASStackLayoutAlignItemsStretch ? crossMin : 0;
const ASSizeRange childSizeRange = directionSizeRange(style.direction, stackMin, stackMax, childCrossMin, crossMax);
return [child measureWithSizeRange:childSizeRange];
ASLayout *layout = [child measureWithSizeRange:childSizeRange];
ASDisplayNodeCAssertNotNil(layout, @"ASLayout returned from measureWithSizeRange: must not be nil: %@", child);
return layout ? : [ASLayout layoutWithLayoutableObject:child constrainedSizeRange:childSizeRange size:CGSizeZero];
}
/**