Fix behaviour of wrapping container within align-items: not stretch
Summary: When a container's children wrap the container should match the parent size and not wrap to the new size of the children. This is confirmed behavior in chrome. Reviewed By: astreet Differential Revision: D4578614 fbshipit-source-id: 5d22a3a673735587384d775189158a87bb1d457d
This commit is contained in:
committed by
Facebook Github Bot
parent
78ade6cfb5
commit
6b39165801
@@ -1142,5 +1142,212 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(50f, root_child4.LayoutHeight);
|
Assert.AreEqual(50f, root_child4.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_wrapped_row_within_align_items_center()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.AlignItems = YogaAlign.Center;
|
||||||
|
root.Width = 200;
|
||||||
|
root.Height = 200;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root_child0.Wrap = YogaWrap.Wrap;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 150;
|
||||||
|
root_child0_child0.Height = 80;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.Width = 80;
|
||||||
|
root_child0_child1.Height = 80;
|
||||||
|
root_child0.Insert(1, root_child0_child1);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(50f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(120f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_wrapped_row_within_align_items_center2()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.AlignItems = YogaAlign.FlexStart;
|
||||||
|
root.Width = 200;
|
||||||
|
root.Height = 200;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root_child0.Wrap = YogaWrap.Wrap;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 150;
|
||||||
|
root_child0_child0.Height = 80;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.Width = 80;
|
||||||
|
root_child0_child1.Height = 80;
|
||||||
|
root_child0.Insert(1, root_child0_child1);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(50f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(120f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_wrapped_row_within_align_items_center3()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.AlignItems = YogaAlign.FlexEnd;
|
||||||
|
root.Width = 200;
|
||||||
|
root.Height = 200;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.FlexDirection = YogaFlexDirection.Row;
|
||||||
|
root_child0.Wrap = YogaWrap.Wrap;
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.Width = 150;
|
||||||
|
root_child0_child0.Height = 80;
|
||||||
|
root_child0.Insert(0, root_child0_child0);
|
||||||
|
|
||||||
|
YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.Width = 80;
|
||||||
|
root_child0_child1.Height = 80;
|
||||||
|
root_child0.Insert(1, root_child0_child1);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(200f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(200f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(160f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(50f, root_child0_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0_child0.LayoutY);
|
||||||
|
Assert.AreEqual(150f, root_child0_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child0.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(120f, root_child0_child1.LayoutX);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutY);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutWidth);
|
||||||
|
Assert.AreEqual(80f, root_child0_child1.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -93,3 +93,23 @@
|
|||||||
<div style="height: 50px; width: 30px;"></div>
|
<div style="height: 50px; width: 30px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapped_row_within_align_items_center" style="width: 200px; height: 200px; align-items: center;">
|
||||||
|
<div style="flex-direction:row; flex-wrap: wrap;">
|
||||||
|
<div style="width: 150px; height: 80px;"></div>
|
||||||
|
<div style="width: 80px; height: 80px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapped_row_within_align_items_flex_start" style="width: 200px; height: 200px; align-items: flex-start;">
|
||||||
|
<div style="flex-direction:row; flex-wrap: wrap;">
|
||||||
|
<div style="width: 150px; height: 80px;"></div>
|
||||||
|
<div style="width: 80px; height: 80px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="wrapped_row_within_align_items_flex_end" style="width: 200px; height: 200px; align-items: flex-end;">
|
||||||
|
<div style="flex-direction:row; flex-wrap: wrap;">
|
||||||
|
<div style="width: 150px; height: 80px;"></div>
|
||||||
|
<div style="width: 80px; height: 80px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -1128,4 +1128,208 @@ public class YGFlexWrapTest {
|
|||||||
assertEquals(50f, root_child4.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child4.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_wrapped_row_within_align_items_center() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setAlignItems(YogaAlign.CENTER);
|
||||||
|
root.setWidth(200f);
|
||||||
|
root.setHeight(200f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root_child0.setWrap(YogaWrap.WRAP);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(150f);
|
||||||
|
root_child0_child0.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.setWidth(80f);
|
||||||
|
root_child0_child1.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(120f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_wrapped_row_within_align_items_center2() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setAlignItems(YogaAlign.FLEX_START);
|
||||||
|
root.setWidth(200f);
|
||||||
|
root.setHeight(200f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root_child0.setWrap(YogaWrap.WRAP);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(150f);
|
||||||
|
root_child0_child0.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.setWidth(80f);
|
||||||
|
root_child0_child1.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(120f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_wrapped_row_within_align_items_center3() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setAlignItems(YogaAlign.FLEX_END);
|
||||||
|
root.setWidth(200f);
|
||||||
|
root.setHeight(200f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||||
|
root_child0.setWrap(YogaWrap.WRAP);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child0 = new YogaNode();
|
||||||
|
root_child0_child0.setWidth(150f);
|
||||||
|
root_child0_child0.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_child0, 0);
|
||||||
|
|
||||||
|
final YogaNode root_child0_child1 = new YogaNode();
|
||||||
|
root_child0_child1.setWidth(80f);
|
||||||
|
root_child0_child1.setHeight(80f);
|
||||||
|
root_child0.addChildAt(root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_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(200f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(200f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(200f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(160f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(50f, root_child0_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(150f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(120f, root_child0_child1.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(80f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1149,3 +1149,213 @@ it("wrap_reverse_column_fixed_size", function () {
|
|||||||
(typeof gc !== "undefined") && gc();
|
(typeof gc !== "undefined") && gc();
|
||||||
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
});
|
});
|
||||||
|
it("wrapped_row_within_align_items_center", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_CENTER);
|
||||||
|
root.setWidth(200);
|
||||||
|
root.setHeight(200);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root_child0.setFlexWrap(Yoga.WRAP_WRAP);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(150);
|
||||||
|
root_child0_child0.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child1 = Yoga.Node.create();
|
||||||
|
root_child0_child1.setWidth(80);
|
||||||
|
root_child0_child1.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0_child0.getComputedLeft(), "50 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(120 === root_child0_child1.getComputedLeft(), "120 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("wrapped_row_within_align_items_center2", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||||
|
root.setWidth(200);
|
||||||
|
root.setHeight(200);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root_child0.setFlexWrap(Yoga.WRAP_WRAP);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(150);
|
||||||
|
root_child0_child0.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child1 = Yoga.Node.create();
|
||||||
|
root_child0_child1.setWidth(80);
|
||||||
|
root_child0_child1.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0_child0.getComputedLeft(), "50 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(120 === root_child0_child1.getComputedLeft(), "120 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("wrapped_row_within_align_items_center3", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_FLEX_END);
|
||||||
|
root.setWidth(200);
|
||||||
|
root.setHeight(200);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setFlexDirection(Yoga.FLEX_DIRECTION_ROW);
|
||||||
|
root_child0.setFlexWrap(Yoga.WRAP_WRAP);
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child0 = Yoga.Node.create();
|
||||||
|
root_child0_child0.setWidth(150);
|
||||||
|
root_child0_child0.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_child0, 0);
|
||||||
|
|
||||||
|
var root_child0_child1 = Yoga.Node.create();
|
||||||
|
root_child0_child1.setWidth(80);
|
||||||
|
root_child0_child1.setHeight(80);
|
||||||
|
root_child0.insertChild(root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0_child1.getComputedLeft(), "0 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_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(200 === root.getComputedWidth(), "200 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(200 === root.getComputedHeight(), "200 === 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(200 === root_child0.getComputedWidth(), "200 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(160 === root_child0.getComputedHeight(), "160 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(50 === root_child0_child0.getComputedLeft(), "50 === 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(150 === root_child0_child0.getComputedWidth(), "150 === root_child0_child0.getComputedWidth() (" + root_child0_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child0.getComputedHeight(), "80 === root_child0_child0.getComputedHeight() (" + root_child0_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(120 === root_child0_child1.getComputedLeft(), "120 === root_child0_child1.getComputedLeft() (" + root_child0_child1.getComputedLeft() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedTop(), "80 === root_child0_child1.getComputedTop() (" + root_child0_child1.getComputedTop() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedWidth(), "80 === root_child0_child1.getComputedWidth() (" + root_child0_child1.getComputedWidth() + ")");
|
||||||
|
console.assert(80 === root_child0_child1.getComputedHeight(), "80 === root_child0_child1.getComputedHeight() (" + root_child0_child1.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
@@ -1110,3 +1110,204 @@ TEST(YogaTest, wrap_reverse_column_fixed_size) {
|
|||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, wrapped_row_within_align_items_center) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignCenter);
|
||||||
|
YGNodeStyleSetWidth(root, 200);
|
||||||
|
YGNodeStyleSetHeight(root, 200);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 150);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child1 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child1, 80);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child1, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child1, 1);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, wrapped_row_within_align_items_center2) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||||
|
YGNodeStyleSetWidth(root, 200);
|
||||||
|
YGNodeStyleSetHeight(root, 200);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 150);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child1 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child1, 80);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child1, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child1, 1);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, wrapped_row_within_align_items_center3) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignFlexEnd);
|
||||||
|
YGNodeStyleSetWidth(root, 200);
|
||||||
|
YGNodeStyleSetHeight(root, 200);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
|
||||||
|
YGNodeStyleSetFlexWrap(root_child0, YGWrapWrap);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child0, 150);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child0, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0_child1 = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root_child0_child1, 80);
|
||||||
|
YGNodeStyleSetHeight(root_child0_child1, 80);
|
||||||
|
YGNodeInsertChild(root_child0, root_child0_child1, 1);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(160, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(150, YGNodeLayoutGetWidth(root_child0_child0));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child0));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetTop(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetWidth(root_child0_child1));
|
||||||
|
ASSERT_FLOAT_EQ(80, YGNodeLayoutGetHeight(root_child0_child1));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
12
yoga/Yoga.c
12
yoga/Yoga.c
@@ -1928,8 +1928,8 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
const float paddingAndBorderAxisCross =
|
const float paddingAndBorderAxisCross =
|
||||||
YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);
|
YGNodePaddingAndBorderForAxis(node, crossAxis, parentWidth);
|
||||||
|
|
||||||
const YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode;
|
YGMeasureMode measureModeMainDim = isMainAxisRow ? widthMeasureMode : heightMeasureMode;
|
||||||
const YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode;
|
YGMeasureMode measureModeCrossDim = isMainAxisRow ? heightMeasureMode : widthMeasureMode;
|
||||||
|
|
||||||
const float paddingAndBorderAxisRow =
|
const float paddingAndBorderAxisRow =
|
||||||
isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
|
isMainAxisRow ? paddingAndBorderAxisMain : paddingAndBorderAxisCross;
|
||||||
@@ -1974,8 +1974,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
// computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly
|
// computedFlexBasis to 0 instead of measuring and shrinking / flexing the child to exactly
|
||||||
// match the remaining space
|
// match the remaining space
|
||||||
YGNodeRef singleFlexChild = NULL;
|
YGNodeRef singleFlexChild = NULL;
|
||||||
if ((isMainAxisRow && widthMeasureMode == YGMeasureModeExactly) ||
|
if (measureModeMainDim == YGMeasureModeExactly) {
|
||||||
(!isMainAxisRow && heightMeasureMode == YGMeasureModeExactly)) {
|
|
||||||
for (uint32_t i = 0; i < childCount; i++) {
|
for (uint32_t i = 0; i < childCount; i++) {
|
||||||
const YGNodeRef child = YGNodeGetChild(node, i);
|
const YGNodeRef child = YGNodeGetChild(node, i);
|
||||||
if (singleFlexChild) {
|
if (singleFlexChild) {
|
||||||
@@ -2047,6 +2046,9 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
|
|
||||||
const bool flexBasisOverflows =
|
const bool flexBasisOverflows =
|
||||||
measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
|
measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim;
|
||||||
|
if (isNodeFlexWrap && flexBasisOverflows && measureModeMainDim == YGMeasureModeAtMost) {
|
||||||
|
measureModeMainDim = YGMeasureModeExactly;
|
||||||
|
}
|
||||||
|
|
||||||
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
|
// STEP 4: COLLECT FLEX ITEMS INTO FLEX LINES
|
||||||
|
|
||||||
@@ -2886,7 +2888,7 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGNodeAbsoluteLayoutChild(node,
|
YGNodeAbsoluteLayoutChild(node,
|
||||||
currentAbsoluteChild,
|
currentAbsoluteChild,
|
||||||
availableInnerWidth,
|
availableInnerWidth,
|
||||||
widthMeasureMode,
|
isMainAxisRow ? measureModeMainDim : measureModeCrossDim,
|
||||||
availableInnerHeight,
|
availableInnerHeight,
|
||||||
direction);
|
direction);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user