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 957ecad4da47dc281d667cbd7d469519da0556cd..5ad5e7298be7466e0ef7603db0a487b01f7670cc 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -265,6 +265,22 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) { |
LayoutUnit available_space_for_columns = AvailableLogicalWidth(); |
ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns); |
+ // We take the chance to store the intrinsic sizes as they are just an |
+ // intermediate result of the track sizing algorithm. Apart from eventually |
+ // saving an algorithm execution (if {min|max}PreferredLogicalWidth() are |
+ // called later), it fixes the use case of computing the preferred logical |
+ // widths *after* the layout process. Although not very common, this happens |
+ // in the Mac (content::RenderViewImpl::didUpdateLayout()) or under some |
+ // circumstances when grids are also flex items (crbug.com/708159). |
+ if (PreferredLogicalWidthsDirty()) { |
+ LayoutUnit scrollbar_width = LayoutUnit(ScrollbarLogicalWidth()); |
+ min_preferred_logical_width_ = |
+ track_sizing_algorithm_.MinContentSize() + scrollbar_width; |
+ max_preferred_logical_width_ = |
+ track_sizing_algorithm_.MaxContentSize() + scrollbar_width; |
+ ClearPreferredLogicalWidthsDirty(); |
+ } |
+ |
// 2- Next, the track sizing algorithm resolves the sizes of the grid rows, |
// using the grid column sizes calculated in the previous step. |
if (CachedHasDefiniteLogicalHeight()) { |