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

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

Issue 1920193003: Remove View::focusable(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
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
Index: ui/views/controls/link.cc
diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc
index 30e50a997607094468ddf8f0d3dc49bb9ea10602..953014feaa3187d1c8e87f6eb97c4d10f25db288 100644
--- a/ui/views/controls/link.cc
+++ b/ui/views/controls/link.cc
@@ -23,7 +23,9 @@
namespace views {
+// static
const char Link::kViewClassName[] = "Link";
+const int Link::kFocusBorderPadding = 1;
Link::Link() : Link(base::string16()) {}
@@ -159,9 +161,7 @@ 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.
+ // Disable focusability for empty links.
SetFocusBehavior(text.empty() ? FocusBehavior::NEVER : FocusBehavior::ALWAYS);
}
@@ -177,6 +177,16 @@ void Link::SetEnabledColor(SkColor color) {
Label::SetEnabledColor(GetEnabledColor());
}
+gfx::Insets Link::GetInsets() const {
+ gfx::Insets insets = Label::GetInsets();
+ // Non-empty links will have a focus border around them.
+ if (!text().empty()) {
karandeepb 2016/04/27 08:04:40 There are 1-2 instances where the focusability of
+ insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding,
+ kFocusBorderPadding, kFocusBorderPadding);
+ }
+ return insets;
+}
+
void Link::SetPressedColor(SkColor color) {
requested_pressed_color_set_ = true;
requested_pressed_color_ = color;

Powered by Google App Engine
This is Rietveld 408576698