Skip to content

Commit 17e3dca

Browse files
woehrl01facebook-github-bot
authored andcommitted
Fix percentage in flexing parent
Summary: If we don't measure exactly, percentage values aren't exactly either. Fix for #414. Closes #416 Closes #414 Reviewed By: astreet Differential Revision: D4604729 Pulled By: emilsjolander fbshipit-source-id: 66880230073209cbe89668b838c2a82e7f9b34df
1 parent 533f560 commit 17e3dca

File tree

6 files changed

+333
-3
lines changed

6 files changed

+333
-3
lines changed

csharp/tests/Facebook.Yoga/YGPercentageTest.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,5 +991,85 @@ public void Test_percentage_width_height_undefined_parent_size()
991991
Assert.AreEqual(0f, root_child0.LayoutHeight);
992992
}
993993

994+
[Test]
995+
public void Test_percent_within_flex_grow()
996+
{
997+
YogaNode root = new YogaNode();
998+
root.FlexDirection = YogaFlexDirection.Row;
999+
root.Width = 350;
1000+
root.Height = 100;
1001+
1002+
YogaNode root_child0 = new YogaNode();
1003+
root_child0.Width = 100;
1004+
root.Insert(0, root_child0);
1005+
1006+
YogaNode root_child1 = new YogaNode();
1007+
root_child1.FlexGrow = 1;
1008+
root.Insert(1, root_child1);
1009+
1010+
YogaNode root_child1_child0 = new YogaNode();
1011+
root_child1_child0.Width = 100.Percent();
1012+
root_child1.Insert(0, root_child1_child0);
1013+
1014+
YogaNode root_child2 = new YogaNode();
1015+
root_child2.Width = 100;
1016+
root.Insert(2, root_child2);
1017+
root.StyleDirection = YogaDirection.LTR;
1018+
root.CalculateLayout();
1019+
1020+
Assert.AreEqual(0f, root.LayoutX);
1021+
Assert.AreEqual(0f, root.LayoutY);
1022+
Assert.AreEqual(350f, root.LayoutWidth);
1023+
Assert.AreEqual(100f, root.LayoutHeight);
1024+
1025+
Assert.AreEqual(0f, root_child0.LayoutX);
1026+
Assert.AreEqual(0f, root_child0.LayoutY);
1027+
Assert.AreEqual(100f, root_child0.LayoutWidth);
1028+
Assert.AreEqual(100f, root_child0.LayoutHeight);
1029+
1030+
Assert.AreEqual(100f, root_child1.LayoutX);
1031+
Assert.AreEqual(0f, root_child1.LayoutY);
1032+
Assert.AreEqual(150f, root_child1.LayoutWidth);
1033+
Assert.AreEqual(100f, root_child1.LayoutHeight);
1034+
1035+
Assert.AreEqual(0f, root_child1_child0.LayoutX);
1036+
Assert.AreEqual(0f, root_child1_child0.LayoutY);
1037+
Assert.AreEqual(150f, root_child1_child0.LayoutWidth);
1038+
Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
1039+
1040+
Assert.AreEqual(250f, root_child2.LayoutX);
1041+
Assert.AreEqual(0f, root_child2.LayoutY);
1042+
Assert.AreEqual(100f, root_child2.LayoutWidth);
1043+
Assert.AreEqual(100f, root_child2.LayoutHeight);
1044+
1045+
root.StyleDirection = YogaDirection.RTL;
1046+
root.CalculateLayout();
1047+
1048+
Assert.AreEqual(0f, root.LayoutX);
1049+
Assert.AreEqual(0f, root.LayoutY);
1050+
Assert.AreEqual(350f, root.LayoutWidth);
1051+
Assert.AreEqual(100f, root.LayoutHeight);
1052+
1053+
Assert.AreEqual(250f, root_child0.LayoutX);
1054+
Assert.AreEqual(0f, root_child0.LayoutY);
1055+
Assert.AreEqual(100f, root_child0.LayoutWidth);
1056+
Assert.AreEqual(100f, root_child0.LayoutHeight);
1057+
1058+
Assert.AreEqual(100f, root_child1.LayoutX);
1059+
Assert.AreEqual(0f, root_child1.LayoutY);
1060+
Assert.AreEqual(150f, root_child1.LayoutWidth);
1061+
Assert.AreEqual(100f, root_child1.LayoutHeight);
1062+
1063+
Assert.AreEqual(0f, root_child1_child0.LayoutX);
1064+
Assert.AreEqual(0f, root_child1_child0.LayoutY);
1065+
Assert.AreEqual(150f, root_child1_child0.LayoutWidth);
1066+
Assert.AreEqual(0f, root_child1_child0.LayoutHeight);
1067+
1068+
Assert.AreEqual(0f, root_child2.LayoutX);
1069+
Assert.AreEqual(0f, root_child2.LayoutY);
1070+
Assert.AreEqual(100f, root_child2.LayoutWidth);
1071+
Assert.AreEqual(100f, root_child2.LayoutHeight);
1072+
}
1073+
9941074
}
9951075
}

gentest/fixtures/YGPercentageTest.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@
8383
<div id="percentage_width_height_undefined_parent_size">
8484
<div style="width: 50%; height: 50%;"></div>
8585
</div>
86+
87+
<div id="percent_within_flex_grow" style="flex-direction:row; width: 350px; height: 100px; align-items: stretch; ">
88+
<div style="width:100px;"></div>
89+
<div style="flex-grow: 1;">
90+
<div style="width:100%;"></div>
91+
</div>
92+
<div style="width: 100px;"></div>
93+
</div>

java/tests/com/facebook/yoga/YGPercentageTest.java

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,4 +973,83 @@ public void test_percentage_width_height_undefined_parent_size() {
973973
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
974974
}
975975

976+
@Test
977+
public void test_percent_within_flex_grow() {
978+
final YogaNode root = new YogaNode();
979+
root.setFlexDirection(YogaFlexDirection.ROW);
980+
root.setWidth(350f);
981+
root.setHeight(100f);
982+
983+
final YogaNode root_child0 = new YogaNode();
984+
root_child0.setWidth(100f);
985+
root.addChildAt(root_child0, 0);
986+
987+
final YogaNode root_child1 = new YogaNode();
988+
root_child1.setFlexGrow(1f);
989+
root.addChildAt(root_child1, 1);
990+
991+
final YogaNode root_child1_child0 = new YogaNode();
992+
root_child1_child0.setWidthPercent(100f);
993+
root_child1.addChildAt(root_child1_child0, 0);
994+
995+
final YogaNode root_child2 = new YogaNode();
996+
root_child2.setWidth(100f);
997+
root.addChildAt(root_child2, 2);
998+
root.setDirection(YogaDirection.LTR);
999+
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1000+
1001+
assertEquals(0f, root.getLayoutX(), 0.0f);
1002+
assertEquals(0f, root.getLayoutY(), 0.0f);
1003+
assertEquals(350f, root.getLayoutWidth(), 0.0f);
1004+
assertEquals(100f, root.getLayoutHeight(), 0.0f);
1005+
1006+
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
1007+
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1008+
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1009+
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
1010+
1011+
assertEquals(100f, root_child1.getLayoutX(), 0.0f);
1012+
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1013+
assertEquals(150f, root_child1.getLayoutWidth(), 0.0f);
1014+
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
1015+
1016+
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1017+
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1018+
assertEquals(150f, root_child1_child0.getLayoutWidth(), 0.0f);
1019+
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
1020+
1021+
assertEquals(250f, root_child2.getLayoutX(), 0.0f);
1022+
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1023+
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
1024+
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
1025+
1026+
root.setDirection(YogaDirection.RTL);
1027+
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
1028+
1029+
assertEquals(0f, root.getLayoutX(), 0.0f);
1030+
assertEquals(0f, root.getLayoutY(), 0.0f);
1031+
assertEquals(350f, root.getLayoutWidth(), 0.0f);
1032+
assertEquals(100f, root.getLayoutHeight(), 0.0f);
1033+
1034+
assertEquals(250f, root_child0.getLayoutX(), 0.0f);
1035+
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
1036+
assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
1037+
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
1038+
1039+
assertEquals(100f, root_child1.getLayoutX(), 0.0f);
1040+
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
1041+
assertEquals(150f, root_child1.getLayoutWidth(), 0.0f);
1042+
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
1043+
1044+
assertEquals(0f, root_child1_child0.getLayoutX(), 0.0f);
1045+
assertEquals(0f, root_child1_child0.getLayoutY(), 0.0f);
1046+
assertEquals(150f, root_child1_child0.getLayoutWidth(), 0.0f);
1047+
assertEquals(0f, root_child1_child0.getLayoutHeight(), 0.0f);
1048+
1049+
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
1050+
assertEquals(0f, root_child2.getLayoutY(), 0.0f);
1051+
assertEquals(100f, root_child2.getLayoutWidth(), 0.0f);
1052+
assertEquals(100f, root_child2.getLayoutHeight(), 0.0f);
1053+
}
1054+
9761055
}

javascript/tests/Facebook.Yoga/YGPercentageTest.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,3 +1002,84 @@ it("percentage_width_height_undefined_parent_size", function () {
10021002
}
10031003
}
10041004
});
1005+
it("percent_within_flex_grow", function () {
1006+
try {
1007+
var root = Yoga.Node.create();
1008+
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
1009+
root.setWidth(350);
1010+
root.setHeight(100);
1011+
1012+
var root_child0 = Yoga.Node.create();
1013+
root_child0.setWidth(100);
1014+
root.insertChild(root_child0, 0);
1015+
1016+
var root_child1 = Yoga.Node.create();
1017+
root_child1.setFlexGrow(1);
1018+
root.insertChild(root_child1, 1);
1019+
1020+
var root_child1_child0 = Yoga.Node.create();
1021+
root_child1_child0.setWidth("100%");
1022+
root_child1.insertChild(root_child1_child0, 0);
1023+
1024+
var root_child2 = Yoga.Node.create();
1025+
root_child2.setWidth(100);
1026+
root.insertChild(root_child2, 2);
1027+
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
1028+
1029+
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
1030+
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
1031+
console.assert(350 === root.getComputedWidth(), "350 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
1032+
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
1033+
1034+
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
1035+
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
1036+
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
1037+
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
1038+
1039+
console.assert(100 === root_child1.getComputedLeft(), "100 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
1040+
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
1041+
console.assert(150 === root_child1.getComputedWidth(), "150 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
1042+
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
1043+
1044+
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
1045+
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
1046+
console.assert(150 === root_child1_child0.getComputedWidth(), "150 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
1047+
console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
1048+
1049+
console.assert(250 === root_child2.getComputedLeft(), "250 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
1050+
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
1051+
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
1052+
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
1053+
1054+
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
1055+
1056+
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
1057+
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
1058+
console.assert(350 === root.getComputedWidth(), "350 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
1059+
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
1060+
1061+
console.assert(250 === root_child0.getComputedLeft(), "250 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
1062+
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
1063+
console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
1064+
console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
1065+
1066+
console.assert(100 === root_child1.getComputedLeft(), "100 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
1067+
console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
1068+
console.assert(150 === root_child1.getComputedWidth(), "150 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
1069+
console.assert(100 === root_child1.getComputedHeight(), "100 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
1070+
1071+
console.assert(0 === root_child1_child0.getComputedLeft(), "0 === root_child1_child0.getComputedLeft() (" + root_child1_child0.getComputedLeft() + ")");
1072+
console.assert(0 === root_child1_child0.getComputedTop(), "0 === root_child1_child0.getComputedTop() (" + root_child1_child0.getComputedTop() + ")");
1073+
console.assert(150 === root_child1_child0.getComputedWidth(), "150 === root_child1_child0.getComputedWidth() (" + root_child1_child0.getComputedWidth() + ")");
1074+
console.assert(0 === root_child1_child0.getComputedHeight(), "0 === root_child1_child0.getComputedHeight() (" + root_child1_child0.getComputedHeight() + ")");
1075+
1076+
console.assert(0 === root_child2.getComputedLeft(), "0 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
1077+
console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
1078+
console.assert(100 === root_child2.getComputedWidth(), "100 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
1079+
console.assert(100 === root_child2.getComputedHeight(), "100 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
1080+
} finally {
1081+
if (typeof root !== "undefined") {
1082+
root.freeRecursive();
1083+
}
1084+
}
1085+
});

tests/YGPercentageTest.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,3 +951,81 @@ TEST(YogaTest, percentage_width_height_undefined_parent_size) {
951951

952952
YGNodeFreeRecursive(root);
953953
}
954+
955+
TEST(YogaTest, percent_within_flex_grow) {
956+
const YGNodeRef root = YGNodeNew();
957+
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
958+
YGNodeStyleSetWidth(root, 350);
959+
YGNodeStyleSetHeight(root, 100);
960+
961+
const YGNodeRef root_child0 = YGNodeNew();
962+
YGNodeStyleSetWidth(root_child0, 100);
963+
YGNodeInsertChild(root, root_child0, 0);
964+
965+
const YGNodeRef root_child1 = YGNodeNew();
966+
YGNodeStyleSetFlexGrow(root_child1, 1);
967+
YGNodeInsertChild(root, root_child1, 1);
968+
969+
const YGNodeRef root_child1_child0 = YGNodeNew();
970+
YGNodeStyleSetWidthPercent(root_child1_child0, 100);
971+
YGNodeInsertChild(root_child1, root_child1_child0, 0);
972+
973+
const YGNodeRef root_child2 = YGNodeNew();
974+
YGNodeStyleSetWidth(root_child2, 100);
975+
YGNodeInsertChild(root, root_child2, 2);
976+
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
977+
978+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
979+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
980+
ASSERT_FLOAT_EQ(350, YGNodeLayoutGetWidth(root));
981+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
982+
983+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
984+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
985+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
986+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
987+
988+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1));
989+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
990+
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1));
991+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
992+
993+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0));
994+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0));
995+
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1_child0));
996+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0));
997+
998+
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child2));
999+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
1000+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
1001+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
1002+
1003+
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
1004+
1005+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
1006+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
1007+
ASSERT_FLOAT_EQ(350, YGNodeLayoutGetWidth(root));
1008+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
1009+
1010+
ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child0));
1011+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
1012+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
1013+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
1014+
1015+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1));
1016+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
1017+
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1));
1018+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1));
1019+
1020+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0));
1021+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0));
1022+
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child1_child0));
1023+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child1_child0));
1024+
1025+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child2));
1026+
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
1027+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child2));
1028+
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2));
1029+
1030+
YGNodeFreeRecursive(root);
1031+
}

yoga/Yoga.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
20452045
}
20462046

20472047
const bool flexBasisOverflows =
2048-
measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
2048+
measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
20492049
if (isNodeFlexWrap && flexBasisOverflows && measureModeMainDim == YGMeasureModeAtMost) {
20502050
measureModeMainDim = YGMeasureModeExactly;
20512051
}
@@ -2338,8 +2338,12 @@ static void YGNodelayoutImpl(const YGNodeRef node,
23382338
childCrossSize = YGValueResolve(currentRelativeChild->resolvedDimensions[dim[crossAxis]],
23392339
availableInnerCrossDim) +
23402340
marginCross;
2341-
childCrossMeasureMode =
2342-
YGFloatIsUndefined(childCrossSize) ? YGMeasureModeUndefined : YGMeasureModeExactly;
2341+
const bool isLoosePercentageMeasurement =
2342+
currentRelativeChild->resolvedDimensions[dim[crossAxis]]->unit == YGUnitPercent &&
2343+
measureModeCrossDim != YGMeasureModeExactly;
2344+
childCrossMeasureMode = YGFloatIsUndefined(childCrossSize) || isLoosePercentageMeasurement
2345+
? YGMeasureModeUndefined
2346+
: YGMeasureModeExactly;
23432347
}
23442348

23452349
if (!YGFloatIsUndefined(currentRelativeChild->style.aspectRatio)) {

0 commit comments

Comments
 (0)