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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
10 #include "ui/aura/window_tree_host.h" | 10 #include "ui/aura/window_tree_host.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 l != result_lines.end(); ++l) { | 128 l != result_lines.end(); ++l) { |
129 if (!result.empty()) | 129 if (!result.empty()) |
130 result.push_back('\n'); | 130 result.push_back('\n'); |
131 int line_width = gfx::GetStringWidth(*l, font_list); | 131 int line_width = gfx::GetStringWidth(*l, font_list); |
132 // Since we only break at word boundaries, it could happen that due to some | 132 // Since we only break at word boundaries, it could happen that due to some |
133 // very long word, line_width is greater than the available_width. In such | 133 // very long word, line_width is greater than the available_width. In such |
134 // case, we simply truncate at available_width and add ellipses at the end. | 134 // case, we simply truncate at available_width and add ellipses at the end. |
135 if (line_width > available_width) { | 135 if (line_width > available_width) { |
136 *width = available_width; | 136 *width = available_width; |
137 result.append(gfx::ElideText(*l, font_list, available_width, | 137 result.append(gfx::ElideText(*l, font_list, available_width, |
138 gfx::ELIDE_AT_END)); | 138 gfx::ELIDE_TAIL)); |
139 } else { | 139 } else { |
140 *width = std::max(*width, line_width); | 140 *width = std::max(*width, line_width); |
141 result.append(*l); | 141 result.append(*l); |
142 } | 142 } |
143 } | 143 } |
144 *text = result; | 144 *text = result; |
145 } | 145 } |
146 | 146 |
147 int TooltipAura::GetMaxWidth(const gfx::Point& location) const { | 147 int TooltipAura::GetMaxWidth(const gfx::Point& location) const { |
148 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure | 148 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 237 } |
238 | 238 |
239 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { | 239 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { |
240 DCHECK_EQ(widget_, widget); | 240 DCHECK_EQ(widget_, widget); |
241 widget_ = NULL; | 241 widget_ = NULL; |
242 tooltip_window_ = NULL; | 242 tooltip_window_ = NULL; |
243 } | 243 } |
244 | 244 |
245 } // namespace corewm | 245 } // namespace corewm |
246 } // namespace views | 246 } // namespace views |
OLD | NEW |