Title: [199728] trunk
Revision
199728
Author
svil...@igalia.com
Date
2016-04-19 08:48:00 -0700 (Tue, 19 Apr 2016)

Log Message

[css-grid] Use the margin box for non-auto minimum sizes
https://bugs.webkit.org/show_bug.cgi?id=156711

Reviewed by Darin Adler.

Source/WebCore:

When computing the min-size of items with non-auto minimum height/width we are incorrectly
returning the size of the border box, and thus incorrectly ignoring the margins of the item.

This is a follow up patch of r199153 were we added the missing border and paddings for
heights. Contrary to that, we were not including margins for both axis.

This CL requires 3 different interrelated changes:
- Add the margins to the min-size returned by minSizeForChild (might require a layout).
- Refactor and extract width computations from logicalHeightForChild(); not totally
mandatory but pretty logical and helpful.
- Use a new update function to isolate the computation of the override width.

Test: fast/css-grid-layout/min-width-margin-box.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeInlineDirectionMargins): Added const to a parameter.
* rendering/RenderBox.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computeTrackSizesForDirection): Initialize the sizingOperation.
(WebCore::RenderGrid::computeIntrinsicLogicalWidths): Ditto.
(WebCore::RenderGrid::computeIntrinsicLogicalHeight): Ditto.
(WebCore::RenderGrid::logicalHeightForChild): Renamed from logicalContentHeightForChild as
it no longer returns the content size but the outer size.
(WebCore::RenderGrid::minSizeForChild):
(WebCore::RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild): Extracted
from logicalHeightForChild().
(WebCore::RenderGrid::minContentForChild): Update override width if needed.
(WebCore::RenderGrid::maxContentForChild): Ditto.
(WebCore::RenderGrid::computeMarginLogicalSizeForChild): Generalized from
computeMarginLogicalHeightForChild(), it can now compute also margins for the inline
direction.
(WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching):
(WebCore::RenderGrid::logicalContentHeightForChild): Deleted.
(WebCore::RenderGrid::computeMarginLogicalHeightForChild): Deleted.
* rendering/RenderGrid.h:

LayoutTests:

* fast/css-grid-layout/min-height-border-box.html:
* fast/css-grid-layout/min-width-margin-box-expected.txt: Added.
* fast/css-grid-layout/min-width-margin-box.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (199727 => 199728)


--- trunk/LayoutTests/ChangeLog	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/LayoutTests/ChangeLog	2016-04-19 15:48:00 UTC (rev 199728)
@@ -1,3 +1,14 @@
+2016-04-19  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Use the margin box for non-auto minimum sizes
+        https://bugs.webkit.org/show_bug.cgi?id=156711
+
+        Reviewed by Darin Adler.
+
+        * fast/css-grid-layout/min-height-border-box.html:
+        * fast/css-grid-layout/min-width-margin-box-expected.txt: Added.
+        * fast/css-grid-layout/min-width-margin-box.html: Added.
+
 2016-04-19  Michael Saboff  <msab...@apple.com>
 
         iTunes crashing _javascript_Core.dll

Modified: trunk/LayoutTests/fast/css-grid-layout/min-height-border-box.html (199727 => 199728)


--- trunk/LayoutTests/fast/css-grid-layout/min-height-border-box.html	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/LayoutTests/fast/css-grid-layout/min-height-border-box.html	2016-04-19 15:48:00 UTC (rev 199728)
@@ -13,11 +13,12 @@
 }
 
 .container { width: 150px; }
-.borderPadding {
+.borderPaddingMargin {
     border-width: 2px 3px 5px 9px;
     border-color: blue;
     border-style: solid;
     padding: 4px 9px 12px 20px;
+    margin: 7px 10px 12px 14px;
 }
 
 </style>
@@ -34,8 +35,8 @@
 </div>
 
 <div class="container">
-    <div class="grid" data-expected-width="150" data-expected-height="58">
-        <div class="item borderPadding" data-expected-width="140" data-expected-height="48">XXX</div>
+    <div class="grid" data-expected-width="150" data-expected-height="77">
+        <div class="item borderPaddingMargin" data-expected-width="116" data-expected-height="48">XXX</div>
     </div>
 </div>
 
@@ -47,8 +48,8 @@
 </div>
 
 <div class="container">
-    <div class="grid" data-expected-width="150" data-expected-height="33">
-        <div class="item borderPadding" style="min-height: 0px;" data-expected-width="140" data-expected-height="23">XXX</div>
+    <div class="grid" data-expected-width="150" data-expected-height="52">
+        <div class="item borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="23">XXX</div>
     </div>
 </div>
 
@@ -60,8 +61,8 @@
 </div>
 
 <div class="container">
-    <div class="grid" data-expected-width="150" data-expected-height="33">
-        <div class="item alignSelfStart borderPadding" style="min-height: 0px;" data-expected-width="140" data-expected-height="48">XXX</div>
+    <div class="grid" data-expected-width="150" data-expected-height="52">
+        <div class="item alignSelfStart borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="48">XXX</div>
     </div>
 </div>
 
@@ -74,7 +75,7 @@
 
 <div class="container">
     <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25">
-        <div class="item borderPadding" style="min-height: 0px;" data-expected-width="140" data-expected-height="23">XXX</div>
+        <div class="item borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="23">XXX</div>
     </div>
 </div>
 
@@ -87,7 +88,7 @@
 
 <div class="container">
     <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25">
-        <div class="item alignSelfStart borderPadding" style="min-height: 0px;" data-expected-width="140" data-expected-height="48">XXX</div>
+        <div class="item alignSelfStart borderPaddingMargin" style="min-height: 0px;" data-expected-width="116" data-expected-height="48">XXX</div>
     </div>
 </div>
 
@@ -99,8 +100,8 @@
 </div>
 
 <div class="container">
-    <div class="grid" data-expected-width="150" data-expected-height="63">
-        <div class="item borderPadding" style="min-height: 30px;" data-expected-width="140" data-expected-height="53">XXX</div>
+    <div class="grid" data-expected-width="150" data-expected-height="82">
+        <div class="item borderPaddingMargin" style="min-height: 30px;" data-expected-width="116" data-expected-height="53">XXX</div>
     </div>
 </div>
 
@@ -112,8 +113,8 @@
 </div>
 
 <div class="container">
-    <div class="grid" data-expected-width="150" data-expected-height="63">
-        <div class="item alignSelfStart borderPadding" style="min-height: 30px;" data-expected-width="140" data-expected-height="53">XXX</div>
+    <div class="grid" data-expected-width="150" data-expected-height="82">
+        <div class="item alignSelfStart borderPaddingMargin" style="min-height: 30px;" data-expected-width="116" data-expected-height="53">XXX</div>
     </div>
 </div>
 

Added: trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box-expected.txt (0 => 199728)


--- trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box-expected.txt	2016-04-19 15:48:00 UTC (rev 199728)
@@ -0,0 +1,42 @@
+grid width: auto
+
+XXXX
+PASS
+XXXX
+PASS
+min-width: 0px. grid height: auto
+
+XXXX
+PASS
+XXXX
+PASS
+min-width: 0px. grid height: 15px
+
+XXXX
+PASS
+XXXX
+PASS
+min-width: 125px. grid height: auto
+
+XXXX
+PASS
+XXXX
+PASS
+min-width: 50%. grid height: auto
+
+XXX XX
+PASS
+XXX XX
+PASS
+min-width: min-content. grid height: auto
+
+XXX XX
+PASS
+XXX XX
+PASS
+min-width: max-content. grid height: auto
+
+XXX XX
+PASS
+XXX XX
+PASS

Added: trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box.html (0 => 199728)


--- trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/min-width-margin-box.html	2016-04-19 15:48:00 UTC (rev 199728)
@@ -0,0 +1,144 @@
+<!DOCTYPE html>
+<link href="" rel="stylesheet">
+<link href="" rel="stylesheet">
+<link href="" rel="stylesheet">
+<style>
+.grid {
+    border: 5px solid magenta;
+    margin-bottom: 60px;
+    -webkit-grid-template-columns: minmax(auto, 0px);
+}
+
+.item {
+    font: 25px/1 Ahem;
+}
+
+.stretchedItem {
+    background-color: green;
+    -webkit-grid-row: 2;
+    height: 15px;
+}
+
+.container { width: 150px; }
+
+.borderPaddingMargin {
+    margin: 7px 10px 12px 14px;
+    border-width: 2px 3px 5px 9px;
+    border-style: solid;
+    border-color: blue;
+    padding: 4px 9px 12px 20px;
+}
+
+</style>
+
+<script src=""
+
+<body _onload_="checkLayout('.grid')">
+
+<h3>grid width: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="50">
+        <div class="item" data-expected-width="100" data-expected-height="25">XXXX</div>
+        <div class="stretchedItem" data-expected-width="100" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="92">
+        <div class="item borderPaddingMargin" data-expected-width="141" data-expected-height="48">XXXX</div>
+        <div class="stretchedItem" data-expected-width="165" data-expected-height="15"></div>
+    </div>
+</div>
+
+<h3>min-width: 0px. grid height: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="50">
+        <div class="item" style="min-width: 0px;" data-expected-width="0" data-expected-height="25">XXXX</div>
+        <div class="stretchedItem" data-expected-width="0" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="92">
+        <div class="item borderPaddingMargin" style="min-width: 0px;" data-expected-width="41" data-expected-height="48">XXXX</div>
+        <div class="stretchedItem" data-expected-width="65" data-expected-height="15"></div>
+    </div>
+</div>
+
+<h3>min-width: 0px. grid height: 15px</h3>
+<div class="container">
+    <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25">
+        <div class="item" style="min-width: 0px;" data-expected-width="0" data-expected-height="25">XXXX</div>
+        <div class="stretchedItem" data-expected-width="0" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" style="height: 15px;" data-expected-width="150" data-expected-height="25">
+        <div class="item border borderPaddingMargin" style="min-width: 0px;" data-expected-width="41" data-expected-height="48">XXXX</div>
+        <div class="stretchedItem" data-expected-width="65" data-expected-height="15"></div>
+    </div>
+</div>
+
+<h3>min-width: 125px. grid height: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="50">
+        <div class="item" style="min-width: 125px;" data-expected-width="125" data-expected-height="25">XXXX</div>
+        <div class="stretchedItem" data-expected-width="125" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="92">
+        <div class="item borderPaddingMargin" style="min-width: 125px;" data-expected-width="166" data-expected-height="48">XXXX</div>
+        <div class="stretchedItem" data-expected-width="190" data-expected-height="15"></div>
+    </div>
+</div>
+
+<h3>min-width: 50%. grid height: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="75">
+        <div class="item" style="min-width: 50%;" data-expected-width="0" data-expected-height="50">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="0" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="117">
+        <div class="item borderPaddingMargin" style="min-width: 50%;" data-expected-width="74" data-expected-height="73">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="65" data-expected-height="15"></div>
+    </div>
+</div>
+
+
+<h3>min-width: min-content. grid height: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="75">
+        <div class="item min-width-min-content" data-expected-width="75" data-expected-height="50">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="75" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="117">
+        <div class="item borderPaddingMargin min-width-min-content" data-expected-width="116" data-expected-height="73">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="140" data-expected-height="15"></div>
+    </div>
+</div>
+
+<h3>min-width: max-content. grid height: auto</h3>
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="50">
+        <div class="item alignSelfStart min-width-max-content" data-expected-width="150" data-expected-height="25">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="150" data-expected-height="15"></div>
+    </div>
+</div>
+
+<div class="container">
+    <div class="grid" data-expected-width="150" data-expected-height="92">
+        <div class="item alignSelfStart borderPaddingMargin min-width-max-content" data-expected-width="191" data-expected-height="48">XXX XX</div>
+        <div class="stretchedItem" data-expected-width="215" data-expected-height="15"></div>
+    </div>
+</div>
+
+</body>

Modified: trunk/Source/WebCore/ChangeLog (199727 => 199728)


--- trunk/Source/WebCore/ChangeLog	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/Source/WebCore/ChangeLog	2016-04-19 15:48:00 UTC (rev 199728)
@@ -1,3 +1,46 @@
+2016-04-19  Sergio Villar Senin  <svil...@igalia.com>
+
+        [css-grid] Use the margin box for non-auto minimum sizes
+        https://bugs.webkit.org/show_bug.cgi?id=156711
+
+        Reviewed by Darin Adler.
+
+        When computing the min-size of items with non-auto minimum height/width we are incorrectly
+        returning the size of the border box, and thus incorrectly ignoring the margins of the item.
+
+        This is a follow up patch of r199153 were we added the missing border and paddings for
+        heights. Contrary to that, we were not including margins for both axis.
+
+        This CL requires 3 different interrelated changes:
+        - Add the margins to the min-size returned by minSizeForChild (might require a layout).
+        - Refactor and extract width computations from logicalHeightForChild(); not totally
+        mandatory but pretty logical and helpful.
+        - Use a new update function to isolate the computation of the override width.
+
+        Test: fast/css-grid-layout/min-width-margin-box.html
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeInlineDirectionMargins): Added const to a parameter.
+        * rendering/RenderBox.h:
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::computeTrackSizesForDirection): Initialize the sizingOperation.
+        (WebCore::RenderGrid::computeIntrinsicLogicalWidths): Ditto.
+        (WebCore::RenderGrid::computeIntrinsicLogicalHeight): Ditto.
+        (WebCore::RenderGrid::logicalHeightForChild): Renamed from logicalContentHeightForChild as
+        it no longer returns the content size but the outer size.
+        (WebCore::RenderGrid::minSizeForChild):
+        (WebCore::RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild): Extracted
+        from logicalHeightForChild().
+        (WebCore::RenderGrid::minContentForChild): Update override width if needed.
+        (WebCore::RenderGrid::maxContentForChild): Ditto.
+        (WebCore::RenderGrid::computeMarginLogicalSizeForChild): Generalized from
+        computeMarginLogicalHeightForChild(), it can now compute also margins for the inline
+        direction.
+        (WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching):
+        (WebCore::RenderGrid::logicalContentHeightForChild): Deleted.
+        (WebCore::RenderGrid::computeMarginLogicalHeightForChild): Deleted.
+        * rendering/RenderGrid.h:
+
 2016-04-19  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [Cairo] GraphicsContext::drawFocusRing methods are not consistent to each other

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (199727 => 199728)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2016-04-19 15:48:00 UTC (rev 199728)
@@ -2614,7 +2614,7 @@
     return false;
 }
 
-void RenderBox::computeInlineDirectionMargins(RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const
+void RenderBox::computeInlineDirectionMargins(const RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const
 {
     const RenderStyle& containingBlockStyle = containingBlock.style();
     Length marginStartLength = style().marginStartUsing(&containingBlockStyle);

Modified: trunk/Source/WebCore/rendering/RenderBox.h (199727 => 199728)


--- trunk/Source/WebCore/rendering/RenderBox.h	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2016-04-19 15:48:00 UTC (rev 199728)
@@ -366,7 +366,7 @@
     };
     // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
     // of the containing block.
-    void computeInlineDirectionMargins(RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
+    void computeInlineDirectionMargins(const RenderBlock& containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
 
     // Used to resolve margins in the containing block's block-flow direction.
     void computeBlockDirectionMargins(const RenderBlock& containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const;

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (199727 => 199728)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2016-04-19 15:48:00 UTC (rev 199728)
@@ -229,6 +229,9 @@
     Optional<LayoutUnit> freeSpaceForDirection(GridTrackSizingDirection direction) { return direction == ForColumns ? freeSpaceForColumns : freeSpaceForRows; }
     void setFreeSpaceForDirection(GridTrackSizingDirection, Optional<LayoutUnit> freeSpace);
 
+    enum SizingOperation { TrackSizing, IntrinsicSizeComputation };
+    SizingOperation sizingOperation { TrackSizing };
+
 private:
     Optional<LayoutUnit> freeSpaceForColumns;
     Optional<LayoutUnit> freeSpaceForRows;
@@ -331,6 +334,7 @@
 {
     LayoutUnit totalGuttersSize = guttersSize(direction, direction == ForRows ? gridRowCount() : gridColumnCount());
     sizingData.setFreeSpaceForDirection(direction, freeSpace - totalGuttersSize);
+    sizingData.sizingOperation = GridSizingData::TrackSizing;
 
     LayoutUnit baseSizes, growthLimits;
     computeUsedBreadthOfGridTracks(direction, sizingData, baseSizes, growthLimits);
@@ -432,6 +436,7 @@
 
     GridSizingData sizingData(gridColumnCount(), gridRowCount());
     sizingData.setFreeSpaceForDirection(ForColumns, Nullopt);
+    sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation;
     const_cast<RenderGrid*>(this)->computeUsedBreadthOfGridTracks(ForColumns, sizingData, minLogicalWidth, maxLogicalWidth);
 
     LayoutUnit totalGuttersSize = guttersSize(ForColumns, sizingData.columnTracks.size());
@@ -450,6 +455,7 @@
 {
     ASSERT(tracksAreWiderThanMinTrackBreadth(ForColumns, sizingData));
     sizingData.setFreeSpaceForDirection(ForRows, Nullopt);
+    sizingData.sizingOperation = GridSizingData::IntrinsicSizeComputation;
     LayoutUnit minHeight, maxHeight;
     computeUsedBreadthOfGridTracks(ForRows, sizingData, minHeight, maxHeight);
 
@@ -713,7 +719,7 @@
     return GridTrackSize(minTrackBreadth, maxTrackBreadth);
 }
 
-LayoutUnit RenderGrid::logicalContentHeightForChild(RenderBox& child, GridSizingData& sizingData)
+LayoutUnit RenderGrid::logicalHeightForChild(RenderBox& child, GridSizingData& sizingData)
 {
     Optional<LayoutUnit> oldOverrideContainingBlockContentLogicalWidth = child.hasOverrideContainingBlockLogicalWidth() ? child.overrideContainingBlockContentLogicalWidth() : LayoutUnit();
     LayoutUnit overrideContainingBlockContentLogicalWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks);
@@ -724,7 +730,6 @@
     if (child.needsLayout())
         child.clearOverrideLogicalContentHeight();
 
-    child.setOverrideContainingBlockContentLogicalWidth(overrideContainingBlockContentLogicalWidth);
     // If |child| has a relative logical height, we shouldn't let it override its intrinsic height, which is
     // what we are interested in here. Thus we need to set the override logical height to Nullopt (no possible resolution).
     if (child.hasRelativeLogicalHeight())
@@ -747,12 +752,28 @@
     if (!childSize.isAuto() || childMinSize.isAuto())
         return minContentForChild(child, direction, sizingData);
 
-    if (isRowAxis)
-        return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, contentLogicalWidth(), *this, nullptr);
+    bool overrideLogicalWidthHasChanged = updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData);
+    if (isRowAxis) {
+        LayoutUnit marginLogicalWidth = sizingData.sizingOperation == GridSizingData::TrackSizing ? computeMarginLogicalSizeForChild(ForColumns, child) : marginIntrinsicLogicalWidthForChild(child);
+        return child.computeLogicalWidthInRegionUsing(MinSize, childMinSize, child.overrideContainingBlockContentLogicalWidth().valueOr(0), *this, nullptr) + marginLogicalWidth;
+    }
 
-    return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0);
+    if (overrideLogicalWidthHasChanged)
+        child.setNeedsLayout(MarkOnlyThis);
+    child.layoutIfNeeded();
+    return child.computeLogicalHeightUsing(MinSize, childMinSize, Nullopt).valueOr(0) + child.marginLogicalHeight() + child.scrollbarLogicalHeight();
 }
 
+bool RenderGrid::updateOverrideContainingBlockContentLogicalWidthForChild(RenderBox& child, GridSizingData& sizingData)
+{
+    LayoutUnit overrideWidth = gridAreaBreadthForChild(child, ForColumns, sizingData.columnTracks);
+    if (child.hasOverrideContainingBlockLogicalWidth() && child.overrideContainingBlockContentLogicalWidth() == overrideWidth)
+        return false;
+
+    child.setOverrideContainingBlockContentLogicalWidth(overrideWidth);
+    return true;
+}
+
 LayoutUnit RenderGrid::minContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData)
 {
     bool hasOrthogonalWritingMode = child.isHorizontalWritingMode() != isHorizontalWritingMode();
@@ -771,7 +792,9 @@
         return child.minPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child);
     }
 
-    return logicalContentHeightForChild(child, sizingData);
+    if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData))
+        child.setNeedsLayout(MarkOnlyThis);
+    return logicalHeightForChild(child, sizingData);
 }
 
 LayoutUnit RenderGrid::maxContentForChild(RenderBox& child, GridTrackSizingDirection direction, GridSizingData& sizingData)
@@ -792,7 +815,9 @@
         return child.maxPreferredLogicalWidth() + marginIntrinsicLogicalWidthForChild(child);
     }
 
-    return logicalContentHeightForChild(child, sizingData);
+    if (updateOverrideContainingBlockContentLogicalWidthForChild(child, sizingData))
+        child.setNeedsLayout(MarkOnlyThis);
+    return logicalHeightForChild(child, sizingData);
 }
 
 class GridItemWithSpan {
@@ -1689,16 +1714,19 @@
     return isHorizontalWritingMode() ? child.verticalMarginExtent() : child.horizontalMarginExtent();
 }
 
-LayoutUnit RenderGrid::computeMarginLogicalHeightForChild(const RenderBox& child) const
+LayoutUnit RenderGrid::computeMarginLogicalSizeForChild(GridTrackSizingDirection direction, const RenderBox& child) const
 {
     if (!child.style().hasMargin())
         return 0;
 
-    LayoutUnit marginBefore;
-    LayoutUnit marginAfter;
-    child.computeBlockDirectionMargins(*this, marginBefore, marginAfter);
+    LayoutUnit marginStart;
+    LayoutUnit marginEnd;
+    if (direction == ForColumns)
+        child.computeInlineDirectionMargins(*this, child.containingBlockLogicalWidthForContentInRegion(nullptr), child.logicalWidth(), marginStart, marginEnd);
+    else
+        child.computeBlockDirectionMargins(*this, marginStart, marginEnd);
 
-    return marginBefore + marginAfter;
+    return marginStart + marginEnd;
 }
 
 LayoutUnit RenderGrid::availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox& child) const
@@ -1706,7 +1734,7 @@
     // Because we want to avoid multiple layouts, stretching logic might be performed before
     // children are laid out, so we can't use the child cached values. Hence, we need to
     // compute margins in order to determine the available height before stretching.
-    return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalHeightForChild(child) : marginLogicalHeightForChild(child));
+    return gridAreaBreadthForChild - (child.needsLayout() ? computeMarginLogicalSizeForChild(ForRows, child) : marginLogicalHeightForChild(child));
 }
 
 // FIXME: This logic is shared by RenderFlexibleBox, so it should be moved to RenderBox.

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (199727 => 199728)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2016-04-19 15:10:36 UTC (rev 199727)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2016-04-19 15:48:00 UTC (rev 199728)
@@ -130,7 +130,8 @@
 
     GridTrackSize gridTrackSize(GridTrackSizingDirection, unsigned) const;
 
-    LayoutUnit logicalContentHeightForChild(RenderBox&, GridSizingData&);
+    bool updateOverrideContainingBlockContentLogicalWidthForChild(RenderBox&, GridSizingData&);
+    LayoutUnit logicalHeightForChild(RenderBox&, GridSizingData&);
     LayoutUnit minSizeForChild(RenderBox&, GridTrackSizingDirection, GridSizingData&);
     LayoutUnit minContentForChild(RenderBox&, GridTrackSizingDirection, GridSizingData&);
     LayoutUnit maxContentForChild(RenderBox&, GridTrackSizingDirection, GridSizingData&);
@@ -152,7 +153,7 @@
     void paintChildren(PaintInfo& forSelf, const LayoutPoint& paintOffset, PaintInfo& forChild, bool usePrintRect) override;
     bool needToStretchChildLogicalHeight(const RenderBox&) const;
     LayoutUnit marginLogicalHeightForChild(const RenderBox&) const;
-    LayoutUnit computeMarginLogicalHeightForChild(const RenderBox&) const;
+    LayoutUnit computeMarginLogicalSizeForChild(GridTrackSizingDirection, const RenderBox&) const;
     LayoutUnit availableAlignmentSpaceForChildBeforeStretching(LayoutUnit gridAreaBreadthForChild, const RenderBox&) const;
     void applyStretchAlignmentToChildIfNeeded(RenderBox&);
     bool hasAutoMarginsInColumnAxis(const RenderBox&) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to