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

Unified Diff: views/controls/button/text_button.cc

Issue 8439015: Make infobar controls focusable by default. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/button/text_button.cc
===================================================================
--- views/controls/button/text_button.cc (revision 107928)
+++ views/controls/button/text_button.cc (working copy)
@@ -34,14 +34,22 @@
// Default space between the icon and text.
static const int kDefaultIconTextSpacing = 5;
-// Preferred padding between text and edge
+// Preferred padding between text and edge.
static const int kPreferredPaddingHorizontal = 6;
static const int kPreferredPaddingVertical = 5;
-// Preferred padding between text and edge for NativeTheme border
+// Preferred padding between text and edge for NativeTheme border.
static const int kPreferredNativeThemePaddingHorizontal = 12;
static const int kPreferredNativeThemePaddingVertical = 5;
+// By default the focus rect is drawn at the border of the view.
+// For a button, we inset the focus rect by 3 pixels so that it
+// doesn't draw on top of the button's border. This roughly matches
+// how the Windows native focus rect for buttons looks. A subclass
+// that draws a button with different padding may need to
+// override OnPaintFocusBorder and do something different.
+static const int kFocusRectInset = 3;
+
// Default background color for buttons.
const SkColor kBackgroundColor = SkColorSetRGB(0xde, 0xde, 0xde);
@@ -744,6 +752,14 @@
return kViewClassName;
}
+void TextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
+ if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
+ gfx::Rect rect(GetLocalBounds());
+ rect.Inset(kFocusRectInset, kFocusRectInset);
+ canvas->DrawFocusRect(rect);
+ }
+}
+
gfx::NativeTheme::Part TextButton::GetThemePart() const {
return gfx::NativeTheme::kPushButton;
}
@@ -825,11 +841,9 @@
void NativeTextButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
#if defined(OS_WIN)
- // On windows, make sure the focus border is inset wrt the entire button so
- // that the native text button appears more like a windows button.
if ((IsFocusable() || IsAccessibilityFocusableInRootView()) && HasFocus()) {
gfx::Rect rect(GetLocalBounds());
- rect.Inset(3, 3);
+ rect.Inset(kFocusRectInset, kFocusRectInset);
canvas->DrawFocusRect(rect);
}
#else
« no previous file with comments | « views/controls/button/text_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698