Chromium Code Reviews| Index: ui/views/controls/link.cc |
| diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc |
| index 2fced0be7b84ba25c4ad7d8a6120cb6f30bc8bc8..3d4257b29099c1e2163d58b94df225bfd5c56d75 100644 |
| --- a/ui/views/controls/link.cc |
| +++ b/ui/views/controls/link.cc |
| @@ -170,7 +170,7 @@ void Link::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| void Link::OnEnabledChanged() { |
| RecalculateFont(); |
| - View::OnEnabledChanged(); |
| + View::OnEnabledChanged(); // Jump over Label. |
| } |
| void Link::OnFocus() { |
| @@ -199,15 +199,13 @@ void Link::SetText(const base::string16& text) { |
| void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| Label::OnNativeThemeChanged(theme); |
| - Label::SetEnabledColor(GetEnabledColor()); |
| - SetDisabledColor( |
| - theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled)); |
| + Label::SetEnabledColor(GetColor()); |
| } |
| void Link::SetEnabledColor(SkColor color) { |
| requested_enabled_color_set_ = true; |
| requested_enabled_color_ = color; |
| - Label::SetEnabledColor(GetEnabledColor()); |
| + Label::SetEnabledColor(GetColor()); |
| } |
| bool Link::IsSelectionSupported() const { |
| @@ -237,7 +235,7 @@ void Link::Init() { |
| void Link::SetPressed(bool pressed) { |
| if (pressed_ != pressed) { |
| pressed_ = pressed; |
| - Label::SetEnabledColor(GetEnabledColor()); |
| + Label::SetEnabledColor(GetColor()); |
| RecalculateFont(); |
| SchedulePaint(); |
| } |
| @@ -269,17 +267,18 @@ void Link::ConfigureFocus() { |
| } |
| } |
| -SkColor Link::GetEnabledColor() { |
| +SkColor Link::GetColor() { |
| + const ui::NativeTheme* theme = GetNativeTheme(); |
| + DCHECK(theme); |
|
Peter Kasting
2017/06/01 04:55:58
The old code conditionalized this. Is it guarante
tapted
2017/06/01 11:22:18
Yup.
View::GetNativeTheme() and Widget::GetNative
|
| + if (!enabled()) |
| + return theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled); |
| + |
| if (requested_enabled_color_set_) |
| return requested_enabled_color_; |
| - if (GetNativeTheme()) { |
| - return GetNativeTheme()->GetSystemColor( |
| - pressed_ ? ui::NativeTheme::kColorId_LinkPressed |
| - : ui::NativeTheme::kColorId_LinkEnabled); |
| - } |
| - |
| - return gfx::kPlaceholderColor; |
| + return GetNativeTheme()->GetSystemColor( |
| + pressed_ ? ui::NativeTheme::kColorId_LinkPressed |
| + : ui::NativeTheme::kColorId_LinkEnabled); |
| } |
| } // namespace views |