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

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

Issue 1070223004: Stop combining text runs which are connected by 'COMMON' blocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address msw@'s comment. Created 5 years, 6 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 | « ui/gfx/render_text_unittest.cc ('k') | ui/gfx/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 // This file defines utility functions for eliding and formatting UI text. 5 // This file defines utility functions for eliding and formatting UI text.
6 6
7 #ifndef UI_GFX_TEXT_ELIDER_H_ 7 #ifndef UI_GFX_TEXT_ELIDER_H_
8 #define UI_GFX_TEXT_ELIDER_H_ 8 #define UI_GFX_TEXT_ELIDER_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // equal-length pieces from the beginning and end of the string; otherwise, 44 // equal-length pieces from the beginning and end of the string; otherwise,
45 // the end of the string is removed and only the beginning remains. If 45 // the end of the string is removed and only the beginning remains. If
46 // |insert_ellipsis| is true, then an ellipsis character will be inserted at 46 // |insert_ellipsis| is true, then an ellipsis character will be inserted at
47 // the cut point (note that the ellipsis will does not count towards the 47 // the cut point (note that the ellipsis will does not count towards the
48 // |length| limit). 48 // |length| limit).
49 // Note: Characters may still be omitted even if |length| is the full string 49 // Note: Characters may still be omitted even if |length| is the full string
50 // length, if surrogate pairs fall on the split boundary. 50 // length, if surrogate pairs fall on the split boundary.
51 base::string16 CutString(size_t length, bool insert_ellipsis) const; 51 base::string16 CutString(size_t length, bool insert_ellipsis) const;
52 52
53 private: 53 private:
54 // Returns a valid cut boundary at or before/after |index|.
55 size_t FindValidBoundaryBefore(size_t index) const;
56 size_t FindValidBoundaryAfter(size_t index) const;
57
58 // The text to be sliced. 54 // The text to be sliced.
59 const base::string16& text_; 55 const base::string16& text_;
60 56
61 // Ellipsis string to use. 57 // Ellipsis string to use.
62 const base::string16& ellipsis_; 58 const base::string16& ellipsis_;
63 59
64 // If true, the middle of the string will be elided. 60 // If true, the middle of the string will be elided.
65 bool elide_in_middle_; 61 bool elide_in_middle_;
66 62
67 // If true, the beginning of the string will be elided. 63 // If true, the beginning of the string will be elided.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // CHARACTER_BREAK, and adds the horizontal ellipsis character (unicode 140 // CHARACTER_BREAK, and adds the horizontal ellipsis character (unicode
145 // character 0x2026) to render "...". The supplied string is returned if the 141 // character 0x2026) to render "...". The supplied string is returned if the
146 // string has |length| characters or less. 142 // string has |length| characters or less.
147 GFX_EXPORT base::string16 TruncateString(const base::string16& string, 143 GFX_EXPORT base::string16 TruncateString(const base::string16& string,
148 size_t length, 144 size_t length,
149 BreakType break_type); 145 BreakType break_type);
150 146
151 } // namespace gfx 147 } // namespace gfx
152 148
153 #endif // UI_GFX_TEXT_ELIDER_H_ 149 #endif // UI_GFX_TEXT_ELIDER_H_
OLDNEW
« no previous file with comments | « ui/gfx/render_text_unittest.cc ('k') | ui/gfx/text_elider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698