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

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

Issue 516943003: Add textfield internal padding from FocusableBorder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 3 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/textfield/textfield.cc
diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc
index bedee3a1c0c8cabcece0a1f5d192c79e9f5d5191..d6af7d53a434638b14303a84a2b4b777cb8727e6 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);
calamity 2014/09/08 03:37:50 Is there any reason that horizontal padding needs
Peter Kasting 2014/09/08 17:45:59 I vetoed this route, because the side padding isn'
calamity 2014/09/09 00:46:38 Ack.
return gfx::Size(GetFontList().GetExpectedTextWidth(default_width_in_chars_) +
insets.width(), GetFontList().GetHeight() + insets.height());
}
@@ -919,7 +921,14 @@ void Textfield::GetAccessibleState(ui::AXViewState* state) {
}
void Textfield::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- GetRenderText()->SetDisplayRect(GetContentsBounds());
+ // Textfield preferred sizing includes a reasonable amount of whitespace on
+ // all sides of the default font list. Fallback fonts with larger heights may
+ // paint over the vertical whitespace as needed. Alternate solutions involve
+ // undesirable behavior like changing the default font size, shrinking some
+ // fallback fonts beyond their legibility, or enlarging controls dynamically.
+ gfx::Rect bounds = GetContentsBounds();
+ bounds.Inset(kTextPadding, 0);
+ GetRenderText()->SetDisplayRect(bounds);
OnCaretBoundsChanged();
}
« ui/app_list/views/search_box_view.cc ('K') | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698