fix bug where nested align: stretch were not properly working
The way the algorithm work is that you first layout fixed children on the main axis, then compute all the dimensions so that you can layout flexible children. This separation doesn't work anymore if we add the other axis. The solution here is a hacky (but working!) attempt at fixing the issue. We start by doing a pass to set the children dimensions if they are stretch.
This commit is contained in:
@@ -2563,6 +2563,55 @@ int main()
|
||||
test("should layout node with text and position absolute", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_css_node();
|
||||
{
|
||||
css_node_t *node_0 = root_node;
|
||||
node_0->style.dimensions[CSS_WIDTH] = 300;
|
||||
init_css_node_children(node_0, 1);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = &node_0->children[0];
|
||||
node_1->style.align_self = CSS_ALIGN_STRETCH;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = &node_1->children[0];
|
||||
node_2->style.align_self = CSS_ALIGN_STRETCH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
css_node_t *root_layout = new_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] = 300;
|
||||
node_0->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
init_css_node_children(node_0, 1);
|
||||
{
|
||||
css_node_t *node_1;
|
||||
node_1 = &node_0->children[0];
|
||||
node_1->layout.position[CSS_TOP] = 0;
|
||||
node_1->layout.position[CSS_LEFT] = 0;
|
||||
node_1->layout.dimensions[CSS_WIDTH] = 300;
|
||||
node_1->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
init_css_node_children(node_1, 1);
|
||||
{
|
||||
css_node_t *node_2;
|
||||
node_2 = &node_1->children[0];
|
||||
node_2->layout.position[CSS_TOP] = 0;
|
||||
node_2->layout.position[CSS_LEFT] = 0;
|
||||
node_2->layout.dimensions[CSS_WIDTH] = 300;
|
||||
node_2->layout.dimensions[CSS_HEIGHT] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test("should layout node with nested alignSelf: stretch", root_node, root_layout);
|
||||
}
|
||||
|
||||
{
|
||||
css_node_t *root_node = new_css_node();
|
||||
{
|
||||
|
Reference in New Issue
Block a user