Measure nodes which have margin: auto and align-item: stretch
Summary: If you have a measurable node and set ```marign-left: auto``` + ```align-item:stretch``` on it, it won't get measured and they get a width/height of ```-(nan)```. This change fixes that behaviour. Fixes #644. Closes https://github.com/facebook/yoga/pull/645 Differential Revision: D6413512 Pulled By: emilsjolander fbshipit-source-id: 755febeb33bb0d4520ca6b3c28d56ac333e4a14d
This commit is contained in:
committed by
Facebook Github Bot
parent
e566fcca08
commit
afaafb4126
@@ -150,6 +150,27 @@ TEST(YogaTest, dont_measure_when_min_equals_max_percentages) {
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
|
||||
TEST(YogaTest, measure_nodes_with_margin_auto_and_stretch) {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetWidth(root, 500);
|
||||
YGNodeStyleSetHeight(root, 500);
|
||||
|
||||
const YGNodeRef root_child0 = YGNodeNew();
|
||||
YGNodeSetMeasureFunc(root_child0, _measure);
|
||||
YGNodeStyleSetMarginAuto(root_child0, YGEdgeLeft);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||
|
||||
EXPECT_EQ(490, YGNodeLayoutGetLeft(root_child0));
|
||||
EXPECT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
EXPECT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||
EXPECT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_width_percent) {
|
||||
const YGNodeRef root = YGNodeNew();
|
||||
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||
|
Reference in New Issue
Block a user