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

Unified Diff: ui/base/l10n/l10n_util.cc

Issue 7669040: content: Move render_widget_host_view_gtk to content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chromeos fix. Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | ui/base/l10n/l10n_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util.cc
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 9230a66561c0e4565e753aaf52ed9fb826038642..ff35b4015ab98a791e1a9ea6c1128fb01dbf19a0 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -741,69 +741,6 @@ string16 GetStringFUTF16Int(int message_id, int64 a) {
return GetStringFUTF16(message_id, UTF8ToUTF16(base::Int64ToString(a)));
}
-string16 TruncateString(const string16& string, size_t length) {
- if (string.size() <= length)
- // String fits, return it.
- return string;
-
- if (length == 0) {
- // No room for the elide string, return an empty string.
- return string16();
- }
- size_t max = length - 1;
-
- // Added to the end of strings that are too big.
- static const char16 kElideString[] = { 0x2026, 0 };
-
- if (max == 0) {
- // Just enough room for the elide string.
- return kElideString;
- }
-
- // Use a line iterator to find the first boundary.
- UErrorCode status = U_ZERO_ERROR;
- scoped_ptr<icu::RuleBasedBreakIterator> bi(
- static_cast<icu::RuleBasedBreakIterator*>(
- icu::RuleBasedBreakIterator::createLineInstance(
- icu::Locale::getDefault(), status)));
- if (U_FAILURE(status))
- return string.substr(0, max) + kElideString;
- bi->setText(string.c_str());
- int32_t index = bi->preceding(static_cast<int32_t>(max));
- if (index == icu::BreakIterator::DONE) {
- index = static_cast<int32_t>(max);
- } else {
- // Found a valid break (may be the beginning of the string). Now use
- // a character iterator to find the previous non-whitespace character.
- icu::StringCharacterIterator char_iterator(string.c_str());
- if (index == 0) {
- // No valid line breaks. Start at the end again. This ensures we break
- // on a valid character boundary.
- index = static_cast<int32_t>(max);
- }
- char_iterator.setIndex(index);
- while (char_iterator.hasPrevious()) {
- char_iterator.previous();
- if (!(u_isspace(char_iterator.current()) ||
- u_charType(char_iterator.current()) == U_CONTROL_CHAR ||
- u_charType(char_iterator.current()) == U_NON_SPACING_MARK)) {
- // Not a whitespace character. Advance the iterator so that we
- // include the current character in the truncated string.
- char_iterator.next();
- break;
- }
- }
- if (char_iterator.hasPrevious()) {
- // Found a valid break point.
- index = char_iterator.getIndex();
- } else {
- // String has leading whitespace, return the elide string.
- return kElideString;
- }
- }
- return string.substr(0, index) + kElideString;
-}
-
// Compares the character data stored in two different string16 strings by
// specified Collator instance.
UCollationResult CompareString16WithCollator(const icu::Collator* collator,
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | ui/base/l10n/l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698