Index: ui/gfx/render_text.h |
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h |
index 8696d690560e6fddc28da3a59740d725c88a8e57..24afd113291ac3d30904bb76d6a98a556f0eff3e 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,11 @@ 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 |available_pixel_width| according to the |
+ // specified |elide_behavior|. Only one of elide or truncate should be used. |
msw
2013/12/11 08:10:14
We should support simultaneous truncation and elid
Anuj
2013/12/11 18:41:32
The second part of the comment mentions what will
msw
2013/12/11 19:39:57
Then this says elide shouldn't be used on windows,
Anuj
2013/12/12 08:08:41
Done.
|
+ // If both are specified, the shorter of the two will be applicable. |
+ void Elide(float available_pixel_width, ElideBehavior elide_behavior); |
msw
2013/12/11 08:10:14
I would rather this function be SetElideBehavior(E
Anuj
2013/12/11 18:41:32
So I will need to add UpdateLayoutText to both of
msw
2013/12/11 19:39:57
I think that'll be okay, but you'll only need to U
Anuj
2013/12/12 08:08:41
Done.
|
+ |
const Rect& display_rect() const { return display_rect_; } |
void SetDisplayRect(const Rect& r); |
@@ -556,6 +562,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 +639,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. |
msw
2013/12/11 08:10:14
nit: " // The maximum width used for eliding, dis
Anuj
2013/12/12 08:08:41
Done.
|
+ float available_pixel_width_; |
+ |
+ // The behavior for eliding or truncating. |
+ ElideBehavior elide_behavior_; |
+ |
// The obscured and/or truncated text that will be displayed. |
base::string16 layout_text_; |