| Index: ui/views/controls/label.cc
|
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
|
| index 3d0cf30192cb2c64104f535e1dbf4f5aa824624b..e627c7afc8ae30b3b8e52625da230b09103c0669 100644
|
| --- a/ui/views/controls/label.cc
|
| +++ b/ui/views/controls/label.cc
|
| @@ -499,10 +499,17 @@ gfx::Rect Label::GetFocusBounds() {
|
|
|
| std::vector<base::string16> Label::GetLinesForWidth(int width) const {
|
| std::vector<base::string16> lines;
|
| - const gfx::WordWrapBehavior wrap =
|
| - allow_character_break_ ? gfx::WRAP_LONG_WORDS : gfx::TRUNCATE_LONG_WORDS;
|
| - gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width,
|
| - std::numeric_limits<int>::max(), wrap, &lines);
|
| + // |width| can be 0 when getting the default text size, in that case
|
| + // the ideal lines (i.e. broken at newline characters) are wanted.
|
| + if (width <= 0) {
|
| + base::SplitString(render_text_->GetDisplayText(), '\n', &lines);
|
| + } else {
|
| + const gfx::WordWrapBehavior wrap = allow_character_break_
|
| + ? gfx::WRAP_LONG_WORDS
|
| + : gfx::TRUNCATE_LONG_WORDS;
|
| + gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width,
|
| + std::numeric_limits<int>::max(), wrap, &lines);
|
| + }
|
| return lines;
|
| }
|
|
|
|
|