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

Side by Side Diff: ui/views/layout/grid_layout.cc

Issue 185653012: rAc - fix off-by-small-number error in grid layout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/layout/grid_layout.h" 5 #include "ui/views/layout/grid_layout.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 template <class T> 50 template <class T>
51 static void DistributeDelta(int delta, std::vector<T*>* elements) { 51 static void DistributeDelta(int delta, std::vector<T*>* elements) {
52 if (delta == 0) 52 if (delta == 0)
53 return; 53 return;
54 54
55 float total_percent = 0; 55 float total_percent = 0;
56 int resize_count = 0; 56 int resize_count = 0;
57 for (typename std::vector<T*>::iterator i = elements->begin(); 57 for (typename std::vector<T*>::iterator i = elements->begin();
58 i != elements->end(); ++i) { 58 i != elements->end(); ++i) {
59 total_percent += (*i)->ResizePercent(); 59 total_percent += (*i)->ResizePercent();
60 resize_count++; 60 if ((*i)->ResizePercent() > 0)
61 resize_count++;
61 } 62 }
62 if (total_percent == 0) { 63 if (total_percent == 0) {
63 // None of the elements are resizable, return. 64 // None of the elements are resizable, return.
64 return; 65 return;
65 } 66 }
66 int remaining = delta; 67 int remaining = delta;
67 int resized = resize_count; 68 int resized = resize_count;
68 for (typename std::vector<T*>::iterator i = elements->begin(); 69 for (typename std::vector<T*>::iterator i = elements->begin();
69 i != elements->end(); ++i) { 70 i != elements->end(); ++i) {
70 T* element = *i; 71 T* element = *i;
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 1064
1064 ColumnSet* GridLayout::GetLastValidColumnSet() { 1065 ColumnSet* GridLayout::GetLastValidColumnSet() {
1065 for (int i = current_row_ - 1; i >= 0; --i) { 1066 for (int i = current_row_ - 1; i >= 0; --i) {
1066 if (rows_[i]->column_set()) 1067 if (rows_[i]->column_set())
1067 return rows_[i]->column_set(); 1068 return rows_[i]->column_set();
1068 } 1069 }
1069 return NULL; 1070 return NULL;
1070 } 1071 }
1071 1072
1072 } // namespace views 1073 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/layout/grid_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698