Fix flex within max width constraint
Summary: Max dimension constraints were not correctly passed down to children. see https://github.com/facebook/css-layout/issues/230 for more info fixes #230 Reviewed By: gkassabli Differential Revision: D4147199 fbshipit-source-id: feb335eb8687a1b7939ee8cd8649e455e0c069a9
This commit is contained in:
committed by
Facebook Github Bot
parent
1baa239389
commit
3e567fdcae
@@ -41,6 +41,12 @@
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
<div style="width: 50px; height: 50px;"></div>
|
||||
</div>
|
||||
|
||||
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
|
||||
<div style="flex-direction: row; max-width: 100px;">
|
||||
<div style="height: 20px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -375,4 +381,56 @@ public class CSSLayoutMinMaxDimensionTest {
|
||||
assertEquals(50, root_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_flex_grow_within_max_width() {
|
||||
final CSSNode root = new CSSNode();
|
||||
root.setStyleWidth(200);
|
||||
root.setStyleHeight(100);
|
||||
|
||||
final CSSNode root_child0 = new CSSNode();
|
||||
root_child0.setFlexDirection(CSSFlexDirection.ROW);
|
||||
root_child0.setStyleMaxWidth(100);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final CSSNode root_child0_child0 = new CSSNode();
|
||||
root_child0_child0.setFlexGrow(1);
|
||||
root_child0_child0.setStyleHeight(20);
|
||||
root_child0.addChildAt(root_child0_child0, 0);
|
||||
root.setDirection(CSSDirection.LTR);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(CSSDirection.RTL);
|
||||
root.calculateLayout(null);
|
||||
|
||||
assertEquals(0, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root.getLayoutY(), 0.0f);
|
||||
assertEquals(200, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(20, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user