Changeset 93996 in webkit


Ignore:
Timestamp:
Aug 29, 2011 11:53:54 AM (13 years ago)
Author:
tony@chromium.org
Message:

Implement -webkit-flex-pack for horizontal flexboxen
https://bugs.webkit.org/show_bug.cgi?id=66898

Reviewed by Ojan Vafai.

Source/WebCore:

Test: css3/flexbox/004.html

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutHorizontalBlock):
(WebCore::hasPackingSpace):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmHorizontal):

LayoutTests:

  • css3/flexbox/004-expected.txt: Added.
  • css3/flexbox/004.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93994 r93996  
     12011-08-29  Tony Chang  <tony@chromium.org>
     2
     3        Implement -webkit-flex-pack for horizontal flexboxen
     4        https://bugs.webkit.org/show_bug.cgi?id=66898
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css3/flexbox/004-expected.txt: Added.
     9        * css3/flexbox/004.html: Added.
     10
    1112011-08-29  Sam Weinig  <sam@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r93995 r93996  
     12011-08-29  Tony Chang  <tony@chromium.org>
     2
     3        Implement -webkit-flex-pack for horizontal flexboxen
     4        https://bugs.webkit.org/show_bug.cgi?id=66898
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Test: css3/flexbox/004.html
     9
     10        * rendering/RenderFlexibleBox.cpp:
     11        (WebCore::RenderFlexibleBox::layoutHorizontalBlock):
     12        (WebCore::hasPackingSpace):
     13        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmHorizontal):
     14
    1152011-08-29  Alexey Proskuryakov  <ap@apple.com>
    216
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r93651 r93996  
    139139    }
    140140
    141     // FIXME: Distribute leftover space to the packing space (second distribution round).
    142141    // FIXME: Handle distribution of vertical space (third distribution round).
    143142}
     
    180179        totalNegativeFlexibility += child->style()->flexboxWidthNegativeFlex();
    181180    }
     181}
     182
     183static bool hasPackingSpace(LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
     184{
     185    return availableFreeSpace > 0 && !totalPositiveFlexibility;
    182186}
    183187
     
    227231    // Now that we know the sizes, layout and position the flex items.
    228232    LayoutUnit xOffset = borderLeft() + paddingLeft();
     233
     234    if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) {
     235        if (style()->flexPack() == PackEnd)
     236            xOffset += availableFreeSpace;
     237        else if (style()->flexPack() == PackCenter)
     238            xOffset += availableFreeSpace / 2;
     239    }
     240
    229241    LayoutUnit yOffset = borderTop() + paddingTop();
    230242    setHeight(0);
     
    248260        child->setLocation(IntPoint(xOffset, yOffset));
    249261        xOffset += child->width() + child->marginRight();
     262
     263        if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && style()->flexPack() == PackJustify && childSizes.size() > 1)
     264            xOffset += availableFreeSpace / (childSizes.size() - 1);
    250265    }
    251266    return true;
Note: See TracChangeset for help on using the changeset viewer.