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/corewm/tooltip_aura.h" | 5 #include "ui/views/corewm/tooltip_aura.h" |
6 | 6 |
7 #include "base/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
9 #include "ui/aura/window_tree_host.h" | 9 #include "ui/aura/window_tree_host.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 line.append(word); | 110 line.append(word); |
111 } | 111 } |
112 result_lines.push_back(line); | 112 result_lines.push_back(line); |
113 } | 113 } |
114 | 114 |
115 // Clamp number of lines to |kMaxLines|. | 115 // Clamp number of lines to |kMaxLines|. |
116 if (result_lines.size() > kMaxLines) { | 116 if (result_lines.size() > kMaxLines) { |
117 result_lines.resize(kMaxLines); | 117 result_lines.resize(kMaxLines); |
118 // Add ellipses character to last line. | 118 // Add ellipses character to last line. |
119 result_lines[kMaxLines - 1] = gfx::TruncateString( | 119 result_lines[kMaxLines - 1] = gfx::TruncateString( |
120 result_lines.back(), result_lines.back().length() - 1); | 120 result_lines.back(), result_lines.back().length() - 1, gfx::WORD_BREAK); |
121 } | 121 } |
122 *line_count = result_lines.size(); | 122 *line_count = result_lines.size(); |
123 | 123 |
124 // Flatten the result. | 124 // Flatten the result. |
125 base::string16 result; | 125 base::string16 result; |
126 for (std::vector<base::string16>::iterator l = result_lines.begin(); | 126 for (std::vector<base::string16>::iterator l = result_lines.begin(); |
127 l != result_lines.end(); ++l) { | 127 l != result_lines.end(); ++l) { |
128 if (!result.empty()) | 128 if (!result.empty()) |
129 result.push_back('\n'); | 129 result.push_back('\n'); |
130 int line_width = gfx::GetStringWidth(*l, font_list); | 130 int line_width = gfx::GetStringWidth(*l, font_list); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 236 } |
237 | 237 |
238 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { | 238 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { |
239 DCHECK_EQ(widget_, widget); | 239 DCHECK_EQ(widget_, widget); |
240 widget_ = NULL; | 240 widget_ = NULL; |
241 tooltip_window_ = NULL; | 241 tooltip_window_ = NULL; |
242 } | 242 } |
243 | 243 |
244 } // namespace corewm | 244 } // namespace corewm |
245 } // namespace views | 245 } // namespace views |
OLD | NEW |