Changeset 112333 in webkit


Ignore:
Timestamp:
Mar 27, 2012 4:56:11 PM (12 years ago)
Author:
tony@chromium.org
Message:

use the correct size when computing flex-pack space
https://bugs.webkit.org/show_bug.cgi?id=82378

Reviewed by Ojan Vafai.

Source/WebCore:

Fix 2 bugs:

  • We weren't properly updating available space before computing packing space. If a min/max is not hit, we still need to adjust the available free space.
  • For flex-pack:end, we need to put the overflow in the start edge.

New test cases in css3/flexbox/flex-pack.html

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::resolveFlexibleLengths):
(WebCore::initialPackingOffset):

LayoutTests:

  • css3/flexbox/flex-pack-expected.txt:
  • css3/flexbox/flex-pack.html:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112324 r112333  
     12012-03-27  Tony Chang  <tony@chromium.org>
     2
     3        use the correct size when computing flex-pack space
     4        https://bugs.webkit.org/show_bug.cgi?id=82378
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css3/flexbox/flex-pack-expected.txt:
     9        * css3/flexbox/flex-pack.html:
     10
    1112012-03-27  Dirk Pranke  <dpranke@chromium.org>
    212
  • trunk/LayoutTests/css3/flexbox/flex-pack-expected.txt

    r110253 r112333  
    99PASS
    1010PASS
     11PASS
     12PASS
     13PASS
     14PASS
     15PASS
  • trunk/LayoutTests/css3/flexbox/flex-pack.html

    r110253 r112333  
    5050</div>
    5151
     52<div class="flexbox" style="-webkit-flex-pack: center">
     53  <div data-expected-width="200" data-offset-x="0" style="width: -webkit-flex(1 100px);"></div>
     54  <div data-expected-width="200" data-offset-x="200" style="width: -webkit-flex(1 100px);"></div>
     55  <div data-expected-width="200" data-offset-x="400" style="width: -webkit-flex(1 100px);"></div>
     56</div>
     57
     58<!-- True centering on overflow. -->
     59<div class="flexbox" style="-webkit-flex-pack: center">
     60  <div data-expected-width="800" data-offset-x="-100" style="width: 800px;"></div>
     61</div>
     62
    5263<div class="flexbox" style="-webkit-flex-pack: justify">
    5364  <div data-expected-width="100" data-offset-x="0" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
    5465  <div data-expected-width="100" data-offset-x="250" style="width: 100px;"></div>
    5566  <div data-expected-width="100" data-offset-x="500" style="width: 100px;"></div>
     67</div>
     68
     69<div class="flexbox" style="-webkit-flex-pack: justify">
     70  <div data-expected-width="200" data-offset-x="0" style="width: -webkit-flex(1 100px);"></div>
     71  <div data-expected-width="200" data-offset-x="200" style="width: -webkit-flex(1 100px);"></div>
     72  <div data-expected-width="200" data-offset-x="400" style="width: -webkit-flex(1 100px);"></div>
    5673</div>
    5774
     
    7087<div class="flexbox" style="-webkit-flex-pack: distribute">
    7188  <div data-expected-width="100" data-offset-x="250" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
     89</div>
     90
     91<!-- True centering on overflow. -->
     92<div class="flexbox" style="-webkit-flex-pack: distribute">
     93  <div data-expected-width="800" data-offset-x="-100" style="width: 800px;"></div>
    7294</div>
    7395
     
    89111</div>
    90112
     113<!-- We overflow the flexbox (no negative flexing) and align the end. The overflow is to the left. -->
     114<div class="flexbox" style="-webkit-flex-pack: end">
     115  <div data-expected-width="300" data-offset-x="-100" style="width: -webkit-flex(1 300px);"></div>
     116  <div data-expected-width="200" data-offset-x="200" style="width: 200px;"></div>
     117  <div data-expected-width="200" data-offset-x="400" style="width: 200px;"></div>
     118</div>
     119
    91120</body>
    92121</html>
  • trunk/Source/WebCore/ChangeLog

    r112332 r112333  
     12012-03-27  Tony Chang  <tony@chromium.org>
     2
     3        use the correct size when computing flex-pack space
     4        https://bugs.webkit.org/show_bug.cgi?id=82378
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Fix 2 bugs:
     9        - We weren't properly updating available space before computing
     10          packing space. If a min/max is not hit, we still need to adjust
     11          the available free space.
     12        - For flex-pack:end, we need to put the overflow in the start edge.
     13
     14        New test cases in css3/flexbox/flex-pack.html
     15
     16        * rendering/RenderFlexibleBox.cpp:
     17        (WebCore::RenderFlexibleBox::resolveFlexibleLengths):
     18        (WebCore::initialPackingOffset):
     19
    1202012-03-27  Dana Jansens  <danakj@chromium.org>
    221
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r112316 r112333  
    770770    LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
    771771    LayoutUnit totalViolation = 0;
     772    LayoutUnit usedFreeSpace = 0;
    772773    WTF::Vector<Violation> minViolations;
    773774    WTF::Vector<Violation> maxViolations;
     
    782783            childSizes.append(inflexibleItems.get(child));
    783784        else {
    784             LayoutUnit childSize = preferredMainAxisContentExtentForChild(child);
     785            LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(child);
     786            LayoutUnit childSize = preferredChildSize;
    785787            if (availableFreeSpace > 0 && totalPositiveFlexibility > 0 && flexSign == PositiveFlexibility)
    786788                childSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility);
     
    790792            LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(child, childSize, flexboxAvailableContentExtent);
    791793            childSizes.append(adjustedChildSize);
     794            usedFreeSpace += adjustedChildSize - preferredChildSize;
    792795
    793796            LayoutUnit violation = adjustedChildSize - childSize;
     
    802805    if (totalViolation)
    803806        freezeViolations(totalViolation < 0 ? maxViolations : minViolations, availableFreeSpace, totalPositiveFlexibility, totalNegativeFlexibility, inflexibleItems);
     807    else
     808        availableFreeSpace -= usedFreeSpace;
     809
    804810    return !totalViolation;
    805811}
     
    807813static LayoutUnit initialPackingOffset(LayoutUnit availableFreeSpace, EFlexPack flexPack, size_t numberOfChildren)
    808814{
    809     if (availableFreeSpace > 0) {
    810         if (flexPack == PackEnd)
    811             return availableFreeSpace;
    812         if (flexPack == PackCenter)
    813             return availableFreeSpace / 2;
    814         if (flexPack == PackDistribute && numberOfChildren)
     815    if (flexPack == PackEnd)
     816        return availableFreeSpace;
     817    if (flexPack == PackCenter)
     818        return availableFreeSpace / 2;
     819    if (flexPack == PackDistribute) {
     820        if (availableFreeSpace > 0 && numberOfChildren)
    815821            return availableFreeSpace / (2 * numberOfChildren);
    816     } else if (availableFreeSpace < 0) {
    817         if (flexPack == PackCenter || flexPack == PackDistribute)
     822        if (availableFreeSpace < 0)
    818823            return availableFreeSpace / 2;
    819824    }
Note: See TracChangeset for help on using the changeset viewer.