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

Side by Side Diff: ui/base/text/text_elider.cc

Issue 11150013: Fix wrong truncation of notification popup messages in ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Withdraw the not so effective tests. Created 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file implements utility functions for eliding and formatting UI text. 5 // This file implements utility functions for eliding and formatting UI text.
6 // 6 //
7 // Note that several of the functions declared in text_elider.h are implemented 7 // Note that several of the functions declared in text_elider.h are implemented
8 // in this file using helper classes in an unnamed namespace. 8 // in this file using helper classes in an unnamed namespace.
9 9
10 #include "ui/base/text/text_elider.h" 10 #include "ui/base/text/text_elider.h"
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (lines_->back().empty() && !last_line_ended_in_lf_) 900 if (lines_->back().empty() && !last_line_ended_in_lf_)
901 lines_->pop_back(); 901 lines_->pop_back();
902 } 902 }
903 if (last_line_ended_in_lf_) 903 if (last_line_ended_in_lf_)
904 lines_->push_back(string16()); 904 lines_->push_back(string16());
905 return full_; 905 return full_;
906 } 906 }
907 907
908 void RectangleText::AddLine(const string16& line) { 908 void RectangleText::AddLine(const string16& line) {
909 const int line_width = font_.GetStringWidth(line); 909 const int line_width = font_.GetStringWidth(line);
910 if (line_width < available_pixel_width_) { 910 if (line_width <= available_pixel_width_) {
911 AddToCurrentLineWithWidth(line, line_width); 911 AddToCurrentLineWithWidth(line, line_width);
912 } else { 912 } else {
913 // Iterate over positions that are valid to break the line at. In general, 913 // Iterate over positions that are valid to break the line at. In general,
914 // these are word boundaries but after any punctuation following the word. 914 // these are word boundaries but after any punctuation following the word.
915 base::i18n::BreakIterator words(line, 915 base::i18n::BreakIterator words(line,
916 base::i18n::BreakIterator::BREAK_LINE); 916 base::i18n::BreakIterator::BREAK_LINE);
917 if (words.Init()) { 917 if (words.Init()) {
918 while (words.Advance()) { 918 while (words.Advance()) {
919 const bool truncate = !current_line_.empty(); 919 const bool truncate = !current_line_.empty();
920 const string16& word = words.GetString(); 920 const string16& word = words.GetString();
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 index = char_iterator.getIndex(); 1114 index = char_iterator.getIndex();
1115 } else { 1115 } else {
1116 // String has leading whitespace, return the elide string. 1116 // String has leading whitespace, return the elide string.
1117 return kElideString; 1117 return kElideString;
1118 } 1118 }
1119 } 1119 }
1120 return string.substr(0, index) + kElideString; 1120 return string.substr(0, index) + kElideString;
1121 } 1121 }
1122 1122
1123 } // namespace ui 1123 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698