Changeset 117897 in webkit
- Timestamp:
- May 21, 2012 9:08:40 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117896 r117897 1 2012-05-21 Tony Chang <tony@chromium.org> 2 3 auto margins on flexbox should allocate space in the flex direction 4 https://bugs.webkit.org/show_bug.cgi?id=83086 5 6 Reviewed by Ojan Vafai. 7 8 * css3/flexbox/flex-algorithm-with-margins-expected.txt: 9 * css3/flexbox/flex-algorithm-with-margins.html: Added safe centering test case. 10 * css3/flexbox/flex-flow-auto-margins-expected.txt: Added. 11 * css3/flexbox/flex-flow-auto-margins.html: Added. 12 * css3/flexbox/flex-pack.html: Fixed old results. 13 1 14 2012-05-21 Abhishek Arya <inferno@chromium.org> 2 15 -
trunk/LayoutTests/css3/flexbox/flex-algorithm-with-margins-expected.txt
r110253 r117897 10 10 PASS 11 11 PASS 12 PASS -
trunk/LayoutTests/css3/flexbox/flex-algorithm-with-margins.html
r117385 r117897 44 44 </div> 45 45 46 <!-- Margins set to auto have a value of 0. -->46 <!-- Margins set to auto get space only if there's space available after flexing. --> 47 47 <div class="flexbox"> 48 48 <div data-expected-width="200" style="-webkit-flex: 1 0 0;"></div> … … 52 52 53 53 <div class="flexbox"> 54 <div data-expected-width="1 33" style="-webkit-flex: 1 0 0;"></div>55 <div data-expected-width=" 233" data-offset-x="133" style="-webkit-flex: 10 100px; margin-left: auto;"></div>56 <div data-expected-width="1 33" data-offset-x="366" style="-webkit-flex: 1 0 0; margin-right: 100px"></div>54 <div data-expected-width="100" style="-webkit-flex: 1 0 0;"></div> 55 <div data-expected-width="300" data-offset-x="100" style="-webkit-flex: 2 0 100px; margin-left: auto;"></div> 56 <div data-expected-width="100" data-offset-x="400" style="-webkit-flex: 1 0 0; margin-right: 100px"></div> 57 57 </div> 58 58 59 <!-- Margins set to auto don't have negative flex either. -->59 <!-- Margins set to auto don't have negative flex. --> 60 60 <div class="flexbox"> 61 61 <div data-expected-width="150" style="-webkit-flex: 1 1 300px;"></div> … … 64 64 </div> 65 65 66 <!-- Margins set to auto don't center in flexboxen. -->67 66 <div class="flexbox"> 68 <div data-expected-width="300px" data-offset-x="0" style="-webkit-flex: 0 0 300px; margin: 0 auto;"></div> 67 <div data-expected-width="300px" data-offset-x="150" style="-webkit-flex: 0 0 300px; margin: 0 auto;"></div> 68 </div> 69 70 <!-- margin: auto safe centers, which means it won't overflow to before the start of the flexbox. --> 71 <div class="flexbox"> 72 <div data-expected-width="700px" data-offset-x="0" style="-webkit-flex: 0 0 700px; margin: 0 auto;"></div> 69 73 </div> 70 74 -
trunk/LayoutTests/css3/flexbox/flex-pack.html
r117385 r117897 97 97 <div class="flexbox" style="-webkit-flex-pack: distribute"></div> 98 98 99 <!-- margin:auto does nothing here. -->99 <!-- margin:auto applies before packing. --> 100 100 <div class="flexbox" style="-webkit-flex-pack: end"> 101 <div data-expected-width="100" data-offset-x=" 300" style="width: 100px;"></div>102 <div data-expected-width="100" data-offset-x=" 400" style="width: 100px; margin-right: auto"></div>101 <div data-expected-width="100" data-offset-x="0" style="width: 100px;"></div> 102 <div data-expected-width="100" data-offset-x="100" style="width: 100px; margin-right: auto"></div> 103 103 <div data-expected-width="100" data-offset-x="500" style="width: 100px;"></div> 104 104 </div> -
trunk/Source/WebCore/ChangeLog
r117890 r117897 1 2012-05-21 Tony Chang <tony@chromium.org> 2 3 auto margins on flexbox should allocate space in the flex direction 4 https://bugs.webkit.org/show_bug.cgi?id=83086 5 6 Reviewed by Ojan Vafai. 7 8 Test: css3/flexbox/flex-flow-auto-margins.html 9 10 * rendering/RenderFlexibleBox.cpp: 11 (WebCore::RenderFlexibleBox::autoMarginOffsetInMainAxis): 12 (WebCore): 13 (WebCore::RenderFlexibleBox::updateAutoMarginsInMainAxis): 14 (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): Update the margins on the RenderBox *after* we do the final child layout. 15 * rendering/RenderFlexibleBox.h: 16 1 17 2012-05-21 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 18 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r116038 r117897 643 643 } 644 644 645 LayoutUnit RenderFlexibleBox::autoMarginOffsetInMainAxis(const OrderedFlexItemList& children, LayoutUnit& availableFreeSpace) 646 { 647 if (availableFreeSpace <= 0) 648 return 0; 649 650 int numberOfAutoMargins = 0; 651 bool isHorizontal = isHorizontalFlow(); 652 for (size_t i = 0; i < children.size(); ++i) { 653 RenderBox* child = children[i]; 654 if (child->isPositioned()) 655 continue; 656 if (isHorizontal) { 657 if (child->style()->marginLeft().isAuto()) 658 ++numberOfAutoMargins; 659 if (child->style()->marginRight().isAuto()) 660 ++numberOfAutoMargins; 661 } else { 662 if (child->style()->marginTop().isAuto()) 663 ++numberOfAutoMargins; 664 if (child->style()->marginBottom().isAuto()) 665 ++numberOfAutoMargins; 666 } 667 } 668 if (!numberOfAutoMargins) 669 return 0; 670 671 LayoutUnit sizeOfAutoMargin = availableFreeSpace / numberOfAutoMargins; 672 availableFreeSpace = 0; 673 return sizeOfAutoMargin; 674 } 675 676 void RenderFlexibleBox::updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit autoMarginOffset) 677 { 678 if (isHorizontalFlow()) { 679 if (child->style()->marginLeft().isAuto()) 680 child->setMarginLeft(autoMarginOffset); 681 if (child->style()->marginRight().isAuto()) 682 child->setMarginRight(autoMarginOffset); 683 } else { 684 if (child->style()->marginTop().isAuto()) 685 child->setMarginTop(autoMarginOffset); 686 if (child->style()->marginBottom().isAuto()) 687 child->setMarginBottom(autoMarginOffset); 688 } 689 } 690 645 691 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox* child) 646 692 { … … 674 720 } 675 721 676 // We set the margins because we want to make sure 'auto' has a margin 677 // of 0 and because if we're not auto sizing, we don't do a layout that 678 // computes the start/end margins. 722 // Before running the flex algorithm, 'auto' has a margin of 0. 723 // Also, if we're not auto sizing, we don't do a layout that computes the start/end margins. 679 724 if (isHorizontalFlow()) { 680 725 child->setMarginLeft(minimumValueForLength(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView)); … … 882 927 { 883 928 ASSERT(childSizes.size() == children.size()); 929 930 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, availableFreeSpace); 884 931 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart(); 885 932 mainAxisOffset += initialPackingOffset(availableFreeSpace, style()->flexPack(), childSizes.size()); … … 902 949 child->setChildNeedsLayout(true); 903 950 child->layoutIfNeeded(); 951 952 updateAutoMarginsInMainAxis(child, autoMarginOffset); 904 953 905 954 LayoutUnit childCrossAxisMarginBoxExtent; -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r115668 r117897 102 102 103 103 void layoutFlexItems(FlexOrderIterator&, WTF::Vector<LineContext>&); 104 LayoutUnit autoMarginOffsetInMainAxis(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace); 105 void updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit autoMarginOffset); 104 106 void repositionLogicalHeightDependentFlexItems(FlexOrderIterator&, WTF::Vector<LineContext>&, LayoutUnit& oldClientAfterEdge); 105 107
Note: See TracChangeset
for help on using the changeset viewer.