diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 23:32:04 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-04 23:32:04 +0000 |
commit | b7878ad5af389c084b09c270bf774aa73b238125 (patch) | |
tree | 7dd3fe72d8a7a2c33332dd320743725ae49be076 /views | |
parent | 8cc585ff4dc4239464ff73841cae62d1839faad1 (diff) | |
download | chromium_src-b7878ad5af389c084b09c270bf774aa73b238125.zip chromium_src-b7878ad5af389c084b09c270bf774aa73b238125.tar.gz chromium_src-b7878ad5af389c084b09c270bf774aa73b238125.tar.bz2 |
Fixes bug in textfield on views/gtk where we weren't properly
accounting for border size if not specified by style. Also changes
button on views/gtk not to fix the pref height at 29. There is no
reason for us to do this.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/462036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/native_button_gtk.cc | 3 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.cc | 41 |
2 files changed, 23 insertions, 21 deletions
diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc index e663db6..317e6bd 100644 --- a/views/controls/button/native_button_gtk.cc +++ b/views/controls/button/native_button_gtk.cc @@ -88,8 +88,7 @@ gfx::Size NativeButtonGtk::GetPreferredSize() { if (preferred_size_.IsEmpty()) { GtkRequisition size_request = { 0, 0 }; gtk_widget_size_request(native_view(), &size_request); - preferred_size_.SetSize(size_request.width, - std::max(size_request.height, 29)); + preferred_size_.SetSize(size_request.width, size_request.height); } return preferred_size_; } diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc index 9728a1d..026a6b7 100644 --- a/views/controls/textfield/native_textfield_gtk.cc +++ b/views/controls/textfield/native_textfield_gtk.cc @@ -6,6 +6,7 @@ #include "views/controls/textfield/native_textfield_gtk.h" +#include "app/gfx/insets.h" #include "app/gfx/gtk_util.h" #include "base/string_util.h" #include "skia/ext/skia_utils_gtk.h" @@ -139,23 +140,29 @@ gfx::Insets NativeTextfieldGtk::CalculateInsets() { GtkWidget* widget = native_view(); GtkEntry* entry = GTK_ENTRY(widget); - const GtkBorder* inner_border = gtk_entry_get_inner_border(entry); - int left = 0, right = 0, top = 0, bottom = 0; - if (!inner_border) - gtk_widget_style_get(widget, "inner-border", &inner_border, NULL); + gfx::Insets insets; + const GtkBorder* inner_border = gtk_entry_get_inner_border(entry); if (inner_border) { - left += inner_border->left; - right += inner_border->right; - top += inner_border->top; - bottom += inner_border->bottom; + insets += gfx::Insets(*inner_border); + } else { + // No explicit border set, try the style. + GtkBorder* style_border; + gtk_widget_style_get(widget, "inner-border", &style_border, NULL); + if (style_border) { + insets += gfx::Insets(*style_border); + gtk_border_free(style_border); + } else { + // If border is null, Gtk uses 2 on all sides. + insets += gfx::Insets(2, 2, 2, 2); + } } if (entry->has_frame) { - left += widget->style->xthickness; - right += widget->style->xthickness; - top += widget->style->ythickness; - bottom += widget->style->ythickness; + insets += gfx::Insets(widget->style->ythickness, + widget->style->xthickness, + widget->style->ythickness, + widget->style->xthickness); } gboolean interior_focus; @@ -164,14 +171,10 @@ gfx::Insets NativeTextfieldGtk::CalculateInsets() { "focus-line-width", &focus_width, "interior-focus", &interior_focus, NULL); - if (!interior_focus) { - left += focus_width; - right += focus_width; - top += focus_width; - bottom += focus_width; - } + if (!interior_focus) + insets += gfx::Insets(focus_width, focus_width, focus_width, focus_width); - return gfx::Insets(top, left, bottom, right); + return insets; } void NativeTextfieldGtk::SetHorizontalMargins(int left, int right) { |