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

Side by Side Diff: ui/views/controls/styled_label.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More compile fix for ToT Created 6 years, 7 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 | « ui/views/controls/styled_label.h ('k') | ui/views/controls/tabbed_pane/tabbed_pane.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/controls/styled_label.h" 5 #include "ui/views/controls/styled_label.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/gfx/font_list.h" 10 #include "ui/gfx/font_list.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 Label::kFocusBorderPadding, Label::kFocusBorderPadding, 150 Label::kFocusBorderPadding, Label::kFocusBorderPadding,
151 Label::kFocusBorderPadding, Label::kFocusBorderPadding); 151 Label::kFocusBorderPadding, Label::kFocusBorderPadding);
152 insets += focus_border_padding; 152 insets += focus_border_padding;
153 break; 153 break;
154 } 154 }
155 } 155 }
156 156
157 return insets; 157 return insets;
158 } 158 }
159 159
160 int StyledLabel::GetHeightForWidth(int w) { 160 int StyledLabel::GetHeightForWidth(int w) const {
161 if (w != calculated_size_.width()) 161 if (w != calculated_size_.width()) {
162 calculated_size_ = CalculateAndDoLayout(w, true); 162 // TODO(erg): Munge the const-ness of the style label. CalculateAndDoLayout
163 // doesn't actually make any changes to member variables when |dry_run| is
164 // set to true. In general, the mutating and non-mutating parts shouldn't
165 // be in the same codepath.
166 calculated_size_ =
167 const_cast<StyledLabel*>(this)->CalculateAndDoLayout(w, true);
168 }
163 return calculated_size_.height(); 169 return calculated_size_.height();
164 } 170 }
165 171
166 void StyledLabel::Layout() { 172 void StyledLabel::Layout() {
167 calculated_size_ = CalculateAndDoLayout(GetLocalBounds().width(), false); 173 calculated_size_ = CalculateAndDoLayout(GetLocalBounds().width(), false);
168 } 174 }
169 175
170 void StyledLabel::PreferredSizeChanged() { 176 void StyledLabel::PreferredSizeChanged() {
171 calculated_size_ = gfx::Size(); 177 calculated_size_ = gfx::Size();
172 View::PreferredSizeChanged(); 178 View::PreferredSizeChanged();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 306 }
301 x += view_size.width() - focus_border_insets.width(); 307 x += view_size.width() - focus_border_insets.width();
302 308
303 remaining_string = remaining_string.substr(chunk.size()); 309 remaining_string = remaining_string.substr(chunk.size());
304 } 310 }
305 311
306 return gfx::Size(width, (line + 1) * line_height + GetInsets().height()); 312 return gfx::Size(width, (line + 1) * line_height + GetInsets().height());
307 } 313 }
308 314
309 } // namespace views 315 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/styled_label.h ('k') | ui/views/controls/tabbed_pane/tabbed_pane.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698