Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
index a9d80d7ebbd8775def2668b9adf41c2c2b336d45..c0a775f9d25d4722d21a050190e45f19d4e0ab5a 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -464,7 +464,7 @@ void LayoutGrid::repeatTracksSizingIfNeeded(GridSizingData& sizingData, |
// all the cases with orthogonal flows require this extra cycle; we need a |
// more specific condition to detect whether child's min-content contribution |
// has changed or not. |
- if (m_hasAnyOrthogonalChild) { |
+ if (!m_orthogonalChildren.isEmpty()) { |
computeTrackSizesForDefiniteSize(ForColumns, sizingData, |
availableSpaceForColumns); |
computeTrackSizesForDefiniteSize(ForRows, sizingData, |
@@ -487,6 +487,25 @@ void LayoutGrid::layoutBlock(bool relayoutChildren) { |
LayoutSize previousSize = size(); |
+ // We need to clear both own and containingBlock override sizes to |
+ // ensure we get the same result when grid's intrinsic size is |
+ // computed again in the updateLogicalWidth call bellow. |
+ if (sizesLogicalWidthToFitContent(styleRef().logicalWidth()) || |
+ styleRef().logicalWidth().isIntrinsicOrAuto()) { |
+ // We do cache orthogonal items during the placeItemsOnGrid call, which is |
+ // executed later. However, we are |
+ // only interested on running this logic when we are performing a |
+ // relayout, hence we have already cached |
+ // the orthogonal items. |
+ for (auto* child : m_orthogonalChildren) { |
+ if (child->isOutOfFlowPositioned()) |
+ continue; |
+ child->clearOverrideSize(); |
+ child->clearContainingBlockOverrideSize(); |
+ child->forceLayout(); |
+ } |
+ } |
+ |
updateLogicalWidth(); |
m_hasDefiniteLogicalHeight = hasDefiniteLogicalHeight(); |
@@ -1913,14 +1932,14 @@ void LayoutGrid::placeItemsOnGrid(SizingOperation sizingOperation) { |
Vector<LayoutBox*> autoMajorAxisAutoGridItems; |
Vector<LayoutBox*> specifiedMajorAxisAutoGridItems; |
- m_hasAnyOrthogonalChild = false; |
+ m_orthogonalChildren.shrink(0); |
for (LayoutBox* child = m_orderIterator.first(); child; |
child = m_orderIterator.next()) { |
if (child->isOutOfFlowPositioned()) |
continue; |
- m_hasAnyOrthogonalChild = |
- m_hasAnyOrthogonalChild || isOrthogonalChild(*child); |
+ if (isOrthogonalChild(*child)) |
+ m_orthogonalChildren.append(child); |
GridArea area = cachedGridArea(*child); |
if (!area.rows.isIndefinite()) |