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

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: Restore Insets const ref. 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
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4c5e7d413500f6565acbe443e7319077374171e7 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() {
@@ -550,6 +551,12 @@ bool Textfield::HasTextBeingDragged() {
////////////////////////////////////////////////////////////////////////////////
// Textfield, View overrides:
+gfx::Insets Textfield::GetInsets() const {
+ gfx::Insets insets = View::GetInsets();
+ insets += gfx::Insets(kTextPadding, kTextPadding, kTextPadding, kTextPadding);
+ return insets;
+}
+
int Textfield::GetBaseline() const {
return GetInsets().top() + GetRenderText()->GetBaseline();
}
@@ -919,7 +926,15 @@ void Textfield::GetAccessibleState(ui::AXViewState* state) {
}
void Textfield::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- GetRenderText()->SetDisplayRect(GetContentsBounds());
+ // Textfield insets include 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 with content.
+ gfx::Rect bounds = GetContentsBounds();
+ // GetContentsBounds() does not actually use the local GetInsets() override.
+ bounds.Inset(gfx::Insets(0, kTextPadding, 0, kTextPadding));
+ GetRenderText()->SetDisplayRect(bounds);
OnCaretBoundsChanged();
}
« no previous file with comments | « ui/views/controls/textfield/textfield.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698