Chromium Code Reviews| Index: ui/views/controls/textfield/textfield.cc |
| diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc |
| index bedee3a1c0c8cabcece0a1f5d192c79e9f5d5191..e5e2500e8102360f0fb88e390e9d3515498b3608 100644 |
| --- a/ui/views/controls/textfield/textfield.cc |
| +++ b/ui/views/controls/textfield/textfield.cc |
| @@ -276,9 +276,18 @@ Textfield::Textfield() |
| weak_ptr_factory_(this) { |
| set_context_menu_controller(this); |
| set_drag_controller(this); |
| - SetBorder(scoped_ptr<Border>(new FocusableBorder())); |
| SetFocusable(true); |
| + // Use most of the FocusableBorder's internal padding for text rendering. |
|
Peter Kasting
2014/08/28 21:15:37
Why not just make FocusableBorder thinner?
msw
2014/08/28 21:29:14
That would be a good next step to give Combobox an
|
| + scoped_ptr<FocusableBorder> border(new FocusableBorder()); |
| + const int kVerticalInset = border->GetMinimumSize().height() / 2; |
| + const gfx::Insets insets(border->GetInsets()); |
| + border->SetInsets(kVerticalInset, insets.left(), |
| + kVerticalInset, insets.right()); |
| + SetBorder(border.PassAs<Border>()); |
| + internal_padding_ = gfx::Insets(insets.top() - kVerticalInset, 0, |
| + insets.bottom() - kVerticalInset, 0); |
| + |
| if (ViewsDelegate::views_delegate) { |
| password_reveal_duration_ = ViewsDelegate::views_delegate-> |
| GetDefaultTextfieldObscuredRevealDuration(); |
| @@ -555,11 +564,18 @@ int Textfield::GetBaseline() const { |
| } |
| gfx::Size Textfield::GetPreferredSize() const { |
| - const gfx::Insets& insets = GetInsets(); |
| + gfx::Insets insets = GetInsets(); |
| + insets += internal_padding_; |
| return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + |
| insets.width(), GetFontList().GetHeight() + insets.height()); |
| } |
| +void Textfield::SetBorder(scoped_ptr<Border> b) { |
| + // Clear the default internal padding if a custom border is used. |
| + internal_padding_ = gfx::Insets(); |
| + View::SetBorder(b.Pass()); |
| +} |
| + |
| const char* Textfield::GetClassName() const { |
| return kViewClassName; |
| } |