| OLD | NEW |
| 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" |
| 11 | 11 |
| 12 #include <stdint.h> | 12 #include <stdint.h> |
| 13 | 13 |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/i18n/break_iterator.h" | 18 #include "base/i18n/break_iterator.h" |
| 19 #include "base/i18n/char_iterator.h" | 19 #include "base/i18n/char_iterator.h" |
| 20 #include "base/i18n/rtl.h" | 20 #include "base/i18n/rtl.h" |
| 21 #include "base/macros.h" |
| 21 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 24 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
| 25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "build/build_config.h" |
| 26 #include "third_party/icu/source/common/unicode/rbbi.h" | 28 #include "third_party/icu/source/common/unicode/rbbi.h" |
| 27 #include "third_party/icu/source/common/unicode/uloc.h" | 29 #include "third_party/icu/source/common/unicode/uloc.h" |
| 28 #include "third_party/icu/source/common/unicode/umachine.h" | 30 #include "third_party/icu/source/common/unicode/umachine.h" |
| 29 #include "ui/gfx/font_list.h" | 31 #include "ui/gfx/font_list.h" |
| 30 #include "ui/gfx/geometry/rect_conversions.h" | 32 #include "ui/gfx/geometry/rect_conversions.h" |
| 31 #include "ui/gfx/render_text.h" | 33 #include "ui/gfx/render_text.h" |
| 32 #include "ui/gfx/text_utils.h" | 34 #include "ui/gfx/text_utils.h" |
| 33 | 35 |
| 34 using base::ASCIIToUTF16; | 36 using base::ASCIIToUTF16; |
| 35 using base::UTF8ToUTF16; | 37 using base::UTF8ToUTF16; |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 // 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. |
| 811 // Do that rather than just returning an ellipsis. | 813 // Do that rather than just returning an ellipsis. |
| 812 if (word_break && (index != static_cast<int32_t>(length - 1))) | 814 if (word_break && (index != static_cast<int32_t>(length - 1))) |
| 813 return string.substr(0, length - 1) + kElideString; | 815 return string.substr(0, length - 1) + kElideString; |
| 814 | 816 |
| 815 // Trying to break after only whitespace, elide all of it. | 817 // Trying to break after only whitespace, elide all of it. |
| 816 return kElideString; | 818 return kElideString; |
| 817 } | 819 } |
| 818 | 820 |
| 819 } // namespace gfx | 821 } // namespace gfx |
| OLD | NEW |