| 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 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 Loading... |
| 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 |
| OLD | NEW |