Chromium Code Reviews| Index: ui/views/controls/label.cc |
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
| index e627c7afc8ae30b3b8e52625da230b09103c0669..4a1a113a1762524cca21bd6e62e8b18f9de3f3be 100644 |
| --- a/ui/views/controls/label.cc |
| +++ b/ui/views/controls/label.cc |
| @@ -150,10 +150,10 @@ void Label::SetObscured(bool obscured) { |
| } |
| void Label::SetAllowCharacterBreak(bool allow_character_break) { |
| - if (allow_character_break_ == allow_character_break) |
| + if (render_text_->allow_character_break() == allow_character_break) |
| return; |
| is_first_paint_text_ = true; |
| - allow_character_break_ = allow_character_break; |
| + render_text_->SetAllowCharacterBreak(allow_character_break); |
| ResetLayout(); |
| } |
| @@ -260,7 +260,7 @@ int Label::GetHeightForWidth(int w) const { |
| int height = 0; |
| // RenderText doesn't support character breaks. |
|
msw
2015/03/25 20:54:15
nit: remove this comment and TODO.
Jun Mukai
2015/03/26 01:35:08
Done.
|
| // TODO(mukai): remove this restriction. |
| - if (render_text_->MultilineSupported() && !allow_character_break_) { |
| + if (render_text_->MultilineSupported()) { |
| // SetDisplayRect() has a side effect for later calls of GetStringSize(). |
| // Be careful to invoke |render_text_->SetDisplayRect(gfx::Rect())| to |
| // cancel this effect before the next time GetStringSize() is called. |
| @@ -393,7 +393,6 @@ void Label::Init(const base::string16& text, const gfx::FontList& font_list) { |
| UpdateColorsFromTheme(ui::NativeTheme::instance()); |
| handles_tooltips_ = true; |
| collapse_when_hidden_ = false; |
| - allow_character_break_ = false; |
| max_width_ = 0; |
| is_first_paint_text_ = true; |
| SetText(text); |
| @@ -451,8 +450,7 @@ void Label::MaybeBuildRenderTextLines() { |
| // TODO(mukai): Add multi-lined elided text support. |
| gfx::ElideBehavior elide_behavior = |
| multi_line() ? gfx::NO_ELIDE : elide_behavior_; |
| - if (!multi_line() || |
| - (render_text_->MultilineSupported() && !allow_character_break_)) { |
| + if (!multi_line() || render_text_->MultilineSupported()) { |
| scoped_ptr<gfx::RenderText> render_text = |
| CreateRenderText(text(), alignment, directionality, elide_behavior); |
| render_text->SetDisplayRect(rect); |
| @@ -504,7 +502,7 @@ std::vector<base::string16> Label::GetLinesForWidth(int width) const { |
| if (width <= 0) { |
| base::SplitString(render_text_->GetDisplayText(), '\n', &lines); |
| } else { |
| - const gfx::WordWrapBehavior wrap = allow_character_break_ |
| + const gfx::WordWrapBehavior wrap = render_text_->allow_character_break() |
| ? gfx::WRAP_LONG_WORDS |
| : gfx::TRUNCATE_LONG_WORDS; |
| gfx::ElideRectangleText(render_text_->GetDisplayText(), font_list(), width, |
| @@ -517,8 +515,7 @@ gfx::Size Label::GetTextSize() const { |
| gfx::Size size; |
| if (text().empty()) { |
| size = gfx::Size(0, std::max(line_height(), font_list().GetHeight())); |
| - } else if (!multi_line() || |
| - (render_text_->MultilineSupported() && !allow_character_break_)) { |
| + } else if (!multi_line() || render_text_->MultilineSupported()) { |
| // Cancel the display rect of |render_text_|. The display rect may be |
| // specified in GetHeightForWidth(), and specifying empty Rect cancels |
| // its effect. See also the comment in GetHeightForWidth(). |