Correct formula for the desired result: space-shortage = sum(flex-basis) - available-space shrink-factor = space-shortage / sum(flex-basis * negative-flex)) main-size = flex-basis * (1 - shrink-factor * negative-flex)) See http://lists.w3.org/Archives/Public/www-style/2012May/0291.html for a test case and some rationale.
Created attachment 144151 [details] Patch
The spec reflects this change as well.
Comment on attachment 144151 [details] Patch Actually, I can overflow and get into an infinite loop. Let me fix that first.
Created attachment 144161 [details] Patch
Comment on attachment 144161 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=144161&action=review > Source/WebCore/rendering/RenderFlexibleBox.cpp:876 > + if (availableFreeSpace > 0 && totalPositiveFlexibility > 0 && flexSign == PositiveFlexibility && isfinite(totalPositiveFlexibility)) > childSize += lroundf(availableFreeSpace * child->style()->positiveFlex() / totalPositiveFlexibility); > - else if (availableFreeSpace < 0 && totalNegativeFlexibility > 0 && flexSign == NegativeFlexibility) > - childSize += lroundf(availableFreeSpace * child->style()->negativeFlex() / totalNegativeFlexibility); > + else if (availableFreeSpace < 0 && totalWeightedNegativeFlexibility > 0 && flexSign == NegativeFlexibility && isfinite(totalWeightedNegativeFlexibility)) Might want to mention this isfinite check in the ChangeLog description.
Created attachment 144164 [details] Patch for landing
Comment on attachment 144164 [details] Patch for landing Clearing flags on attachment: 144164 Committed r118600: <http://trac.webkit.org/changeset/118600>
All reviewed patches have been landed. Closing bug.