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

Unified Diff: ui/views/layout/grid_layout.cc

Issue 2743743003: GridLayout: Guard against layout queries while adding a view. (Closed)
Patch Set: Rebase for BUILD.gn conflict Created 3 years, 9 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 | « chrome/test/BUILD.gn ('k') | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/layout/grid_layout.cc
diff --git a/ui/views/layout/grid_layout.cc b/ui/views/layout/grid_layout.cc
index 4ff22d5471243fb7321a2259b5e94cf46e1ea3dd..135fe19022c7677ba77bcae7900f4df595275cd1 100644
--- a/ui/views/layout/grid_layout.cc
+++ b/ui/views/layout/grid_layout.cc
@@ -820,6 +820,11 @@ int GridLayout::GetPreferredHeightForWidth(const View* host, int width) const {
void GridLayout::SizeRowsAndColumns(bool layout, int width, int height,
gfx::Size* pref) const {
+ // Protect against clients asking for metrics during the addition of a View.
+ // The View is in the hierarchy, but it will not be accounted for in the
+ // layout calculations at this point, so the result will be incorrect.
+ DCHECK(!adding_view_) << "GridLayout queried while adding a view.";
+
// Make sure the master columns have been calculated.
CalculateMasterColumnsIfNecessary();
pref->SetSize(0, 0);
« no previous file with comments | « chrome/test/BUILD.gn ('k') | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698