Fix flex within max size if max size is not constraint to
Summary: Previous fix for flex in max size constraint was not entirely correct and was missing a test case for the time when the max constraint is not applied. This diff addresses that. Reviewed By: gkassabli Differential Revision: D4162104 fbshipit-source-id: 08feba6cb4e789c9aa12179e2cdeadc66b011841
This commit is contained in:
committed by
Facebook Github Bot
parent
70e01a4476
commit
aaa977f645
@@ -47,6 +47,12 @@
|
||||
<div style="height: 20px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="flex_grow_within_constrained_max_width" style="width: 200px; height: 100px;">
|
||||
<div style="flex-direction: row; max-width: 300px;">
|
||||
<div style="height: 20px; flex-grow: 1;"></div>
|
||||
</div>
|
||||
</div>
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -420,3 +426,54 @@ TEST(CSSLayoutTest, flex_grow_within_max_width) {
|
||||
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
||||
TEST(CSSLayoutTest, flex_grow_within_constrained_max_width) {
|
||||
const CSSNodeRef root = CSSNodeNew();
|
||||
CSSNodeStyleSetWidth(root, 200);
|
||||
CSSNodeStyleSetHeight(root, 100);
|
||||
|
||||
const CSSNodeRef root_child0 = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexDirection(root_child0, CSSFlexDirectionRow);
|
||||
CSSNodeStyleSetMaxWidth(root_child0, 300);
|
||||
CSSNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
const CSSNodeRef root_child0_child0 = CSSNodeNew();
|
||||
CSSNodeStyleSetFlexGrow(root_child0_child0, 1);
|
||||
CSSNodeStyleSetHeight(root_child0_child0, 20);
|
||||
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root));
|
||||
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root));
|
||||
ASSERT_EQ(100, CSSNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_EQ(200, CSSNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_EQ(20, CSSNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
CSSNodeFreeRecursive(root);
|
||||
}
|
||||
|
Reference in New Issue
Block a user