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

Unified Diff: ui/views/controls/label.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/label.cc
diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc
index 8d46029a8041d452e6a702a0e891fe843c6b2aba..2e54c1ea2418dd72afb430ffd8e2b9415b607b7c 100644
--- a/ui/views/controls/label.cc
+++ b/ui/views/controls/label.cc
@@ -38,7 +38,6 @@ const gfx::FontList& GetDefaultFontList() {
// static
const char Label::kViewClassName[] = "Label";
-const int Label::kFocusBorderPadding = 1;
Label::Label() : Label(base::string16()) {
}
@@ -211,15 +210,6 @@ base::string16 Label::GetDisplayTextForTesting() {
return result;
}
-gfx::Insets Label::GetInsets() const {
sky 2016/04/27 16:34:20 Is there a reason to remove this? Isn't is possibl
- gfx::Insets insets = View::GetInsets();
- if (focusable()) {
- insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding,
- kFocusBorderPadding, kFocusBorderPadding);
- }
- return insets;
-}
-
int Label::GetBaseline() const {
return GetInsets().top() + font_list().GetBaseline();
}
@@ -434,9 +424,10 @@ void Label::MaybeBuildRenderTextLines() {
if (!lines_.empty())
return;
- gfx::Rect rect = GetContentsBounds();
- if (focusable())
- rect.Inset(kFocusBorderPadding, kFocusBorderPadding);
+ // GetContentBounds() does not use GetInsets() which may be overriden in Label
sky 2016/04/28 00:05:56 ick. We should fix GetcontentsBounds to call GetIn
karandeepb 2016/04/28 00:13:34 Will assign a bug to myself and fix this.
+ // subclasses which are focusable, for eg, link. Hence use GetLocalBounds().
+ gfx::Rect rect = GetLocalBounds();
+ rect.Inset(GetInsets());
if (rect.IsEmpty())
return;
rect.Inset(-gfx::ShadowValue::GetMargin(shadows()));
@@ -497,8 +488,7 @@ gfx::Rect Label::GetFocusBounds() {
focus_bounds.Union(gfx::Rect(origin, lines_[i]->GetStringSize()));
}
}
-
- focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
+ focus_bounds.Inset(-GetInsets());
karandeepb 2016/04/27 08:04:40 This will be different from the current value if t
focus_bounds.Intersect(GetLocalBounds());
return focus_bounds;
}

Powered by Google App Engine
This is Rietveld 408576698