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

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

Issue 1898633004: Views: Add new SetFocusBehavior method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 8 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_unittest.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | 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 ec955b385979911957b4c951a59fe53d2357399d..30e50a997607094468ddf8f0d3dc49bb9ea10602 100644
--- a/ui/views/controls/link.cc
+++ b/ui/views/controls/link.cc
@@ -162,7 +162,7 @@ void Link::SetText(const base::string16& 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::ALWAYS);
}
void Link::OnNativeThemeChanged(const ui::NativeTheme* theme) {
@@ -198,9 +198,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 set the focus behavior
+ // here as well
+ SetFocusBehavior(text().empty() ? FocusBehavior::NEVER
+ : FocusBehavior::ALWAYS);
}
void Link::SetPressed(bool pressed) {
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/controls/menu/menu_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698