Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutGrid.cpp

Issue 2839893002: [css-grid] Preemptively store intrinsic sizes during layout (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« no previous file with comments | « third_party/WebKit/Source/core/layout/GridTrackSizingAlgorithm.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698