summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-16 23:27:58 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-16 23:27:58 +0000
commit007bbbf037b21bc5ca60de9f5f8cce808b859d8e (patch)
treee768535f5ff569a7090f7e07146e6c0e8c92dbf0 /ui
parent58fbcc7b94eb323b00c44c6d069739700814669f (diff)
downloadchromium_src-007bbbf037b21bc5ca60de9f5f8cce808b859d8e.zip
chromium_src-007bbbf037b21bc5ca60de9f5f8cce808b859d8e.tar.gz
chromium_src-007bbbf037b21bc5ca60de9f5f8cce808b859d8e.tar.bz2
Make the views textfield respect any explicit horizontal or vertical margins
even if we don't want to draw a visible border. BUG=231005 TEST=none R=ben@chromium.org, msw@chromium.org Review URL: https://codereview.chromium.org/14618011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200650 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/controls/textfield/native_textfield_views.cc20
-rw-r--r--ui/views/controls/textfield/native_textfield_views.h4
-rw-r--r--ui/views/controls/textfield/native_textfield_wrapper.h3
3 files changed, 15 insertions, 12 deletions
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc
index ceb0d5b..b5ba993 100644
--- a/ui/views/controls/textfield/native_textfield_views.cc
+++ b/ui/views/controls/textfield/native_textfield_views.cc
@@ -547,14 +547,17 @@ void NativeTextfieldViews::ClearSelection() {
}
void NativeTextfieldViews::UpdateBorder() {
- if (textfield_->draw_border()) {
- gfx::Insets insets = GetInsets();
- textfield_->SetHorizontalMargins(insets.left(), insets.right());
- textfield_->SetVerticalMargins(insets.top(), insets.bottom());
- } else {
- textfield_->SetHorizontalMargins(0, 0);
- textfield_->SetVerticalMargins(0, 0);
- }
+ // By default, if a caller calls Textfield::RemoveBorder() and does not set
+ // any explicit margins, they should get zero margins. But also call
+ // UpdateXXXMargins() so we respect any explicitly-set margins.
+ //
+ // NOTE: If someday Textfield supports toggling |draw_border_| back on, we'll
+ // need to update this conditional to set the insets to their default values.
+ if (!textfield_->draw_border())
+ text_border_->SetInsets(0, 0, 0, 0);
+ UpdateHorizontalMargins();
+ UpdateVerticalMargins();
+ UpdateBorderColor();
}
void NativeTextfieldViews::UpdateBorderColor() {
@@ -614,7 +617,6 @@ void NativeTextfieldViews::UpdateHorizontalMargins() {
if (!textfield_->GetHorizontalMargins(&left, &right))
return;
gfx::Insets inset = GetInsets();
-
text_border_->SetInsets(inset.top(), left, inset.bottom(), right);
OnBoundsChanged(GetBounds());
}
diff --git a/ui/views/controls/textfield/native_textfield_views.h b/ui/views/controls/textfield/native_textfield_views.h
index e424678..53917c5 100644
--- a/ui/views/controls/textfield/native_textfield_views.h
+++ b/ui/views/controls/textfield/native_textfield_views.h
@@ -291,7 +291,9 @@ class VIEWS_EXPORT NativeTextfieldViews : public View,
// The text model.
scoped_ptr<TextfieldViewsModel> model_;
- // The reference to the border class. The object is owned by View::border_.
+ // The focusable border. This is always non-NULL, but may not actually be
+ // drawn. If it is not drawn, then by default it's also zero-sized unless the
+ // Textfield has explicitly-set margins.
FocusableBorder* text_border_;
// The textfield's text and drop cursor visibility.
diff --git a/ui/views/controls/textfield/native_textfield_wrapper.h b/ui/views/controls/textfield/native_textfield_wrapper.h
index 0fb4cd3..b9d62b3 100644
--- a/ui/views/controls/textfield/native_textfield_wrapper.h
+++ b/ui/views/controls/textfield/native_textfield_wrapper.h
@@ -62,8 +62,7 @@ class VIEWS_EXPORT NativeTextfieldWrapper {
// Clears the selection within the edit field and sets the caret to the end.
virtual void ClearSelection() = 0;
- // Updates the border display for the native text field with the state desired
- // by the Textfield.
+ // Updates whether there is a visible border.
virtual void UpdateBorder() = 0;
// Updates the color of the border with the state desired by the Textfield.