 Chromium Code Reviews
 Chromium Code Reviews Issue 112063003:
  Implement eliding/truncating at end in RenderText  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 112063003:
  Implement eliding/truncating at end in RenderText  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: ui/gfx/render_text.h | 
| diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h | 
| index 8696d690560e6fddc28da3a59740d725c88a8e57..b30b72ba10fb003f8ff26931f58d99234b467b26 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; | 
| @@ -227,6 +228,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 | 
| + // applicable. | 
| + void SetElideBehavior(ElideBehavior elide_behavior); | 
| + | 
| const Rect& display_rect() const { return display_rect_; } | 
| void SetDisplayRect(const Rect& r); | 
| @@ -535,6 +542,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); | 
| @@ -556,6 +565,11 @@ class GFX_EXPORT RenderText { | 
| // Updates |layout_text_| if the text is obscured or truncated. | 
| void UpdateLayoutText(); | 
| + // Elides |text| to fit in the |available_pixel_width_| 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(); | 
| @@ -628,6 +642,12 @@ class GFX_EXPORT RenderText { | 
| // The maximum length of text to display, 0 forgoes a hard limit. | 
| size_t truncate_length_; | 
| + // The maxmium width available to display the text. | 
| + float available_pixel_width_; | 
| 
msw
2013/12/12 19:28:29
Remove this.
 
Anuj
2013/12/13 01:23:50
Done.
 | 
| + | 
| + // The behavior for eliding or truncating. | 
| + ElideBehavior elide_behavior_; | 
| + | 
| // The obscured and/or truncated text that will be displayed. | 
| base::string16 layout_text_; |