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 00436b95c574ea8221b85725c835a36ec99822cc..66dd81d64a79617e4a76bf8d8db2fef1f0fd8f3a 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp |
@@ -280,6 +280,22 @@ void LayoutGrid::UpdateBlockLayout(bool relayout_children) { |
// resolve heights properly (like for positioned items for example). |
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()) { |