Skip to content

Commit

Permalink
Let measure behave more like on the web
Browse files Browse the repository at this point in the history
Summary:
Nodes with a measure function needs to be measured even so it seems there is no available space. So it behaves more like on the web. Fix facebook/yoga#488
Closes facebook/yoga#499

Reviewed By: astreet

Differential Revision: D4954008

Pulled By: emilsjolander

fbshipit-source-id: 5b6d9afae0cdebe33f8b82b67620b3b4527d1efc
  • Loading branch information
woehrl01 authored and facebook-github-bot committed Apr 27, 2017
1 parent 4397b1e commit b135191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
7 changes: 0 additions & 7 deletions lib/yoga/src/main/cpp/yoga/Yoga.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,13 +1659,6 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth);
node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(
node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth);
} else if (innerWidth <= 0.0f || innerHeight <= 0.0f) {
// Don't bother sizing the text if there's no horizontal or vertical
// space.
node->layout.measuredDimensions[YGDimensionWidth] =
YGNodeBoundAxis(node, YGFlexDirectionRow, 0.0f, availableWidth, availableWidth);
node->layout.measuredDimensions[YGDimensionHeight] =
YGNodeBoundAxis(node, YGFlexDirectionColumn, 0.0f, availableHeight, availableWidth);
} else {
// Measure the text under the current constraints.
const YGSize measuredSize =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ protected ComponentLayout onCreateLayoutWithSizeSpec(

final ComponentLayout.Builder builder1 =
TestDrawableComponent.create(c, false, true, true, false, false)
.withLayout().flexShrink(0)
.withLayout()
.backgroundColor(0xFFFF0000);
final ComponentLayout.Builder builder2 = TestViewComponent.create(c, false, true, true, false)
.withLayout().flexShrink(0)
.withLayout()
.marginPx(YogaEdge.ALL, 3);

if (state.hasFixedSizes) {
Expand All @@ -58,12 +58,10 @@ protected ComponentLayout onCreateLayoutWithSizeSpec(
return builder1.build();
}

return Column.create(c).flexShrink(0).alignContent(YogaAlign.FLEX_START)
return Column.create(c)
.paddingPx(YogaEdge.ALL, 5)
.child(
builder1)
.child(
builder2)
.child(builder1)
.child(builder2)
.build();
}

Expand Down

0 comments on commit b135191

Please sign in to comment.