Changeset 93547 in webkit


Ignore:
Timestamp:
Aug 22, 2011 2:49:06 PM (13 years ago)
Author:
tony@chromium.org
Message:

handle child margin values when flexing
https://bugs.webkit.org/show_bug.cgi?id=65887

Reviewed by David Hyatt.

Source/WebCore:

Test: css3/flexbox/002.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeLogicalWidth):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutHorizontalBlock):
(WebCore::RenderFlexibleBox::computePreferredSize): If the margin is

auto, treat it as flex(1 0 0).

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::isFlexibleBoxIncludingDeprecated): Added.

LayoutTests:

  • css3/flexbox/002-expected.txt: Added.
  • css3/flexbox/002.html: Added.
  • css3/flexbox/resources/flexbox.js:

(checkHorizontalBoxen):

Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93541 r93547  
     12011-08-22  Tony Chang  <tony@chromium.org>
     2
     3        handle child margin values when flexing
     4        https://bugs.webkit.org/show_bug.cgi?id=65887
     5
     6        Reviewed by David Hyatt.
     7
     8        * css3/flexbox/002-expected.txt: Added.
     9        * css3/flexbox/002.html: Added.
     10        * css3/flexbox/resources/flexbox.js:
     11        (checkHorizontalBoxen):
     12
    1132011-08-22  Peter Kasting  <pkasting@google.com>
    214
  • trunk/LayoutTests/css3/flexbox/resources/flexbox.js

    r92628 r93547  
    1717          if (child.offsetWidth && expectedWidth) {
    1818              if (child.offsetWidth != parseInt(expectedWidth)) {
    19                   failures += "Expected " + expectedWidth + " but got " + child.offsetWidth + ". ";
     19                  failures += "Expected " + expectedWidth + " for width, but got " + child.offsetWidth + ". ";
    2020              }
    2121          }
     22
     23          var expectedOffset = child.getAttribute && child.getAttribute("data-offset-x");
     24          if (child.offsetLeft && expectedOffset) {
     25              if (child.offsetLeft != parseInt(expectedOffset)) {
     26                  failures += "Expected " + expectedOffset + " for offsetLeft, but got " + child.offsetLeft + ". ";
     27              }
     28          }
     29
    2230          child = child.nextSibling;
    2331      }
  • trunk/Source/WebCore/ChangeLog

    r93542 r93547  
     12011-08-22  Tony Chang  <tony@chromium.org>
     2
     3        handle child margin values when flexing
     4        https://bugs.webkit.org/show_bug.cgi?id=65887
     5
     6        Reviewed by David Hyatt.
     7
     8        Test: css3/flexbox/002.html
     9
     10        * rendering/RenderBox.cpp:
     11        (WebCore::RenderBox::computeLogicalWidth):
     12        * rendering/RenderFlexibleBox.cpp:
     13        (WebCore::RenderFlexibleBox::layoutHorizontalBlock):
     14        (WebCore::RenderFlexibleBox::computePreferredSize): If the margin is
     15            auto, treat it as flex(1 0 0).
     16        * rendering/RenderObject.cpp:
     17        (WebCore::RenderObject::isFlexibleBoxIncludingDeprecated): Added.
     18
    1192011-08-22  Nat Duca  <nduca@chromium.org>
    220
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r93284 r93547  
    16311631
    16321632    if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (logicalWidth() + marginStart() + marginEnd())
    1633             && !isFloating() && !isInline() && !cb->isDeprecatedFlexibleBox())
     1633            && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated())
    16341634        cb->setMarginEndForChild(this, containerLogicalWidth - logicalWidth() - cb->marginStartForChild(this));
    16351635}
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r92628 r93547  
    149149        setHeight(std::max(height(), borderTop() + paddingTop() + child->marginTop() + child->height() + child->marginBottom() + paddingBottom() + borderBottom() + horizontalScrollbarHeight()));
    150150
    151         // FIXME: Handle child margins.
     151        if (child->style()->marginLeft().isAuto())
     152            child->setMarginLeft(availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
     153        if (child->style()->marginRight().isAuto())
     154            child->setMarginRight(availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
     155
     156        xOffset += child->marginLeft();
    152157        child->setLocation(IntPoint(xOffset, yOffset));
    153         xOffset += child->width();
     158        xOffset += child->width() + child->marginRight();
    154159    }
    155160
     
    177182        child->layoutIfNeeded();
    178183
    179         // FIXME: Margins and paddings set to auto have a positive flexibility of 1.
    180184        preferredSize += preferredSizeForMarginsAndPadding(child->style()->marginLeft(), flexboxAvailableLogicalWidth);
    181185        preferredSize += preferredSizeForMarginsAndPadding(child->style()->marginRight(), flexboxAvailableLogicalWidth);
     
    183187        preferredSize += preferredSizeForMarginsAndPadding(child->style()->paddingRight(), flexboxAvailableLogicalWidth);
    184188
     189        if (child->style()->marginLeft().isAuto())
     190            totalPositiveFlexibility += 1;
     191        if (child->style()->marginRight().isAuto())
     192            totalPositiveFlexibility += 1;
     193
    185194        preferredSize += child->borderLeft() + child->borderRight();
    186195
  • trunk/Source/WebCore/rendering/RenderObject.h

    r93144 r93547  
    753753    virtual bool isFlexibleBox() const { return false; }
    754754#endif
     755
     756    bool isFlexibleBoxIncludingDeprecated() const
     757    {
     758#if ENABLE(CSS3_FLEXBOX)
     759        return isFlexibleBox() || isDeprecatedFlexibleBox();
     760#else
     761        return isDeprecatedFlexibleBox();
     762#endif
     763    }
    755764
    756765    virtual bool isCombineText() const { return false; }
Note: See TracChangeset for help on using the changeset viewer.