Commit bda24832 authored by Kristyn Hamasaki's avatar Kristyn Hamasaki Committed by Commit Bot

Convert Link fields to be properties

Change-Id: Iaf08c1356f929605bef59a5e6e9a1829e9b868ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1721293Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Kristyn Hamasaki <khamasaki@google.com>
Cr-Commit-Position: refs/heads/master@{#682380}
parent 8790fef2
......@@ -47,6 +47,21 @@ Link::FocusStyle Link::GetFocusStyle() const {
return GetDefaultFocusStyle();
}
SkColor Link::GetColor() const {
// TODO(tapted): Use style::GetColor().
const ui::NativeTheme* theme = GetNativeTheme();
DCHECK(theme);
if (!GetEnabled())
return theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled);
if (requested_enabled_color_set_)
return requested_enabled_color_;
return GetNativeTheme()->GetSystemColor(
pressed_ ? ui::NativeTheme::kColorId_LinkPressed
: ui::NativeTheme::kColorId_LinkEnabled);
}
void Link::PaintFocusRing(gfx::Canvas* canvas) const {
if (GetFocusStyle() == FocusStyle::RING) {
gfx::Rect focus_ring_bounds = GetTextBounds();
......@@ -200,11 +215,16 @@ bool Link::IsSelectionSupported() const {
return false;
}
bool Link::GetUnderline() const {
return underline_;
}
void Link::SetUnderline(bool underline) {
if (underline_ == underline)
return;
underline_ = underline;
RecalculateFont();
OnPropertyChanged(&underline_, kPropertyEffectsPreferredSizeChanged);
}
void Link::Init() {
......@@ -259,23 +279,15 @@ void Link::ConfigureFocus() {
}
}
SkColor Link::GetColor() {
// TODO(tapted): Use style::GetColor().
const ui::NativeTheme* theme = GetNativeTheme();
DCHECK(theme);
if (!GetEnabled())
return theme->GetSystemColor(ui::NativeTheme::kColorId_LinkDisabled);
if (requested_enabled_color_set_)
return requested_enabled_color_;
return GetNativeTheme()->GetSystemColor(
pressed_ ? ui::NativeTheme::kColorId_LinkPressed
: ui::NativeTheme::kColorId_LinkEnabled);
}
DEFINE_ENUM_CONVERTERS(Link::FocusStyle,
{Link::FocusStyle::UNDERLINE,
base::ASCIIToUTF16("UNDERLINE")},
{Link::FocusStyle::RING, base::ASCIIToUTF16("RING")})
BEGIN_METADATA(Link)
METADATA_PARENT_CLASS(Label)
ADD_READONLY_PROPERTY_METADATA(Link, SkColor, Color)
ADD_READONLY_PROPERTY_METADATA(Link, Link::FocusStyle, FocusStyle)
ADD_PROPERTY_METADATA(Link, bool, Underline)
END_METADATA()
} // namespace views
......@@ -53,6 +53,8 @@ class VIEWS_EXPORT Link : public Label {
const LinkListener* listener() { return listener_; }
void set_listener(LinkListener* listener) { listener_ = listener; }
SkColor GetColor() const;
// Label:
void PaintFocusRing(gfx::Canvas* canvas) const override;
gfx::Insets GetInsets() const override;
......@@ -74,6 +76,7 @@ class VIEWS_EXPORT Link : public Label {
void SetEnabledColor(SkColor color) override;
bool IsSelectionSupported() const override;
bool GetUnderline() const;
// TODO(estade): almost all the places that call this pass false. With
// Harmony, false is already the default so those callsites can be removed.
// TODO(tapted): Then remove all callsites when client code sets a correct
......@@ -89,8 +92,6 @@ class VIEWS_EXPORT Link : public Label {
void ConfigureFocus();
SkColor GetColor();
LinkListener* listener_;
// Whether the link should be underlined when enabled.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment