Redo layout of 'stretch' aligned items for correct positioning of nested
items Fixes facebook/css-layout#83, facebook/css-layout#100, facebook/css-layout#127.
This commit is contained in:
@@ -7720,6 +7720,202 @@ int main()
|
||||
test("should correctly progagate size contraints from flexible parents", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_node;
|
||||
node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
|
||||
node_0->style.align_items = CSS_ALIGN_STRETCH;
|
||||
node_0->style.dimensions[CSS_WIDTH] = 150;
|
||||
init_css_node_children(node_0, 2);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
node_1->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
|
||||
node_1->style.margin[CSS_LEFT] = 10;
|
||||
node_1->style.margin[CSS_TOP] = 10;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
node_2->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
|
||||
init_css_node_children(node_2, 1);
|
||||
{
|
||||
css_node_t *node_3;
|
||||
node_3 = node_2->get_child(node_2->context, 0);
|
||||
node_3->style.align_self = CSS_ALIGN_CENTER;
|
||||
}
|
||||
}
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->style.dimensions[CSS_HEIGHT] = 150;
|
||||
}
|
||||
}
|
||||
|
||||
css_node_t *root_layout = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_layout;
|
||||
node_0->layout.position[CSS_TOP] = 0;
|
||||
node_0->layout.position[CSS_LEFT] = 0;
|
||||
node_0->layout.dimensions[CSS_WIDTH] = 150;
|
||||
node_0->layout.dimensions[CSS_HEIGHT] = 150;
|
||||
init_css_node_children(node_0, 2);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
node_1->layout.position[CSS_TOP] = 10;
|
||||
node_1->layout.position[CSS_LEFT] = 10;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 140;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
node_2->layout.position[CSS_TOP] = 0;
|
||||
node_2->layout.position[CSS_LEFT] = 0;
|
||||
node_2->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_2->layout.dimensions[CSS_HEIGHT] = 140;
|
||||
init_css_node_children(node_2, 1);
|
||||
{
|
||||
css_node_t *node_3;
|
||||
node_3 = node_2->get_child(node_2->context, 0);
|
||||
node_3->layout.position[CSS_TOP] = 70;
|
||||
node_3->layout.position[CSS_LEFT] = 0;
|
||||
node_3->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_3->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
}
|
||||
}
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->layout.position[CSS_TOP] = 0;
|
||||
node_1->layout.position[CSS_LEFT] = 10;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 150;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout content of an item which is stretched late", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_node;
|
||||
init_css_node_children(node_0, 2);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
node_2->style.dimensions[CSS_WIDTH] = 200;
|
||||
node_2->style.dimensions[CSS_HEIGHT] = 200;
|
||||
}
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->style.margin[CSS_LEFT] = 10;
|
||||
node_1->style.margin[CSS_TOP] = 10;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
css_node_t *root_layout = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_layout;
|
||||
node_0->layout.position[CSS_TOP] = 0;
|
||||
node_0->layout.position[CSS_LEFT] = 0;
|
||||
node_0->layout.dimensions[CSS_WIDTH] = 200;
|
||||
node_0->layout.dimensions[CSS_HEIGHT] = 210;
|
||||
init_css_node_children(node_0, 2);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
node_1->layout.position[CSS_TOP] = 0;
|
||||
node_1->layout.position[CSS_LEFT] = 0;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 200;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 200;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
node_2->layout.position[CSS_TOP] = 0;
|
||||
node_2->layout.position[CSS_LEFT] = 0;
|
||||
node_2->layout.dimensions[CSS_WIDTH] = 200;
|
||||
node_2->layout.dimensions[CSS_HEIGHT] = 200;
|
||||
}
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->layout.position[CSS_TOP] = 210;
|
||||
node_1->layout.position[CSS_LEFT] = 10;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 190;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = node_1->get_child(node_1->context, 0);
|
||||
node_2->layout.position[CSS_TOP] = 0;
|
||||
node_2->layout.position[CSS_LEFT] = 0;
|
||||
node_2->layout.dimensions[CSS_WIDTH] = 190;
|
||||
node_2->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout items whose positioning is determined by sibling tree branches", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_node;
|
||||
node_0->style.flex_direction = CSS_FLEX_DIRECTION_ROW;
|
||||
init_css_node_children(node_0, 3);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
node_1->style.align_self = CSS_ALIGN_FLEX_START;
|
||||
node_1->style.margin[CSS_LEFT] = 10;
|
||||
node_1->style.margin[CSS_TOP] = 10;
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->style.align_self = CSS_ALIGN_STRETCH;
|
||||
node_1->style.dimensions[CSS_WIDTH] = 1;
|
||||
node_1 = node_0->get_child(node_0->context, 2);
|
||||
node_1->style.dimensions[CSS_HEIGHT] = 150;
|
||||
}
|
||||
}
|
||||
|
||||
css_node_t *root_layout = new_test_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_layout;
|
||||
node_0->layout.position[CSS_TOP] = 0;
|
||||
node_0->layout.position[CSS_LEFT] = 0;
|
||||
node_0->layout.dimensions[CSS_WIDTH] = 11;
|
||||
node_0->layout.dimensions[CSS_HEIGHT] = 150;
|
||||
init_css_node_children(node_0, 3);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = node_0->get_child(node_0->context, 0);
|
||||
node_1->layout.position[CSS_TOP] = 10;
|
||||
node_1->layout.position[CSS_LEFT] = 10;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
node_1 = node_0->get_child(node_0->context, 1);
|
||||
node_1->layout.position[CSS_TOP] = 0;
|
||||
node_1->layout.position[CSS_LEFT] = 10;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 1;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 150;
|
||||
node_1 = node_0->get_child(node_0->context, 2);
|
||||
node_1->layout.position[CSS_TOP] = 0;
|
||||
node_1->layout.position[CSS_LEFT] = 11;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 0;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 150;
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout child whose cross axis is undefined and whose alignSelf is stretch", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_test_css_node();
|
||||
{
|
||||
|
Reference in New Issue
Block a user