passing height to the measure function
This diff: * adds height as another parameter passed to the measure function, computed the same way width is * adds tests for this extension, which has involved adding a new measure function to all of js, c, java and c# tests
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Facebook.CSSLayout.Tests
|
||||
CSSNode parent = new CSSNode();
|
||||
CSSNode child = new CSSNode();
|
||||
|
||||
Assert.Null(child.getParent());
|
||||
Assert.IsNull(child.getParent());
|
||||
Assert.AreEqual(0, parent.getChildCount());
|
||||
|
||||
parent.addChildAt(child, 0);
|
||||
@@ -35,7 +35,7 @@ namespace Facebook.CSSLayout.Tests
|
||||
|
||||
parent.removeChildAt(0);
|
||||
|
||||
Assert.Null(child.getParent());
|
||||
Assert.IsNull(child.getParent());
|
||||
Assert.AreEqual(0, parent.getChildCount());
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ namespace Facebook.CSSLayout.Tests
|
||||
markLayoutAppliedForTree(root);
|
||||
|
||||
root.calculateLayout();
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
assertTreeHasNewLayout(false, c0);
|
||||
assertTreeHasNewLayout(false, c1);
|
||||
}
|
||||
@@ -81,14 +81,14 @@ namespace Facebook.CSSLayout.Tests
|
||||
c0.addChildAt(c0c1, 1);
|
||||
|
||||
root.calculateLayout();
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.True(c0c1.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsTrue(c0c1.HasNewLayout);
|
||||
|
||||
Assert.True(c0c0.HasNewLayout);
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.IsTrue(c0c0.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
|
||||
Assert.False(c1c0.HasNewLayout);
|
||||
Assert.IsFalse(c1c0.HasNewLayout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -108,11 +108,11 @@ namespace Facebook.CSSLayout.Tests
|
||||
c1.AlignSelf = CSSAlign.Center;
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.False(c0c0.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsFalse(c0c0.HasNewLayout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -132,11 +132,11 @@ namespace Facebook.CSSLayout.Tests
|
||||
c1.SetMargin(CSSSpacingType.Left, 10);
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.False(c0c0.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsFalse(c0c0.HasNewLayout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -158,12 +158,12 @@ namespace Facebook.CSSLayout.Tests
|
||||
c0.Height = 200;
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.True(c0c0.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsTrue(c0c0.HasNewLayout);
|
||||
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.False(c1c0.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
Assert.IsFalse(c1c0.HasNewLayout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -184,7 +184,7 @@ namespace Facebook.CSSLayout.Tests
|
||||
root.Width = 200;
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
assertTreeHasNewLayout(false, c0);
|
||||
assertTreeHasNewLayout(false, c1);
|
||||
}
|
||||
@@ -206,10 +206,10 @@ namespace Facebook.CSSLayout.Tests
|
||||
c0.Height = 100;
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.False(c1c0.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
Assert.IsFalse(c1c0.HasNewLayout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -226,15 +226,15 @@ namespace Facebook.CSSLayout.Tests
|
||||
root.calculateLayout();
|
||||
markLayoutAppliedForTree(root);
|
||||
|
||||
c1.setMeasureFunction((node, width) => new MeasureOutput(100, 20));
|
||||
c1.setMeasureFunction((node, width, height) => new MeasureOutput(100, 20));
|
||||
|
||||
root.calculateLayout();
|
||||
|
||||
Assert.True(root.HasNewLayout);
|
||||
Assert.True(c1.HasNewLayout);
|
||||
Assert.IsTrue(root.HasNewLayout);
|
||||
Assert.IsTrue(c1.HasNewLayout);
|
||||
|
||||
Assert.True(c0.HasNewLayout);
|
||||
Assert.False(c0c0.HasNewLayout);
|
||||
Assert.IsTrue(c0.HasNewLayout);
|
||||
Assert.IsFalse(c0c0.HasNewLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ using NUnit.Framework;
|
||||
|
||||
namespace Facebook.CSSLayout.Tests
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* Tests for {@link LayoutEngine}
|
||||
*/
|
||||
@@ -24,27 +24,35 @@ public class LayoutEngineTest
|
||||
const int POSITION_BOTTOM = CSSLayout.POSITION_BOTTOM;
|
||||
const int DIMENSION_HEIGHT = CSSLayout.DIMENSION_HEIGHT;
|
||||
const int DIMENSION_WIDTH = CSSLayout.DIMENSION_WIDTH;
|
||||
|
||||
static readonly MeasureFunction sTestMeasureFunction = (node, width) =>
|
||||
{
|
||||
if (CSSConstants.IsUndefined(width)) {
|
||||
width = 10000000;
|
||||
}
|
||||
|
||||
static readonly MeasureFunction sTestMeasureFunction = (node, width, height) =>
|
||||
{
|
||||
TestCSSNode testNode = (TestCSSNode) node;
|
||||
if (testNode.context.Equals(TestConstants.SMALL_TEXT))
|
||||
{
|
||||
if (testNode.context.Equals(TestConstants.SMALL_TEXT)) {
|
||||
if (CSSConstants.IsUndefined(width)) {
|
||||
width = 10000000;
|
||||
}
|
||||
return new MeasureOutput(
|
||||
Math.Min(width, TestConstants.SMALL_WIDTH),
|
||||
TestConstants.SMALL_HEIGHT);
|
||||
} else if (testNode.context.Equals(TestConstants.LONG_TEXT))
|
||||
{
|
||||
} else if (testNode.context.Equals(TestConstants.LONG_TEXT)) {
|
||||
if (CSSConstants.IsUndefined(width)) {
|
||||
width = 10000000;
|
||||
}
|
||||
return new MeasureOutput(width >= TestConstants.BIG_WIDTH
|
||||
? TestConstants.BIG_WIDTH
|
||||
: Math.Max(TestConstants.BIG_MIN_WIDTH, width),
|
||||
width >= TestConstants.BIG_WIDTH
|
||||
? TestConstants.SMALL_HEIGHT
|
||||
: TestConstants.BIG_HEIGHT);
|
||||
} else if (testNode.context.Equals(TestConstants.MEASURE_WITH_RATIO_2)) {
|
||||
if (width > 0) {
|
||||
return new MeasureOutput(width, width * 2);
|
||||
} else if (height > 0) {
|
||||
return new MeasureOutput(height * 2, height);
|
||||
} else {
|
||||
return new MeasureOutput(99999, 99999);
|
||||
}
|
||||
} else {
|
||||
throw new Exception("Got unknown test: " + testNode.context);
|
||||
}
|
||||
@@ -71,8 +79,8 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
private static void assertLayoutsEqual(String message, CSSNode actual, CSSNode expected) {
|
||||
Assert.True(
|
||||
areLayoutsEqual(actual, expected),
|
||||
Assert.IsTrue(
|
||||
areLayoutsEqual(actual, expected),
|
||||
message + "\nActual:\n" + actual.ToString() + "\nExpected:\n" + expected.ToString()
|
||||
);
|
||||
}
|
||||
@@ -4249,6 +4257,168 @@ public class LayoutEngineTest
|
||||
|
||||
[Test]
|
||||
public void TestCase95()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.dimensions[DIMENSION_WIDTH] = 100;
|
||||
node_0.setMeasureFunction(sTestMeasureFunction);
|
||||
node_0.context = "measureWithRatio2";
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.position[POSITION_TOP] = 0;
|
||||
node_0.layout.position[POSITION_LEFT] = 0;
|
||||
node_0.layout.dimensions[DIMENSION_WIDTH] = 100;
|
||||
node_0.layout.dimensions[DIMENSION_HEIGHT] = 200;
|
||||
}
|
||||
|
||||
test("should layout node with fixed width and custom measure function", root_node, root_layout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase96()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
node_0.setMeasureFunction(sTestMeasureFunction);
|
||||
node_0.context = "measureWithRatio2";
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.position[POSITION_TOP] = 0;
|
||||
node_0.layout.position[POSITION_LEFT] = 0;
|
||||
node_0.layout.dimensions[DIMENSION_WIDTH] = 200;
|
||||
node_0.layout.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
}
|
||||
|
||||
test("should layout node with fixed height and custom measure function", root_node, root_layout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase97()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.dimensions[DIMENSION_WIDTH] = 100;
|
||||
node_0.style.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
node_0.setMeasureFunction(sTestMeasureFunction);
|
||||
node_0.context = "measureWithRatio2";
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.position[POSITION_TOP] = 0;
|
||||
node_0.layout.position[POSITION_LEFT] = 0;
|
||||
node_0.layout.dimensions[DIMENSION_WIDTH] = 100;
|
||||
node_0.layout.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
}
|
||||
|
||||
test("should layout node with fixed height and fixed width, ignoring custom measure function", root_node, root_layout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase98()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.setMeasureFunction(sTestMeasureFunction);
|
||||
node_0.context = "measureWithRatio2";
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.position[POSITION_TOP] = 0;
|
||||
node_0.layout.position[POSITION_LEFT] = 0;
|
||||
node_0.layout.dimensions[DIMENSION_WIDTH] = 99999;
|
||||
node_0.layout.dimensions[DIMENSION_HEIGHT] = 99999;
|
||||
}
|
||||
|
||||
test("should layout node with no fixed dimension and custom measure function", root_node, root_layout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase99()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_node;
|
||||
node_0.style.flexDirection = CSSFlexDirection.Column;
|
||||
node_0.style.dimensions[DIMENSION_WIDTH] = 320;
|
||||
addChildren(node_0, 2);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.setMeasureFunction(sTestMeasureFunction);
|
||||
node_1.context = "measureWithRatio2";
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.style.flexDirection = CSSFlexDirection.Row;
|
||||
node_1.style.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
addChildren(node_1, 2);
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "measureWithRatio2";
|
||||
node_2 = node_1.getChildAt(1);
|
||||
node_2.setMeasureFunction(sTestMeasureFunction);
|
||||
node_2.context = "measureWithRatio2";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestCSSNode root_layout = new TestCSSNode();
|
||||
{
|
||||
TestCSSNode node_0 = root_layout;
|
||||
node_0.layout.position[POSITION_TOP] = 0;
|
||||
node_0.layout.position[POSITION_LEFT] = 0;
|
||||
node_0.layout.dimensions[DIMENSION_WIDTH] = 320;
|
||||
node_0.layout.dimensions[DIMENSION_HEIGHT] = 740;
|
||||
addChildren(node_0, 2);
|
||||
{
|
||||
TestCSSNode node_1;
|
||||
node_1 = node_0.getChildAt(0);
|
||||
node_1.layout.position[POSITION_TOP] = 0;
|
||||
node_1.layout.position[POSITION_LEFT] = 0;
|
||||
node_1.layout.dimensions[DIMENSION_WIDTH] = 320;
|
||||
node_1.layout.dimensions[DIMENSION_HEIGHT] = 640;
|
||||
node_1 = node_0.getChildAt(1);
|
||||
node_1.layout.position[POSITION_TOP] = 640;
|
||||
node_1.layout.position[POSITION_LEFT] = 0;
|
||||
node_1.layout.dimensions[DIMENSION_WIDTH] = 320;
|
||||
node_1.layout.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
addChildren(node_1, 2);
|
||||
{
|
||||
TestCSSNode node_2;
|
||||
node_2 = node_1.getChildAt(0);
|
||||
node_2.layout.position[POSITION_TOP] = 0;
|
||||
node_2.layout.position[POSITION_LEFT] = 0;
|
||||
node_2.layout.dimensions[DIMENSION_WIDTH] = 200;
|
||||
node_2.layout.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
node_2 = node_1.getChildAt(1);
|
||||
node_2.layout.position[POSITION_TOP] = 0;
|
||||
node_2.layout.position[POSITION_LEFT] = 200;
|
||||
node_2.layout.dimensions[DIMENSION_WIDTH] = 200;
|
||||
node_2.layout.dimensions[DIMENSION_HEIGHT] = 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with nested stacks and custom measure function", root_node, root_layout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase100()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4271,7 +4441,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase96()
|
||||
public void TestCase101()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4293,7 +4463,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase97()
|
||||
public void TestCase102()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4344,7 +4514,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase98()
|
||||
public void TestCase103()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4397,7 +4567,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase99()
|
||||
public void TestCase104()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4451,7 +4621,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase100()
|
||||
public void TestCase105()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4504,7 +4674,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase101()
|
||||
public void TestCase106()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4558,7 +4728,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase102()
|
||||
public void TestCase107()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4597,7 +4767,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase103()
|
||||
public void TestCase108()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4662,7 +4832,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase104()
|
||||
public void TestCase109()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4705,7 +4875,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase105()
|
||||
public void TestCase110()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4749,7 +4919,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase106()
|
||||
public void TestCase111()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4787,7 +4957,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase107()
|
||||
public void TestCase112()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4826,7 +4996,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase108()
|
||||
public void TestCase113()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4884,7 +5054,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase109()
|
||||
public void TestCase114()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -4943,7 +5113,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase110()
|
||||
public void TestCase115()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5000,7 +5170,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase111()
|
||||
public void TestCase116()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5041,7 +5211,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase112()
|
||||
public void TestCase117()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5088,7 +5258,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase113()
|
||||
public void TestCase118()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5136,7 +5306,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase114()
|
||||
public void TestCase119()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5184,7 +5354,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase115()
|
||||
public void TestCase120()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5229,7 +5399,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase116()
|
||||
public void TestCase121()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5267,7 +5437,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase117()
|
||||
public void TestCase122()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5325,7 +5495,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase118()
|
||||
public void TestCase123()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5362,7 +5532,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase119()
|
||||
public void TestCase124()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5399,7 +5569,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase120()
|
||||
public void TestCase125()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5437,7 +5607,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase121()
|
||||
public void TestCase126()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5475,7 +5645,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase122()
|
||||
public void TestCase127()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5512,7 +5682,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase123()
|
||||
public void TestCase128()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5549,7 +5719,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase124()
|
||||
public void TestCase129()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5585,7 +5755,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase125()
|
||||
public void TestCase130()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5621,7 +5791,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase126()
|
||||
public void TestCase131()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5657,7 +5827,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase127()
|
||||
public void TestCase132()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5693,7 +5863,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase128()
|
||||
public void TestCase133()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5743,7 +5913,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase129()
|
||||
public void TestCase134()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5798,7 +5968,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase130()
|
||||
public void TestCase135()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5854,7 +6024,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase131()
|
||||
public void TestCase136()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5898,7 +6068,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase132()
|
||||
public void TestCase137()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5922,7 +6092,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase133()
|
||||
public void TestCase138()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5946,7 +6116,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase134()
|
||||
public void TestCase139()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5972,7 +6142,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase135()
|
||||
public void TestCase140()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -5998,7 +6168,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase136()
|
||||
public void TestCase141()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6022,7 +6192,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase137()
|
||||
public void TestCase142()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6046,7 +6216,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase138()
|
||||
public void TestCase143()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6072,7 +6242,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase139()
|
||||
public void TestCase144()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6098,7 +6268,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase140()
|
||||
public void TestCase145()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6151,7 +6321,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase141()
|
||||
public void TestCase146()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6205,7 +6375,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase142()
|
||||
public void TestCase147()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6259,7 +6429,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase143()
|
||||
public void TestCase148()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6314,7 +6484,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase144()
|
||||
public void TestCase149()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6367,7 +6537,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase145()
|
||||
public void TestCase150()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6421,7 +6591,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase146()
|
||||
public void TestCase151()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6476,7 +6646,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase147()
|
||||
public void TestCase152()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6532,7 +6702,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase148()
|
||||
public void TestCase153()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6587,7 +6757,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase149()
|
||||
public void TestCase154()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6643,7 +6813,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase150()
|
||||
public void TestCase155()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6682,7 +6852,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase151()
|
||||
public void TestCase156()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6720,7 +6890,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase152()
|
||||
public void TestCase157()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6758,7 +6928,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase153()
|
||||
public void TestCase158()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6806,7 +6976,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase154()
|
||||
public void TestCase159()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6852,7 +7022,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase155()
|
||||
public void TestCase160()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6898,7 +7068,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase156()
|
||||
public void TestCase161()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6939,7 +7109,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase157()
|
||||
public void TestCase162()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -6978,7 +7148,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase158()
|
||||
public void TestCase163()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7017,7 +7187,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase159()
|
||||
public void TestCase164()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7056,7 +7226,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase160()
|
||||
public void TestCase165()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7096,7 +7266,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase161()
|
||||
public void TestCase166()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7139,7 +7309,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase162()
|
||||
public void TestCase167()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7182,7 +7352,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase163()
|
||||
public void TestCase168()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7248,7 +7418,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase164()
|
||||
public void TestCase169()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7320,7 +7490,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase165()
|
||||
public void TestCase170()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7382,7 +7552,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase166()
|
||||
public void TestCase171()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7476,7 +7646,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase167()
|
||||
public void TestCase172()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7557,7 +7727,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase168()
|
||||
public void TestCase173()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7597,7 +7767,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase169()
|
||||
public void TestCase174()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7637,7 +7807,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase170()
|
||||
public void TestCase175()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7677,7 +7847,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase171()
|
||||
public void TestCase176()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7715,7 +7885,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase172()
|
||||
public void TestCase177()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7754,7 +7924,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase173()
|
||||
public void TestCase178()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7792,7 +7962,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase174()
|
||||
public void TestCase179()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7831,7 +8001,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase175()
|
||||
public void TestCase180()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7869,7 +8039,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase176()
|
||||
public void TestCase181()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7908,7 +8078,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase177()
|
||||
public void TestCase182()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -7944,7 +8114,7 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCase178()
|
||||
public void TestCase183()
|
||||
{
|
||||
TestCSSNode root_node = new TestCSSNode();
|
||||
{
|
||||
@@ -8193,4 +8363,3 @@ public class LayoutEngineTest
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -23,6 +23,7 @@ namespace Facebook.CSSLayout.Tests
|
||||
public static readonly float BIG_MIN_WIDTH = 100f;
|
||||
public static readonly string SMALL_TEXT = "small";
|
||||
public static readonly string LONG_TEXT = "loooooooooong with space";
|
||||
public static readonly string MEASURE_WITH_RATIO_2 = "measureWithRatio2";
|
||||
/** END_GENERATED **/
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ namespace Facebook.CSSLayout
|
||||
* Should measure the given node and put the result in the given MeasureOutput.
|
||||
*/
|
||||
|
||||
public delegate MeasureOutput MeasureFunction(CSSNode node, float width);
|
||||
public delegate MeasureOutput MeasureFunction(CSSNode node, float width, float height);
|
||||
|
||||
/**
|
||||
* A CSS Node. It has a style object you can manipulate at {@link #style}. After calling
|
||||
@@ -140,13 +140,13 @@ namespace Facebook.CSSLayout
|
||||
get { return mMeasureFunction != null; }
|
||||
}
|
||||
|
||||
internal MeasureOutput measure(MeasureOutput measureOutput, float width)
|
||||
internal MeasureOutput measure(MeasureOutput measureOutput, float width, float height)
|
||||
{
|
||||
if (!IsMeasureDefined)
|
||||
{
|
||||
throw new Exception("Measure function isn't defined!");
|
||||
}
|
||||
return Assertions.assertNotNull(mMeasureFunction)(this, width);
|
||||
return Assertions.assertNotNull(mMeasureFunction)(this, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ namespace Facebook.CSSLayout
|
||||
public void CalculateLayout()
|
||||
{
|
||||
layout.resetResult();
|
||||
LayoutEngine.layoutNode(DummyLayoutContext, this, CSSConstants.Undefined, null);
|
||||
LayoutEngine.layoutNode(DummyLayoutContext, this, CSSConstants.Undefined, CSSConstants.Undefined, null);
|
||||
}
|
||||
|
||||
static readonly CSSLayoutContext DummyLayoutContext = new CSSLayoutContext();
|
||||
@@ -469,10 +469,10 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
/*
|
||||
Explicitly mark this node as dirty.
|
||||
|
||||
|
||||
Calling this function is required when the measure function points to the same instance,
|
||||
but changes its behavior.
|
||||
|
||||
|
||||
For all other property changes, the node is automatically marked dirty.
|
||||
*/
|
||||
|
||||
|
@@ -20,5 +20,6 @@ namespace Facebook.CSSLayout
|
||||
public float requestedWidth = CSSConstants.Undefined;
|
||||
public float requestedHeight = CSSConstants.Undefined;
|
||||
public float parentMaxWidth = CSSConstants.Undefined;
|
||||
public float parentMaxHeight = CSSConstants.Undefined;
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ namespace Facebook.CSSLayout
|
||||
{
|
||||
|
||||
/**
|
||||
* Calculates layouts based on CSS style. See {@link #layoutNode(CSSNode, float)}.
|
||||
* Calculates layouts based on CSS style. See {@link #layoutNode(CSSNode, float, float)}.
|
||||
*/
|
||||
|
||||
static class LayoutEngine
|
||||
@@ -205,7 +205,7 @@ namespace Facebook.CSSLayout
|
||||
return node.IsMeasureDefined;
|
||||
}
|
||||
|
||||
static boolean needsRelayout(CSSNode node, float parentMaxWidth)
|
||||
static boolean needsRelayout(CSSNode node, float parentMaxWidth, float parentMaxHeight)
|
||||
{
|
||||
return node.isDirty() ||
|
||||
!FloatUtil.floatsEqual(
|
||||
@@ -214,18 +214,20 @@ namespace Facebook.CSSLayout
|
||||
!FloatUtil.floatsEqual(
|
||||
node.lastLayout.requestedWidth,
|
||||
node.layout.dimensions[DIMENSION_WIDTH]) ||
|
||||
!FloatUtil.floatsEqual(node.lastLayout.parentMaxWidth, parentMaxWidth);
|
||||
!FloatUtil.floatsEqual(node.lastLayout.parentMaxWidth, parentMaxWidth) ||
|
||||
!FloatUtil.floatsEqual(node.lastLayout.parentMaxHeight, parentMaxHeight);
|
||||
}
|
||||
|
||||
internal static void layoutNode(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, CSSDirection? parentDirection)
|
||||
internal static void layoutNode(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, float parentMaxHeight, CSSDirection? parentDirection)
|
||||
{
|
||||
if (needsRelayout(node, parentMaxWidth))
|
||||
if (needsRelayout(node, parentMaxWidth, parentMaxHeight))
|
||||
{
|
||||
node.lastLayout.requestedWidth = node.layout.dimensions[DIMENSION_WIDTH];
|
||||
node.lastLayout.requestedHeight = node.layout.dimensions[DIMENSION_HEIGHT];
|
||||
node.lastLayout.parentMaxWidth = parentMaxWidth;
|
||||
node.lastLayout.parentMaxHeight = parentMaxHeight;
|
||||
|
||||
layoutNodeImpl(layoutContext, node, parentMaxWidth, parentDirection);
|
||||
layoutNodeImpl(layoutContext, node, parentMaxWidth, parentMaxHeight, parentDirection);
|
||||
node.lastLayout.copy(node.layout);
|
||||
}
|
||||
else
|
||||
@@ -236,7 +238,7 @@ namespace Facebook.CSSLayout
|
||||
node.markHasNewLayout();
|
||||
}
|
||||
|
||||
static void layoutNodeImpl(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, CSSDirection? parentDirection)
|
||||
static void layoutNodeImpl(CSSLayoutContext layoutContext, CSSNode node, float parentMaxWidth, float parentMaxHeight, CSSDirection? parentDirection)
|
||||
{
|
||||
var childCount_ = node.getChildCount();
|
||||
for (int i_ = 0; i_ < childCount_; i_++)
|
||||
@@ -274,6 +276,7 @@ namespace Facebook.CSSLayout
|
||||
// invocations during the layout calculation.
|
||||
int childCount = node.getChildCount();
|
||||
float paddingAndBorderAxisResolvedRow = ((node.style.padding.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.border.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis])) + (node.style.padding.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]) + node.style.border.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])));
|
||||
float paddingAndBorderAxisColumn = ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
||||
|
||||
if (isMeasureDefined(node)) {
|
||||
boolean isResolvedRowDimDefined = !float.IsNaN(node.layout.dimensions[dim[resolvedRowAxis]]);
|
||||
@@ -289,6 +292,17 @@ namespace Facebook.CSSLayout
|
||||
}
|
||||
width -= paddingAndBorderAxisResolvedRow;
|
||||
|
||||
float height = CSSConstants.Undefined;
|
||||
if ((!float.IsNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
|
||||
height = node.style.dimensions[DIMENSION_HEIGHT];
|
||||
} else if (!float.IsNaN(node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]])) {
|
||||
height = node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]];
|
||||
} else {
|
||||
height = parentMaxHeight -
|
||||
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis]));
|
||||
}
|
||||
height -= ((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
||||
|
||||
// We only need to give a dimension for the text if we haven't got any
|
||||
// for it computed yet. It can either be from the style attribute or because
|
||||
// the element is flexible.
|
||||
@@ -301,7 +315,8 @@ namespace Facebook.CSSLayout
|
||||
MeasureOutput measureDim = node.measure(
|
||||
|
||||
layoutContext.measureOutput,
|
||||
width
|
||||
width,
|
||||
height
|
||||
);
|
||||
if (isRowUndefined) {
|
||||
node.layout.dimensions[DIMENSION_WIDTH] = measureDim.width +
|
||||
@@ -309,7 +324,7 @@ namespace Facebook.CSSLayout
|
||||
}
|
||||
if (isColumnUndefined) {
|
||||
node.layout.dimensions[DIMENSION_HEIGHT] = measureDim.height +
|
||||
((node.style.padding.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN])) + (node.style.padding.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN]) + node.style.border.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])));
|
||||
paddingAndBorderAxisColumn;
|
||||
}
|
||||
}
|
||||
if (childCount == 0) {
|
||||
@@ -390,6 +405,7 @@ namespace Facebook.CSSLayout
|
||||
float crossDim = 0;
|
||||
|
||||
float maxWidth;
|
||||
float maxHeight;
|
||||
for (i = startLine; i < childCount; ++i) {
|
||||
child = node.getChildAt(i);
|
||||
child.lineIndex = linesCount;
|
||||
@@ -470,6 +486,8 @@ namespace Facebook.CSSLayout
|
||||
|
||||
} else {
|
||||
maxWidth = CSSConstants.Undefined;
|
||||
maxHeight = CSSConstants.Undefined;
|
||||
|
||||
if (!isMainRowDirection) {
|
||||
if ((!float.IsNaN(node.style.dimensions[dim[resolvedRowAxis]]) && node.style.dimensions[dim[resolvedRowAxis]] >= 0.0)) {
|
||||
maxWidth = node.layout.dimensions[dim[resolvedRowAxis]] -
|
||||
@@ -479,11 +497,20 @@ namespace Facebook.CSSLayout
|
||||
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])) -
|
||||
paddingAndBorderAxisResolvedRow;
|
||||
}
|
||||
} else {
|
||||
if ((!float.IsNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
|
||||
maxHeight = node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] -
|
||||
paddingAndBorderAxisColumn;
|
||||
} else {
|
||||
maxHeight = parentMaxHeight -
|
||||
(node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) -
|
||||
paddingAndBorderAxisColumn;
|
||||
}
|
||||
}
|
||||
|
||||
// This is the main recursive call. We layout non flexible children.
|
||||
if (alreadyComputedNextLayout == 0) {
|
||||
layoutNode(layoutContext, child, maxWidth, direction);
|
||||
layoutNode(layoutContext, child, maxWidth, maxHeight, direction);
|
||||
}
|
||||
|
||||
// Absolute positioned elements do not take part of the layout, so we
|
||||
@@ -613,9 +640,18 @@ namespace Facebook.CSSLayout
|
||||
(node.style.margin.getWithFallback(leadingSpacing[resolvedRowAxis], leading[resolvedRowAxis]) + node.style.margin.getWithFallback(trailingSpacing[resolvedRowAxis], trailing[resolvedRowAxis])) -
|
||||
paddingAndBorderAxisResolvedRow;
|
||||
}
|
||||
maxHeight = CSSConstants.Undefined;
|
||||
if ((!float.IsNaN(node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]]) && node.style.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] >= 0.0)) {
|
||||
maxHeight = node.layout.dimensions[dim[CSS_FLEX_DIRECTION_COLUMN]] -
|
||||
paddingAndBorderAxisColumn;
|
||||
} else if (isMainRowDirection) {
|
||||
maxHeight = parentMaxHeight -
|
||||
(node.style.margin.getWithFallback(leadingSpacing[CSS_FLEX_DIRECTION_COLUMN], leading[CSS_FLEX_DIRECTION_COLUMN]) + node.style.margin.getWithFallback(trailingSpacing[CSS_FLEX_DIRECTION_COLUMN], trailing[CSS_FLEX_DIRECTION_COLUMN])) -
|
||||
paddingAndBorderAxisColumn;
|
||||
}
|
||||
|
||||
// And we recursively call the layout algorithm for this child
|
||||
layoutNode(layoutContext, currentFlexChild, maxWidth, direction);
|
||||
layoutNode(layoutContext, currentFlexChild, maxWidth, maxHeight, direction);
|
||||
|
||||
child = currentFlexChild;
|
||||
currentFlexChild = currentFlexChild.nextFlexChild;
|
||||
|
Reference in New Issue
Block a user