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

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

Issue 1690543004: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed review comments. Created 4 years, 9 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
Index: ui/views/controls/link.cc
diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc
index ec955b385979911957b4c951a59fe53d2357399d..c6036a099d1779bbf9971feeea7f48367a197ba6 100644
--- a/ui/views/controls/link.cc
+++ b/ui/views/controls/link.cc
@@ -159,10 +159,12 @@ void Link::SetFontList(const gfx::FontList& font_list) {
void Link::SetText(const base::string16& text) {
Label::SetText(text);
+
// Disable focusability for empty links. Otherwise Label::GetInsets() will
// give them an unconditional 1-px. inset on every side to allow for a focus
// border, when in this case we probably wanted zero width.
- SetFocusable(!text.empty());
+ SetFocusBehavior(text.empty() ? FocusBehavior::NEVER
+ : FocusBehavior::CONTROL);
}
void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) {
@@ -198,9 +200,10 @@ void Link::Init() {
// Label::Init() calls SetText(), but if that's being called from Label(), our
// SetText() override will not be reached (because the constructed class is
- // only a Label at the moment, not yet a Link). So so the set_focusable()
- // call explicitly here.
- SetFocusable(!text().empty());
+ // only a Label at the moment, not yet a Link). So explicitly set
+ // focusability here.
+ SetFocusBehavior(text().empty() ? FocusBehavior::NEVER
+ : FocusBehavior::CONTROL);
}
void Link::SetPressed(bool pressed) {

Powered by Google App Engine
This is Rietveld 408576698