Repository navigation
Commit eb9993f
Keep cross axis margins and relative insets of items in wrapping containers
Summary:
Fixes react/yoga#1856
Fixes react/yoga#1067
In wrapping containers, STEP 8 (multi line alignment) of `CalculateLayout.cpp` repositions items on the cross axis and drops part of each box. In react/yoga#1856 the container is a column (Yoga's default), so `left` is on the cross axis.
- `flex-start` uses `computeFlexStartPosition` (the inset) where `computeFlexStartMargin` belongs. v2.0.1 used the margin, so this is a 3.0 regression from react/yoga#1561.
- `stretch`, `center` and `flex-end` never add the relative inset.
- `center` centers the border box instead of the margin box, which is react/yoga#1067.
Every case now uses the leading margin, trailing margin and `relativePosition`. `wrap-reverse` mirrors positions afterwards, so it leads with the flex end margin and applies the inset after mirroring, keeping each margin on its edge and `top: 10` moving the item down.
Also, a percentage inset on a `flex-start` item now resolves against the container's cross size, as without wrap (`top: 10%` in a 100x200 row: 10 to 20), and baseline rows, which run this pass even without wrap, honor `bottom` and ignore insets on static items.
Column container, padding 10, `flex-wrap: wrap`, default `align-content: flex-start`, item with margin 5 and `left: 10` (item left; expected worked out from the spec):
| `align-items` | main | this PR | expected |
|---|---|---|---|
| `flex-start` | 20 | 25 | 25 |
| `stretch` | 15 | 25 | 25 |
| `center` | 15 | 25 | 25 |
| `flex-end` | 15 | 25 | 25 |
| `flex-start`, no inset | 10 | 15 | 15 |
The react/yoga#1067 repro goes from top 50 to 100.
I added `tests/YGFlexWrapCrossAlignmentTest.cpp`: 9 hand written gtest cases like the other non generated tests, covering row and column, LTR and RTL, `wrap` and `wrap-reverse` (including one sided margins), baseline, static items and both issue repros. All 9 fail without the `CalculateLayout.cpp` change; with it, all 877 tests pass (868 plus 9). I can move them into gentest fixtures or add an `Errata` flag if you prefer.
X-link: react/yoga#2045
Differential Revision: D127132637
Pulled By: javache1 parent 79c6c23 commit eb9993f
1 file changed
Lines changed: 38 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2325 | 2325 | | |
2326 | 2326 | | |
2327 | 2327 | | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
2328 | 2331 | | |
2329 | 2332 | | |
2330 | 2333 | | |
| |||
2443 | 2446 | | |
2444 | 2447 | | |
2445 | 2448 | | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
2446 | 2460 | | |
2447 | 2461 | | |
2448 | 2462 | | |
2449 | 2463 | | |
2450 | 2464 | | |
2451 | 2465 | | |
2452 | 2466 | | |
2453 | | - | |
2454 | | - | |
2455 | | - | |
| 2467 | + | |
2456 | 2468 | | |
2457 | 2469 | | |
2458 | 2470 | | |
2459 | 2471 | | |
2460 | 2472 | | |
2461 | | - | |
2462 | | - | |
2463 | | - | |
| 2473 | + | |
2464 | 2474 | | |
2465 | | - | |
| 2475 | + | |
| 2476 | + | |
2466 | 2477 | | |
2467 | 2478 | | |
2468 | 2479 | | |
2469 | 2480 | | |
2470 | | - | |
2471 | | - | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
2472 | 2484 | | |
2473 | 2485 | | |
2474 | | - | |
| 2486 | + | |
| 2487 | + | |
2475 | 2488 | | |
2476 | 2489 | | |
2477 | 2490 | | |
2478 | 2491 | | |
2479 | 2492 | | |
2480 | | - | |
2481 | | - | |
2482 | | - | |
| 2493 | + | |
2483 | 2494 | | |
2484 | 2495 | | |
2485 | 2496 | | |
| |||
2527 | 2538 | | |
2528 | 2539 | | |
2529 | 2540 | | |
2530 | | - | |
2531 | | - | |
2532 | | - | |
2533 | | - | |
2534 | | - | |
| 2541 | + | |
2535 | 2542 | | |
2536 | 2543 | | |
2537 | 2544 | | |
| |||
2643 | 2650 | | |
2644 | 2651 | | |
2645 | 2652 | | |
2646 | | - | |
| 2653 | + | |
| 2654 | + | |
2647 | 2655 | | |
2648 | 2656 | | |
2649 | 2657 | | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
2650 | 2666 | | |
2651 | 2667 | | |
2652 | | - | |
2653 | | - | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
2654 | 2671 | | |
2655 | 2672 | | |
2656 | 2673 | | |
| |||
0 commit comments