Index: ui/gfx/text_elider.cc |
diff --git a/ui/gfx/text_elider.cc b/ui/gfx/text_elider.cc |
index 279e5cb3be87ff3142647f3f3ab5d15fde476f97..0f6e5208fa4f1deefd24a856d4515030ea1add3d 100644 |
--- a/ui/gfx/text_elider.cc |
+++ b/ui/gfx/text_elider.cc |
@@ -471,7 +471,8 @@ class RectangleText { |
float available_pixel_width, |
int available_pixel_height, |
WordWrapBehavior wrap_behavior, |
- std::vector<base::string16>* lines) |
+ std::vector<base::string16>* lines, |
+ float* max_width) |
: font_list_(font_list), |
line_height_(font_list.GetHeight()), |
available_pixel_width_(available_pixel_width), |
@@ -482,7 +483,8 @@ class RectangleText { |
last_line_ended_in_lf_(false), |
lines_(lines), |
insufficient_width_(false), |
- insufficient_height_(false) {} |
+ insufficient_height_(false), |
+ max_width_(max_width) {} |
// Perform deferred initializions following creation. Must be called |
// before any input can be added via AddString(). |
@@ -562,6 +564,8 @@ class RectangleText { |
// Indicates whether there were too many lines for the available height. |
bool insufficient_height_; |
+ float* max_width_; |
Alexei Svitkine (slow)
2014/10/02 16:59:37
I suggest not making this a pointer, but rather a
|
+ |
DISALLOW_COPY_AND_ASSIGN(RectangleText); |
}; |
@@ -691,6 +695,8 @@ int RectangleText::AddWord(const base::string16& word) { |
// Word can be made to fit, no need to fragment it. |
if ((current_width_ + trimmed_width > available_pixel_width_) && NewLine()) |
lines_added++; |
+ if (max_width_) |
+ *max_width_ = std::max(*max_width_, current_width_ + trimmed_width); |
// Append the non-trimmed word, in case more words are added after. |
AddToCurrentLine(word); |
} else { |
@@ -744,12 +750,14 @@ int ElideRectangleText(const base::string16& input, |
float available_pixel_width, |
int available_pixel_height, |
WordWrapBehavior wrap_behavior, |
- std::vector<base::string16>* lines) { |
+ std::vector<base::string16>* lines, |
+ float* max_width) { |
RectangleText rect(font_list, |
available_pixel_width, |
available_pixel_height, |
wrap_behavior, |
- lines); |
+ lines, |
+ max_width); |
rect.Init(); |
rect.AddString(input); |
return rect.Finalize(); |