| 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/message_center/views/bounded_label.h" | 5 #include "ui/message_center/views/bounded_label.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return (limit < 0 || lines <= limit) ? lines : limit; | 99 return (limit < 0 || lines <= limit) ? lines : limit; |
| 100 } | 100 } |
| 101 | 101 |
| 102 gfx::Size InnerBoundedLabel::GetSizeForWidthAndLines(int width, int lines) { | 102 gfx::Size InnerBoundedLabel::GetSizeForWidthAndLines(int width, int lines) { |
| 103 if (width == 0 || lines == 0) | 103 if (width == 0 || lines == 0) |
| 104 return gfx::Size(); | 104 return gfx::Size(); |
| 105 std::pair<int, int> key(width, lines); | 105 std::pair<int, int> key(width, lines); |
| 106 gfx::Size size = GetCachedSize(key); | 106 gfx::Size size = GetCachedSize(key); |
| 107 if (size.height() == std::numeric_limits<int>::max()) { | 107 if (size.height() == std::numeric_limits<int>::max()) { |
| 108 gfx::Insets insets = owner_->GetInsets(); | 108 gfx::Insets insets = owner_->GetInsets(); |
| 109 int text_width = (width < 0) ? std::numeric_limits<int>::max() : | 109 float text_width = (width < 0) ? std::numeric_limits<int>::max() : |
| 110 std::max(width - insets.width(), 0); | 110 std::max(width - insets.width(), 0); |
| 111 int text_height = std::numeric_limits<int>::max(); | 111 float text_height = std::numeric_limits<int>::max(); |
| 112 std::vector<string16> wrapped = GetWrappedText(text_width, lines); | 112 std::vector<string16> wrapped = GetWrappedText(text_width, lines); |
| 113 gfx::Canvas::SizeStringInt(JoinString(wrapped, '\n'), font(), | 113 gfx::Canvas::SizeStringInt(JoinString(wrapped, '\n'), font(), |
| 114 &text_width, &text_height, | 114 &text_width, &text_height, |
| 115 owner_->GetLineHeight(), | 115 owner_->GetLineHeight(), |
| 116 GetTextFlags()); | 116 GetTextFlags()); |
| 117 size.set_width(text_width + insets.width()); | 117 size.set_width(text_width + insets.width()); |
| 118 size.set_height(text_height + insets.height()); | 118 size.set_height(text_height + insets.height()); |
| 119 SetCachedSize(key, size); | 119 SetCachedSize(key, size); |
| 120 } | 120 } |
| 121 return size; | 121 return size; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 339 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 340 label_->SetNativeTheme(theme); | 340 label_->SetNativeTheme(theme); |
| 341 } | 341 } |
| 342 | 342 |
| 343 string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) { | 343 string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) { |
| 344 return JoinString(label_->GetWrappedText(width, lines), '\n'); | 344 return JoinString(label_->GetWrappedText(width, lines), '\n'); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace message_center | 347 } // namespace message_center |
| OLD | NEW |