Changeset 110772 in webkit


Ignore:
Timestamp:
Mar 14, 2012 3:56:15 PM (12 years ago)
Author:
tony@chromium.org
Message:

fix negative flexing in auto sized columns
https://bugs.webkit.org/show_bug.cgi?id=80069

Reviewed by Ojan Vafai.

Source/WebCore:

New test cases in css3/flexbox/columns-auto-size.html.

  • rendering/RenderFlexibleBox.cpp:

(WebCore):
(WebCore::RenderFlexibleBox::computeAvailableFreeSpace): Properly compute this for auto sizing columns. Previously, we would always return 0.
(WebCore::RenderFlexibleBox::layoutFlexItems):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithm): Drop an unnecessary check against undefined. isSpecified covers this for us.

  • rendering/RenderFlexibleBox.h:

(RenderFlexibleBox):

LayoutTests:

  • css3/flexbox/columns-auto-size-expected.txt:
  • css3/flexbox/columns-auto-size.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r110771 r110772  
     12012-03-14  Tony Chang  <tony@chromium.org>
     2
     3        fix negative flexing in auto sized columns
     4        https://bugs.webkit.org/show_bug.cgi?id=80069
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css3/flexbox/columns-auto-size-expected.txt:
     9        * css3/flexbox/columns-auto-size.html:
     10
    1112012-03-14  Adam Barth  <abarth@webkit.org>
    212
  • trunk/LayoutTests/css3/flexbox/columns-auto-size-expected.txt

    r98628 r110772  
    55PASS
    66PASS
     7PASS
     8PASS
     9PASS
     10PASS
  • trunk/LayoutTests/css3/flexbox/columns-auto-size.html

    r98628 r110772  
    7777</div>
    7878
     79<div class="flexbox horizontal" data-expected-height="20">
     80  <div data-expected-height="10" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
     81  <div data-expected-height="10" data-offset-y="10" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
     82</div>
     83
     84<div class="flexbox horizontal" style="min-height: 10px" data-expected-height="20">
     85  <div data-expected-height="10" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
     86  <div data-expected-height="10" data-offset-y="10" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
     87</div>
     88
     89<div class="flexbox horizontal" style="min-height: 5px; max-height: 17px;" data-expected-height="17">
     90  <div data-expected-height="9" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
     91  <div data-expected-height="8" data-offset-y="9" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
     92</div>
     93
     94<div class="flexbox horizontal" style="min-height: 5px; max-height: 30px; padding-top: 1px; padding-bottom: 2px;" data-expected-height="33">
     95  <div data-expected-height="15" data-offset-y="1" style="height: -webkit-flex(0 1 auto)"><div style="height: 20px"></div></div>
     96  <div data-expected-height="15" data-offset-y="16" style="height: -webkit-flex(0 1 auto)"><div style="height: 20px"></div></div>
     97</div>
     98
    7999<div class="flexbox vertical">
    80100  <div data-expected-width="10" data-offset-x="20" style="width: -webkit-flex(1 0 10px)"></div>
  • trunk/Source/WebCore/ChangeLog

    r110769 r110772  
     12012-03-14  Tony Chang  <tony@chromium.org>
     2
     3        fix negative flexing in auto sized columns
     4        https://bugs.webkit.org/show_bug.cgi?id=80069
     5
     6        Reviewed by Ojan Vafai.
     7
     8        New test cases in css3/flexbox/columns-auto-size.html.
     9
     10        * rendering/RenderFlexibleBox.cpp:
     11        (WebCore):
     12        (WebCore::RenderFlexibleBox::computeAvailableFreeSpace): Properly compute this for auto sizing columns. Previously, we would always return 0.
     13        (WebCore::RenderFlexibleBox::layoutFlexItems):
     14        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithm): Drop an unnecessary check against undefined. isSpecified covers this for us.
     15        * rendering/RenderFlexibleBox.h:
     16        (RenderFlexibleBox):
     17
    1182012-03-14  Grace Ku  <gracek@codeaurora.org>
    219
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r110747 r110772  
    577577}
    578578
     579LayoutUnit RenderFlexibleBox::computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent)
     580{
     581    if (!isColumnFlow())
     582        return mainAxisContentExtent() - preferredMainAxisExtent;
     583
     584    if (hasOverrideHeight())
     585        return overrideHeight();
     586
     587    LayoutUnit heightResult = computeContentLogicalHeightUsing(style()->logicalHeight());
     588    if (heightResult == -1)
     589        heightResult = preferredMainAxisExtent;
     590    LayoutUnit minHeight = computeContentLogicalHeightUsing(style()->logicalMinHeight()); // Leave as -1 if unset.
     591    LayoutUnit maxHeight = style()->logicalMaxHeight().isUndefined() ? heightResult : computeContentLogicalHeightUsing(style()->logicalMaxHeight());
     592    if (maxHeight == -1)
     593        maxHeight = heightResult;
     594    heightResult = std::min(maxHeight, heightResult);
     595    heightResult = std::max(minHeight, heightResult);
     596
     597    return heightResult - preferredMainAxisExtent;
     598}
     599
    579600void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren)
    580601{
     
    593614
    594615    LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
    595     LayoutUnit mainAxisFlexibleSpace = mainAxisContentExtent();
    596616    while (computeNextFlexLine(flexIterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility)) {
    597         LayoutUnit availableFreeSpace = mainAxisFlexibleSpace - preferredMainAxisExtent;
     617        LayoutUnit availableFreeSpace = computeAvailableFreeSpace(preferredMainAxisExtent);
    598618        InflexibleFlexItemSize inflexibleItems;
    599619        WTF::Vector<LayoutUnit> childSizes;
     
    739759
    740760                Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
    741                 if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) {
     761                if (childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) {
    742762                    childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent);
    743763                    availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForChild(child);
     
    751771
    752772                Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
    753                 if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) {
     773                if (childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) {
    754774                    childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableContentExtent);
    755775                    availableFreeSpace += preferredMainAxisContentExtentForChild(child) - childPreferredSize;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r110747 r110772  
    106106    LayoutUnit lineBreakLength();
    107107    bool computeNextFlexLine(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
     108    LayoutUnit computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent);
    108109    bool runFreeSpaceAllocationAlgorithm(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
    109110    void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
Note: See TracChangeset for help on using the changeset viewer.