Fix bugs around align-content
Summary: @public Regenerating the “golden master” tests with chrome surfaced different bugs around `align-content`: - a misunderstanding that values in `align-content` only applied *if there is only one line.* In fact, it applies *every time* a container is set to `flex-wrap: wrap`. Chrome had this wrong, and as such our tests were generated with incorrect parameters. - empty children growing to the cross axis size of the container, even when `align-content` is different from `stretch`. This was implemented incorrectly in Chrome as well. Here, we fix it with an extra check. Reviewed By: SidharthGuglani Differential Revision: D14725402 fbshipit-source-id: a45bebdadb9c694dc0eb7e27cb52b3d247f81c50
This commit is contained in:
committed by
Facebook Github Bot
parent
3d8afa9e90
commit
bc7e504b29
@@ -366,39 +366,6 @@ public class YGAlignContentTest {
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
@@ -423,6 +390,39 @@ public class YGAlignContentTest {
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
|
||||
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
|
||||
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
|
||||
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -59,8 +59,7 @@ public class YGAndroidNewsFeed {
|
||||
root_child0_child0_child0_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child0_child0_child0_child0.setWidth(120f);
|
||||
root_child0_child0_child0_child0_child0_child0.setHeight(120f);
|
||||
root_child0_child0_child0_child0_child0.addChildAt(
|
||||
root_child0_child0_child0_child0_child0_child0, 0);
|
||||
root_child0_child0_child0_child0_child0.addChildAt(root_child0_child0_child0_child0_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child0_child0_child1 = createNode(config);
|
||||
root_child0_child0_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
|
||||
@@ -76,14 +75,12 @@ public class YGAndroidNewsFeed {
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root_child0_child0_child0_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child0.setFlexShrink(1f);
|
||||
root_child0_child0_child0_child0_child1.addChildAt(
|
||||
root_child0_child0_child0_child0_child1_child0, 0);
|
||||
root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child0_child0_child1_child1 = createNode(config);
|
||||
root_child0_child0_child0_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child0_child0_child1_child1.setFlexShrink(1f);
|
||||
root_child0_child0_child0_child0_child1.addChildAt(
|
||||
root_child0_child0_child0_child0_child1_child1, 1);
|
||||
root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child1, 1);
|
||||
|
||||
final YogaNode root_child0_child0_child1 = createNode(config);
|
||||
root_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
|
||||
@@ -106,8 +103,7 @@ public class YGAndroidNewsFeed {
|
||||
root_child0_child0_child1_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child1_child0_child0_child0.setWidth(72f);
|
||||
root_child0_child0_child1_child0_child0_child0.setHeight(72f);
|
||||
root_child0_child0_child1_child0_child0.addChildAt(
|
||||
root_child0_child0_child1_child0_child0_child0, 0);
|
||||
root_child0_child0_child1_child0_child0.addChildAt(root_child0_child0_child1_child0_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child1_child0_child1 = createNode(config);
|
||||
root_child0_child0_child1_child0_child1.setAlignContent(YogaAlign.STRETCH);
|
||||
@@ -123,14 +119,12 @@ public class YGAndroidNewsFeed {
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
|
||||
root_child0_child0_child1_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child0.setFlexShrink(1f);
|
||||
root_child0_child0_child1_child0_child1.addChildAt(
|
||||
root_child0_child0_child1_child0_child1_child0, 0);
|
||||
root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0_child1_child0_child1_child1 = createNode(config);
|
||||
root_child0_child0_child1_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
|
||||
root_child0_child0_child1_child0_child1_child1.setFlexShrink(1f);
|
||||
root_child0_child0_child1_child0_child1.addChildAt(
|
||||
root_child0_child0_child1_child0_child1_child1, 1);
|
||||
root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child1, 1);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
|
@@ -531,12 +531,12 @@ public class YGFlexWrapTest {
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
root.setDirection(YogaDirection.RTL);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
@@ -549,12 +549,12 @@ public class YGFlexWrapTest {
|
||||
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
|
||||
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user