Changeset 112154 in webkit
- Timestamp:
- Mar 26, 2012 3:26:02 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112151 r112154 1 2012-03-26 Tony Chang <tony@chromium.org> 2 3 apply cross axis constraints before aligning children in flexbox 4 https://bugs.webkit.org/show_bug.cgi?id=82240 5 6 Reviewed by Ojan Vafai. 7 8 * css3/flexbox/flex-align-expected.txt: 9 * css3/flexbox/flex-align.html: 10 1 11 2012-03-26 Ojan Vafai <ojan@chromium.org> 2 12 -
trunk/LayoutTests/css3/flexbox/flex-align-expected.txt
r105015 r112154 1 PASS 1 2 PASS 2 3 PASS -
trunk/LayoutTests/css3/flexbox/flex-align.html
r105015 r112154 223 223 </div> 224 224 225 <div class="flexbox" style="max-height: 20px"> 226 <div data-expected-height="40" data-offset-y="-10" style="width: -webkit-flex(1 0 0); -webkit-flex-item-align: center; height: 40px;"></div> 227 <div data-expected-height="40" data-offset-y="-20" style="width: -webkit-flex(1 0 0); -webkit-flex-item-align: end; height: 40px;"></div> 228 <div data-expected-height="40" data-offset-y="0" style="width: -webkit-flex(1 0 0); height: 40px;"></div> 229 <div data-expected-height="20" data-offset-y="0" style="width: -webkit-flex(1 0 0);"></div> 230 </div> 231 225 232 <div class="flexbox" style="font-family: test;"> 226 233 <div id="baseline1" style="width: -webkit-flex(1 0 0); -webkit-flex-item-align: baseline;">ahem</div> -
trunk/Source/WebCore/ChangeLog
r112148 r112154 1 2012-03-26 Tony Chang <tony@chromium.org> 2 3 apply cross axis constraints before aligning children in flexbox 4 https://bugs.webkit.org/show_bug.cgi?id=82240 5 6 Reviewed by Ojan Vafai. 7 8 We weren't applying max-height constraints before aligning children. 9 This would cause center, end, stretch alignment to be wrong if we hit 10 a max-height on a flexbox. 11 12 This patch also moves the repositioning logic to happen after 13 computeLogicalHeight, which will be useful for flex-line-pack. 14 15 New test case in css3/flexbox/flex-align.html 16 17 * rendering/RenderFlexibleBox.cpp: 18 (WebCore::RenderFlexibleBox::layoutBlock): 19 (WebCore::RenderFlexibleBox::layoutFlexItems): 20 (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): 21 * rendering/RenderFlexibleBox.h: 22 1 23 2012-03-26 Anders Carlsson <andersca@apple.com> 2 24 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r111961 r112154 251 251 252 252 setLogicalHeight(0); 253 // We need to call both of these because we grab both crossAxisExtent and mainAxisExtent in layoutFlexItems.254 253 computeLogicalWidth(); 255 computeLogicalHeight();256 254 257 255 m_overflow.clear(); … … 265 263 } 266 264 267 layoutFlexItems(relayoutChildren); 265 WTF::Vector<LineContext> lineContexts; 266 FlexOrderHashSet flexOrderValues; 267 computeMainAxisPreferredSizes(relayoutChildren, flexOrderValues); 268 FlexOrderIterator flexIterator(this, flexOrderValues); 269 layoutFlexItems(relayoutChildren, flexIterator, lineContexts); 268 270 269 271 LayoutUnit oldClientAfterEdge = clientLogicalBottom(); 270 272 computeLogicalHeight(); 273 repositionLogicalHeightDependentFlexItems(flexIterator, lineContexts, oldClientAfterEdge); 271 274 272 275 if (size() != previousSize) … … 290 293 291 294 setNeedsLayout(false); 295 } 296 297 void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(FlexOrderIterator& iterator, WTF::Vector<LineContext>& lineContexts, LayoutUnit& oldClientAfterEdge) 298 { 299 // If we have a single line flexbox, the line height is all the available space. 300 // For flex-direction: row, this means we need to use the height, so we do this after calling computeLogicalHeight. 301 if (!isMultiline() && lineContexts.size() == 1) 302 lineContexts[0].crossAxisExtent = crossAxisContentExtent(); 303 alignChildren(iterator, lineContexts); 304 305 if (style()->flexWrap() == FlexWrapReverse) { 306 if (isHorizontalFlow()) 307 oldClientAfterEdge = clientLogicalBottom(); 308 flipForWrapReverse(iterator, lineContexts); 309 } 310 311 // direction:rtl + flex-direction:column means the cross-axis direction is flipped. 312 flipForRightToLeftColumn(iterator); 292 313 } 293 314 … … 590 611 } 591 612 592 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) 593 { 594 FlexOrderHashSet flexOrderValues; 595 computeMainAxisPreferredSizes(relayoutChildren, flexOrderValues); 596 613 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren, FlexOrderIterator& iterator, WTF::Vector<LineContext>& lineContexts) 614 { 597 615 OrderedFlexItemList orderedChildren; 598 616 LayoutUnit preferredMainAxisExtent; … … 600 618 float totalNegativeFlexibility; 601 619 LayoutUnit minMaxAppliedMainAxisExtent; 602 WTF::Vector<LineContext> lineContexts;603 FlexOrderIterator flexIterator(this, flexOrderValues);604 620 605 621 LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore(); 606 while (computeNextFlexLine( flexIterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility, minMaxAppliedMainAxisExtent)) {622 while (computeNextFlexLine(iterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility, minMaxAppliedMainAxisExtent)) { 607 623 LayoutUnit availableFreeSpace = computeAvailableFreeSpace(preferredMainAxisExtent); 608 624 FlexSign flexSign = (minMaxAppliedMainAxisExtent < preferredMainAxisExtent + availableFreeSpace) ? PositiveFlexibility : NegativeFlexibility; … … 616 632 layoutAndPlaceChildren(crossAxisOffset, orderedChildren, childSizes, availableFreeSpace, lineContexts); 617 633 } 618 //619 alignChildren(flexIterator, lineContexts);620 621 if (style()->flexWrap() == FlexWrapReverse)622 flipForWrapReverse(flexIterator, lineContexts);623 624 // direction:rtl + flex-direction:column means the cross-axis direction is flipped.625 flipForRightToLeftColumn(flexIterator);626 634 } 627 635 … … 928 936 } 929 937 930 LayoutUnit lineCrossAxisExtent = isMultiline() ? maxChildCrossAxisExtent : crossAxisContentExtent(); 931 lineContexts.append(LineContext(crossAxisOffset, lineCrossAxisExtent, children.size(), maxAscent)); 932 crossAxisOffset += lineCrossAxisExtent; 938 lineContexts.append(LineContext(crossAxisOffset, maxChildCrossAxisExtent, children.size(), maxAscent)); 939 crossAxisOffset += maxChildCrossAxisExtent; 933 940 } 934 941 … … 1077 1084 void RenderFlexibleBox::flipForWrapReverse(FlexOrderIterator& iterator, const WTF::Vector<LineContext>& lineContexts) 1078 1085 { 1079 if (!isColumnFlow())1080 computeLogicalHeight();1081 1082 1086 LayoutUnit contentExtent = crossAxisContentExtent(); 1083 1087 RenderBox* child = iterator.first(); -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r111767 r112154 101 101 LayoutUnit preferredMainAxisContentExtentForChild(RenderBox* child) const; 102 102 103 void layoutFlexItems(bool relayoutChildren); 103 void layoutFlexItems(bool relayoutChildren, FlexOrderIterator&, WTF::Vector<LineContext>&); 104 void repositionLogicalHeightDependentFlexItems(FlexOrderIterator&, WTF::Vector<LineContext>&, LayoutUnit& oldClientAfterEdge); 104 105 105 106 float positiveFlexForChild(RenderBox* child) const; … … 120 121 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize); 121 122 void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset); 122 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, WTF::Vector<LineContext>& lineContexts);123 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, WTF::Vector<LineContext>&); 123 124 void layoutColumnReverse(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace); 124 125 void alignChildren(FlexOrderIterator&, const WTF::Vector<LineContext>&);
Note: See TracChangeset
for help on using the changeset viewer.