Fix justify content with min/max constraint parent
Summary: The min/max inner width shouldn't take the margins into account. Adds a test for both cases. Fixes #664 Closes https://github.com/facebook/yoga/pull/665 Differential Revision: D6407982 Pulled By: emilsjolander fbshipit-source-id: ffa549a06f802263e3b8488e90756aa3f722d52d
This commit is contained in:
committed by
Facebook Github Bot
parent
0b13a0c168
commit
a69545a6ae
@@ -699,5 +699,173 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
Assert.AreEqual(10f, root_child2.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_justify_content_row_min_width_and_margin()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.MarginLeft = 100;
|
||||||
|
root.MinWidth = 50;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.Width = 20;
|
||||||
|
root_child0.Height = 20;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(100f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(50f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(15f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(100f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(50f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(15f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_justify_content_row_max_width_and_margin()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.MarginLeft = 100;
|
||||||
|
root.Width = 100;
|
||||||
|
root.MaxWidth = 80;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.Width = 20;
|
||||||
|
root_child0.Height = 20;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(100f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(100f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_justify_content_column_min_height_and_margin()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.MarginTop = 100;
|
||||||
|
root.MinHeight = 50;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.Width = 20;
|
||||||
|
root_child0.Height = 20;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(100f, root.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(15f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(100f, root.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(50f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(15f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_justify_content_colunn_max_height_and_margin()
|
||||||
|
{
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
YogaNode root = new YogaNode(config);
|
||||||
|
root.JustifyContent = YogaJustify.Center;
|
||||||
|
root.MarginTop = 100;
|
||||||
|
root.Height = 100;
|
||||||
|
root.MaxHeight = 80;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.Width = 20;
|
||||||
|
root_child0.Height = 20;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(100f, root.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(100f, root.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(30f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(20f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,3 +57,19 @@
|
|||||||
<div style="height: 10px;"></div>
|
<div style="height: 10px;"></div>
|
||||||
<div style="height: 10px;"></div>
|
<div style="height: 10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="justify_content_row_min_width_and_margin" style="min-width: 50px; margin-left: 100px; justify-content: center; flex-direction: row;">
|
||||||
|
<div style="height: 20px; width: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="justify_content_row_max_width_and_margin" style="width: 100px; max-width: 80px; margin-left: 100px; justify-content: center; flex-direction: row;">
|
||||||
|
<div style="height: 20px; width: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="justify_content_column_min_height_and_margin" style="min-height: 50px; margin-top: 100px; justify-content: center; flex-direction: column;">
|
||||||
|
<div style="height: 20px; width: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="justify_content_colunn_max_height_and_margin" style="height: 100px; max-height: 80px; margin-top: 100px; justify-content: center; flex-direction: column;">
|
||||||
|
<div style="height: 20px; width: 20px;"></div>
|
||||||
|
</div>
|
||||||
|
@@ -688,4 +688,168 @@ public class YGJustifyContentTest {
|
|||||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_justify_content_row_min_width_and_margin() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = new YogaNode(config);
|
||||||
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setMargin(YogaEdge.LEFT, 100f);
|
||||||
|
root.setMinWidth(50f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.setWidth(20f);
|
||||||
|
root_child0.setHeight(20f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(15f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(50f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(15f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_justify_content_row_max_width_and_margin() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = new YogaNode(config);
|
||||||
|
root.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setMargin(YogaEdge.LEFT, 100f);
|
||||||
|
root.setWidth(100f);
|
||||||
|
root.setMaxWidth(80f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.setWidth(20f);
|
||||||
|
root_child0.setHeight(20f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(30f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(100f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(30f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_justify_content_column_min_height_and_margin() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = new YogaNode(config);
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setMargin(YogaEdge.TOP, 100f);
|
||||||
|
root.setMinHeight(50f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.setWidth(20f);
|
||||||
|
root_child0.setHeight(20f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(50f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(15f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_justify_content_colunn_max_height_and_margin() {
|
||||||
|
YogaConfig config = new YogaConfig();
|
||||||
|
|
||||||
|
final YogaNode root = new YogaNode(config);
|
||||||
|
root.setJustifyContent(YogaJustify.CENTER);
|
||||||
|
root.setMargin(YogaEdge.TOP, 100f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
root.setMaxHeight(80f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode(config);
|
||||||
|
root_child0.setWidth(20f);
|
||||||
|
root_child0.setHeight(20f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(30f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(20f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -723,3 +723,183 @@ it("justify_content_column_space_around", function () {
|
|||||||
config.free();
|
config.free();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
it("justify_content_row_min_width_and_margin", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setMargin(Yoga.EDGE_LEFT, 100);
|
||||||
|
root.setMinWidth(50);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setWidth(20);
|
||||||
|
root_child0.setHeight(20);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(100 === root.getComputedLeft(), "100 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(15 === root_child0.getComputedLeft(), "15 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(100 === root.getComputedLeft(), "100 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(50 === root.getComputedWidth(), "50 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(15 === root_child0.getComputedLeft(), "15 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("justify_content_row_max_width_and_margin", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setMargin(Yoga.EDGE_LEFT, 100);
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setMaxWidth(80);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setWidth(20);
|
||||||
|
root_child0.setHeight(20);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(100 === root.getComputedLeft(), "100 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root.getComputedWidth(), "80 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(30 === root_child0.getComputedLeft(), "30 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(100 === root.getComputedLeft(), "100 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root.getComputedWidth(), "80 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root.getComputedHeight(), "20 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(30 === root_child0.getComputedLeft(), "30 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("justify_content_column_min_height_and_margin", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setMargin(Yoga.EDGE_TOP, 100);
|
||||||
|
root.setMinHeight(50);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setWidth(20);
|
||||||
|
root_child0.setHeight(20);
|
||||||
|
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(100 === root.getComputedTop(), "100 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(50 === root.getComputedHeight(), "50 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(15 === root_child0.getComputedTop(), "15 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === 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(100 === root.getComputedTop(), "100 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(50 === root.getComputedHeight(), "50 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(15 === root_child0.getComputedTop(), "15 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
it("justify_content_colunn_max_height_and_margin", function () {
|
||||||
|
var config = Yoga.Config.create();
|
||||||
|
|
||||||
|
try {
|
||||||
|
var root = Yoga.Node.create(config);
|
||||||
|
root.setJustifyContent(Yoga.JUSTIFY_CENTER);
|
||||||
|
root.setMargin(Yoga.EDGE_TOP, 100);
|
||||||
|
root.setHeight(100);
|
||||||
|
root.setMaxHeight(80);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create(config);
|
||||||
|
root_child0.setWidth(20);
|
||||||
|
root_child0.setHeight(20);
|
||||||
|
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(100 === root.getComputedTop(), "100 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root.getComputedHeight(), "80 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === 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(100 === root.getComputedTop(), "100 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root.getComputedWidth(), "20 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root.getComputedHeight(), "80 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(30 === root_child0.getComputedTop(), "30 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedWidth(), "20 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(20 === root_child0.getComputedHeight(), "20 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
} finally {
|
||||||
|
if (typeof root !== "undefined") {
|
||||||
|
root.freeRecursive();
|
||||||
|
}
|
||||||
|
|
||||||
|
config.free();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@@ -693,3 +693,171 @@ TEST(YogaTest, justify_content_column_space_around) {
|
|||||||
|
|
||||||
YGConfigFree(config);
|
YGConfigFree(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, justify_content_row_min_width_and_margin) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetMargin(root, YGEdgeLeft, 100);
|
||||||
|
YGNodeStyleSetMinWidth(root, 50);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 20);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 20);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, justify_content_row_max_width_and_margin) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetMargin(root, YGEdgeLeft, 100);
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetMaxWidth(root, 80);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 20);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 20);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, justify_content_column_min_height_and_margin) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetMargin(root, YGEdgeTop, 100);
|
||||||
|
YGNodeStyleSetMinHeight(root, 50);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 20);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 20);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, justify_content_colunn_max_height_and_margin) {
|
||||||
|
const YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
const YGNodeRef root = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetJustifyContent(root, YGJustifyCenter);
|
||||||
|
YGNodeStyleSetMargin(root, YGEdgeTop, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
YGNodeStyleSetMaxHeight(root, 80);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||||
|
YGNodeStyleSetWidth(root_child0, 20);
|
||||||
|
YGNodeStyleSetHeight(root_child0, 20);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
|
||||||
|
YGConfigFree(config);
|
||||||
|
}
|
||||||
|
@@ -1862,17 +1862,17 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
|
// STEP 2: DETERMINE AVAILABLE SIZE IN MAIN AND CROSS DIRECTIONS
|
||||||
const float minInnerWidth =
|
const float minInnerWidth =
|
||||||
YGResolveValue(&node->style.minDimensions[YGDimensionWidth], parentWidth) - marginAxisRow -
|
YGResolveValue(&node->style.minDimensions[YGDimensionWidth], parentWidth) -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float maxInnerWidth =
|
const float maxInnerWidth =
|
||||||
YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], parentWidth) - marginAxisRow -
|
YGResolveValue(&node->style.maxDimensions[YGDimensionWidth], parentWidth) -
|
||||||
paddingAndBorderAxisRow;
|
paddingAndBorderAxisRow;
|
||||||
const float minInnerHeight =
|
const float minInnerHeight =
|
||||||
YGResolveValue(&node->style.minDimensions[YGDimensionHeight], parentHeight) -
|
YGResolveValue(&node->style.minDimensions[YGDimensionHeight], parentHeight) -
|
||||||
marginAxisColumn - paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
const float maxInnerHeight =
|
const float maxInnerHeight =
|
||||||
YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], parentHeight) -
|
YGResolveValue(&node->style.maxDimensions[YGDimensionHeight], parentHeight) -
|
||||||
marginAxisColumn - paddingAndBorderAxisColumn;
|
paddingAndBorderAxisColumn;
|
||||||
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
|
const float minInnerMainDim = isMainAxisRow ? minInnerWidth : minInnerHeight;
|
||||||
const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight;
|
const float maxInnerMainDim = isMainAxisRow ? maxInnerWidth : maxInnerHeight;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user