Ensure that flex children adopt their parent's cross-axis min dimension.

This commit is contained in:
Russell Keith-Magee
2015-04-07 10:52:15 +08:00
parent b912acf8e3
commit b8316413b3
6 changed files with 162 additions and 13 deletions

View File

@@ -446,9 +446,9 @@ public class LayoutEngine {
child = node.getChildAt(i);
float nextContentDim = 0;
// It only makes sense to consider a child flexible if we have a computed
// dimension for the node.
if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis))) && isFlex(child)) {
// If it's a flexible child, accumulate the size that the child potentially
// contributes to the row
if (isFlex(child)) {
flexibleChildrenCount++;
totalFlexible = totalFlexible + getFlex(child);
@@ -514,7 +514,7 @@ public class LayoutEngine {
if (!CSSConstants.isUndefined(getLayoutDimension(node, getDim(mainAxis)))) {
remainingMainDim = definedMainDim - mainContentDim;
} else {
remainingMainDim = Math.max(mainContentDim, 0) - mainContentDim;
remainingMainDim = boundAxis(node, mainAxis, Math.max(mainContentDim, 0)) - mainContentDim;
}
// If there are flexible children in the mix, they are going to fill the

View File

@@ -5002,5 +5002,76 @@ public class LayoutEngineTest {
test("should layout node with position absolute, top and left and min bounds", root_node, root_layout);
}
@Test
public void testCase120()
{
TestCSSNode root_node = new TestCSSNode();
{
TestCSSNode node_0 = root_node;
node_0.style.minHeight = 800;
addChildren(node_0, 1);
{
TestCSSNode node_1;
node_1 = node_0.getChildAt(0);
node_1.style.flex = 1;
}
}
TestCSSNode root_layout = new TestCSSNode();
{
TestCSSNode node_0 = root_layout;
node_0.layout.y = 0;
node_0.layout.x = 0;
node_0.layout.width = 0;
node_0.layout.height = 800;
addChildren(node_0, 1);
{
TestCSSNode node_1;
node_1 = node_0.getChildAt(0);
node_1.layout.y = 0;
node_1.layout.x = 0;
node_1.layout.width = 0;
node_1.layout.height = 800;
}
}
test("should layout minHeight with a flex child", root_node, root_layout);
}
@Test
public void testCase121()
{
TestCSSNode root_node = new TestCSSNode();
{
TestCSSNode node_0 = root_node;
node_0.style.minHeight = 800;
addChildren(node_0, 1);
{
TestCSSNode node_1;
node_1 = node_0.getChildAt(0);
}
}
TestCSSNode root_layout = new TestCSSNode();
{
TestCSSNode node_0 = root_layout;
node_0.layout.y = 0;
node_0.layout.x = 0;
node_0.layout.width = 0;
node_0.layout.height = 800;
addChildren(node_0, 1);
{
TestCSSNode node_1;
node_1 = node_0.getChildAt(0);
node_1.layout.y = 0;
node_1.layout.x = 0;
node_1.layout.width = 0;
node_1.layout.height = 0;
}
}
test("should layout minHeight without a flex child", root_node, root_layout);
}
/** END_GENERATED **/
}