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..9e424894920cbe789852651e152caea3f2544397 100644 |
--- a/ui/views/controls/textfield/textfield.cc |
+++ b/ui/views/controls/textfield/textfield.cc |
@@ -238,6 +238,7 @@ int GetViewsCommand(const ui::TextEditCommandAuraLinux& command, bool rtl) { |
// static |
const char Textfield::kViewClassName[] = "Textfield"; |
+const int Textfield::kTextPadding = 3; |
// static |
size_t Textfield::GetCaretBlinkMs() { |
@@ -555,7 +556,8 @@ int Textfield::GetBaseline() const { |
} |
gfx::Size Textfield::GetPreferredSize() const { |
- const gfx::Insets& insets = GetInsets(); |
+ gfx::Insets insets = GetInsets(); |
+ insets += gfx::Insets(kTextPadding, kTextPadding, kTextPadding, kTextPadding); |
return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) + |
insets.width(), GetFontList().GetHeight() + insets.height()); |
} |
@@ -919,7 +921,13 @@ void Textfield::GetAccessibleState(ui::AXViewState* state) { |
} |
void Textfield::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
- GetRenderText()->SetDisplayRect(GetContentsBounds()); |
+ // Allow the text to paint over vertical padding, but not horizontal padding. |
+ // kTextPadding was previously unused FocusableBorder inset padding, now that |
+ // space is reserved for excessively tall text from unforseen fallback fonts. |
+ // This is better than clipping text, shrinking text or painting over borders. |
Peter Kasting
2014/08/30 00:46:43
Hmm, I'd really rather not talk about "previously"
msw
2014/09/04 01:25:51
I revised the comment.
|
+ gfx::Rect bounds = GetContentsBounds(); |
+ bounds.Inset(kTextPadding, 0); |
+ GetRenderText()->SetDisplayRect(bounds); |
OnCaretBoundsChanged(); |
} |