Repository navigation
Commit dd9b6c5
Don't break a flex line on floating-point rounding noise (#2022)
Summary:
A content-sized wrapping row sizes itself to the max-content sum of its
items, then recovers the space available to those items by subtracting its
padding and border back off (calculateAvailableInnerDimension). In float32
that add-then-subtract round-trip can land a fraction of an ulp below the
sum it came from.
For an item with a measure function the measurement cache still returns the
max-content measurement in that situation: oldSizeIsMaxContentAndStillFits
accepts a cached width up to the inexactEquals epsilon (1e-4) wider than the
space now available. calculateFlexLine then compared that basis against
availableInnerMainDim with a bare `>`, so the basis the cache had just
accepted as fitting read as overflow and the line broke.
Because the container had already been sized for a single line, the result
was a box one line tall with its items laid out on two, overflowing its own
padding and border. In React Native this reproduced on both iOS and Android
and was extremely sensitive to the measured text width, since only some
values leave a residue inside the window.
Make the overflow test tolerant of the same epsilon the cache uses, so the
two agree. Items without a measure function are unaffected: they take their
exact style width in both passes and never enter that cache path.
The regression test sweeps fractional measured widths whose content sum sits
just under 128 while the outer width sits just over it, so adding padding and
border crosses a float32 binade and the subtraction cannot always recover the
original value.
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D126040642
fbshipit-source-id: 676a2623d5a7efc3a54fe74e443bf75063d57711
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 800f350 commit dd9b6c5
1 file changed
Lines changed: 18 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
| |||
0 commit comments