| 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 <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 208 |
| 209 void StyledLabel::PreferredSizeChanged() { | 209 void StyledLabel::PreferredSizeChanged() { |
| 210 calculated_size_ = gfx::Size(); | 210 calculated_size_ = gfx::Size(); |
| 211 width_at_last_size_calculation_ = 0; | 211 width_at_last_size_calculation_ = 0; |
| 212 width_at_last_layout_ = 0; | 212 width_at_last_layout_ = 0; |
| 213 View::PreferredSizeChanged(); | 213 View::PreferredSizeChanged(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void StyledLabel::LinkClicked(Link* source, int event_flags) { | 216 void StyledLabel::LinkClicked(Link* source, int event_flags) { |
| 217 if (listener_) | 217 if (listener_) |
| 218 listener_->StyledLabelLinkClicked(link_targets_[source], event_flags); | 218 listener_->StyledLabelLinkClicked(this, link_targets_[source], event_flags); |
| 219 } | 219 } |
| 220 | 220 |
| 221 gfx::Size StyledLabel::CalculateAndDoLayout(int width, bool dry_run) { | 221 gfx::Size StyledLabel::CalculateAndDoLayout(int width, bool dry_run) { |
| 222 if (width == width_at_last_size_calculation_ && | 222 if (width == width_at_last_size_calculation_ && |
| 223 (dry_run || width == width_at_last_layout_)) | 223 (dry_run || width == width_at_last_layout_)) |
| 224 return calculated_size_; | 224 return calculated_size_; |
| 225 | 225 |
| 226 width_at_last_size_calculation_ = width; | 226 width_at_last_size_calculation_ = width; |
| 227 if (!dry_run) | 227 if (!dry_run) |
| 228 width_at_last_layout_ = width; | 228 width_at_last_layout_ = width; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 DCHECK_LE(used_width, width); | 370 DCHECK_LE(used_width, width); |
| 371 // The user-specified line height only applies to interline spacing, so the | 371 // The user-specified line height only applies to interline spacing, so the |
| 372 // final line's height is unaffected. | 372 // final line's height is unaffected. |
| 373 int total_height = line * line_height + | 373 int total_height = line * line_height + |
| 374 CalculateLineHeight(font_list_) + GetInsets().height(); | 374 CalculateLineHeight(font_list_) + GetInsets().height(); |
| 375 calculated_size_ = gfx::Size(used_width + GetInsets().width(), total_height); | 375 calculated_size_ = gfx::Size(used_width + GetInsets().width(), total_height); |
| 376 return calculated_size_; | 376 return calculated_size_; |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace views | 379 } // namespace views |
| OLD | NEW |