Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: ui/views/widget/tooltip_manager.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More fixes per feedback plus new tests Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/widget/tooltip_manager.h" 5 #include "ui/views/widget/tooltip_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 lines.resize(kMaxLines); 45 lines.resize(kMaxLines);
46 *line_count = static_cast<int>(lines.size()); 46 *line_count = static_cast<int>(lines.size());
47 47
48 // Format each line to fit. 48 // Format each line to fit.
49 const gfx::FontList& font_list = GetDefaultFontList(); 49 const gfx::FontList& font_list = GetDefaultFontList();
50 string16 result; 50 string16 result;
51 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); 51 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end();
52 ++i) { 52 ++i) {
53 string16 elided_text = 53 string16 elided_text =
54 gfx::ElideText(*i, font_list, available_width, gfx::ELIDE_AT_END); 54 gfx::ElideText(*i, font_list, available_width, gfx::ELIDE_AT_END);
55 *max_width = std::max(*max_width, 55 *max_width = std::max<int>(
56 gfx::GetStringWidth(elided_text, font_list)); 56 *max_width, gfx::GetStringWidth(elided_text, font_list));
57 if (!result.empty()) 57 if (!result.empty())
58 result.push_back('\n'); 58 result.push_back('\n');
59 result.append(elided_text); 59 result.append(elided_text);
60 } 60 }
61 *text = result; 61 *text = result;
62 } 62 }
63 63
64 } // namespace views 64 } // namespace views
OLDNEW
« ui/gfx/font.h ('K') | « ui/views/corewm/tooltip_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698