Bug 86528 - implement new negative flexing algorithm
Summary: implement new negative flexing algorithm
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tony Chang
URL:
Keywords:
Depends on:
Blocks: 62048
  Show dependency treegraph
 
Reported: 2012-05-15 14:25 PDT by Tony Chang
Modified: 2012-05-25 19:07 PDT (History)
3 users (show)

See Also:


Attachments
Patch (13.04 KB, patch)
2012-05-25 14:48 PDT, Tony Chang
no flags Details | Formatted Diff | Diff
Patch (14.94 KB, patch)
2012-05-25 15:53 PDT, Tony Chang
no flags Details | Formatted Diff | Diff
Patch for landing (14.98 KB, patch)
2012-05-25 16:05 PDT, Tony Chang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Chang 2012-05-15 14:25:55 PDT
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.
Comment 1 Tony Chang 2012-05-25 14:48:15 PDT
Created attachment 144151 [details]
Patch
Comment 2 Tony Chang 2012-05-25 14:48:44 PDT
The spec reflects this change as well.
Comment 3 Tony Chang 2012-05-25 14:51:51 PDT
Comment on attachment 144151 [details]
Patch

Actually, I can overflow and get into an infinite loop.  Let me fix that first.
Comment 4 Tony Chang 2012-05-25 15:53:58 PDT
Created attachment 144161 [details]
Patch
Comment 5 Ojan Vafai 2012-05-25 16:03:14 PDT
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.
Comment 6 Tony Chang 2012-05-25 16:05:29 PDT
Created attachment 144164 [details]
Patch for landing
Comment 7 WebKit Review Bot 2012-05-25 19:07:34 PDT
Comment on attachment 144164 [details]
Patch for landing

Clearing flags on attachment: 144164

Committed r118600: <http://trac.webkit.org/changeset/118600>
Comment 8 WebKit Review Bot 2012-05-25 19:07:44 PDT
All reviewed patches have been landed.  Closing bug.