Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Unified Diff: ui/views/controls/link.cc

Issue 2023453002: MD links - underline to indicate focus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix website settings Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/label.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/link.cc
diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc
index df1177f452e537a72209a8e2a8f0c4c4e2d25ccd..405625b6637353a5c12fffc23a04ca733a1375b3 100644
--- a/ui/views/controls/link.cc
+++ b/ui/views/controls/link.cc
@@ -142,12 +142,14 @@ void Link::OnEnabledChanged() {
void Link::OnFocus() {
Label::OnFocus();
+ RecalculateFont();
// We render differently focused.
SchedulePaint();
}
void Link::OnBlur() {
Label::OnBlur();
+ RecalculateFont();
// We render differently focused.
SchedulePaint();
}
@@ -210,10 +212,15 @@ void Link::SetPressed(bool pressed) {
}
void Link::RecalculateFont() {
- // Underline the link iff it is enabled and |underline_| is true.
+ // Underline the link if it is enabled and |underline_| is true. Also
+ // underline to indicate focus in MD.
const int style = font_list().GetFontStyle();
- const int intended_style = (enabled() && underline_) ?
+ const bool underline =
+ underline_ ||
+ (HasFocus() && ui::MaterialDesignController::IsSecondaryUiMaterial());
+ const int intended_style = (enabled() && underline) ?
(style | gfx::Font::UNDERLINE) : (style & ~gfx::Font::UNDERLINE);
+
if (style != intended_style)
Label::SetFontList(font_list().DeriveWithStyle(intended_style));
}
« no previous file with comments | « ui/views/controls/label.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698