Chromium Code Reviews| Index: ui/base/text/text_elider.h |
| diff --git a/ui/base/text/text_elider.h b/ui/base/text/text_elider.h |
| index 5dd3dc5c5250b68ad1df965fab84aba86c062505..a5e4206146abb5ddb006c6c70a7f0ea636a2a33b 100644 |
| --- a/ui/base/text/text_elider.h |
| +++ b/ui/base/text/text_elider.h |
| @@ -12,6 +12,8 @@ |
| #include "base/basictypes.h" |
| #include "base/string16.h" |
| #include "ui/gfx/font.h" |
| +#include "third_party/skia/include/core/SkPaint.h" |
| +#include "third_party/skia/include/core/SkScalar.h" |
| class FilePath; |
| class GURL; |
| @@ -20,6 +22,13 @@ namespace ui { |
| extern const char kEllipsis[]; |
| +// Specifies what type of object is passed into the Elide functions. |
| +// These are used to measure the width of the text string. |
| +enum ObjectType { |
| + Skia_Paint, // SkPaint object. |
| + GFX_Font // gfx::Font object. |
| +}; |
| + |
| // This function takes a GURL object and elides it. It returns a string |
| // which composed of parts from subdomain, domain, path, filename and query. |
| // A "..." is added automatically at the end if the elided string is bigger |
| @@ -38,6 +47,24 @@ string16 ElideUrl(const GURL& url, |
| int available_pixel_width, |
| const std::string& languages); |
| +// Overloaded function. |
| +// Takes a SkPaint object to determine the width of the text on the screen. |
| +string16 ElideUrl(const GURL& url, |
| + const SkPaint paint, |
| + SkScalar available_point_width, |
| + const std::string& languages); |
| + |
| +// Overloaded function. |
| +// The |font_or_paint| argument is a pointer to either a Font or Paint object |
| +// and that is specified in the |object_type| parameter. |
| +// Depending on what type of object is passed, the appropriate function is |
| +// called to measure the width of the text. |
| +string16 ElideUrl(const GURL& url, |
|
Lei Zhang
2011/07/12 22:04:50
You shouldn't expose the internal implementation.
Aayush Kumar
2011/07/13 21:52:16
Done.
|
| + void* font_or_paint, |
| + int available_pixel_width, |
| + const std::string& languages, |
| + ObjectType object_type); |
| + |
| // Elides |text| to fit in |available_pixel_width|. If |elide_in_middle| is |
| // set the ellipsis is placed in the middle of the string; otherwise it is |
| // placed at the end. |
| @@ -46,6 +73,24 @@ string16 ElideText(const string16& text, |
| int available_pixel_width, |
| bool elide_in_middle); |
| +// Overloaded function. |
| +// Takes a SkPaint object to determine the width of the text on the screen. |
| +string16 ElideText(const string16& text, |
| + const SkPaint paint, |
| + SkScalar available_point_width, |
| + bool elide_in_middle); |
| + |
| +// Overloaded function. |
| +// The |font_or_paint| argument is a pointer to either a Font or Paint object |
| +// and that is specified in the |object_type| parameter. |
| +// Depending on what type of object is passed, the appropriate function is |
| +// called to measure the width of the text. |
| +string16 ElideText(const string16& text, |
| + void* font_or_paint, |
| + SkScalar available_pixel_width, |
| + bool elide_in_middle, |
| + ObjectType object_type); |
| + |
| // Elide a filename to fit a given pixel width, with an emphasis on not hiding |
| // the extension unless we have to. If filename contains a path, the path will |
| // be removed if filename doesn't fit into available_pixel_width. The elided |