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

Side by Side Diff: ui/gfx/text_elider.cc

Issue 1565923002: Add updated comment back (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« 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/gfx/text_elider.h" 10 #include "ui/gfx/text_elider.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 193 }
194 194
195 base::string16 ElideText(const base::string16& text, 195 base::string16 ElideText(const base::string16& text,
196 const FontList& font_list, 196 const FontList& font_list,
197 float available_pixel_width, 197 float available_pixel_width,
198 ElideBehavior behavior) { 198 ElideBehavior behavior) {
199 #if !defined(OS_ANDROID) && !defined(OS_IOS) 199 #if !defined(OS_ANDROID) && !defined(OS_IOS)
200 DCHECK_NE(behavior, FADE_TAIL); 200 DCHECK_NE(behavior, FADE_TAIL);
201 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 201 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
202 render_text->SetCursorEnabled(false); 202 render_text->SetCursorEnabled(false);
203 // TODO(bshe): 5000 is out dated. We should remove it. See crbug.com/551660.
203 // Do not bother accurately sizing strings over 5000 characters here, for 204 // Do not bother accurately sizing strings over 5000 characters here, for
204 // performance purposes. This matches the behavior of Canvas::SizeStringFloat. 205 // performance purposes. This matches the behavior of Canvas::SizeStringFloat.
205 render_text->set_truncate_length(5000); 206 render_text->set_truncate_length(5000);
206 render_text->SetFontList(font_list); 207 render_text->SetFontList(font_list);
207 available_pixel_width = std::ceil(available_pixel_width); 208 available_pixel_width = std::ceil(available_pixel_width);
208 render_text->SetDisplayRect( 209 render_text->SetDisplayRect(
209 gfx::ToEnclosingRect(gfx::RectF(gfx::SizeF(available_pixel_width, 1)))); 210 gfx::ToEnclosingRect(gfx::RectF(gfx::SizeF(available_pixel_width, 1))));
210 render_text->SetElideBehavior(behavior); 211 render_text->SetElideBehavior(behavior);
211 render_text->SetText(text); 212 render_text->SetText(text);
212 return render_text->GetDisplayText(); 213 return render_text->GetDisplayText();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // of, and we can fit at least one character of the word in the elided string. 812 // of, and we can fit at least one character of the word in the elided string.
812 // Do that rather than just returning an ellipsis. 813 // Do that rather than just returning an ellipsis.
813 if (word_break && (index != static_cast<int32_t>(length - 1))) 814 if (word_break && (index != static_cast<int32_t>(length - 1)))
814 return string.substr(0, length - 1) + kElideString; 815 return string.substr(0, length - 1) + kElideString;
815 816
816 // Trying to break after only whitespace, elide all of it. 817 // Trying to break after only whitespace, elide all of it.
817 return kElideString; 818 return kElideString;
818 } 819 }
819 820
820 } // namespace gfx 821 } // namespace gfx
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