Changeset 199728 in webkit
- Timestamp:
- Apr 19, 2016 8:48:00 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r199726 r199728 1 2016-04-19 Sergio Villar Senin <svillar@igalia.com> 2 3 [css-grid] Use the margin box for non-auto minimum sizes 4 https://bugs.webkit.org/show_bug.cgi?id=156711 5 6 Reviewed by Darin Adler. 7 8 * fast/css-grid-layout/min-height-border-box.html: 9 * fast/css-grid-layout/min-width-margin-box-expected.txt: Added. 10 * fast/css-grid-layout/min-width-margin-box.html: Added. 11 1 12 2016-04-19 Michael Saboff <msaboff@apple.com> 2 13 -
trunk/LayoutTests/fast/css-grid-layout/min-height-border-box.html
r199153 r199728 14 14 15 15 .container { width: 150px; } 16 .borderPadding {16 .borderPaddingMargin { 17 17 border-width: 2px 3px 5px 9px; 18 18 border-color: blue; 19 19 border-style: solid; 20 20 padding: 4px 9px 12px 20px; 21 margin: 7px 10px 12px 14px; 21 22 } 22 23 … … 35 36 36 37 <div class="container"> 37 <div class="grid" data-expected-width="150" data-expected-height=" 58">38 <div class="item borderPadding " data-expected-width="140" data-expected-height="48">XXX</div>38 <div class="grid" data-expected-width="150" data-expected-height="77"> 39 <div class="item borderPaddingMargin" data-expected-width="116" data-expected-height="48">XXX</div> 39 40 </div> 40 41 </div> … … 48 49 49 50 <div class="container"> 50 <div class="grid" data-expected-width="150" data-expected-height=" 33">51 <div class="item borderPadding " style="min-height: 0px;" data-expected-width="140" data-expected-height="23">XXX</div>51 <div class="grid" data-expected-width="150" data-expected-height="52"> 52 <div class="item borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="23">XXX</div> 52 53 </div> 53 54 </div> … … 61 62 62 63 <div class="container"> 63 <div class="grid" data-expected-width="150" data-expected-height=" 33">64 <div class="item alignSelfStart borderPadding " style="min-height: 0px;" data-expected-width="140" data-expected-height="48">XXX</div>64 <div class="grid" data-expected-width="150" data-expected-height="52"> 65 <div class="item alignSelfStart borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="48">XXX</div> 65 66 </div> 66 67 </div> … … 75 76 <div class="container"> 76 77 <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25"> 77 <div class="item borderPadding " style="min-height: 0px;" data-expected-width="140" data-expected-height="23">XXX</div>78 <div class="item borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="23">XXX</div> 78 79 </div> 79 80 </div> … … 88 89 <div class="container"> 89 90 <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25"> 90 <div class="item alignSelfStart borderPadding " style="min-height: 0px;" data-expected-width="140" data-expected-height="48">XXX</div>91 <div class="item alignSelfStart borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="48">XXX</div> 91 92 </div> 92 93 </div> … … 100 101 101 102 <div class="container"> 102 <div class="grid" data-expected-width="150" data-expected-height=" 63">103 <div class="item borderPadding " style="min-height: 30px;" data-expected-width="140" data-expected-height="53">XXX</div>103 <div class="grid" data-expected-width="150" data-expected-height="82"> 104 <div class="item borderPaddingMargin" style="min-height: 30px;" data-expected-width="116" data-expected-height="53">XXX</div> 104 105 </div> 105 106 </div> … … 113 114 114 115 <div class="container"> 115 <div class="grid" data-expected-width="150" data-expected-height=" 63">116 <div class="item alignSelfStart borderPadding " style="min-height: 30px;" data-expected-width="140" data-expected-height="53">XXX</div>116 <div class="grid" data-expected-width="150" data-expected-height="82"> 117 <div class="item alignSelfStart borderPaddingMargin" style="min-height: 30px;" data-expected-width="116" data-expected-height="53">XXX</div> 117 118 </div> 118 119 </div> -
trunk/Source/WebCore/ChangeLog
r199727 r199728 1 2016-04-19 Sergio Villar Senin <svillar@igalia.com> 2 3 [css-grid] Use the margin box for non-auto minimum sizes 4 https://bugs.webkit.org/show_bug.cgi?id=156711 5 6 Reviewed by Darin Adler. 7 8 When computing the min-size of items with non-auto minimum height/width we are incorrectly 9 returning the size of the border box, and thus incorrectly ignoring the margins of the item. 10 11 This is a follow up patch of r199153 were we added the missing border and paddings for 12 heights. Contrary to that, we were not including margins for both axis. 13 14 This CL requires 3 different interrelated changes: 15 - Add the margins to the min-size returned by minSizeForChild (might require a layout). 16 - Refactor and extract width computations from logicalHeightForChild(); not totally 17 mandatory but pretty logical and helpful. 18 - Use a new update function to isolate the computation of the override width. 19 20 Test: fast/css-grid-layout/min-width-margin-box.html 21 22 * rendering/RenderBox.cpp: 23 (WebCore::RenderBox::computeInlineDirectionMargins): Added const to a parameter. 24 * rendering/RenderBox.h: 25 * rendering/RenderGrid.cpp: 26 (WebCore::RenderGrid::computeTrackSizesForDirection): Initialize the sizingOperation. 27 (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Ditto. 28 (WebCore::RenderGrid::computeIntrinsicLogicalHeight): Ditto. 29 (WebCore::RenderGrid::logicalHeightForChild): Renamed from logicalContentHeightForChild as 30 it no longer returns the content size but the outer size. 31 (WebCore::RenderGrid::minSizeForChild): 32 (WebCore::RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild): Extracted 33 from logicalHeightForChild(). 34 (WebCore::RenderGrid::minContentForChild): Update override width if needed. 35 (WebCore::RenderGrid::maxContentForChild): Ditto. 36 (WebCore::RenderGrid::computeMarginLogicalSizeForChild): Generalized from 37 computeMarginLogicalHeightForChild(), it can now compute also margins for the inline 38 direction. 39 (WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching): 40 (WebCore::RenderGrid::logicalContentHeightForChild): Deleted. 41 (WebCore::RenderGrid::computeMarginLogicalHeightForChild): Deleted. 42 * rendering/RenderGrid.h: 43 1 44 2016-04-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 45 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r198943 r199728 2615 2615 } 2616 2616 2617 void RenderBox::computeInlineDirectionMargins( RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const2617 void RenderBox::computeInlineDirectionMargins(const RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const 2618 2618 { 2619 2619 const RenderStyle& containingBlockStyle = containingBlock.style(); -
trunk/Source/WebCore/rendering/RenderBox.h
r198843 r199728 367 367 // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end 368 368 // of the containing block. 369 void computeInlineDirectionMargins( RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;369 void computeInlineDirectionMargins(const RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const; 370 370 371 371 // Used to resolve margins in the containing block's block-flow direction. -
trunk/Source/WebCore/rendering/RenderGrid.cpp
r199657 r199728 230 230 void setFreeSpaceForDirection(GridTrackSizingDirection, Optional<LayoutUnit> freeSpace); 231 231 232 enum SizingOperation { TrackSizing, IntrinsicSizeComputation }; 233 SizingOperation sizingOperation { TrackSizing }; 234 232 235 private: 233 236 Optional<LayoutUnit> freeSpaceForColumns; … … 332 335 LayoutUnit totalGuttersSize = guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount()); 333 336 sizingData.setFreeSpaceForDirection(direction, freeSpace - totalGuttersSize); 337 sizingData.sizingOperation = GridSizingData::TrackSizing; 334 338 335 339 LayoutUnit baseSizes, growthLimits; … … 433 437 GridSizingData sizingData(gridColumnCount(), gridRowCount()); 434 438 sizingData.setFreeSpaceForDirection(ForColumns, Nullopt); 439 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; 435 440 const_cast<RenderGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxLogicalWidth); 436 441 … … 451 456 ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData)); 452 457 sizingData.setFreeSpaceForDirection(ForRows, Nullopt); 458 sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation; 453 459 LayoutUnit minHeight, maxHeight; 454 460 computeUsedBreadthOfGridTracks(ForRows, sizingData, minHeight, maxHeight); … … 714 720 } 715 721 716 LayoutUnit RenderGrid::logical ContentHeightForChild(RenderBox& child, GridSizingData& sizingData)722 LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, GridSizingData& sizingData) 717 723 { 718 724 Optional<LayoutUnit> oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit(); … … 725 731 child.clearOverrideLogicalContentHeight(); 726 732 727 child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth);728 733 // If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is 729 734 // what we are interested in here. Thus we need to set the override logical height to Nullopt (no possible resolution). … … 748 753 return minContentForChild(child, direction, sizingData); 749 754 750 if (isRowAxis) 751 return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, contentLogicalWidth(), *this, nullptr); 752 753 return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0); 755 bool overrideLogicalWidthHasChanged = updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData); 756 if (isRowAxis) { 757 LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizingData::TrackSizing ? computeMarginLogicalSizeForChild(ForColumns, child) : marginIntrinsicLogicalWidthForChild(child); 758 return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, child.overrideContainingBlockContentLogicalWidth().valueOr(0), *this, nullptr) + marginLogicalWidth; 759 } 760 761 if (overrideLogicalWidthHasChanged) 762 child.setNeedsLayout(MarkOnlyThis); 763 child.layoutIfNeeded(); 764 return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0) + child.marginLogicalHeight() + child.scrollbarLogicalHeight(); 765 } 766 767 bool RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild(RenderBox& child, GridSizingData& sizingData) 768 { 769 LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks); 770 if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContainingBlockContentLogicalWidth() == overrideWidth) 771 return false; 772 773 child.setOverrideContainingBlockContentLogicalWidth(overrideWidth); 774 return true; 754 775 } 755 776 … … 772 793 } 773 794 774 return logicalContentHeightForChild(child, sizingData); 795 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData)) 796 child.setNeedsLayout(MarkOnlyThis); 797 return logicalHeightForChild(child, sizingData); 775 798 } 776 799 … … 793 816 } 794 817 795 return logicalContentHeightForChild(child, sizingData); 818 if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData)) 819 child.setNeedsLayout(MarkOnlyThis); 820 return logicalHeightForChild(child, sizingData); 796 821 } 797 822 … … 1690 1715 } 1691 1716 1692 LayoutUnit RenderGrid::computeMarginLogical HeightForChild(const RenderBox& child) const1717 LayoutUnit RenderGrid::computeMarginLogicalSizeForChild(GridTrackSizingDirection direction, const RenderBox& child) const 1693 1718 { 1694 1719 if (!child.style().hasMargin()) 1695 1720 return 0; 1696 1721 1697 LayoutUnit marginBefore; 1698 LayoutUnit marginAfter; 1699 child.computeBlockDirectionMargins(*this, marginBefore, marginAfter); 1700 1701 return marginBefore + marginAfter; 1722 LayoutUnit marginStart; 1723 LayoutUnit marginEnd; 1724 if (direction == ForColumns) 1725 child.computeInlineDirectionMargins(*this, child.containingBlockLogicalWidthForContentInRegion(nullptr), child.logicalWidth(), marginStart, marginEnd); 1726 else 1727 child.computeBlockDirectionMargins(*this, marginStart, marginEnd); 1728 1729 return marginStart + marginEnd; 1702 1730 } 1703 1731 … … 1707 1735 // children are laid out, so we can't use the child cached values. Hence, we need to 1708 1736 // compute margins in order to determine the available height before stretching. 1709 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogical HeightForChild(child) : marginLogicalHeightForChild(child));1737 return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalSizeForChild(ForRows, child) : marginLogicalHeightForChild(child)); 1710 1738 } 1711 1739 -
trunk/Source/WebCore/rendering/RenderGrid.h
r199657 r199728 131 131 GridTrackSize gridTrackSize(GridTrackSizingDirection, unsigned) const; 132 132 133 LayoutUnit logicalContentHeightForChild(RenderBox&, GridSizingData&); 133 bool updateOverrideContainingBlockContentLogicalWidthForChild(RenderBox&, GridSizingData&); 134 LayoutUnit logicalHeightForChild(RenderBox&, GridSizingData&); 134 135 LayoutUnit minSizeForChild(RenderBox&, GridTrackSizingDirection, GridSizingData&); 135 136 LayoutUnit minContentForChild(RenderBox&, GridTrackSizingDirection, GridSizingData&); … … 153 154 bool needToStretchChildLogicalHeight(const RenderBox&) const; 154 155 LayoutUnit marginLogicalHeightForChild(const RenderBox&) const; 155 LayoutUnit computeMarginLogical HeightForChild(const RenderBox&) const;156 LayoutUnit computeMarginLogicalSizeForChild(GridTrackSizingDirection, const RenderBox&) const; 156 157 LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox&) const; 157 158 void applyStretchAlignmentToChildIfNeeded(RenderBox&);
Note: See TracChangeset
for help on using the changeset viewer.