Auto merge of #29863 - nicoburns:fix-infinite-loop-when-shrinking, r=Loirooriol

Fix infinite loop in flexbox algorithm

Only apply step 5c of "resolve flexible lengths" if sum of scaled flexible shrink factors > 0
Probably fixes #29852 (but speculative as I can't get mach to run).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
This commit is contained in:
bors-servo 2023-06-10 16:54:24 +02:00 committed by GitHub
commit 7d9839acc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 10 deletions

View file

@ -976,6 +976,7 @@ impl FlexLine<'_> {
let scaled_shrink_factors_sum: Length = unfrozen_items()
.map(|(item, _)| scaled_shrink_factor(item))
.sum();
if scaled_shrink_factors_sum > Length::zero() {
for (item, target_main_size) in unfrozen_items() {
let ratio = scaled_shrink_factor(item) / scaled_shrink_factors_sum;
target_main_size
@ -983,6 +984,7 @@ impl FlexLine<'_> {
}
}
}
}
// “Fix min/max violations.”
let violation = |(item, target_main_size): (&FlexItem, &Cell<Length>)| {

View file

@ -1,5 +1,4 @@
[flex-aspect-ratio-img-row-013.html]
expected: TIMEOUT
[img 1]
expected: FAIL

View file

@ -1,5 +1,4 @@
[flex-item-compressible-002.html]
expected: TIMEOUT
[.flexbox 14]
expected: FAIL

View file

@ -1,5 +1,4 @@
[flex-minimum-height-flex-items-031.html]
expected: TIMEOUT
[.flex 1]
expected: FAIL

View file

@ -1,2 +1,2 @@
[flexbox-align-self-stretch-vert-001.html]
expected: TIMEOUT
expected: FAIL

View file

@ -1,2 +1,2 @@
[flexbox-overflow-vert-002.html]
expected: TIMEOUT
expected: FAIL

View file

@ -1,2 +1,2 @@
[percentage-padding-002.html]
expected: TIMEOUT
expected: FAIL