Chromium Code Reviews| Index: ui/gfx/render_text.h |
| diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h |
| index 06d53f4a9e410b2d2ba665ff6d09c2f612016cfa..1a306aad3e0b1bd686ee6cd4de8bf9d3517f4b02 100644 |
| --- a/ui/gfx/render_text.h |
| +++ b/ui/gfx/render_text.h |
| @@ -27,6 +27,7 @@ |
| #include "ui/gfx/shadow_value.h" |
| #include "ui/gfx/size_f.h" |
| #include "ui/gfx/text_constants.h" |
| +#include "ui/gfx/text_elider.h" |
| #include "ui/gfx/vector2d.h" |
| class SkCanvas; |
| @@ -228,6 +229,12 @@ class GFX_EXPORT RenderText { |
| // WARNING: Only use this for system limits, it lacks complex text support. |
| void set_truncate_length(size_t length) { truncate_length_ = length; } |
| + // Elides the text to fit in |display_rect| according to the specified |
| + // |elide_behavior|. |ELIDE_IN_MIDDLE| is not supported. |
| + // If both truncate and elide are specified, the shorter of the two will be |
|
msw
2013/12/27 22:54:33
nit: wrap this above
Anuj
2013/12/30 22:46:58
Done.
|
| + // applicable. |
| + void SetElideBehavior(ElideBehavior elide_behavior); |
| + |
| const Rect& display_rect() const { return display_rect_; } |
| void SetDisplayRect(const Rect& r); |
| @@ -536,6 +543,8 @@ class GFX_EXPORT RenderText { |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ApplyColorAndStyle); |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ObscuredText); |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, RevealObscuredText); |
| + FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ElidedText); |
| + FRIEND_TEST_ALL_PREFIXES(RenderTextTest, ElidedObscuredText); |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedText); |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, TruncatedObscuredText); |
| FRIEND_TEST_ALL_PREFIXES(RenderTextTest, GraphemePositions); |
| @@ -557,6 +566,10 @@ class GFX_EXPORT RenderText { |
| // Updates |layout_text_| if the text is obscured or truncated. |
| void UpdateLayoutText(); |
| + // Elides |text| to fit in the |display_rect_| with given |elide_behavior_|. |
| + // See ElideText in ui/gfx/text_elider.cc for reference. |
| + base::string16 ElideText(const base::string16& text); |
| + |
| // Update the cached bounds and display offset to ensure that the current |
| // cursor is within the visible display area. |
| void UpdateCachedBoundsAndOffset(); |
| @@ -629,6 +642,9 @@ class GFX_EXPORT RenderText { |
| // The maximum length of text to display, 0 forgoes a hard limit. |
| size_t truncate_length_; |
| + // The behavior for eliding or truncating. |
| + ElideBehavior elide_behavior_; |
| + |
| // The obscured and/or truncated text that will be displayed. |
| base::string16 layout_text_; |