Fix min/max not overriding width/height
Summary: Two bugs: 1. Min/Max width/height should have higher priority than width/height 2. custom measure nodes percentages should be based in parent size like everything else. Differential Revision: D4537576 fbshipit-source-id: c003f723f424afbca63170d41e54fd5ff837926d
This commit is contained in:
committed by
Facebook Github Bot
parent
a5b94ebd0c
commit
240c2dd657
@@ -675,5 +675,138 @@ namespace Facebook.Yoga
|
|||||||
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
Assert.AreEqual(50f, root_child1.LayoutHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_min_width_overrides_width()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Width = 50;
|
||||||
|
root.MinWidth = 100;
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(0f, root.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(0f, root.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_max_width_overrides_width()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Width = 200;
|
||||||
|
root.MaxWidth = 100;
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(0f, root.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(0f, root.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_min_height_overrides_height()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Height = 50;
|
||||||
|
root.MinHeight = 100;
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_max_height_overrides_height()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.Height = 200;
|
||||||
|
root.MaxHeight = 100;
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(0f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test_min_max_percent_no_width_height()
|
||||||
|
{
|
||||||
|
YogaNode root = new YogaNode();
|
||||||
|
root.AlignItems = YogaAlign.FlexStart;
|
||||||
|
root.Width = 100;
|
||||||
|
root.Height = 100;
|
||||||
|
|
||||||
|
YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.MinWidth = 10.Percent();
|
||||||
|
root_child0.MaxWidth = 10.Percent();
|
||||||
|
root_child0.MinHeight = 10.Percent();
|
||||||
|
root_child0.MaxHeight = 10.Percent();
|
||||||
|
root.Insert(0, root_child0);
|
||||||
|
root.StyleDirection = YogaDirection.LTR;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||||
|
|
||||||
|
root.StyleDirection = YogaDirection.RTL;
|
||||||
|
root.CalculateLayout();
|
||||||
|
|
||||||
|
Assert.AreEqual(0f, root.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root.LayoutY);
|
||||||
|
Assert.AreEqual(100f, root.LayoutWidth);
|
||||||
|
Assert.AreEqual(100f, root.LayoutHeight);
|
||||||
|
|
||||||
|
Assert.AreEqual(90f, root_child0.LayoutX);
|
||||||
|
Assert.AreEqual(0f, root_child0.LayoutY);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutWidth);
|
||||||
|
Assert.AreEqual(10f, root_child0.LayoutHeight);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -63,3 +63,20 @@
|
|||||||
<div style="flex-shrink:1; flex-basis:100px"></div>
|
<div style="flex-shrink:1; flex-basis:100px"></div>
|
||||||
<div style="height: 50px;"></div>
|
<div style="height: 50px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="min_width_overrides_width" style="min-width: 100px; width: 50px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="max_width_overrides_width" style="max-width: 100px; width: 200px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="min_height_overrides_height" style="min-height: 100px; height: 50px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="max_height_overrides_height" style="max-height: 100px; height: 200px;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="min_max_percent_no_width_height" style="width: 100px; height: 100px; align-items: flex-start;">
|
||||||
|
<div style="min-width: 10%; max-width: 10%; min-height: 10%; max-height: 10%;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@@ -661,4 +661,132 @@ public class YGMinMaxDimensionTest {
|
|||||||
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
assertEquals(50f, root_child1.getLayoutHeight(), 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_min_width_overrides_width() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(50f);
|
||||||
|
root.setMinWidth(100f);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(0f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_max_width_overrides_width() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setWidth(200f);
|
||||||
|
root.setMaxWidth(100f);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(0f, root.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(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_min_height_overrides_height() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setHeight(50f);
|
||||||
|
root.setMinHeight(100f);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_max_height_overrides_height() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setHeight(200f);
|
||||||
|
root.setMaxHeight(100f);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_min_max_percent_no_width_height() {
|
||||||
|
final YogaNode root = new YogaNode();
|
||||||
|
root.setAlignItems(YogaAlign.FLEX_START);
|
||||||
|
root.setWidth(100f);
|
||||||
|
root.setHeight(100f);
|
||||||
|
|
||||||
|
final YogaNode root_child0 = new YogaNode();
|
||||||
|
root_child0.setMinWidthPercent(10f);
|
||||||
|
root_child0.setMaxWidthPercent(10f);
|
||||||
|
root_child0.setMinHeightPercent(10f);
|
||||||
|
root_child0.setMaxHeightPercent(10f);
|
||||||
|
root.addChildAt(root_child0, 0);
|
||||||
|
root.setDirection(YogaDirection.LTR);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
root.setDirection(YogaDirection.RTL);
|
||||||
|
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||||
|
|
||||||
|
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||||
|
|
||||||
|
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
|
||||||
|
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
|
||||||
|
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -682,3 +682,141 @@ it("flex_grow_within_constrained_max_column", 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("min_width_overrides_width", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(50);
|
||||||
|
root.setMinWidth(100);
|
||||||
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("max_width_overrides_width", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setWidth(200);
|
||||||
|
root.setMaxWidth(100);
|
||||||
|
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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.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(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(0 === root.getComputedHeight(), "0 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("min_height_overrides_height", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setHeight(50);
|
||||||
|
root.setMinHeight(100);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("max_height_overrides_height", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setHeight(200);
|
||||||
|
root.setMaxHeight(100);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(0 === root.getComputedWidth(), "0 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
it("min_max_percent_no_width_height", function () {
|
||||||
|
var root = Yoga.Node.create();
|
||||||
|
root.setAlignItems(Yoga.ALIGN_FLEX_START);
|
||||||
|
root.setWidth(100);
|
||||||
|
root.setHeight(100);
|
||||||
|
|
||||||
|
var root_child0 = Yoga.Node.create();
|
||||||
|
root_child0.setMinWidth("10%");
|
||||||
|
root_child0.setMaxWidth("10%");
|
||||||
|
root_child0.setMinHeight("10%");
|
||||||
|
root_child0.setMaxHeight("10%");
|
||||||
|
root.insertChild(root_child0, 0);
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_LTR);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(0 === root_child0.getComputedLeft(), "0 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
root.calculateLayout(Yoga.UNDEFINED, Yoga.UNDEFINED, Yoga.DIRECTION_RTL);
|
||||||
|
|
||||||
|
console.assert(0 === root.getComputedLeft(), "0 === root.getComputedLeft() (" + root.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root.getComputedTop(), "0 === root.getComputedTop() (" + root.getComputedTop() + ")");
|
||||||
|
console.assert(100 === root.getComputedWidth(), "100 === root.getComputedWidth() (" + root.getComputedWidth() + ")");
|
||||||
|
console.assert(100 === root.getComputedHeight(), "100 === root.getComputedHeight() (" + root.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
console.assert(90 === root_child0.getComputedLeft(), "90 === root_child0.getComputedLeft() (" + root_child0.getComputedLeft() + ")");
|
||||||
|
console.assert(0 === root_child0.getComputedTop(), "0 === root_child0.getComputedTop() (" + root_child0.getComputedTop() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedWidth(), "10 === root_child0.getComputedWidth() (" + root_child0.getComputedWidth() + ")");
|
||||||
|
console.assert(10 === root_child0.getComputedHeight(), "10 === root_child0.getComputedHeight() (" + root_child0.getComputedHeight() + ")");
|
||||||
|
|
||||||
|
if (typeof root !== "undefined")
|
||||||
|
root.freeRecursive();
|
||||||
|
|
||||||
|
(typeof gc !== "undefined") && gc();
|
||||||
|
console.assert(0 === Yoga.getInstanceCount(), "0 === Yoga.getInstanceCount() (" + Yoga.getInstanceCount() + ")");
|
||||||
|
});
|
||||||
|
@@ -123,7 +123,7 @@ TEST(YogaTest, dont_measure_when_min_equals_max_percentages) {
|
|||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(YogaTest, dont_measure_when_min_equals_max_mixed) {
|
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_width_percent) {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||||
YGNodeStyleSetWidth(root, 100);
|
YGNodeStyleSetWidth(root, 100);
|
||||||
@@ -151,7 +151,7 @@ TEST(YogaTest, dont_measure_when_min_equals_max_mixed) {
|
|||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_2) {
|
TEST(YogaTest, dont_measure_when_min_equals_max_mixed_height_percent) {
|
||||||
const YGNodeRef root = YGNodeNew();
|
const YGNodeRef root = YGNodeNew();
|
||||||
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||||
YGNodeStyleSetWidth(root, 100);
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
@@ -643,3 +643,126 @@ TEST(YogaTest, flex_grow_within_constrained_max_column) {
|
|||||||
|
|
||||||
YGNodeFreeRecursive(root);
|
YGNodeFreeRecursive(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, min_width_overrides_width) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 50);
|
||||||
|
YGNodeStyleSetMinWidth(root, 100);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, max_width_overrides_width) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetWidth(root, 200);
|
||||||
|
YGNodeStyleSetMaxWidth(root, 100);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, min_height_overrides_height) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetHeight(root, 50);
|
||||||
|
YGNodeStyleSetMinHeight(root, 100);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, max_height_overrides_height) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetHeight(root, 200);
|
||||||
|
YGNodeStyleSetMaxHeight(root, 100);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(YogaTest, min_max_percent_no_width_height) {
|
||||||
|
const YGNodeRef root = YGNodeNew();
|
||||||
|
YGNodeStyleSetAlignItems(root, YGAlignFlexStart);
|
||||||
|
YGNodeStyleSetWidth(root, 100);
|
||||||
|
YGNodeStyleSetHeight(root, 100);
|
||||||
|
|
||||||
|
const YGNodeRef root_child0 = YGNodeNew();
|
||||||
|
YGNodeStyleSetMinWidthPercent(root_child0, 10);
|
||||||
|
YGNodeStyleSetMaxWidthPercent(root_child0, 10);
|
||||||
|
YGNodeStyleSetMinHeightPercent(root_child0, 10);
|
||||||
|
YGNodeStyleSetMaxHeightPercent(root_child0, 10);
|
||||||
|
YGNodeInsertChild(root, root_child0, 0);
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
||||||
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
||||||
|
|
||||||
|
ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
|
||||||
|
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
|
||||||
|
|
||||||
|
YGNodeFreeRecursive(root);
|
||||||
|
}
|
||||||
|
111
yoga/YGEnums.h
111
yoga/YGEnums.h
@@ -15,21 +15,26 @@ YG_EXTERN_C_BEGIN
|
|||||||
|
|
||||||
#define YGAlignCount 6
|
#define YGAlignCount 6
|
||||||
typedef YG_ENUM_BEGIN(YGAlign) {
|
typedef YG_ENUM_BEGIN(YGAlign) {
|
||||||
YGAlignAuto, YGAlignFlexStart, YGAlignCenter, YGAlignFlexEnd, YGAlignStretch, YGAlignBaseline,
|
YGAlignAuto,
|
||||||
}
|
YGAlignFlexStart,
|
||||||
YG_ENUM_END(YGAlign);
|
YGAlignCenter,
|
||||||
|
YGAlignFlexEnd,
|
||||||
|
YGAlignStretch,
|
||||||
|
YGAlignBaseline,
|
||||||
|
} YG_ENUM_END(YGAlign);
|
||||||
|
|
||||||
#define YGDimensionCount 2
|
#define YGDimensionCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDimension) {
|
typedef YG_ENUM_BEGIN(YGDimension) {
|
||||||
YGDimensionWidth, YGDimensionHeight,
|
YGDimensionWidth,
|
||||||
}
|
YGDimensionHeight,
|
||||||
YG_ENUM_END(YGDimension);
|
} YG_ENUM_END(YGDimension);
|
||||||
|
|
||||||
#define YGDirectionCount 3
|
#define YGDirectionCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGDirection) {
|
typedef YG_ENUM_BEGIN(YGDirection) {
|
||||||
YGDirectionInherit, YGDirectionLTR, YGDirectionRTL,
|
YGDirectionInherit,
|
||||||
}
|
YGDirectionLTR,
|
||||||
YG_ENUM_END(YGDirection);
|
YGDirectionRTL,
|
||||||
|
} YG_ENUM_END(YGDirection);
|
||||||
|
|
||||||
#define YGDisplayCount 2
|
#define YGDisplayCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGDisplay) {
|
typedef YG_ENUM_BEGIN(YGDisplay) {
|
||||||
@@ -39,71 +44,87 @@ typedef YG_ENUM_BEGIN(YGDisplay) {
|
|||||||
|
|
||||||
#define YGEdgeCount 9
|
#define YGEdgeCount 9
|
||||||
typedef YG_ENUM_BEGIN(YGEdge) {
|
typedef YG_ENUM_BEGIN(YGEdge) {
|
||||||
YGEdgeLeft, YGEdgeTop, YGEdgeRight, YGEdgeBottom, YGEdgeStart, YGEdgeEnd, YGEdgeHorizontal,
|
YGEdgeLeft,
|
||||||
YGEdgeVertical, YGEdgeAll,
|
YGEdgeTop,
|
||||||
}
|
YGEdgeRight,
|
||||||
YG_ENUM_END(YGEdge);
|
YGEdgeBottom,
|
||||||
|
YGEdgeStart,
|
||||||
|
YGEdgeEnd,
|
||||||
|
YGEdgeHorizontal,
|
||||||
|
YGEdgeVertical,
|
||||||
|
YGEdgeAll,
|
||||||
|
} YG_ENUM_END(YGEdge);
|
||||||
|
|
||||||
#define YGExperimentalFeatureCount 2
|
#define YGExperimentalFeatureCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
typedef YG_ENUM_BEGIN(YGExperimentalFeature) {
|
||||||
YGExperimentalFeatureRounding, YGExperimentalFeatureWebFlexBasis,
|
YGExperimentalFeatureRounding,
|
||||||
}
|
YGExperimentalFeatureWebFlexBasis,
|
||||||
YG_ENUM_END(YGExperimentalFeature);
|
} YG_ENUM_END(YGExperimentalFeature);
|
||||||
|
|
||||||
#define YGFlexDirectionCount 4
|
#define YGFlexDirectionCount 4
|
||||||
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
typedef YG_ENUM_BEGIN(YGFlexDirection) {
|
||||||
YGFlexDirectionColumn, YGFlexDirectionColumnReverse, YGFlexDirectionRow,
|
YGFlexDirectionColumn,
|
||||||
YGFlexDirectionRowReverse,
|
YGFlexDirectionColumnReverse,
|
||||||
}
|
YGFlexDirectionRow,
|
||||||
YG_ENUM_END(YGFlexDirection);
|
YGFlexDirectionRowReverse,
|
||||||
|
} YG_ENUM_END(YGFlexDirection);
|
||||||
|
|
||||||
#define YGJustifyCount 5
|
#define YGJustifyCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGJustify) {
|
typedef YG_ENUM_BEGIN(YGJustify) {
|
||||||
YGJustifyFlexStart, YGJustifyCenter, YGJustifyFlexEnd, YGJustifySpaceBetween,
|
YGJustifyFlexStart,
|
||||||
YGJustifySpaceAround,
|
YGJustifyCenter,
|
||||||
}
|
YGJustifyFlexEnd,
|
||||||
YG_ENUM_END(YGJustify);
|
YGJustifySpaceBetween,
|
||||||
|
YGJustifySpaceAround,
|
||||||
|
} YG_ENUM_END(YGJustify);
|
||||||
|
|
||||||
#define YGLogLevelCount 5
|
#define YGLogLevelCount 5
|
||||||
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
typedef YG_ENUM_BEGIN(YGLogLevel) {
|
||||||
YGLogLevelError, YGLogLevelWarn, YGLogLevelInfo, YGLogLevelDebug, YGLogLevelVerbose,
|
YGLogLevelError,
|
||||||
}
|
YGLogLevelWarn,
|
||||||
YG_ENUM_END(YGLogLevel);
|
YGLogLevelInfo,
|
||||||
|
YGLogLevelDebug,
|
||||||
|
YGLogLevelVerbose,
|
||||||
|
} YG_ENUM_END(YGLogLevel);
|
||||||
|
|
||||||
#define YGMeasureModeCount 3
|
#define YGMeasureModeCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
typedef YG_ENUM_BEGIN(YGMeasureMode) {
|
||||||
YGMeasureModeUndefined, YGMeasureModeExactly, YGMeasureModeAtMost,
|
YGMeasureModeUndefined,
|
||||||
}
|
YGMeasureModeExactly,
|
||||||
YG_ENUM_END(YGMeasureMode);
|
YGMeasureModeAtMost,
|
||||||
|
} YG_ENUM_END(YGMeasureMode);
|
||||||
|
|
||||||
#define YGOverflowCount 3
|
#define YGOverflowCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGOverflow) {
|
typedef YG_ENUM_BEGIN(YGOverflow) {
|
||||||
YGOverflowVisible, YGOverflowHidden, YGOverflowScroll,
|
YGOverflowVisible,
|
||||||
}
|
YGOverflowHidden,
|
||||||
YG_ENUM_END(YGOverflow);
|
YGOverflowScroll,
|
||||||
|
} YG_ENUM_END(YGOverflow);
|
||||||
|
|
||||||
#define YGPositionTypeCount 2
|
#define YGPositionTypeCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGPositionType) {
|
typedef YG_ENUM_BEGIN(YGPositionType) {
|
||||||
YGPositionTypeRelative, YGPositionTypeAbsolute,
|
YGPositionTypeRelative,
|
||||||
}
|
YGPositionTypeAbsolute,
|
||||||
YG_ENUM_END(YGPositionType);
|
} YG_ENUM_END(YGPositionType);
|
||||||
|
|
||||||
#define YGPrintOptionsCount 3
|
#define YGPrintOptionsCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
typedef YG_ENUM_BEGIN(YGPrintOptions) {
|
||||||
YGPrintOptionsLayout = 1, YGPrintOptionsStyle = 2, YGPrintOptionsChildren = 4,
|
YGPrintOptionsLayout = 1,
|
||||||
}
|
YGPrintOptionsStyle = 2,
|
||||||
YG_ENUM_END(YGPrintOptions);
|
YGPrintOptionsChildren = 4,
|
||||||
|
} YG_ENUM_END(YGPrintOptions);
|
||||||
|
|
||||||
#define YGUnitCount 3
|
#define YGUnitCount 3
|
||||||
typedef YG_ENUM_BEGIN(YGUnit) {
|
typedef YG_ENUM_BEGIN(YGUnit) {
|
||||||
YGUnitUndefined, YGUnitPixel, YGUnitPercent,
|
YGUnitUndefined,
|
||||||
}
|
YGUnitPixel,
|
||||||
YG_ENUM_END(YGUnit);
|
YGUnitPercent,
|
||||||
|
} YG_ENUM_END(YGUnit);
|
||||||
|
|
||||||
#define YGWrapCount 2
|
#define YGWrapCount 2
|
||||||
typedef YG_ENUM_BEGIN(YGWrap) {
|
typedef YG_ENUM_BEGIN(YGWrap) {
|
||||||
YGWrapNoWrap, YGWrapWrap,
|
YGWrapNoWrap,
|
||||||
}
|
YGWrapWrap,
|
||||||
YG_ENUM_END(YGWrap);
|
} YG_ENUM_END(YGWrap);
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
YG_EXTERN_C_END
|
||||||
|
48
yoga/Yoga.c
48
yoga/Yoga.c
@@ -641,13 +641,11 @@ static inline bool YGValueEqual(const YGValue a, const YGValue b) {
|
|||||||
|
|
||||||
static inline void YGResolveDimensions(YGNodeRef node) {
|
static inline void YGResolveDimensions(YGNodeRef node) {
|
||||||
for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) {
|
for (YGDimension dim = YGDimensionWidth; dim <= YGDimensionHeight; dim++) {
|
||||||
if (node->style.dimensions[dim].unit != YGUnitUndefined) {
|
if (node->style.maxDimensions[dim].unit != YGUnitUndefined &&
|
||||||
node->resolvedDimensions[dim] = node->style.dimensions[dim];
|
YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) {
|
||||||
|
node->resolvedDimensions[dim] = node->style.maxDimensions[dim];
|
||||||
} else {
|
} else {
|
||||||
if (node->style.maxDimensions[dim].unit != YGUnitUndefined &&
|
node->resolvedDimensions[dim] = node->style.dimensions[dim];
|
||||||
YGValueEqual(node->style.maxDimensions[dim], node->style.minDimensions[dim])) {
|
|
||||||
node->resolvedDimensions[dim] = node->style.maxDimensions[dim];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1167,14 +1165,13 @@ static float YGNodeBoundAxisWithinMinAndMax(const YGNodeRef node,
|
|||||||
const float axisSize) {
|
const float axisSize) {
|
||||||
float min = YGUndefined;
|
float min = YGUndefined;
|
||||||
float max = YGUndefined;
|
float max = YGUndefined;
|
||||||
if (!YGNodeIsStyleDimDefined(node, axis, axisSize)) {
|
|
||||||
if (YGFlexDirectionIsColumn(axis)) {
|
if (YGFlexDirectionIsColumn(axis)) {
|
||||||
min = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], axisSize);
|
min = YGValueResolve(&node->style.minDimensions[YGDimensionHeight], axisSize);
|
||||||
max = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], axisSize);
|
max = YGValueResolve(&node->style.maxDimensions[YGDimensionHeight], axisSize);
|
||||||
} else if (YGFlexDirectionIsRow(axis)) {
|
} else if (YGFlexDirectionIsRow(axis)) {
|
||||||
min = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], axisSize);
|
min = YGValueResolve(&node->style.minDimensions[YGDimensionWidth], axisSize);
|
||||||
max = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], axisSize);
|
max = YGValueResolve(&node->style.maxDimensions[YGDimensionWidth], axisSize);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float boundValue = value;
|
float boundValue = value;
|
||||||
@@ -1545,7 +1542,9 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
|
|||||||
const float availableWidth,
|
const float availableWidth,
|
||||||
const float availableHeight,
|
const float availableHeight,
|
||||||
const YGMeasureMode widthMeasureMode,
|
const YGMeasureMode widthMeasureMode,
|
||||||
const YGMeasureMode heightMeasureMode) {
|
const YGMeasureMode heightMeasureMode,
|
||||||
|
const float parentWidth,
|
||||||
|
const float parentHeight) {
|
||||||
YG_ASSERT(node->measure, "Expected node to have custom measure function");
|
YG_ASSERT(node->measure, "Expected node to have custom measure function");
|
||||||
|
|
||||||
const float paddingAndBorderAxisRow =
|
const float paddingAndBorderAxisRow =
|
||||||
@@ -1561,13 +1560,9 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(const YGNodeRef node,
|
|||||||
if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) {
|
if (widthMeasureMode == YGMeasureModeExactly && heightMeasureMode == YGMeasureModeExactly) {
|
||||||
// Don't bother sizing the text if both dimensions are already defined.
|
// Don't bother sizing the text if both dimensions are already defined.
|
||||||
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
node->layout.measuredDimensions[YGDimensionWidth] = YGNodeBoundAxis(
|
||||||
node, YGFlexDirectionRow, availableWidth - marginAxisRow, availableWidth, availableWidth);
|
node, YGFlexDirectionRow, availableWidth - marginAxisRow, parentWidth, parentWidth);
|
||||||
node->layout.measuredDimensions[YGDimensionHeight] =
|
node->layout.measuredDimensions[YGDimensionHeight] = YGNodeBoundAxis(
|
||||||
YGNodeBoundAxis(node,
|
node, YGFlexDirectionColumn, availableHeight - marginAxisColumn, parentHeight, parentWidth);
|
||||||
YGFlexDirectionColumn,
|
|
||||||
availableHeight - marginAxisColumn,
|
|
||||||
availableHeight,
|
|
||||||
availableWidth);
|
|
||||||
} else if (innerWidth <= 0.0f || innerHeight <= 0.0f) {
|
} else if (innerWidth <= 0.0f || innerHeight <= 0.0f) {
|
||||||
// Don't bother sizing the text if there's no horizontal or vertical
|
// Don't bother sizing the text if there's no horizontal or vertical
|
||||||
// space.
|
// space.
|
||||||
@@ -1841,8 +1836,13 @@ static void YGNodelayoutImpl(const YGNodeRef node,
|
|||||||
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
YGNodeTrailingPadding(node, flexColumnDirection, parentWidth);
|
||||||
|
|
||||||
if (node->measure) {
|
if (node->measure) {
|
||||||
YGNodeWithMeasureFuncSetMeasuredDimensions(
|
YGNodeWithMeasureFuncSetMeasuredDimensions(node,
|
||||||
node, availableWidth, availableHeight, widthMeasureMode, heightMeasureMode);
|
availableWidth,
|
||||||
|
availableHeight,
|
||||||
|
widthMeasureMode,
|
||||||
|
heightMeasureMode,
|
||||||
|
parentWidth,
|
||||||
|
parentHeight);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user