Fix typo causing wrapped children to be sized by wrong axis margin

Summary: Fixes https://github.com/facebook/yoga/issues/548

Reviewed By: passy

Differential Revision: D5044470

fbshipit-source-id: 7d203dd48b258a5fe5c4b3c493099092a1d334db
This commit is contained in:
Emil Sjolander
2017-05-12 09:03:24 -07:00
committed by Facebook Github Bot
parent 488a7c1fe0
commit b2b0c7ee37
6 changed files with 406 additions and 1 deletions

View File

@@ -1643,5 +1643,103 @@ namespace Facebook.Yoga
Assert.AreEqual(40f, root_child0_child1_child0.LayoutHeight);
}
[Test]
public void Test_wrap_nodes_with_content_sizing_margin_cross()
{
YogaConfig config = new YogaConfig();
YogaNode root = new YogaNode(config);
root.Width = 500;
root.Height = 500;
YogaNode root_child0 = new YogaNode(config);
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.Wrap = YogaWrap.Wrap;
root_child0.Width = 70;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode(config);
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.Width = 40;
root_child0_child0_child0.Height = 40;
root_child0_child0.Insert(0, root_child0_child0_child0);
YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.MarginTop = 10;
root_child0.Insert(1, root_child0_child1);
YogaNode root_child0_child1_child0 = new YogaNode(config);
root_child0_child1_child0.Width = 40;
root_child0_child1_child0.Height = 40;
root_child0_child1.Insert(0, root_child0_child1_child0);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(70f, root_child0.LayoutWidth);
Assert.AreEqual(90f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1.LayoutX);
Assert.AreEqual(50f, root_child0_child1.LayoutY);
Assert.AreEqual(40f, root_child0_child1.LayoutWidth);
Assert.AreEqual(40f, root_child0_child1.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child1_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child1_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child1_child0.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(500f, root.LayoutWidth);
Assert.AreEqual(500f, root.LayoutHeight);
Assert.AreEqual(430f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(70f, root_child0.LayoutWidth);
Assert.AreEqual(90f, root_child0.LayoutHeight);
Assert.AreEqual(30f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child0_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child0_child0.LayoutHeight);
Assert.AreEqual(30f, root_child0_child1.LayoutX);
Assert.AreEqual(50f, root_child0_child1.LayoutY);
Assert.AreEqual(40f, root_child0_child1.LayoutWidth);
Assert.AreEqual(40f, root_child0_child1.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child1_child0.LayoutY);
Assert.AreEqual(40f, root_child0_child1_child0.LayoutWidth);
Assert.AreEqual(40f, root_child0_child1_child0.LayoutHeight);
}
}
}

View File

@@ -136,3 +136,14 @@
</div>
</div>
</div>
<div id="wrap_nodes_with_content_sizing_margin_cross" style="width: 500px; height: 500px;">
<div style="flex-direction: row; flex-wrap: wrap; width: 70px;">
<div>
<div style="height: 40px; width: 40px;"></div>
</div>
<div style="margin-top: 10px;">
<div style="height: 40px; width: 40px;"></div>
</div>
</div>
</div>

View File

@@ -1623,4 +1623,101 @@ public class YGFlexWrapTest {
assertEquals(40f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_wrap_nodes_with_content_sizing_margin_cross() {
YogaConfig config = new YogaConfig();
final YogaNode root = new YogaNode(config);
root.setWidth(500f);
root.setHeight(500f);
final YogaNode root_child0 = new YogaNode(config);
root_child0.setFlexDirection(YogaFlexDirection.ROW);
root_child0.setWrap(YogaWrap.WRAP);
root_child0.setWidth(70f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = new YogaNode(config);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = new YogaNode(config);
root_child0_child0_child0.setWidth(40f);
root_child0_child0_child0.setHeight(40f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child1 = new YogaNode(config);
root_child0_child1.setMargin(YogaEdge.TOP, 10f);
root_child0.addChildAt(root_child0_child1, 1);
final YogaNode root_child0_child1_child0 = new YogaNode(config);
root_child0_child1_child0.setWidth(40f);
root_child0_child1_child0.setHeight(40f);
root_child0_child1.addChildAt(root_child0_child1_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(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(70f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child1_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(500f, root.getLayoutWidth(), 0.0f);
assertEquals(500f, root.getLayoutHeight(), 0.0f);
assertEquals(430f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(70f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(90f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(30f, root_child0_child1.getLayoutX(), 0.0f);
assertEquals(50f, root_child0_child1.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child1.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child1.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
assertEquals(40f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
assertEquals(40f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
}
}

View File

@@ -1694,3 +1694,104 @@ it("wrap_nodes_with_content_sizing_overflowing_margin", function () {
config.free();
}
});
it("wrap_nodes_with_content_sizing_margin_cross", function () {
var config = Yoga.Config.create();
try {
var root = Yoga.Node.create(config);
root.setWidth(500);
root.setHeight(500);
var root_child0 = Yoga.Node.create(config);
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
root_child0.setFlexWrap(Yoga.WRAP_WRAP);
root_child0.setWidth(70);
root.insertChild(root_child0, 0);
var root_child0_child0 = Yoga.Node.create(config);
root_child0.insertChild(root_child0_child0, 0);
var root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setWidth(40);
root_child0_child0_child0.setHeight(40);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
var root_child0_child1 = Yoga.Node.create(config);
root_child0_child1.setMargin(Yoga.EDGE_TOP, 10);
root_child0.insertChild(root_child0_child1, 1);
var root_child0_child1_child0 = Yoga.Node.create(config);
root_child0_child1_child0.setWidth(40);
root_child0_child1_child0.setHeight(40);
root_child0_child1.insertChild(root_child0_child1_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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === 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(70 === root_child0.getComputedWidth(), "70 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(90 === root_child0.getComputedHeight(), "90 === 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(40 === root_child0_child0.getComputedWidth(), "40 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child0.getComputedHeight(), "40 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(40 === root_child0_child0_child0.getComputedWidth(), "40 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child0_child0.getComputedHeight(), "40 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
console.assert(50 === root_child0_child1.getComputedTop(), "50 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
console.assert(40 === root_child0_child1.getComputedWidth(), "40 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
console.assert(40 === root_child0_child1.getComputedHeight(), "40 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
console.assert(0 === root_child0_child1_child0.getComputedLeft(), "0 === root_child0_child1_child0.getComputedLeft() (" + root_child0_child1_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child1_child0.getComputedTop(), "0 === root_child0_child1_child0.getComputedTop() (" + root_child0_child1_child0.getComputedTop() + ")");
console.assert(40 === root_child0_child1_child0.getComputedWidth(), "40 === root_child0_child1_child0.getComputedWidth() (" + root_child0_child1_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child1_child0.getComputedHeight(), "40 === root_child0_child1_child0.getComputedHeight() (" + root_child0_child1_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(500 === root.getComputedWidth(), "500 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
console.assert(500 === root.getComputedHeight(), "500 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
console.assert(430 === root_child0.getComputedLeft(), "430 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
console.assert(70 === root_child0.getComputedWidth(), "70 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
console.assert(90 === root_child0.getComputedHeight(), "90 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
console.assert(30 === root_child0_child0.getComputedLeft(), "30 === 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(40 === root_child0_child0.getComputedWidth(), "40 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child0.getComputedHeight(), "40 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
console.assert(0 === root_child0_child0_child0.getComputedLeft(), "0 === root_child0_child0_child0.getComputedLeft() (" + root_child0_child0_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child0_child0.getComputedTop(), "0 === root_child0_child0_child0.getComputedTop() (" + root_child0_child0_child0.getComputedTop() + ")");
console.assert(40 === root_child0_child0_child0.getComputedWidth(), "40 === root_child0_child0_child0.getComputedWidth() (" + root_child0_child0_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child0_child0.getComputedHeight(), "40 === root_child0_child0_child0.getComputedHeight() (" + root_child0_child0_child0.getComputedHeight() + ")");
console.assert(30 === root_child0_child1.getComputedLeft(), "30 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
console.assert(50 === root_child0_child1.getComputedTop(), "50 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
console.assert(40 === root_child0_child1.getComputedWidth(), "40 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
console.assert(40 === root_child0_child1.getComputedHeight(), "40 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
console.assert(0 === root_child0_child1_child0.getComputedLeft(), "0 === root_child0_child1_child0.getComputedLeft() (" + root_child0_child1_child0.getComputedLeft() + ")");
console.assert(0 === root_child0_child1_child0.getComputedTop(), "0 === root_child0_child1_child0.getComputedTop() (" + root_child0_child1_child0.getComputedTop() + ")");
console.assert(40 === root_child0_child1_child0.getComputedWidth(), "40 === root_child0_child1_child0.getComputedWidth() (" + root_child0_child1_child0.getComputedWidth() + ")");
console.assert(40 === root_child0_child1_child0.getComputedHeight(), "40 === root_child0_child1_child0.getComputedHeight() (" + root_child0_child1_child0.getComputedHeight() + ")");
} finally {
if (typeof root !== "undefined") {
root.freeRecursive();
}
config.free();
}
});

View File

@@ -1637,3 +1637,101 @@ TEST(YogaTest, wrap_nodes_with_content_sizing_overflowing_margin) {
YGConfigFree(config);
}
TEST(YogaTest, wrap_nodes_with_content_sizing_margin_cross) {
const YGConfigRef config = YGConfigNew();
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 500);
YGNodeStyleSetHeight(root, 500);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
YGNodeStyleSetWidth(root_child0, 70);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child0_child0, 40);
YGNodeStyleSetHeight(root_child0_child0_child0, 40);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0_child1, YGEdgeTop, 10);
YGNodeInsertChild(root_child0, root_child0_child1, 1);
const YGNodeRef root_child0_child1_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root_child0_child1_child0, 40);
YGNodeStyleSetHeight(root_child0_child1_child0, 40);
YGNodeInsertChild(root_child0_child1, root_child0_child1_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(500, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(430, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(70, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(30, YGNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child1_child0));
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetHeight(root_child0_child1_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -2937,7 +2937,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
if (!YGNodeIsStyleDimDefined(child, crossAxis, availableInnerCrossDim)) {
const float childWidth =
isMainAxisRow ? (child->layout.measuredDimensions[YGDimensionWidth] +
YGNodeMarginForAxis(child, crossAxis, availableInnerWidth))
YGNodeMarginForAxis(child, mainAxis, availableInnerWidth))
: lineHeight;
const float childHeight =