Changeset 124987 in webkit


Ignore:
Timestamp:
Aug 7, 2012 10:25:34 PM (12 years ago)
Author:
ojan@chromium.org
Message:

percentage margins + flex incorrectly overflows the flexbox
https://bugs.webkit.org/show_bug.cgi?id=93411

Reviewed by Tony Chang.

Source/WebCore:

Percent margins should always be computed with respect to the containing
block's width, not it's height. We were getting this wrong in column flows.

Test: css3/flexbox/percent-margins.html

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeMarginValue):
(WebCore):
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):

  • rendering/RenderFlexibleBox.h:

LayoutTests:

  • css3/flexbox/percent-margins-expected.txt: Added.
  • css3/flexbox/percent-margins.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r124986 r124987  
     12012-08-07  Ojan Vafai  <ojan@chromium.org>
     2
     3        percentage margins + flex incorrectly overflows the flexbox
     4        https://bugs.webkit.org/show_bug.cgi?id=93411
     5
     6        Reviewed by Tony Chang.
     7
     8        * css3/flexbox/percent-margins-expected.txt: Added.
     9        * css3/flexbox/percent-margins.html: Added.
     10
    1112012-08-07  Eric Carlson  <eric.carlson@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r124985 r124987  
     12012-08-07  Ojan Vafai  <ojan@chromium.org>
     2
     3        percentage margins + flex incorrectly overflows the flexbox
     4        https://bugs.webkit.org/show_bug.cgi?id=93411
     5
     6        Reviewed by Tony Chang.
     7
     8        Percent margins should always be computed with respect to the containing
     9        block's width, not it's height. We were getting this wrong in column flows.
     10
     11        Test: css3/flexbox/percent-margins.html
     12
     13        * rendering/RenderFlexibleBox.cpp:
     14        (WebCore::RenderFlexibleBox::computeMarginValue):
     15        (WebCore):
     16        (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
     17        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
     18        * rendering/RenderFlexibleBox.h:
     19
    1202012-08-07  Kentaro Hara  <haraken@chromium.org>
    221
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r124793 r124987  
    759759}
    760760
     761LayoutUnit RenderFlexibleBox::computeMarginValue(Length margin, LayoutUnit availableSize, RenderView* view)
     762{
     763    // CSS always computes percent margins with respect to the containing block's width, even for margin-top/margin-bottom.
     764    if (margin.isPercent())
     765        availableSize = logicalWidth();
     766    return minimumValueForLength(margin, availableSize, view);
     767}
     768
    761769void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet& orderValues)
    762770{
     
    781789        // Also, if we're not auto sizing, we don't do a layout that computes the start/end margins.
    782790        if (isHorizontalFlow()) {
    783             child->setMarginLeft(minimumValueForLength(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView));
    784             child->setMarginRight(minimumValueForLength(child->style()->marginRight(), flexboxAvailableContentExtent, renderView));
     791            child->setMarginLeft(computeMarginValue(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView));
     792            child->setMarginRight(computeMarginValue(child->style()->marginRight(), flexboxAvailableContentExtent, renderView));
    785793        } else {
    786             child->setMarginTop(minimumValueForLength(child->style()->marginTop(), flexboxAvailableContentExtent, renderView));
    787             child->setMarginBottom(minimumValueForLength(child->style()->marginBottom(), flexboxAvailableContentExtent, renderView));
     794            child->setMarginTop(computeMarginValue(child->style()->marginTop(), flexboxAvailableContentExtent, renderView));
     795            child->setMarginBottom(computeMarginValue(child->style()->marginBottom(), flexboxAvailableContentExtent, renderView));
    788796        }
    789797    }
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r124793 r124987  
    120120    LayoutUnit marginBoxAscentForChild(RenderBox*);
    121121
     122    LayoutUnit computeMarginValue(Length margin, LayoutUnit availableSize, RenderView*);
    122123    void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&);
    123124    LayoutUnit lineBreakLength();
Note: See TracChangeset for help on using the changeset viewer.