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

Unified Diff: ui/gfx/render_text.h

Issue 354963003: Move gfx::ElideText functionality to RenderText. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and rebase. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text.h
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index 6258c8bd22d4a5a37d0efb94ad9f411353f07f6d..afd62eae6b972a587deb4ad5e74767b65967aa89 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -29,7 +29,6 @@
#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;
@@ -254,11 +253,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_MIDDLE| is not supported. If a truncate length and
- // an elide mode are specified, the shorter of the two will be applicable.
+ // The layout text will be elided to fit |display_rect| using this behavior.
+ // The layout text may be shortened further by the truncate length.
void SetElideBehavior(ElideBehavior elide_behavior);
+ const base::string16& layout_text() const { return layout_text_; }
+
const Rect& display_rect() const { return display_rect_; }
void SetDisplayRect(const Rect& r);
@@ -355,7 +355,7 @@ class GFX_EXPORT RenderText {
// Returns the width of the content (which is the wrapped width in multiline
// mode). Reserves room for the cursor if |cursor_enabled_| is true.
- int GetContentWidth();
+ float GetContentWidth();
// Returns the common baseline of the text. The return value is the vertical
// offset from the top of |display_rect_| to the text baseline, in pixels.
@@ -581,9 +581,13 @@ 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);
+ // Elides |text| as needed to fit in the |available_width| using |behavior|.
+ base::string16 Elide(const base::string16& text,
+ float available_width,
+ ElideBehavior behavior);
+
+ // Elides |email| as needed to fit the |available_width|.
+ base::string16 ElideEmail(const base::string16& email, float available_width);
// Update the cached bounds and display offset to ensure that the current
// cursor is within the visible display area.
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_result_view.cc ('k') | ui/gfx/render_text.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698