From 7c2f8a9e14f4c36718c8721660c78d710a085f38 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 10 Jan 2017 08:26:50 -0800 Subject: [PATCH] Allow aspect ratio to expand beyond bounds of parent Reviewed By: passy Differential Revision: D4397547 fbshipit-source-id: d2b1ca7b096f2f17b3efbd8f47a50678bfe7bb5f --- ReactCommon/yoga/yoga/Yoga.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ReactCommon/yoga/yoga/Yoga.c b/ReactCommon/yoga/yoga/Yoga.c index d5e4917b3e..0e7bec4778 100644 --- a/ReactCommon/yoga/yoga/Yoga.c +++ b/ReactCommon/yoga/yoga/Yoga.c @@ -2239,8 +2239,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth)); childHeightMeasureMode = YGMeasureModeExactly; - childHeight = fminf(childHeight, availableInnerHeight); - childWidth = childHeight * currentRelativeChild->style.aspectRatio; + // Parent size constraint should have higher priority than flex + if (YGNodeIsFlex(currentRelativeChild)) { + childHeight = fminf(childHeight, availableInnerHeight); + childWidth = childHeight * currentRelativeChild->style.aspectRatio; + } } else { childWidth = fmaxf(childHeight * currentRelativeChild->style.aspectRatio, YGNodePaddingAndBorderForAxis(currentRelativeChild, @@ -2248,8 +2251,11 @@ static void YGNodelayoutImpl(const YGNodeRef node, availableInnerWidth)); childWidthMeasureMode = YGMeasureModeExactly; - childWidth = fminf(childWidth, availableInnerWidth); - childHeight = childWidth / currentRelativeChild->style.aspectRatio; + // Parent size constraint should have higher priority than flex + if (YGNodeIsFlex(currentRelativeChild)) { + childWidth = fminf(childWidth, availableInnerWidth); + childHeight = childWidth / currentRelativeChild->style.aspectRatio; + } } }