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

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: Fix the initial width of OmniboxResultView's elided RenderTexts. 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
Index: ui/gfx/render_text.h
diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h
index 3c87440eddd7f4da2852a61348607c0b348abc70..414d8f9af9317693d94dc4227e59ad268c44b582 100644
--- a/ui/gfx/render_text.h
+++ b/ui/gfx/render_text.h
@@ -28,7 +28,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.
@@ -580,9 +580,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.

Powered by Google App Engine
This is Rietveld 408576698