Chromium Code Reviews| Index: ui/views/controls/label.cc |
| diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc |
| index 8d46029a8041d452e6a702a0e891fe843c6b2aba..a72c2c8bffb903ff46bdb003d171f6b5245880a9 100644 |
| --- a/ui/views/controls/label.cc |
| +++ b/ui/views/controls/label.cc |
| @@ -213,7 +213,7 @@ base::string16 Label::GetDisplayTextForTesting() { |
| gfx::Insets Label::GetInsets() const { |
| gfx::Insets insets = View::GetInsets(); |
| - if (focusable()) { |
| + if (IsFocusable()) { |
| insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, |
| kFocusBorderPadding, kFocusBorderPadding); |
| } |
| @@ -333,6 +333,11 @@ bool Label::GetTooltipText(const gfx::Point& p, base::string16* tooltip) const { |
| void Label::OnEnabledChanged() { |
| RecalculateColors(); |
| + |
| + // If the label has become focusable now due to being enabled, GetInsets() |
| + // will return a different value. Hence reset layout. |
|
karandeepb
2016/04/27 23:53:17
I am not totally sure whether this is needed or no
|
| + if (IsFocusable()) |
| + ResetLayout(); |
| } |
| std::unique_ptr<gfx::RenderText> Label::CreateRenderText( |
| @@ -397,6 +402,11 @@ void Label::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| void Label::VisibilityChanged(View* starting_from, bool is_visible) { |
| if (!is_visible) |
| lines_.clear(); |
| + |
| + // If the label has become focusable now due to being visible, GetInsets() |
| + // will return a different value. Hence reset layout. |
| + if (IsFocusable()) |
| + ResetLayout(); |
| } |
| void Label::Init(const base::string16& text, const gfx::FontList& font_list) { |
| @@ -435,7 +445,7 @@ void Label::MaybeBuildRenderTextLines() { |
| return; |
| gfx::Rect rect = GetContentsBounds(); |
| - if (focusable()) |
| + if (IsFocusable()) |
| rect.Inset(kFocusBorderPadding, kFocusBorderPadding); |
| if (rect.IsEmpty()) |
| return; |