Changeset 97313 in webkit
- Timestamp:
- Oct 12, 2011 3:49:25 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r97312 r97313 1 2011-10-12 Tony Chang <tony@chromium.org> 2 3 Implement -webkit-flex-align for cross axis alignment in flex-flow: row 4 https://bugs.webkit.org/show_bug.cgi?id=69808 5 6 Reviewed by David Hyatt. 7 8 * css3/flexbox/flex-align-expected.txt: Added. 9 * css3/flexbox/flex-align-percent-height-expected.txt: Added. 10 * css3/flexbox/flex-align-percent-height.html: Added. 11 * css3/flexbox/flex-align-vertical-writing-mode-expected.txt: Added. 12 * css3/flexbox/flex-align-vertical-writing-mode.html: Added. 13 * css3/flexbox/flex-align.html: Added. 14 1 15 2011-10-12 Ojan Vafai <ojan@chromium.org> 2 16 -
trunk/Source/WebCore/ChangeLog
r97308 r97313 1 2011-10-12 Tony Chang <tony@chromium.org> 2 3 Implement -webkit-flex-align for cross axis alignment in flex-flow: row 4 https://bugs.webkit.org/show_bug.cgi?id=69808 5 6 Reviewed by David Hyatt. 7 8 Tests: css3/flexbox/flex-align-percent-height.html 9 css3/flexbox/flex-align-vertical-writing-mode.html 10 css3/flexbox/flex-align.html 11 12 * rendering/RenderFlexibleBox.cpp: 13 (WebCore::RenderFlexibleBox::isFlowAwareLogicalHeightAuto): 14 (WebCore::RenderFlexibleBox::flowAwareContentLogicalHeight): 15 (WebCore::RenderFlexibleBox::flowAwareBorderAndPaddingLogicalHeight): 16 (WebCore::RenderFlexibleBox::flowAwareMarginLogicalHeightForChild): 17 (WebCore::RenderFlexibleBox::flowAwareLogicalLocationForChild): 18 (WebCore::RenderFlexibleBox::layoutInlineDirection): 19 (WebCore::RenderFlexibleBox::availableLogicalHeightForChild): 20 (WebCore::RenderFlexibleBox::marginBoxAscent): 21 (WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection): 22 (WebCore::RenderFlexibleBox::adjustLocationLogicalTopForChild): 23 (WebCore::RenderFlexibleBox::alignChildrenBlockDirection): 24 * rendering/RenderFlexibleBox.h: 25 1 26 2011-10-12 Mihnea Ovidenie <mihnea@adobe.com> 2 27 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp
r96776 r97313 210 210 // FIXME: Make all these flow aware methods actually be flow aware. 211 211 212 bool RenderFlexibleBox::isFlowAwareLogicalHeightAuto() const 213 { 214 Length height = isHorizontalFlow() ? style()->height() : style()->width(); 215 return height.isAuto(); 216 } 217 212 218 void RenderFlexibleBox::setFlowAwareLogicalHeight(LayoutUnit size) 213 219 { … … 235 241 } 236 242 243 LayoutUnit RenderFlexibleBox::flowAwareContentLogicalHeight() const 244 { 245 return contentLogicalHeight(); 246 } 247 237 248 LayoutUnit RenderFlexibleBox::flowAwareContentLogicalWidth() const 238 249 { … … 255 266 } 256 267 268 LayoutUnit RenderFlexibleBox::flowAwareBorderAndPaddingLogicalHeight() const 269 { 270 // FIXME: Only do the flow check once. 271 return flowAwareBorderBefore() + flowAwarePaddingBefore() + flowAwarePaddingAfter() + flowAwareBorderAfter(); 272 } 273 257 274 LayoutUnit RenderFlexibleBox::flowAwarePaddingStart() const 258 275 { … … 275 292 } 276 293 294 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox* child) const 295 { 296 return marginStartForChild(child); 297 } 298 277 299 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox* child) const 278 300 { … … 283 305 { 284 306 return marginAfterForChild(child); 307 } 308 309 LayoutUnit RenderFlexibleBox::flowAwareMarginLogicalHeightForChild(RenderBox* child) const 310 { 311 // FIXME: Only do the flow check once. 312 return flowAwareMarginBeforeForChild(child) + flowAwareMarginAfterForChild(child); 313 } 314 315 LayoutPoint RenderFlexibleBox::flowAwareLogicalLocationForChild(RenderBox* child) const 316 { 317 return isHorizontalFlow() ? child->location() : child->location().transposedPoint(); 285 318 } 286 319 … … 356 389 357 390 layoutAndPlaceChildrenInlineDirection(flexIterator, childSizes, availableFreeSpace, totalPositiveFlexibility); 358 359 // FIXME: Handle distribution of cross-axis space (third distribution round).360 391 } 361 392 … … 368 399 { 369 400 return isHorizontalFlow() ? child->style()->flexboxWidthNegativeFlex() : child->style()->flexboxHeightNegativeFlex(); 401 } 402 403 LayoutUnit RenderFlexibleBox::availableLogicalHeightForChild(RenderBox* child) 404 { 405 LayoutUnit contentLogicalHeight = flowAwareContentLogicalHeight(); 406 LayoutUnit currentChildHeight = flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child); 407 return contentLogicalHeight - currentChildHeight; 408 } 409 410 LayoutUnit RenderFlexibleBox::marginBoxAscent(RenderBox* child) 411 { 412 LayoutUnit ascent = child->firstLineBoxBaseline(); 413 if (ascent == -1) 414 ascent = flowAwareLogicalHeightForChild(child) + flowAwareMarginAfterForChild(child); 415 return ascent + flowAwareMarginBeforeForChild(child); 370 416 } 371 417 … … 471 517 LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore(); 472 518 LayoutUnit totalLogicalWidth = flowAwareLogicalWidth(); 473 setFlowAwareLogicalHeight(0); 519 if (isFlowAwareLogicalHeightAuto()) 520 setFlowAwareLogicalHeight(0); 521 LayoutUnit maxAscent = 0, maxDescent = 0; // Used when flex-align: baseline. 474 522 size_t i = 0; 475 523 for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) { 476 // FIXME: Does this need to take the scrollbar width into account?477 524 LayoutUnit childPreferredSize = childSizes[i] + logicalBorderAndPaddingWidthForChild(child); 478 525 setLogicalOverrideSize(child, childPreferredSize); … … 480 527 child->layoutIfNeeded(); 481 528 482 setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderBefore() + flowAwarePaddingBefore() + flowAwareMarginBeforeForChild(child) + flowAwareLogicalHeightForChild(child) + flowAwareMarginAfterForChild(child) + flowAwarePaddingAfter() + flowAwareBorderAfter() + scrollbarLogicalHeight())); 529 if (child->style()->flexAlign() == AlignBaseline) { 530 LayoutUnit ascent = marginBoxAscent(child); 531 LayoutUnit descent = (flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child)) - ascent; 532 533 maxAscent = std::max(maxAscent, ascent); 534 maxDescent = std::max(maxDescent, descent); 535 536 // FIXME: add flowAwareScrollbarLogicalHeight. 537 if (isFlowAwareLogicalHeightAuto()) 538 setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderAndPaddingLogicalHeight() + flowAwareMarginLogicalHeightForChild(child) + maxAscent + maxDescent + scrollbarLogicalHeight())); 539 } else if (isFlowAwareLogicalHeightAuto()) 540 setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderAndPaddingLogicalHeight() + flowAwareMarginLogicalHeightForChild(child) + flowAwareLogicalHeightForChild(child) + scrollbarLogicalHeight())); 483 541 484 542 if (marginStartStyleForChild(child).isAuto()) … … 499 557 startEdge += availableFreeSpace / (childSizes.size() - 1); 500 558 } 559 560 alignChildrenBlockDirection(iterator, maxAscent); 561 } 562 563 void RenderFlexibleBox::adjustLocationLogicalTopForChild(RenderBox* child, LayoutUnit delta) 564 { 565 setFlowAwareLogicalLocationForChild(child, flowAwareLogicalLocationForChild(child) + LayoutSize(0, delta)); 566 } 567 568 void RenderFlexibleBox::alignChildrenBlockDirection(FlexOrderIterator& iterator, LayoutUnit maxAscent) 569 { 570 for (RenderBox* child = iterator.first(); child; child = iterator.next()) { 571 switch (child->style()->flexAlign()) { 572 case AlignStretch: { 573 Length height = isHorizontalFlow() ? child->style()->height() : child->style()->width(); 574 if (height.isAuto()) { 575 // FIXME: Clamp to max-height once it's spec'ed (should we align towards the start or center?). 576 LayoutUnit stretchedHeight = logicalHeightForChild(child) + RenderFlexibleBox::availableLogicalHeightForChild(child); 577 if (isHorizontalFlow()) 578 child->setHeight(stretchedHeight); 579 else 580 child->setWidth(stretchedHeight); 581 } 582 break; 583 } 584 case AlignStart: 585 break; 586 case AlignEnd: 587 adjustLocationLogicalTopForChild(child, RenderFlexibleBox::availableLogicalHeightForChild(child)); 588 break; 589 case AlignCenter: 590 adjustLocationLogicalTopForChild(child, RenderFlexibleBox::availableLogicalHeightForChild(child) / 2); 591 break; 592 case AlignBaseline: { 593 LayoutUnit ascent = marginBoxAscent(child); 594 adjustLocationLogicalTopForChild(child, maxAscent - ascent); 595 break; 596 } 597 } 598 } 501 599 } 502 600 -
trunk/Source/WebCore/rendering/RenderFlexibleBox.h
r96159 r97313 57 57 bool isHorizontalFlow() const; 58 58 bool isLeftToRightFlow() const; 59 bool isFlowAwareLogicalHeightAuto() const; 59 60 void setFlowAwareLogicalHeight(LayoutUnit); 60 61 LayoutUnit flowAwareLogicalHeightForChild(RenderBox* child); … … 62 63 LayoutUnit flowAwareLogicalHeight() const; 63 64 LayoutUnit flowAwareLogicalWidth() const; 65 LayoutUnit flowAwareContentLogicalHeight() const; 64 66 LayoutUnit flowAwareContentLogicalWidth() const; 65 67 LayoutUnit flowAwareBorderStart() const; 66 68 LayoutUnit flowAwareBorderBefore() const; 67 69 LayoutUnit flowAwareBorderAfter() const; 70 LayoutUnit flowAwareBorderAndPaddingLogicalHeight() const; 68 71 LayoutUnit flowAwarePaddingStart() const; 69 72 LayoutUnit flowAwarePaddingBefore() const; 70 73 LayoutUnit flowAwarePaddingAfter() const; 71 74 LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const; 75 LayoutUnit flowAwareMarginEndForChild(RenderBox* child) const; 72 76 LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const; 73 77 LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const; 78 LayoutUnit flowAwareMarginLogicalHeightForChild(RenderBox* child) const; 79 LayoutPoint flowAwareLogicalLocationForChild(RenderBox* child) const; 74 80 void setFlowAwareMarginStartForChild(RenderBox* child, LayoutUnit); 75 81 void setFlowAwareMarginEndForChild(RenderBox* child, LayoutUnit); 76 82 // FIXME: Supporting layout deltas. 77 83 void setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint&); 84 void adjustLocationLogicalTopForChild(RenderBox* child, LayoutUnit); 78 85 LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child) const; 79 86 LayoutUnit logicalScrollbarHeightForChild(RenderBox* child) const; … … 87 94 float logicalNegativeFlexForChild(RenderBox* child) const; 88 95 96 LayoutUnit availableLogicalHeightForChild(RenderBox*); 97 LayoutUnit marginBoxAscent(RenderBox*); 98 89 99 void computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility); 90 100 bool runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes); 91 101 void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize); 92 102 void layoutAndPlaceChildrenInlineDirection(FlexOrderIterator&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility); 103 void alignChildrenBlockDirection(FlexOrderIterator&, LayoutUnit maxAscent); 93 104 }; 94 105
Note: See TracChangeset
for help on using the changeset viewer.