diff --git a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
index 1aec99c1..59bb7d02 100644
--- a/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
+++ b/java/tests/com/facebook/yoga/YGMinMaxDimensionTest.java
@@ -357,6 +357,7 @@ public class YGMinMaxDimensionTest {
@Test
public void test_flex_grow_to_min() {
YogaConfig config = new YogaConfig();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
final YogaNode root = new YogaNode(config);
root.setWidth(100f);
@@ -409,8 +410,9 @@ public class YGMinMaxDimensionTest {
}
@Test
- public void test_flex_grow_skip_child() {
+ public void test_flex_grow_in_at_most_container() {
YogaConfig config = new YogaConfig();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
final YogaNode root = new YogaNode(config);
root.setFlexDirection(YogaFlexDirection.ROW);
@@ -425,7 +427,6 @@ public class YGMinMaxDimensionTest {
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0_child0.setFlexGrow(1f);
root_child0_child0.setFlexBasis(0f);
- root_child0_child0.setHeight(100f);
root_child0.addChildAt(root_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
@@ -438,12 +439,12 @@ public class YGMinMaxDimensionTest {
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
@@ -456,51 +457,12 @@ public class YGMinMaxDimensionTest {
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
- }
-
- @Test
- public void test_flex_grow_child() {
- YogaConfig config = new YogaConfig();
-
- final YogaNode root = new YogaNode(config);
- root.setFlexDirection(YogaFlexDirection.ROW);
-
- final YogaNode root_child0 = new YogaNode(config);
- root_child0.setFlexGrow(1f);
- root_child0.setFlexBasis(0f);
- root_child0.setHeight(100f);
- root.addChildAt(root_child0, 0);
- root.setDirection(YogaDirection.LTR);
- root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
-
- assertEquals(0f, root.getLayoutX(), 0.0f);
- assertEquals(0f, root.getLayoutY(), 0.0f);
- assertEquals(0f, root.getLayoutWidth(), 0.0f);
- assertEquals(100f, root.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child0.getLayoutX(), 0.0f);
- assertEquals(0f, root_child0.getLayoutY(), 0.0f);
- assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
-
- root.setDirection(YogaDirection.RTL);
- root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
-
- assertEquals(0f, root.getLayoutX(), 0.0f);
- assertEquals(0f, root.getLayoutY(), 0.0f);
- assertEquals(0f, root.getLayoutWidth(), 0.0f);
- assertEquals(100f, root.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child0.getLayoutX(), 0.0f);
- assertEquals(0f, root_child0.getLayoutY(), 0.0f);
- assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
+ assertEquals(0f, root_child0_child0.getLayoutHeight(), 0.0f);
}
@Test
@@ -715,58 +677,6 @@ public class YGMinMaxDimensionTest {
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
}
- @Test
- public void test_flex_grow_within_constrained_min_max_column() {
- YogaConfig config = new YogaConfig();
-
- final YogaNode root = new YogaNode(config);
- root.setMinHeight(100f);
- root.setMaxHeight(200f);
-
- final YogaNode root_child0 = new YogaNode(config);
- root_child0.setFlexGrow(1f);
- root.addChildAt(root_child0, 0);
-
- final YogaNode root_child1 = new YogaNode(config);
- root_child1.setHeight(50f);
- root.addChildAt(root_child1, 1);
- root.setDirection(YogaDirection.LTR);
- root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
-
- assertEquals(0f, root.getLayoutX(), 0.0f);
- assertEquals(0f, root.getLayoutY(), 0.0f);
- assertEquals(0f, root.getLayoutWidth(), 0.0f);
- assertEquals(100f, root.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child0.getLayoutX(), 0.0f);
- assertEquals(0f, root_child0.getLayoutY(), 0.0f);
- assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child1.getLayoutX(), 0.0f);
- assertEquals(50f, root_child1.getLayoutY(), 0.0f);
- assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
- assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
-
- root.setDirection(YogaDirection.RTL);
- root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
-
- assertEquals(0f, root.getLayoutX(), 0.0f);
- assertEquals(0f, root.getLayoutY(), 0.0f);
- assertEquals(0f, root.getLayoutWidth(), 0.0f);
- assertEquals(100f, root.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child0.getLayoutX(), 0.0f);
- assertEquals(0f, root_child0.getLayoutY(), 0.0f);
- assertEquals(0f, root_child0.getLayoutWidth(), 0.0f);
- assertEquals(50f, root_child0.getLayoutHeight(), 0.0f);
-
- assertEquals(0f, root_child1.getLayoutX(), 0.0f);
- assertEquals(50f, root_child1.getLayoutY(), 0.0f);
- assertEquals(0f, root_child1.getLayoutWidth(), 0.0f);
- assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
- }
-
@Test
public void test_flex_grow_within_constrained_max_row() {
YogaConfig config = new YogaConfig();
@@ -1026,4 +936,111 @@ public class YGMinMaxDimensionTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
+ @Test
+ public void test_min_width_in_flex_distribution() {
+ YogaConfig config = new YogaConfig();
+
+ final YogaNode root = new YogaNode(config);
+ root.setFlexDirection(YogaFlexDirection.ROW);
+ root.setWidth(300f);
+ root.setHeight(300f);
+
+ final YogaNode root_child0 = new YogaNode(config);
+ root_child0.setFlexGrow(2f);
+ root_child0.setFlexShrink(1f);
+ root_child0.setFlexBasisPercent(0f);
+ root_child0.setMinWidth(100f);
+ root_child0.setMaxWidth(200f);
+ root.addChildAt(root_child0, 0);
+
+ final YogaNode root_child1 = new YogaNode(config);
+ root_child1.setFlexGrow(1f);
+ root_child1.setFlexShrink(1f);
+ root_child1.setFlexBasisPercent(0f);
+ root.addChildAt(root_child1, 1);
+
+ final YogaNode root_child2 = new YogaNode(config);
+ root_child2.setFlexGrow(1f);
+ root_child2.setFlexShrink(1f);
+ root_child2.setFlexBasisPercent(0f);
+ root.addChildAt(root_child2, 2);
+
+ final YogaNode root_child3 = new YogaNode(config);
+ root_child3.setFlexGrow(1f);
+ root_child3.setFlexShrink(1f);
+ root_child3.setFlexBasisPercent(0f);
+ root.addChildAt(root_child3, 3);
+
+ final YogaNode root_child4 = new YogaNode(config);
+ root_child4.setFlexGrow(1f);
+ root_child4.setFlexShrink(1f);
+ root_child4.setFlexBasisPercent(0f);
+ root.addChildAt(root_child4, 4);
+ root.setDirection(YogaDirection.LTR);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(100f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(150f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(200f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child3.getLayoutHeight(), 0.0f);
+
+ assertEquals(250f, root_child4.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child4.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child4.getLayoutHeight(), 0.0f);
+
+ root.setDirection(YogaDirection.RTL);
+ root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
+
+ assertEquals(0f, root.getLayoutX(), 0.0f);
+ assertEquals(0f, root.getLayoutY(), 0.0f);
+ assertEquals(300f, root.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root.getLayoutHeight(), 0.0f);
+
+ assertEquals(200f, root_child0.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child0.getLayoutY(), 0.0f);
+ assertEquals(100f, root_child0.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child0.getLayoutHeight(), 0.0f);
+
+ assertEquals(150f, root_child1.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child1.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child1.getLayoutHeight(), 0.0f);
+
+ assertEquals(100f, root_child2.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child2.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child2.getLayoutHeight(), 0.0f);
+
+ assertEquals(50f, root_child3.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child3.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child3.getLayoutHeight(), 0.0f);
+
+ assertEquals(0f, root_child4.getLayoutX(), 0.0f);
+ assertEquals(0f, root_child4.getLayoutY(), 0.0f);
+ assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
+ assertEquals(300f, root_child4.getLayoutHeight(), 0.0f);
+ }
+
}
diff --git a/java/tests/com/facebook/yoga/YGPercentageTest.java b/java/tests/com/facebook/yoga/YGPercentageTest.java
index 62b97066..88a19644 100644
--- a/java/tests/com/facebook/yoga/YGPercentageTest.java
+++ b/java/tests/com/facebook/yoga/YGPercentageTest.java
@@ -1043,6 +1043,7 @@ public class YGPercentageTest {
@Test
public void test_percentage_container_in_wrapping_container() {
YogaConfig config = new YogaConfig();
+ config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_FLEX_FIX, true);
final YogaNode root = new YogaNode(config);
root.setJustifyContent(YogaJustify.CENTER);
diff --git a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
index 10371730..64dc553d 100644
--- a/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
+++ b/javascript/tests/Facebook.Yoga/YGMinMaxDimensionTest.js
@@ -380,6 +380,8 @@ it("justify_content_overflow_min_max", function () {
it("flex_grow_to_min", function () {
var config = Yoga.Config.create();
+ config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
+
try {
var root = Yoga.Node.create(config);
root.setWidth(100);
@@ -435,9 +437,11 @@ it("flex_grow_to_min", function () {
config.free();
}
});
-it("flex_grow_skip_child", function () {
+it("flex_grow_in_at_most_container", function () {
var config = Yoga.Config.create();
+ config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
+
try {
var root = Yoga.Node.create(config);
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
@@ -452,7 +456,6 @@ it("flex_grow_skip_child", function () {
var root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setFlexGrow(1);
root_child0_child0.setFlexBasis(0);
- root_child0_child0.setHeight(100);
root_child0.insertChild(root_child0_child0, 0);
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
@@ -464,12 +467,12 @@ it("flex_grow_skip_child", function () {
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+ console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(0 === root_child0_child0.getComputedWidth(), "0 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
+ console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
@@ -481,55 +484,12 @@ it("flex_grow_skip_child", function () {
console.assert(100 === root_child0.getComputedLeft(), "100 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+ console.assert(0 === root_child0.getComputedHeight(), "0 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0.getComputedLeft(), "0 === root_child0_child0.getComputedLeft() (" + root_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0.getComputedTop(), "0 === root_child0_child0.getComputedTop() (" + root_child0_child0.getComputedTop() + ")");
console.assert(0 === root_child0_child0.getComputedWidth(), "0 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0_child0.getComputedHeight(), "100 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
- } finally {
- if (typeof root !== "undefined") {
- root.freeRecursive();
- }
-
- config.free();
- }
-});
-it("flex_grow_child", function () {
- var config = Yoga.Config.create();
-
- try {
- var root = Yoga.Node.create(config);
- root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
-
- var root_child0 = Yoga.Node.create(config);
- root_child0.setFlexGrow(1);
- root_child0.setFlexBasis(0);
- root_child0.setHeight(100);
- root.insertChild(root_child0, 0);
- root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
-
- console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
- console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
- console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
- console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
-
- console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
- console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
- console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
-
- root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
-
- console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
- console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
- console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
- console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
-
- console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
- console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
- console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(100 === root_child0.getComputedHeight(), "100 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+ console.assert(0 === root_child0_child0.getComputedHeight(), "0 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
@@ -766,62 +726,6 @@ it("flex_grow_within_constrained_min_column", function () {
config.free();
}
});
-it("flex_grow_within_constrained_min_max_column", function () {
- var config = Yoga.Config.create();
-
- try {
- var root = Yoga.Node.create(config);
- root.setMinHeight(100);
- root.setMaxHeight(200);
-
- var root_child0 = Yoga.Node.create(config);
- root_child0.setFlexGrow(1);
- root.insertChild(root_child0, 0);
-
- var root_child1 = Yoga.Node.create(config);
- root_child1.setHeight(50);
- root.insertChild(root_child1, 1);
- root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
-
- console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
- console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
- console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
- console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
-
- console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
- console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
- console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
-
- console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
- console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
- console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
- console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
-
- root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
-
- console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
- console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
- console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
- console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
-
- console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
- console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
- console.assert(0 === root_child0.getComputedWidth(), "0 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
- console.assert(50 === root_child0.getComputedHeight(), "50 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
-
- console.assert(0 === root_child1.getComputedLeft(), "0 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
- console.assert(50 === root_child1.getComputedTop(), "50 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
- console.assert(0 === root_child1.getComputedWidth(), "0 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
- console.assert(50 === root_child1.getComputedHeight(), "50 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
- } finally {
- if (typeof root !== "undefined") {
- root.freeRecursive();
- }
-
- config.free();
- }
-});
it("flex_grow_within_constrained_max_row", function () {
var config = Yoga.Config.create();
@@ -1109,3 +1013,114 @@ it("min_max_percent_no_width_height", function () {
config.free();
}
});
+it("min_width_in_flex_distribution", function () {
+ var config = Yoga.Config.create();
+
+ try {
+ var root = Yoga.Node.create(config);
+ root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
+ root.setWidth(300);
+ root.setHeight(300);
+
+ var root_child0 = Yoga.Node.create(config);
+ root_child0.setFlexGrow(2);
+ root_child0.setFlexShrink(1);
+ root_child0.setFlexBasis("0%");
+ root_child0.setMinWidth(100);
+ root_child0.setMaxWidth(200);
+ root.insertChild(root_child0, 0);
+
+ var root_child1 = Yoga.Node.create(config);
+ root_child1.setFlexGrow(1);
+ root_child1.setFlexShrink(1);
+ root_child1.setFlexBasis("0%");
+ root.insertChild(root_child1, 1);
+
+ var root_child2 = Yoga.Node.create(config);
+ root_child2.setFlexGrow(1);
+ root_child2.setFlexShrink(1);
+ root_child2.setFlexBasis("0%");
+ root.insertChild(root_child2, 2);
+
+ var root_child3 = Yoga.Node.create(config);
+ root_child3.setFlexGrow(1);
+ root_child3.setFlexShrink(1);
+ root_child3.setFlexBasis("0%");
+ root.insertChild(root_child3, 3);
+
+ var root_child4 = Yoga.Node.create(config);
+ root_child4.setFlexGrow(1);
+ root_child4.setFlexShrink(1);
+ root_child4.setFlexBasis("0%");
+ root.insertChild(root_child4, 4);
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(100 === root_child1.getComputedLeft(), "100 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(150 === root_child2.getComputedLeft(), "150 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+
+ console.assert(200 === root_child3.getComputedLeft(), "200 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
+ console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
+ console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
+ console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
+
+ console.assert(250 === root_child4.getComputedLeft(), "250 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
+ console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
+ console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
+ console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
+
+ root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
+
+ console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
+ console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
+ console.assert(300 === root.getComputedWidth(), "300 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
+ console.assert(300 === root.getComputedHeight(), "300 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
+
+ console.assert(200 === root_child0.getComputedLeft(), "200 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
+ console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
+ console.assert(100 === root_child0.getComputedWidth(), "100 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
+ console.assert(300 === root_child0.getComputedHeight(), "300 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
+
+ console.assert(150 === root_child1.getComputedLeft(), "150 === root_child1.getComputedLeft() (" + root_child1.getComputedLeft() + ")");
+ console.assert(0 === root_child1.getComputedTop(), "0 === root_child1.getComputedTop() (" + root_child1.getComputedTop() + ")");
+ console.assert(50 === root_child1.getComputedWidth(), "50 === root_child1.getComputedWidth() (" + root_child1.getComputedWidth() + ")");
+ console.assert(300 === root_child1.getComputedHeight(), "300 === root_child1.getComputedHeight() (" + root_child1.getComputedHeight() + ")");
+
+ console.assert(100 === root_child2.getComputedLeft(), "100 === root_child2.getComputedLeft() (" + root_child2.getComputedLeft() + ")");
+ console.assert(0 === root_child2.getComputedTop(), "0 === root_child2.getComputedTop() (" + root_child2.getComputedTop() + ")");
+ console.assert(50 === root_child2.getComputedWidth(), "50 === root_child2.getComputedWidth() (" + root_child2.getComputedWidth() + ")");
+ console.assert(300 === root_child2.getComputedHeight(), "300 === root_child2.getComputedHeight() (" + root_child2.getComputedHeight() + ")");
+
+ console.assert(50 === root_child3.getComputedLeft(), "50 === root_child3.getComputedLeft() (" + root_child3.getComputedLeft() + ")");
+ console.assert(0 === root_child3.getComputedTop(), "0 === root_child3.getComputedTop() (" + root_child3.getComputedTop() + ")");
+ console.assert(50 === root_child3.getComputedWidth(), "50 === root_child3.getComputedWidth() (" + root_child3.getComputedWidth() + ")");
+ console.assert(300 === root_child3.getComputedHeight(), "300 === root_child3.getComputedHeight() (" + root_child3.getComputedHeight() + ")");
+
+ console.assert(0 === root_child4.getComputedLeft(), "0 === root_child4.getComputedLeft() (" + root_child4.getComputedLeft() + ")");
+ console.assert(0 === root_child4.getComputedTop(), "0 === root_child4.getComputedTop() (" + root_child4.getComputedTop() + ")");
+ console.assert(50 === root_child4.getComputedWidth(), "50 === root_child4.getComputedWidth() (" + root_child4.getComputedWidth() + ")");
+ console.assert(300 === root_child4.getComputedHeight(), "300 === root_child4.getComputedHeight() (" + root_child4.getComputedHeight() + ")");
+ } finally {
+ if (typeof root !== "undefined") {
+ root.freeRecursive();
+ }
+
+ config.free();
+ }
+});
diff --git a/javascript/tests/Facebook.Yoga/YGPercentageTest.js b/javascript/tests/Facebook.Yoga/YGPercentageTest.js
index ae5e9024..f94761aa 100644
--- a/javascript/tests/Facebook.Yoga/YGPercentageTest.js
+++ b/javascript/tests/Facebook.Yoga/YGPercentageTest.js
@@ -1126,6 +1126,8 @@ it("percent_within_flex_grow", function () {
it("percentage_container_in_wrapping_container", function () {
var config = Yoga.Config.create();
+ config.setExperimentalFeatureEnabled(Yoga.EXPERIMENTAL_FEATURE_MIN_FLEX_FIX, true);
+
try {
var root = Yoga.Node.create(config);
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
diff --git a/tests/YGMinMaxDimensionTest.cpp b/tests/YGMinMaxDimensionTest.cpp
index c6e57fcd..b480296f 100644
--- a/tests/YGMinMaxDimensionTest.cpp
+++ b/tests/YGMinMaxDimensionTest.cpp
@@ -359,6 +359,7 @@ TEST(YogaTest, justify_content_overflow_min_max) {
TEST(YogaTest, flex_grow_to_min) {
const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 100);
@@ -412,8 +413,9 @@ TEST(YogaTest, flex_grow_to_min) {
YGConfigFree(config);
}
-TEST(YogaTest, flex_grow_skip_child) {
+TEST(YogaTest, flex_grow_in_at_most_container) {
const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
@@ -428,7 +430,6 @@ TEST(YogaTest, flex_grow_skip_child) {
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexGrow(root_child0_child0, 1);
YGNodeStyleSetFlexBasis(root_child0_child0, 0);
- YGNodeStyleSetHeight(root_child0_child0, 100);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
@@ -440,12 +441,12 @@ TEST(YogaTest, flex_grow_skip_child) {
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
@@ -457,52 +458,12 @@ TEST(YogaTest, flex_grow_skip_child) {
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
-
- YGNodeFreeRecursive(root);
-
- YGConfigFree(config);
-}
-
-TEST(YogaTest, flex_grow_child) {
- const YGConfigRef config = YGConfigNew();
-
- const YGNodeRef root = YGNodeNewWithConfig(config);
- YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
-
- const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
- YGNodeStyleSetFlexGrow(root_child0, 1);
- YGNodeStyleSetFlexBasis(root_child0, 0);
- YGNodeStyleSetHeight(root_child0, 100);
- YGNodeInsertChild(root, root_child0, 0);
- YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
-
- YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0));
YGNodeFreeRecursive(root);
@@ -725,59 +686,6 @@ TEST(YogaTest, flex_grow_within_constrained_min_column) {
YGConfigFree(config);
}
-TEST(YogaTest, flex_grow_within_constrained_min_max_column) {
- const YGConfigRef config = YGConfigNew();
-
- const YGNodeRef root = YGNodeNewWithConfig(config);
- YGNodeStyleSetMinHeight(root, 100);
- YGNodeStyleSetMaxHeight(root, 200);
-
- const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
- YGNodeStyleSetFlexGrow(root_child0, 1);
- YGNodeInsertChild(root, root_child0, 0);
-
- const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
- YGNodeStyleSetHeight(root_child1, 50);
- YGNodeInsertChild(root, root_child1, 1);
- YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
-
- YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
- ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child0));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
-
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child1));
- ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root_child1));
- ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child1));
-
- YGNodeFreeRecursive(root);
-
- YGConfigFree(config);
-}
-
TEST(YogaTest, flex_grow_within_constrained_max_row) {
const YGConfigRef config = YGConfigNew();
@@ -1043,3 +951,111 @@ TEST(YogaTest, min_max_percent_no_width_height) {
YGConfigFree(config);
}
+
+TEST(YogaTest, min_width_in_flex_distribution) {
+ const YGConfigRef config = YGConfigNew();
+
+ const YGNodeRef root = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
+ YGNodeStyleSetWidth(root, 300);
+ YGNodeStyleSetHeight(root, 300);
+
+ const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child0, 2);
+ YGNodeStyleSetFlexShrink(root_child0, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child0, 0);
+ YGNodeStyleSetMinWidth(root_child0, 100);
+ YGNodeStyleSetMaxWidth(root_child0, 200);
+ YGNodeInsertChild(root, root_child0, 0);
+
+ const YGNodeRef root_child1 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child1, 1);
+ YGNodeStyleSetFlexShrink(root_child1, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child1, 0);
+ YGNodeInsertChild(root, root_child1, 1);
+
+ const YGNodeRef root_child2 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child2, 1);
+ YGNodeStyleSetFlexShrink(root_child2, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child2, 0);
+ YGNodeInsertChild(root, root_child2, 2);
+
+ const YGNodeRef root_child3 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child3, 1);
+ YGNodeStyleSetFlexShrink(root_child3, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child3, 0);
+ YGNodeInsertChild(root, root_child3, 3);
+
+ const YGNodeRef root_child4 = YGNodeNewWithConfig(config);
+ YGNodeStyleSetFlexGrow(root_child4, 1);
+ YGNodeStyleSetFlexShrink(root_child4, 1);
+ YGNodeStyleSetFlexBasisPercent(root_child4, 0);
+ YGNodeInsertChild(root, root_child4, 4);
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child3));
+
+ ASSERT_FLOAT_EQ(250, YGNodeLayoutGetLeft(root_child4));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child4));
+
+ YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetWidth(root));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root));
+
+ ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child0));
+
+ ASSERT_FLOAT_EQ(150, YGNodeLayoutGetLeft(root_child1));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child1));
+
+ ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child2));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child2));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child2));
+
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child3));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child3));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child3));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child3));
+
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child4));
+ ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child4));
+ ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child4));
+ ASSERT_FLOAT_EQ(300, YGNodeLayoutGetHeight(root_child4));
+
+ YGNodeFreeRecursive(root);
+
+ YGConfigFree(config);
+}
diff --git a/tests/YGPercentageTest.cpp b/tests/YGPercentageTest.cpp
index 3b1c7849..86ee8b78 100644
--- a/tests/YGPercentageTest.cpp
+++ b/tests/YGPercentageTest.cpp
@@ -1056,6 +1056,7 @@ TEST(YogaTest, percent_within_flex_grow) {
TEST(YogaTest, percentage_container_in_wrapping_container) {
const YGConfigRef config = YGConfigNew();
+ YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinFlexFix, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
diff --git a/yoga/YGEnums.c b/yoga/YGEnums.c
index 53a05778..0108e6a6 100644
--- a/yoga/YGEnums.c
+++ b/yoga/YGEnums.c
@@ -93,6 +93,8 @@ const char *YGExperimentalFeatureToString(const YGExperimentalFeature value){
return "rounding";
case YGExperimentalFeatureWebFlexBasis:
return "web-flex-basis";
+ case YGExperimentalFeatureMinFlexFix:
+ return "min-flex-fix";
}
return "unknown";
}
diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h
index aa14933b..8a929b9e 100644
--- a/yoga/YGEnums.h
+++ b/yoga/YGEnums.h
@@ -66,6 +66,7 @@ WIN_EXPORT const char *YGEdgeToString(const YGEdge value);
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
YGExperimentalFeatureRounding,
YGExperimentalFeatureWebFlexBasis,
+ YGExperimentalFeatureMinFlexFix,
} YG_ENUM_END(YGExperimentalFeature);
WIN_EXPORT const char *YGExperimentalFeatureToString(const YGExperimentalFeature value);
diff --git a/yoga/Yoga.c b/yoga/Yoga.c
index 4acfae74..f7be592a 100644
--- a/yoga/Yoga.c
+++ b/yoga/Yoga.c
@@ -203,6 +203,7 @@ static YGConfig gYGConfigDefaults = {
.experimentalFeatures =
{
[YGExperimentalFeatureRounding] = false,
+ [YGExperimentalFeatureMinFlexFix] = false,
[YGExperimentalFeatureWebFlexBasis] = false,
},
.useWebDefaults = false,
@@ -2202,9 +2203,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
availableInnerMainDim = minInnerMainDim;
} else if (!YGFloatIsUndefined(maxInnerMainDim) && sizeConsumedOnCurrentLine > maxInnerMainDim) {
availableInnerMainDim = maxInnerMainDim;
- } else if (totalFlexGrowFactors == 0 || YGResolveFlexGrow(node) == 0) {
- // If we don't have any children to flex or we can't flex the node itself,
- // space we've used is all space we need
+ } else if (YGConfigIsExperimentalFeatureEnabled(node->config, YGExperimentalFeatureMinFlexFix)) {
+ // TODO: this needs to be moved out of experimental feature, as this is legitimate fix
+ // If the measurement isn't exact, we want to use as little space as possible
availableInnerMainDim = sizeConsumedOnCurrentLine;
}
}