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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 height, gfx::WRAP_LONG_WORDS, &wrapped); | 148 height, gfx::WRAP_LONG_WORDS, &wrapped); |
149 | 149 |
150 // Elide if necessary. | 150 // Elide if necessary. |
151 if (lines > 0 && wrapped.size() > static_cast<unsigned int>(lines)) { | 151 if (lines > 0 && wrapped.size() > static_cast<unsigned int>(lines)) { |
152 // Add an ellipsis to the last line. If this ellipsis makes the last line | 152 // Add an ellipsis to the last line. If this ellipsis makes the last line |
153 // too wide, that line will be further elided by the gfx::ElideText below, | 153 // too wide, that line will be further elided by the gfx::ElideText below, |
154 // so for example "ABC" could become "ABC..." and then "AB...". | 154 // so for example "ABC" could become "ABC..." and then "AB...". |
155 base::string16 last = | 155 base::string16 last = |
156 wrapped[lines - 1] + base::UTF8ToUTF16(gfx::kEllipsis); | 156 wrapped[lines - 1] + base::UTF8ToUTF16(gfx::kEllipsis); |
157 if (width > 0 && gfx::GetStringWidth(last, font_list()) > width) | 157 if (width > 0 && gfx::GetStringWidth(last, font_list()) > width) |
158 last = gfx::ElideText(last, font_list(), width, gfx::ELIDE_AT_END); | 158 last = gfx::ElideText(last, font_list(), width, gfx::ELIDE_TAIL); |
159 wrapped.resize(lines - 1); | 159 wrapped.resize(lines - 1); |
160 wrapped.push_back(last); | 160 wrapped.push_back(last); |
161 } | 161 } |
162 | 162 |
163 return wrapped; | 163 return wrapped; |
164 } | 164 } |
165 | 165 |
166 void InnerBoundedLabel::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 166 void InnerBoundedLabel::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
167 ClearCaches(); | 167 ClearCaches(); |
168 views::Label::OnBoundsChanged(previous_bounds); | 168 views::Label::OnBoundsChanged(previous_bounds); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 348 |
349 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 349 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
350 label_->SetNativeTheme(theme); | 350 label_->SetNativeTheme(theme); |
351 } | 351 } |
352 | 352 |
353 base::string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) { | 353 base::string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) { |
354 return JoinString(label_->GetWrappedText(width, lines), '\n'); | 354 return JoinString(label_->GetWrappedText(width, lines), '\n'); |
355 } | 355 } |
356 | 356 |
357 } // namespace message_center | 357 } // namespace message_center |
OLD | NEW |