Skip to content

Commit bc7e504

Browse files
davidaureliofacebook-github-bot
authored andcommitted
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
1 parent 3d8afa9 commit bc7e504

File tree

10 files changed

+74
-73
lines changed

10 files changed

+74
-73
lines changed

csharp/tests/Facebook.Yoga/YGAlignContentTest.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -361,27 +361,27 @@ public void Test_align_content_flex_end()
361361
Assert.AreEqual(100f, root.LayoutWidth);
362362
Assert.AreEqual(100f, root.LayoutHeight);
363363

364-
Assert.AreEqual(0f, root_child0.LayoutX);
364+
Assert.AreEqual(50f, root_child0.LayoutX);
365365
Assert.AreEqual(0f, root_child0.LayoutY);
366366
Assert.AreEqual(50f, root_child0.LayoutWidth);
367367
Assert.AreEqual(10f, root_child0.LayoutHeight);
368368

369-
Assert.AreEqual(0f, root_child1.LayoutX);
369+
Assert.AreEqual(50f, root_child1.LayoutX);
370370
Assert.AreEqual(10f, root_child1.LayoutY);
371371
Assert.AreEqual(50f, root_child1.LayoutWidth);
372372
Assert.AreEqual(10f, root_child1.LayoutHeight);
373373

374-
Assert.AreEqual(0f, root_child2.LayoutX);
374+
Assert.AreEqual(50f, root_child2.LayoutX);
375375
Assert.AreEqual(20f, root_child2.LayoutY);
376376
Assert.AreEqual(50f, root_child2.LayoutWidth);
377377
Assert.AreEqual(10f, root_child2.LayoutHeight);
378378

379-
Assert.AreEqual(0f, root_child3.LayoutX);
379+
Assert.AreEqual(50f, root_child3.LayoutX);
380380
Assert.AreEqual(30f, root_child3.LayoutY);
381381
Assert.AreEqual(50f, root_child3.LayoutWidth);
382382
Assert.AreEqual(10f, root_child3.LayoutHeight);
383383

384-
Assert.AreEqual(0f, root_child4.LayoutX);
384+
Assert.AreEqual(50f, root_child4.LayoutX);
385385
Assert.AreEqual(40f, root_child4.LayoutY);
386386
Assert.AreEqual(50f, root_child4.LayoutWidth);
387387
Assert.AreEqual(10f, root_child4.LayoutHeight);
@@ -394,27 +394,27 @@ public void Test_align_content_flex_end()
394394
Assert.AreEqual(100f, root.LayoutWidth);
395395
Assert.AreEqual(100f, root.LayoutHeight);
396396

397-
Assert.AreEqual(50f, root_child0.LayoutX);
397+
Assert.AreEqual(0f, root_child0.LayoutX);
398398
Assert.AreEqual(0f, root_child0.LayoutY);
399399
Assert.AreEqual(50f, root_child0.LayoutWidth);
400400
Assert.AreEqual(10f, root_child0.LayoutHeight);
401401

402-
Assert.AreEqual(50f, root_child1.LayoutX);
402+
Assert.AreEqual(0f, root_child1.LayoutX);
403403
Assert.AreEqual(10f, root_child1.LayoutY);
404404
Assert.AreEqual(50f, root_child1.LayoutWidth);
405405
Assert.AreEqual(10f, root_child1.LayoutHeight);
406406

407-
Assert.AreEqual(50f, root_child2.LayoutX);
407+
Assert.AreEqual(0f, root_child2.LayoutX);
408408
Assert.AreEqual(20f, root_child2.LayoutY);
409409
Assert.AreEqual(50f, root_child2.LayoutWidth);
410410
Assert.AreEqual(10f, root_child2.LayoutHeight);
411411

412-
Assert.AreEqual(50f, root_child3.LayoutX);
412+
Assert.AreEqual(0f, root_child3.LayoutX);
413413
Assert.AreEqual(30f, root_child3.LayoutY);
414414
Assert.AreEqual(50f, root_child3.LayoutWidth);
415415
Assert.AreEqual(10f, root_child3.LayoutHeight);
416416

417-
Assert.AreEqual(50f, root_child4.LayoutX);
417+
Assert.AreEqual(0f, root_child4.LayoutX);
418418
Assert.AreEqual(40f, root_child4.LayoutY);
419419
Assert.AreEqual(50f, root_child4.LayoutWidth);
420420
Assert.AreEqual(10f, root_child4.LayoutHeight);

csharp/tests/Facebook.Yoga/YGFlexWrapTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,12 @@ public void Test_flex_wrap_align_stretch_fits_one_row()
529529
Assert.AreEqual(0f, root_child0.LayoutX);
530530
Assert.AreEqual(0f, root_child0.LayoutY);
531531
Assert.AreEqual(50f, root_child0.LayoutWidth);
532-
Assert.AreEqual(100f, root_child0.LayoutHeight);
532+
Assert.AreEqual(0f, root_child0.LayoutHeight);
533533

534534
Assert.AreEqual(50f, root_child1.LayoutX);
535535
Assert.AreEqual(0f, root_child1.LayoutY);
536536
Assert.AreEqual(50f, root_child1.LayoutWidth);
537-
Assert.AreEqual(100f, root_child1.LayoutHeight);
537+
Assert.AreEqual(0f, root_child1.LayoutHeight);
538538

539539
root.StyleDirection = YogaDirection.RTL;
540540
root.CalculateLayout();
@@ -547,12 +547,12 @@ public void Test_flex_wrap_align_stretch_fits_one_row()
547547
Assert.AreEqual(100f, root_child0.LayoutX);
548548
Assert.AreEqual(0f, root_child0.LayoutY);
549549
Assert.AreEqual(50f, root_child0.LayoutWidth);
550-
Assert.AreEqual(100f, root_child0.LayoutHeight);
550+
Assert.AreEqual(0f, root_child0.LayoutHeight);
551551

552552
Assert.AreEqual(50f, root_child1.LayoutX);
553553
Assert.AreEqual(0f, root_child1.LayoutY);
554554
Assert.AreEqual(50f, root_child1.LayoutWidth);
555-
Assert.AreEqual(100f, root_child1.LayoutHeight);
555+
Assert.AreEqual(0f, root_child1.LayoutHeight);
556556
}
557557

558558
[Test]

java/tests/com/facebook/yoga/YGAlignContentTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,27 +366,27 @@ public void test_align_content_flex_end() {
366366
assertEquals(100f, root.getLayoutWidth(), 0.0f);
367367
assertEquals(100f, root.getLayoutHeight(), 0.0f);
368368

369-
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
369+
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
370370
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
371371
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
372372
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
373373

374-
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
374+
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
375375
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
376376
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
377377
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
378378

379-
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
379+
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
380380
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
381381
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
382382
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
383383

384-
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
384+
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
385385
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
386386
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
387387
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
388388

389-
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
389+
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
390390
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
391391
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
392392
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);
@@ -399,27 +399,27 @@ public void test_align_content_flex_end() {
399399
assertEquals(100f, root.getLayoutWidth(), 0.0f);
400400
assertEquals(100f, root.getLayoutHeight(), 0.0f);
401401

402-
assertEquals(50f, root_child0.getLayoutX(), 0.0f);
402+
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
403403
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
404404
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
405405
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
406406

407-
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
407+
assertEquals(0f, root_child1.getLayoutX(), 0.0f);
408408
assertEquals(10f, root_child1.getLayoutY(), 0.0f);
409409
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
410410
assertEquals(10f, root_child1.getLayoutHeight(), 0.0f);
411411

412-
assertEquals(50f, root_child2.getLayoutX(), 0.0f);
412+
assertEquals(0f, root_child2.getLayoutX(), 0.0f);
413413
assertEquals(20f, root_child2.getLayoutY(), 0.0f);
414414
assertEquals(50f, root_child2.getLayoutWidth(), 0.0f);
415415
assertEquals(10f, root_child2.getLayoutHeight(), 0.0f);
416416

417-
assertEquals(50f, root_child3.getLayoutX(), 0.0f);
417+
assertEquals(0f, root_child3.getLayoutX(), 0.0f);
418418
assertEquals(30f, root_child3.getLayoutY(), 0.0f);
419419
assertEquals(50f, root_child3.getLayoutWidth(), 0.0f);
420420
assertEquals(10f, root_child3.getLayoutHeight(), 0.0f);
421421

422-
assertEquals(50f, root_child4.getLayoutX(), 0.0f);
422+
assertEquals(0f, root_child4.getLayoutX(), 0.0f);
423423
assertEquals(40f, root_child4.getLayoutY(), 0.0f);
424424
assertEquals(50f, root_child4.getLayoutWidth(), 0.0f);
425425
assertEquals(10f, root_child4.getLayoutHeight(), 0.0f);

java/tests/com/facebook/yoga/YGAndroidNewsFeed.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ public void test_android_news_feed() {
5959
root_child0_child0_child0_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
6060
root_child0_child0_child0_child0_child0_child0.setWidth(120f);
6161
root_child0_child0_child0_child0_child0_child0.setHeight(120f);
62-
root_child0_child0_child0_child0_child0.addChildAt(
63-
root_child0_child0_child0_child0_child0_child0, 0);
62+
root_child0_child0_child0_child0_child0.addChildAt(root_child0_child0_child0_child0_child0_child0, 0);
6463

6564
final YogaNode root_child0_child0_child0_child0_child1 = createNode(config);
6665
root_child0_child0_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -76,14 +75,12 @@ public void test_android_news_feed() {
7675
root_child0_child0_child0_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
7776
root_child0_child0_child0_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
7877
root_child0_child0_child0_child0_child1_child0.setFlexShrink(1f);
79-
root_child0_child0_child0_child0_child1.addChildAt(
80-
root_child0_child0_child0_child0_child1_child0, 0);
78+
root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child0, 0);
8179

8280
final YogaNode root_child0_child0_child0_child0_child1_child1 = createNode(config);
8381
root_child0_child0_child0_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
8482
root_child0_child0_child0_child0_child1_child1.setFlexShrink(1f);
85-
root_child0_child0_child0_child0_child1.addChildAt(
86-
root_child0_child0_child0_child0_child1_child1, 1);
83+
root_child0_child0_child0_child0_child1.addChildAt(root_child0_child0_child0_child0_child1_child1, 1);
8784

8885
final YogaNode root_child0_child0_child1 = createNode(config);
8986
root_child0_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -106,8 +103,7 @@ public void test_android_news_feed() {
106103
root_child0_child0_child1_child0_child0_child0.setAlignContent(YogaAlign.STRETCH);
107104
root_child0_child0_child1_child0_child0_child0.setWidth(72f);
108105
root_child0_child0_child1_child0_child0_child0.setHeight(72f);
109-
root_child0_child0_child1_child0_child0.addChildAt(
110-
root_child0_child0_child1_child0_child0_child0, 0);
106+
root_child0_child0_child1_child0_child0.addChildAt(root_child0_child0_child1_child0_child0_child0, 0);
111107

112108
final YogaNode root_child0_child0_child1_child0_child1 = createNode(config);
113109
root_child0_child0_child1_child0_child1.setAlignContent(YogaAlign.STRETCH);
@@ -123,14 +119,12 @@ public void test_android_news_feed() {
123119
root_child0_child0_child1_child0_child1_child0.setFlexDirection(YogaFlexDirection.ROW);
124120
root_child0_child0_child1_child0_child1_child0.setAlignContent(YogaAlign.STRETCH);
125121
root_child0_child0_child1_child0_child1_child0.setFlexShrink(1f);
126-
root_child0_child0_child1_child0_child1.addChildAt(
127-
root_child0_child0_child1_child0_child1_child0, 0);
122+
root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child0, 0);
128123

129124
final YogaNode root_child0_child0_child1_child0_child1_child1 = createNode(config);
130125
root_child0_child0_child1_child0_child1_child1.setAlignContent(YogaAlign.STRETCH);
131126
root_child0_child0_child1_child0_child1_child1.setFlexShrink(1f);
132-
root_child0_child0_child1_child0_child1.addChildAt(
133-
root_child0_child0_child1_child0_child1_child1, 1);
127+
root_child0_child0_child1_child0_child1.addChildAt(root_child0_child0_child1_child0_child1_child1, 1);
134128
root.setDirection(YogaDirection.LTR);
135129
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
136130

java/tests/com/facebook/yoga/YGFlexWrapTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,12 @@ public void test_flex_wrap_align_stretch_fits_one_row() {
531531
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
532532
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
533533
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
534-
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
534+
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
535535

536536
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
537537
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
538538
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
539-
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
539+
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
540540

541541
root.setDirection(YogaDirection.RTL);
542542
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
@@ -549,12 +549,12 @@ public void test_flex_wrap_align_stretch_fits_one_row() {
549549
assertEquals(100f, root_child0.getLayoutX(), 0.0f);
550550
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
551551
assertEquals(50f, root_child0.getLayoutWidth(), 0.0f);
552-
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
552+
assertEquals(0f, root_child0.getLayoutHeight(), 0.0f);
553553

554554
assertEquals(50f, root_child1.getLayoutX(), 0.0f);
555555
assertEquals(0f, root_child1.getLayoutY(), 0.0f);
556556
assertEquals(50f, root_child1.getLayoutWidth(), 0.0f);
557-
assertEquals(100f, root_child1.getLayoutHeight(), 0.0f);
557+
assertEquals(0f, root_child1.getLayoutHeight(), 0.0f);
558558
}
559559

560560
@Test

0 commit comments

Comments
 (0)