Changeset 112544 in webkit
- Timestamp:
- Mar 29, 2012 10:16:39 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112534 r112544 1 2012-03-29 Tony Chang <tony@chromium.org> 2 3 Need to implement flex-line-pack 4 https://bugs.webkit.org/show_bug.cgi?id=70794 5 6 Reviewed by Ojan Vafai. 7 8 Updated the old multiline tests to have -webkit-flex-line-pack: start, 9 which was the previous default behavior. The correct default behavior 10 is stretch. 11 12 * css3/flexbox/multiline-align.html: 13 * css3/flexbox/multiline-column-auto.html: 14 * css3/flexbox/multiline-line-pack-expected.txt: Added. 15 * css3/flexbox/multiline-line-pack-horizontal-column-expected.txt: Added. 16 * css3/flexbox/multiline-line-pack-horizontal-column.html: Added. 17 * css3/flexbox/multiline-line-pack.html: Added. 18 * css3/flexbox/multiline-pack.html: 19 * css3/flexbox/multiline-reverse-wrap-overflow.html: 20 * css3/flexbox/multiline-shrink-to-fit.html: 21 * css3/flexbox/multiline.html: 22 1 23 2012-03-29 Csaba Osztrogonác <ossy@webkit.org> 2 24 -
trunk/LayoutTests/css3/flexbox/multiline-align.html
r110583 r112544 7 7 background-color: grey; 8 8 max-width: 600px; 9 -webkit-flex-line-pack: start; 9 10 } 10 11 .title { -
trunk/LayoutTests/css3/flexbox/multiline-column-auto.html
r110747 r112544 8 8 -webkit-flex-flow: column wrap; 9 9 margin-top: 20px; 10 -webkit-flex-line-pack: start; 10 11 } 11 12 .flexbox > div { -
trunk/LayoutTests/css3/flexbox/multiline-pack.html
r110583 r112544 7 7 background-color: grey; 8 8 max-width: 100px; 9 -webkit-flex-line-pack: start; 9 10 } 10 11 .title { -
trunk/LayoutTests/css3/flexbox/multiline-reverse-wrap-overflow.html
r110634 r112544 8 8 -webkit-flex-wrap: wrap-reverse; 9 9 margin-top: 20px; 10 -webkit-flex-line-pack: start; 10 11 } 11 12 .flexbox > div { -
trunk/LayoutTests/css3/flexbox/multiline-shrink-to-fit.html
r110747 r112544 9 9 -webkit-flex-direction: column; 10 10 float: left; 11 -webkit-flex-line-pack: start; 11 12 } 12 13 -
trunk/LayoutTests/css3/flexbox/multiline.html
r110583 r112544 7 7 background-color: grey; 8 8 max-width: 600px; 9 -webkit-flex-line-pack: start; 9 10 } 10 11 .title { … … 42 43 } 43 44 .wrap { 44 -webkit-flex-wrap: wrap;45 -webkit-flex-wrap: wrap; 45 46 } 46 47 .wrap-reverse { 47 -webkit-flex-wrap: wrap-reverse;48 -webkit-flex-wrap: wrap-reverse; 48 49 } 49 50 .flexbox > :nth-child(1) { -
trunk/Source/WebCore/ChangeLog
r112541 r112544 1 2012-03-29 Tony Chang <tony@chromium.org> 2 3 Need to implement flex-line-pack 4 https://bugs.webkit.org/show_bug.cgi?id=70794 5 6 Reviewed by Ojan Vafai. 7 8 Tests: css3/flexbox/multiline-line-pack-horizontal-column.html 9 css3/flexbox/multiline-line-pack.html 10 11 * rendering/RenderFlexibleBox.cpp: 12 (WebCore::RenderFlexibleBox::repositionLogicalHeightDependentFlexItems): 13 (WebCore::initialLinePackingOffset): Similar to initialPackingOffset. 14 (WebCore): 15 (WebCore::linePackingSpaceBetweenChildren): Similar to packingSpaceBetweenChildren. 16 (WebCore::RenderFlexibleBox::packFlexLines): Move lines based on flex-line-pack. 17 Note that we don't need to relayout on stretch because 18 alignChildren will do that for us (only auto size needs stretching). 19 (WebCore::RenderFlexibleBox::flipForWrapReverse): Pull out the initial 20 cross axis offset before calling packFlexLines because we can 21 move the the line contexts. 22 * rendering/RenderFlexibleBox.h: 23 1 24 2012-03-29 Vsevolod Vlasov <vsevik@chromium.org> 2 25 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r112425 r112544 297 297 void RenderFlexibleBox::repositionLogicalHeightDependentFlexItems(FlexOrderIterator& iterator, WTF::Vector<LineContext>& lineContexts, LayoutUnit& oldClientAfterEdge) 298 298 { 299 LayoutUnit crossAxisStartEdge = lineContexts.isEmpty() ? 0 : lineContexts[0].crossAxisOffset; 300 packFlexLines(iterator, lineContexts); 301 299 302 // If we have a single line flexbox, the line height is all the available space. 300 303 // For flex-direction: row, this means we need to use the height, so we do this after calling computeLogicalHeight. … … 306 309 if (isHorizontalFlow()) 307 310 oldClientAfterEdge = clientLogicalBottom(); 308 flipForWrapReverse(iterator, lineContexts );311 flipForWrapReverse(iterator, lineContexts, crossAxisStartEdge); 309 312 } 310 313 … … 971 974 mainAxisOffset -= flowAwareMarginStartForChild(child); 972 975 mainAxisOffset -= packingSpaceBetweenChildren(availableFreeSpace, style()->flexPack(), childSizes.size()); 976 } 977 } 978 979 static LayoutUnit initialLinePackingOffset(LayoutUnit availableFreeSpace, EFlexLinePack linePack, size_t numberOfLines) 980 { 981 if (linePack == LinePackEnd) 982 return availableFreeSpace; 983 if (linePack == LinePackCenter) 984 return availableFreeSpace / 2; 985 if (linePack == LinePackDistribute) { 986 if (availableFreeSpace > 0 && numberOfLines) 987 return availableFreeSpace / (2 * numberOfLines); 988 if (availableFreeSpace < 0) 989 return availableFreeSpace / 2; 990 } 991 return 0; 992 } 993 994 static LayoutUnit linePackingSpaceBetweenChildren(LayoutUnit availableFreeSpace, EFlexLinePack linePack, size_t numberOfLines) 995 { 996 if (availableFreeSpace > 0 && numberOfLines > 1) { 997 if (linePack == LinePackJustify) 998 return availableFreeSpace / (numberOfLines - 1); 999 if (linePack == LinePackDistribute || linePack == LinePackStretch) 1000 return availableFreeSpace / numberOfLines; 1001 } 1002 return 0; 1003 } 1004 1005 void RenderFlexibleBox::packFlexLines(FlexOrderIterator& iterator, WTF::Vector<LineContext>& lineContexts) 1006 { 1007 if (!isMultiline() || style()->flexLinePack() == LinePackStart) 1008 return; 1009 1010 LayoutUnit availableCrossAxisSpace = crossAxisContentExtent(); 1011 for (size_t i = 0; i < lineContexts.size(); ++i) 1012 availableCrossAxisSpace -= lineContexts[i].crossAxisExtent; 1013 1014 RenderBox* child = iterator.first(); 1015 LayoutUnit lineOffset = initialLinePackingOffset(availableCrossAxisSpace, style()->flexLinePack(), lineContexts.size()); 1016 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) { 1017 lineContexts[lineNumber].crossAxisOffset += lineOffset; 1018 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = iterator.next()) 1019 adjustAlignmentForChild(child, lineOffset); 1020 1021 if (style()->flexLinePack() == LinePackStretch && availableCrossAxisSpace > 0) 1022 lineContexts[lineNumber].crossAxisExtent += availableCrossAxisSpace / lineContexts.size(); 1023 1024 lineOffset += linePackingSpaceBetweenChildren(availableCrossAxisSpace, style()->flexLinePack(), lineContexts.size()); 973 1025 } 974 1026 } … … 1088 1140 } 1089 1141 1090 void RenderFlexibleBox::flipForWrapReverse(FlexOrderIterator& iterator, const WTF::Vector<LineContext>& lineContexts )1142 void RenderFlexibleBox::flipForWrapReverse(FlexOrderIterator& iterator, const WTF::Vector<LineContext>& lineContexts, LayoutUnit crossAxisStartEdge) 1091 1143 { 1092 1144 LayoutUnit contentExtent = crossAxisContentExtent(); … … 1097 1149 LayoutPoint location = flowAwareLocationForChild(child); 1098 1150 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisExtent; 1099 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - lineContexts[0].crossAxisOffset;1151 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1100 1152 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxisExtent; 1101 1153 location.setY(location.y() + newOffset - originalOffset); -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r112316 r112544 123 123 void layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, WTF::Vector<LineContext>&); 124 124 void layoutColumnReverse(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit crossAxisOffset, LayoutUnit availableFreeSpace); 125 void packFlexLines(FlexOrderIterator&, WTF::Vector<LineContext>&); 125 126 void alignChildren(FlexOrderIterator&, const WTF::Vector<LineContext>&); 126 127 void applyStretchAlignmentToChild(RenderBox*, LayoutUnit lineCrossAxisExtent); 127 128 void flipForRightToLeftColumn(FlexOrderIterator&); 128 void flipForWrapReverse(FlexOrderIterator&, const WTF::Vector<LineContext>& );129 void flipForWrapReverse(FlexOrderIterator&, const WTF::Vector<LineContext>&, LayoutUnit crossAxisStartEdge); 129 130 }; 130 131
Note: See TracChangeset
for help on using the changeset viewer.