Changeset 95577 in webkit


Ignore:
Timestamp:
Sep 20, 2011, 3:46:19 PM (14 years ago)
Author:
ojan@chromium.org
Message:

change RenderFlexibleBox to act on logical coordinates
https://bugs.webkit.org/show_bug.cgi?id=68129

Reviewed by David Hyatt.

Source/WebCore:

This makes RenderFlexibleBox respect direction and writing-mode.
We now properly support the default flex-flow value of "row".

Test: css3/flexbox/writing-modes.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::setLogicalLocationForChild):

  • rendering/RenderBlock.h:
  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutBlock):
(WebCore::RenderFlexibleBox::logicalBorderWidthForChild):
(WebCore::RenderFlexibleBox::logicalPaddingWidthForChild):
(WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
(WebCore::RenderFlexibleBox::marginStartStyleForChild):
(WebCore::RenderFlexibleBox::marginEndStyleForChild):
(WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
(WebCore::RenderFlexibleBox::layoutInlineDirection):
(WebCore::RenderFlexibleBox::logicalPositiveFlexForChild):
(WebCore::RenderFlexibleBox::logicalNegativeFlexForChild):
(WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
(WebCore::RenderFlexibleBox::setLogicalOverrideSize):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):

  • rendering/RenderFlexibleBox.h:

LayoutTests:

  • css3/flexbox/resources/flexbox.js:
  • css3/flexbox/writing-modes-expected.txt: Added.
  • css3/flexbox/writing-modes.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95574 r95577  
     12011-09-18  Ojan Vafai  <ojan@chromium.org>
     2
     3        change RenderFlexibleBox to act on logical coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=68129
     5
     6        Reviewed by David Hyatt.
     7
     8        * css3/flexbox/resources/flexbox.js:
     9        * css3/flexbox/writing-modes-expected.txt: Added.
     10        * css3/flexbox/writing-modes.html: Added.
     11
    1122011-09-20  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/LayoutTests/css3/flexbox/resources/flexbox.js

    r94250 r95577  
    1515    }
    1616
     17    var expectedHeight = node.getAttribute && node.getAttribute("data-expected-height");
     18    if (expectedHeight) {
     19        if (node.offsetHeight != parseInt(expectedHeight))
     20            failures.push("Expected " + expectedHeight + " for height, but got " + node.offsetHeight + ". ");
     21    }
     22
    1723    var expectedOffset = node.getAttribute && node.getAttribute("data-offset-x");
    1824    if (expectedOffset) {
    1925        if (node.offsetLeft != parseInt(expectedOffset))
    2026            failures.push("Expected " + expectedOffset + " for offsetLeft, but got " + node.offsetLeft + ". ");
     27    }
     28
     29    var expectedOffset = node.getAttribute && node.getAttribute("data-offset-y");
     30    if (expectedOffset) {
     31        if (node.offsetTop != parseInt(expectedOffset))
     32            failures.push("Expected " + expectedOffset + " for offsetTop, but got " + node.offsetTop + ". ");
    2133    }
    2234}
  • trunk/Source/WebCore/ChangeLog

    r95576 r95577  
     12011-09-18  Ojan Vafai  <ojan@chromium.org>
     2
     3        change RenderFlexibleBox to act on logical coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=68129
     5
     6        Reviewed by David Hyatt.
     7
     8        This makes RenderFlexibleBox respect direction and writing-mode.
     9        We now properly support the default flex-flow value of "row".
     10
     11        Test: css3/flexbox/writing-modes.html
     12
     13        * rendering/RenderBlock.cpp:
     14        (WebCore::RenderBlock::setLogicalLocationForChild):
     15        * rendering/RenderBlock.h:
     16        * rendering/RenderFlexibleBox.cpp:
     17        (WebCore::RenderFlexibleBox::layoutBlock):
     18        (WebCore::RenderFlexibleBox::logicalBorderWidthForChild):
     19        (WebCore::RenderFlexibleBox::logicalPaddingWidthForChild):
     20        (WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
     21        (WebCore::RenderFlexibleBox::marginStartStyleForChild):
     22        (WebCore::RenderFlexibleBox::marginEndStyleForChild):
     23        (WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
     24        (WebCore::RenderFlexibleBox::layoutInlineDirection):
     25        (WebCore::RenderFlexibleBox::logicalPositiveFlexForChild):
     26        (WebCore::RenderFlexibleBox::logicalNegativeFlexForChild):
     27        (WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
     28        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
     29        (WebCore::RenderFlexibleBox::setLogicalOverrideSize):
     30        (WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
     31        * rendering/RenderFlexibleBox.h:
     32
    1332011-09-20  Marshall Greenblatt  <marshall@chromium.org>
    234
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r95574 r95577  
    18611861}
    18621862
     1863void RenderBlock::setLogicalLocationForChild(RenderBox* child, const LayoutPoint& location)
     1864{
     1865    if (style()->isHorizontalWritingMode())
     1866        child->setLocation(location);
     1867    else
     1868        child->setLocation(location.transposedPoint());
     1869}
     1870
    18631871void RenderBlock::setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode applyDelta)
    18641872{
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r95264 r95577  
    210210    LayoutUnit logicalTopForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->y() : child->x(); }
    211211    LayoutUnit logicalLeftForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->x() : child->y(); }
     212    // FIXME: Supporting layout deltas.
     213    void setLogicalLocationForChild(RenderBox* child, const LayoutPoint&);
    212214    void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
    213215    void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r94706 r95577  
    100100    m_overflow.clear();
    101101
    102     // FIXME: Assume horizontal layout until flex-flow is added.
    103     layoutHorizontalBlock(relayoutChildren);
     102    layoutInlineDirection(relayoutChildren);
    104103
    105104    computeLogicalHeight();
     
    115114}
    116115
    117 static LayoutUnit preferredFlexItemContentWidth(RenderBox* child)
    118 {
    119     // FIXME: Handle vertical writing modes with horizontal flexing.
    120     if (child->style()->width().isAuto())
    121         return child->maxPreferredLogicalWidth() - child->borderLeft() - child->borderRight() - child->verticalScrollbarWidth() - child->paddingLeft() - child->paddingRight();
    122     return child->contentWidth();
    123 }
    124 
    125 void RenderFlexibleBox::layoutHorizontalBlock(bool relayoutChildren)
    126 {
    127     LayoutUnit preferredSize;
     116LayoutUnit RenderFlexibleBox::logicalBorderWidthForChild(RenderBox* child)
     117{
     118    if (isHorizontalWritingMode())
     119        return child->borderLeft() + child->borderRight();
     120    return child->borderTop() + child->borderBottom();
     121}
     122
     123LayoutUnit RenderFlexibleBox::logicalPaddingWidthForChild(RenderBox* child)
     124{
     125    if (isHorizontalWritingMode())
     126        return child->paddingLeft() + child->paddingRight();
     127    return child->paddingTop() + child->paddingBottom();
     128}
     129
     130LayoutUnit RenderFlexibleBox::logicalScrollbarHeightForChild(RenderBox* child)
     131{
     132    if (isHorizontalWritingMode())
     133        return child->horizontalScrollbarHeight();
     134    return child->verticalScrollbarWidth();
     135}
     136
     137Length RenderFlexibleBox::marginStartStyleForChild(RenderBox* child)
     138{
     139    if (isHorizontalWritingMode())
     140        return style()->isLeftToRightDirection() ? child->style()->marginLeft() : child->style()->marginRight();
     141    return style()->isLeftToRightDirection() ? child->style()->marginTop() : child->style()->marginBottom();
     142}
     143
     144Length RenderFlexibleBox::marginEndStyleForChild(RenderBox* child)
     145{
     146    if (isHorizontalWritingMode())
     147        return style()->isLeftToRightDirection() ? child->style()->marginRight() : child->style()->marginLeft();
     148    return style()->isLeftToRightDirection() ? child->style()->marginBottom() : child->style()->marginTop();
     149}
     150
     151LayoutUnit RenderFlexibleBox::preferredLogicalContentWidthForFlexItem(RenderBox* child)
     152{
     153    Length width = isHorizontalWritingMode() ? child->style()->width() : child->style()->height();
     154    if (width.isAuto()) {
     155        LayoutUnit logicalWidth = isHorizontalWritingMode() == child->isHorizontalWritingMode() ? child->maxPreferredLogicalWidth() : child->logicalHeight();
     156        return logicalWidth - logicalBorderWidthForChild(child) - logicalScrollbarHeightForChild(child) - logicalPaddingWidthForChild(child);
     157    }
     158    return isHorizontalWritingMode() ? child->contentWidth() : child->contentHeight();
     159}
     160
     161void RenderFlexibleBox::layoutInlineDirection(bool relayoutChildren)
     162{
     163    LayoutUnit preferredLogicalWidth;
    128164    float totalPositiveFlexibility;
    129165    float totalNegativeFlexibility;
    130166    FlexibleBoxIterator iterator(this);
    131167
    132     computePreferredSizeHorizontal(relayoutChildren, iterator, preferredSize, totalPositiveFlexibility, totalNegativeFlexibility);
    133     LayoutUnit availableFreeSpace = contentWidth() - preferredSize;
     168    computePreferredLogicalWidth(relayoutChildren, iterator, preferredLogicalWidth, totalPositiveFlexibility, totalNegativeFlexibility);
     169    LayoutUnit availableFreeSpace = contentLogicalWidth() - preferredLogicalWidth;
    134170
    135171    InflexibleFlexItemSize inflexibleItems;
    136172    WTF::Vector<LayoutUnit> childSizes;
    137     while (!runFreeSpaceAllocationAlgorithmHorizontal(availableFreeSpace, totalPositiveFlexibility, totalNegativeFlexibility, inflexibleItems, childSizes)) {
     173    while (!runFreeSpaceAllocationAlgorithmInlineDirection(availableFreeSpace, totalPositiveFlexibility, totalNegativeFlexibility, inflexibleItems, childSizes)) {
    138174        ASSERT(totalPositiveFlexibility >= 0 && totalNegativeFlexibility >= 0);
    139175        ASSERT(inflexibleItems.size() > 0);
    140176    }
    141177
    142     layoutAndPlaceChildrenHorizontal(childSizes, availableFreeSpace, totalPositiveFlexibility);
    143 
    144     // FIXME: Handle distribution of vertical space (third distribution round).
    145 }
    146 
    147 static LayoutUnit preferredSizeForMarginsAndPadding(Length length, LayoutUnit containerLength)
    148 {
    149     return length.calcMinValue(containerLength);
    150 }
    151 
    152 void RenderFlexibleBox::computePreferredSizeHorizontal(bool relayoutChildren, FlexibleBoxIterator& iterator, LayoutUnit& preferredSize, float& totalPositiveFlexibility, float& totalNegativeFlexibility)
    153 {
    154     preferredSize = 0;
     178    layoutAndPlaceChildrenInlineDirection(childSizes, availableFreeSpace, totalPositiveFlexibility);
     179
     180    // FIXME: Handle distribution of cross-axis space (third distribution round).
     181}
     182
     183float RenderFlexibleBox::logicalPositiveFlexForChild(RenderBox* child)
     184{
     185    return isHorizontalWritingMode() ? child->style()->flexboxWidthPositiveFlex() : child->style()->flexboxHeightPositiveFlex();
     186}
     187
     188float RenderFlexibleBox::logicalNegativeFlexForChild(RenderBox* child)
     189{
     190    return isHorizontalWritingMode() ? child->style()->flexboxWidthNegativeFlex() : child->style()->flexboxHeightNegativeFlex();
     191}
     192
     193void RenderFlexibleBox::computePreferredLogicalWidth(bool relayoutChildren, FlexibleBoxIterator& iterator, LayoutUnit& preferredLogicalWidth, float& totalPositiveFlexibility, float& totalNegativeFlexibility)
     194{
     195    preferredLogicalWidth = 0;
    155196    totalPositiveFlexibility = totalNegativeFlexibility = 0;
    156197
    157     // FIXME: Handle vertical writing modes with horizontal flexing.
    158198    LayoutUnit flexboxAvailableLogicalWidth = availableLogicalWidth();
    159199    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
     
    165205        child->layoutIfNeeded();
    166206
    167         preferredSize += preferredSizeForMarginsAndPadding(child->style()->marginLeft(), flexboxAvailableLogicalWidth);
    168         preferredSize += preferredSizeForMarginsAndPadding(child->style()->marginRight(), flexboxAvailableLogicalWidth);
    169         preferredSize += preferredSizeForMarginsAndPadding(child->style()->paddingLeft(), flexboxAvailableLogicalWidth);
    170         preferredSize += preferredSizeForMarginsAndPadding(child->style()->paddingRight(), flexboxAvailableLogicalWidth);
    171 
    172         if (child->style()->marginLeft().isAuto())
     207        if (isHorizontalWritingMode()) {
     208            preferredLogicalWidth += child->style()->marginLeft().calcMinValue(flexboxAvailableLogicalWidth);
     209            preferredLogicalWidth += child->style()->marginRight().calcMinValue(flexboxAvailableLogicalWidth);
     210            preferredLogicalWidth += child->style()->paddingLeft().calcMinValue(flexboxAvailableLogicalWidth);
     211            preferredLogicalWidth += child->style()->paddingRight().calcMinValue(flexboxAvailableLogicalWidth);
     212        } else {
     213            preferredLogicalWidth += child->style()->marginTop().calcMinValue(flexboxAvailableLogicalWidth);
     214            preferredLogicalWidth += child->style()->marginBottom().calcMinValue(flexboxAvailableLogicalWidth);
     215            preferredLogicalWidth += child->style()->paddingTop().calcMinValue(flexboxAvailableLogicalWidth);
     216            preferredLogicalWidth += child->style()->paddingBottom().calcMinValue(flexboxAvailableLogicalWidth);
     217        }
     218
     219        if (marginStartStyleForChild(child).isAuto())
    173220            totalPositiveFlexibility += 1;
    174         if (child->style()->marginRight().isAuto())
     221        if (marginEndStyleForChild(child).isAuto())
    175222            totalPositiveFlexibility += 1;
    176223
    177         preferredSize += child->borderLeft() + child->borderRight();
    178 
    179         preferredSize += preferredFlexItemContentWidth(child);
    180 
    181         totalPositiveFlexibility += child->style()->flexboxWidthPositiveFlex();
    182         totalNegativeFlexibility += child->style()->flexboxWidthNegativeFlex();
     224        preferredLogicalWidth += logicalBorderWidthForChild(child);
     225        preferredLogicalWidth += preferredLogicalContentWidthForFlexItem(child);
     226
     227        totalPositiveFlexibility += logicalPositiveFlexForChild(child);
     228        totalNegativeFlexibility += logicalNegativeFlexForChild(child);
    183229    }
    184230}
    185231
    186232// Returns true if we successfully ran the algorithm and sized the flex items.
    187 bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithmHorizontal(LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize& inflexibleItems, WTF::Vector<LayoutUnit>& childSizes)
     233bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection(LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize& inflexibleItems, WTF::Vector<LayoutUnit>& childSizes)
    188234{
    189235    FlexibleBoxIterator iterator(this);
    190236    childSizes.clear();
    191237
    192     // FIXME: Handle vertical writing modes with horizontal flexing.
    193238    LayoutUnit flexboxAvailableLogicalWidth = availableLogicalWidth();
    194239    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
     
    197242            childPreferredSize = inflexibleItems.get(child);
    198243        else {
    199             childPreferredSize = preferredFlexItemContentWidth(child);
     244            childPreferredSize = preferredLogicalContentWidthForFlexItem(child);
    200245            if (availableFreeSpace > 0 && totalPositiveFlexibility > 0) {
    201                 childPreferredSize += lroundf(availableFreeSpace * child->style()->flexboxWidthPositiveFlex() / totalPositiveFlexibility);
    202 
    203                 Length childMaxWidth = child->style()->maxWidth();
    204                 if (!childMaxWidth.isUndefined() && childMaxWidth.isSpecified() && childPreferredSize > childMaxWidth.calcValue(flexboxAvailableLogicalWidth)) {
    205                     childPreferredSize = childMaxWidth.calcValue(flexboxAvailableLogicalWidth);
    206                     availableFreeSpace -= childPreferredSize - preferredFlexItemContentWidth(child);
    207                     totalPositiveFlexibility -= child->style()->flexboxWidthPositiveFlex();
     246                childPreferredSize += lroundf(availableFreeSpace * logicalPositiveFlexForChild(child) / totalPositiveFlexibility);
     247
     248                Length childLogicalMaxWidth = isHorizontalWritingMode() ? child->style()->maxWidth() : child->style()->maxHeight();
     249                if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth)) {
     250                    childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth);
     251                    availableFreeSpace -= childPreferredSize - preferredLogicalContentWidthForFlexItem(child);
     252                    totalPositiveFlexibility -= logicalPositiveFlexForChild(child);
    208253
    209254                    inflexibleItems.set(child, childPreferredSize);
     
    211256                }
    212257            } else if (availableFreeSpace < 0 && totalNegativeFlexibility > 0) {
    213                 childPreferredSize += lroundf(availableFreeSpace * child->style()->flexboxWidthNegativeFlex() / totalNegativeFlexibility);
    214 
    215                 Length childMinWidth = child->style()->minWidth();
    216                 if (!childMinWidth.isUndefined() && childMinWidth.isSpecified() && childPreferredSize < childMinWidth.calcValue(flexboxAvailableLogicalWidth)) {
    217                     childPreferredSize = childMinWidth.calcValue(flexboxAvailableLogicalWidth);
    218                     availableFreeSpace += preferredFlexItemContentWidth(child) - childPreferredSize;
    219                     totalNegativeFlexibility -= child->style()->flexboxWidthNegativeFlex();
     258                childPreferredSize += lroundf(availableFreeSpace * logicalNegativeFlexForChild(child) / totalNegativeFlexibility);
     259
     260                Length childLogicalMinWidth = isHorizontalWritingMode() ? child->style()->minWidth() : child->style()->minHeight();
     261                if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth)) {
     262                    childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth);
     263                    availableFreeSpace += preferredLogicalContentWidthForFlexItem(child) - childPreferredSize;
     264                    totalNegativeFlexibility -= logicalNegativeFlexForChild(child);
    220265
    221266                    inflexibleItems.set(child, childPreferredSize);
     
    234279}
    235280
    236 void RenderFlexibleBox::layoutAndPlaceChildrenHorizontal(const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
     281void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize)
     282{
     283    // FIXME: Rename setOverrideWidth/setOverrideHeight to setOverrideLogicalWidth/setOverrideLogicalHeight.
     284    if (isHorizontalWritingMode())
     285        child->isHorizontalWritingMode() ? child->setOverrideWidth(childPreferredSize) : child->setOverrideHeight(childPreferredSize);
     286    else
     287        child->isHorizontalWritingMode() ? child->setOverrideHeight(childPreferredSize) : child->setOverrideWidth(childPreferredSize);
     288}
     289
     290void RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection(const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
    237291{
    238292    FlexibleBoxIterator iterator(this);
    239     // Now that we know the sizes, layout and position the flex items.
    240     LayoutUnit xOffset = borderLeft() + paddingLeft();
     293    LayoutUnit startEdge = borderStart() + paddingStart();
    241294
    242295    if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) {
    243296        if (style()->flexPack() == PackEnd)
    244             xOffset += availableFreeSpace;
     297            startEdge += availableFreeSpace;
    245298        else if (style()->flexPack() == PackCenter)
    246             xOffset += availableFreeSpace / 2;
    247     }
    248 
    249     LayoutUnit yOffset = borderTop() + paddingTop();
    250     setHeight(0);
     299            startEdge += availableFreeSpace / 2;
     300    }
     301
     302    LayoutUnit logicalTop = borderBefore() + paddingBefore();
     303    LayoutUnit totalAvailableLogicalWidth = availableLogicalWidth();
     304    setLogicalHeight(0);
    251305    size_t i = 0;
    252306    for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) {
    253         LayoutUnit childPreferredSize = child->borderLeft() + child->paddingLeft() + childSizes[i] + child->paddingRight() + child->borderRight();
    254         // FIXME: Handle vertical writing modes with horizontal flexing.
    255         child->setOverrideWidth(childPreferredSize);
     307        // FIXME: Does this need to take the scrollbar width into account?
     308        LayoutUnit childPreferredSize = childSizes[i] + logicalBorderWidthForChild(child) + logicalPaddingWidthForChild(child);
     309        setLogicalOverrideSize(child, childPreferredSize);
    256310        child->setChildNeedsLayout(true);
    257311        child->layoutIfNeeded();
    258312
    259         setHeight(std::max(height(), borderTop() + paddingTop() + child->marginTop() + child->height() + child->marginBottom() + paddingBottom() + borderBottom() + horizontalScrollbarHeight()));
    260 
    261         if (child->style()->marginLeft().isAuto())
    262             child->setMarginLeft(availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
    263         if (child->style()->marginRight().isAuto())
    264             child->setMarginRight(availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
    265 
    266         xOffset += child->marginLeft();
    267         child->setLocation(IntPoint(xOffset, yOffset));
    268         xOffset += child->width() + child->marginRight();
     313        setLogicalHeight(std::max(logicalHeight(), borderBefore() + paddingBefore() + marginBeforeForChild(child) + logicalHeightForChild(child) + marginAfterForChild(child) + paddingAfter() + borderAfter() + scrollbarLogicalHeight()));
     314
     315        if (marginStartStyleForChild(child).isAuto())
     316            setMarginStartForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
     317        if (marginEndStyleForChild(child).isAuto())
     318            setMarginEndForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
     319
     320        startEdge += marginStartForChild(child);
     321
     322        LayoutUnit childLogicalWidth = logicalWidthForChild(child);
     323        LayoutUnit logicalLeft = style()->isLeftToRightDirection() ? startEdge : totalAvailableLogicalWidth - startEdge - childLogicalWidth;
     324        // FIXME: Do repaintDuringLayoutIfMoved.
     325        // FIXME: Supporting layout deltas.
     326        setLogicalLocationForChild(child, IntPoint(logicalLeft, logicalTop));
     327        startEdge += childLogicalWidth + marginEndForChild(child);
    269328
    270329        if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && style()->flexPack() == PackJustify && childSizes.size() > 1)
    271             xOffset += availableFreeSpace / (childSizes.size() - 1);
     330            startEdge += availableFreeSpace / (childSizes.size() - 1);
    272331    }
    273332}
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r94117 r95577  
    5353    typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
    5454
    55     void layoutHorizontalBlock(bool relayoutChildren);
     55    LayoutUnit logicalBorderWidthForChild(RenderBox* child);
     56    LayoutUnit logicalPaddingWidthForChild(RenderBox* child);
     57    LayoutUnit logicalScrollbarHeightForChild(RenderBox* child);
     58    Length marginStartStyleForChild(RenderBox* child);
     59    Length marginEndStyleForChild(RenderBox* child);
     60    LayoutUnit preferredLogicalContentWidthForFlexItem(RenderBox* child);
    5661
    57     void computePreferredSizeHorizontal(bool relayoutChildren, FlexibleBoxIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
    58     bool runFreeSpaceAllocationAlgorithmHorizontal(LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
    59     void layoutAndPlaceChildrenHorizontal(const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility);
     62    void layoutInlineDirection(bool relayoutChildren);
     63
     64    float logicalPositiveFlexForChild(RenderBox* child);
     65    float logicalNegativeFlexForChild(RenderBox* child);
     66
     67    void computePreferredLogicalWidth(bool relayoutChildren, FlexibleBoxIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
     68    bool runFreeSpaceAllocationAlgorithmInlineDirection(LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
     69    void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
     70    void layoutAndPlaceChildrenInlineDirection(const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility);
    6071};
    6172
Note: See TracChangeset for help on using the changeset viewer.