OLD | NEW |
---|---|
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 Loading... | |
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 // | |
167 // I only feel OK about this quick hack since this code is going away | |
sky
2014/05/13 16:13:57
Why is this code going away?
Elliot Glaysher
2014/05/14 00:48:58
I actually got the wrong impression from msw@. Thi
| |
168 // anyway? | |
169 calculated_size_ = | |
170 const_cast<StyledLabel*>(this)->CalculateAndDoLayout(w, true); | |
171 } | |
163 return calculated_size_.height(); | 172 return calculated_size_.height(); |
164 } | 173 } |
165 | 174 |
166 void StyledLabel::Layout() { | 175 void StyledLabel::Layout() { |
167 calculated_size_ = CalculateAndDoLayout(GetLocalBounds().width(), false); | 176 calculated_size_ = CalculateAndDoLayout(GetLocalBounds().width(), false); |
168 } | 177 } |
169 | 178 |
170 void StyledLabel::PreferredSizeChanged() { | 179 void StyledLabel::PreferredSizeChanged() { |
171 calculated_size_ = gfx::Size(); | 180 calculated_size_ = gfx::Size(); |
172 View::PreferredSizeChanged(); | 181 View::PreferredSizeChanged(); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 } | 309 } |
301 x += view_size.width() - focus_border_insets.width(); | 310 x += view_size.width() - focus_border_insets.width(); |
302 | 311 |
303 remaining_string = remaining_string.substr(chunk.size()); | 312 remaining_string = remaining_string.substr(chunk.size()); |
304 } | 313 } |
305 | 314 |
306 return gfx::Size(width, (line + 1) * line_height + GetInsets().height()); | 315 return gfx::Size(width, (line + 1) * line_height + GetInsets().height()); |
307 } | 316 } |
308 | 317 |
309 } // namespace views | 318 } // namespace views |
OLD | NEW |