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

Side by Side Diff: base/string_util.cc

Issue 10386016: Modify ui::ElideRectangleText() to honor trailing newlines. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | ui/base/text/text_elider.cc » ('j') | 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 #include "base/string_util.h" 5 #include "base/string_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <ctype.h> 9 #include <ctype.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return CollapseWhitespaceT(text, trim_sequences_with_line_breaks); 371 return CollapseWhitespaceT(text, trim_sequences_with_line_breaks);
372 } 372 }
373 #endif 373 #endif
374 374
375 std::string CollapseWhitespaceASCII(const std::string& text, 375 std::string CollapseWhitespaceASCII(const std::string& text,
376 bool trim_sequences_with_line_breaks) { 376 bool trim_sequences_with_line_breaks) {
377 return CollapseWhitespaceT(text, trim_sequences_with_line_breaks); 377 return CollapseWhitespaceT(text, trim_sequences_with_line_breaks);
378 } 378 }
379 379
380 bool ContainsOnlyWhitespaceASCII(const std::string& str) { 380 bool ContainsOnlyWhitespaceASCII(const std::string& str) {
381 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) { 381 for (std::string::const_iterator i(str.begin()); i != str.end(); ++i) {
tfarina 2012/05/15 02:49:52 Can we simplify this as well?
Alexei Svitkine (slow) 2012/05/15 03:04:23 I considered it, but unfortunately kWhitespaceASCI
382 if (!IsAsciiWhitespace(*i)) 382 if (!IsAsciiWhitespace(*i))
383 return false; 383 return false;
384 } 384 }
385 return true; 385 return true;
386 } 386 }
387 387
388 bool ContainsOnlyWhitespace(const string16& str) { 388 bool ContainsOnlyWhitespace(const string16& str) {
389 for (string16::const_iterator i(str.begin()); i != str.end(); ++i) { 389 return str.find_first_not_of(kWhitespaceUTF16) == string16::npos;
390 if (!IsWhitespace(*i))
391 return false;
392 }
393 return true;
394 } 390 }
395 391
396 template<typename STR> 392 template<typename STR>
397 static bool ContainsOnlyCharsT(const STR& input, const STR& characters) { 393 static bool ContainsOnlyCharsT(const STR& input, const STR& characters) {
398 for (typename STR::const_iterator iter = input.begin(); 394 for (typename STR::const_iterator iter = input.begin();
399 iter != input.end(); ++iter) { 395 iter != input.end(); ++iter) {
400 if (characters.find(*iter) == STR::npos) 396 if (characters.find(*iter) == STR::npos)
401 return false; 397 return false;
402 } 398 }
403 return true; 399 return true;
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 } 1042 }
1047 1043
1048 } // namespace 1044 } // namespace
1049 1045
1050 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { 1046 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) {
1051 return lcpyT<char>(dst, src, dst_size); 1047 return lcpyT<char>(dst, src, dst_size);
1052 } 1048 }
1053 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { 1049 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) {
1054 return lcpyT<wchar_t>(dst, src, dst_size); 1050 return lcpyT<wchar_t>(dst, src, dst_size);
1055 } 1051 }
OLDNEW
« no previous file with comments | « no previous file | ui/base/text/text_elider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698