summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 22:07:11 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-20 22:07:11 +0000
commitd7fc97946625fee2c54e18bce4f61608efeeef03 (patch)
treee2033035f58d2342f55cdb677e38d281cc655152 /views
parentb12d815dbd8295b3e7f5e4b4a7350aebc580270c (diff)
downloadchromium_src-d7fc97946625fee2c54e18bce4f61608efeeef03.zip
chromium_src-d7fc97946625fee2c54e18bce4f61608efeeef03.tar.gz
chromium_src-d7fc97946625fee2c54e18bce4f61608efeeef03.tar.bz2
Fixes two issues from valgrind, and some cleanup:
. Makes it so observer installed by WidgetGtk is cleaned up and not leaked. . Removes unnecessary static_cast<int> in view. . Fixes some leaks in textfield and button. . Removes AutocompletePopupViewGTK's copy of PangoFontFromGfxFont. BUG=none TEST=none Review URL: http://codereview.chromium.org/420005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/native_button_gtk.cc7
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc6
-rw-r--r--views/view.cc3
-rw-r--r--views/widget/widget_gtk.cc11
4 files changed, 17 insertions, 10 deletions
diff --git a/views/controls/button/native_button_gtk.cc b/views/controls/button/native_button_gtk.cc
index 17a25e2..e663db6 100644
--- a/views/controls/button/native_button_gtk.cc
+++ b/views/controls/button/native_button_gtk.cc
@@ -40,9 +40,10 @@ void NativeButtonGtk::UpdateFont() {
if (!native_view())
return;
- gtk_widget_modify_font(
- native_view(),
- gfx::Font::PangoFontFromGfxFont(native_button_->font()));
+ PangoFontDescription* pfd =
+ gfx::Font::PangoFontFromGfxFont(native_button_->font());
+ gtk_widget_modify_font(native_view(), pfd);
+ pango_font_description_free(pfd);
preferred_size_ = gfx::Size();
}
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index 911ae38..9728a1d 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -121,8 +121,10 @@ void NativeTextfieldGtk::UpdateReadOnly() {
void NativeTextfieldGtk::UpdateFont() {
if (!native_view())
return;
- gtk_widget_modify_font(native_view(),
- gfx::Font::PangoFontFromGfxFont(textfield_->font()));
+ PangoFontDescription* pfd =
+ gfx::Font::PangoFontFromGfxFont(textfield_->font());
+ gtk_widget_modify_font(native_view(), pfd);
+ pango_font_description_free(pfd);
}
void NativeTextfieldGtk::UpdateEnabled() {
diff --git a/views/view.cc b/views/view.cc
index 839616e..3450e9a 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -417,8 +417,7 @@ gfx::NativeCursor View::GetCursorForPoint(Event::EventType event_type, int x,
}
bool View::HitTest(const gfx::Point& l) const {
- if (l.x() >= 0 && l.x() < static_cast<int>(width()) &&
- l.y() >= 0 && l.y() < static_cast<int>(height())) {
+ if (l.x() >= 0 && l.x() < width() && l.y() >= 0 && l.y() < height()) {
if (HasHitTestMask()) {
gfx::Path mask;
GetHitTestMask(&mask);
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index 8762e14..87fdb8d 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -25,7 +25,11 @@ namespace views {
// drag-leave that GTK generates.
class WidgetGtk::DropObserver : public MessageLoopForUI::Observer {
public:
- DropObserver() { }
+ DropObserver() {}
+
+ static DropObserver* Get() {
+ return Singleton<DropObserver>::get();
+ }
virtual void WillProcessEvent(GdkEvent* event) {
if (event->type == GDK_DROP_START) {
@@ -98,7 +102,7 @@ WidgetGtk::WidgetGtk(Type type)
installed_message_loop_observer = true;
MessageLoopForUI* loop = MessageLoopForUI::current();
if (loop)
- loop->AddObserver(new DropObserver());
+ loop->AddObserver(DropObserver::Get());
}
if (type_ != TYPE_CHILD)
@@ -1082,7 +1086,8 @@ gboolean WidgetGtk::CallQueryTooltip(GtkWidget* widget,
gboolean keyboard_mode,
GtkTooltip* tooltip,
WidgetGtk* host) {
- return host->OnQueryTooltip(x, y, keyboard_mode, tooltip);
+ return host->OnQueryTooltip(static_cast<int>(x), static_cast<int>(y),
+ keyboard_mode, tooltip);
}
gboolean WidgetGtk::CallScroll(GtkWidget* widget, GdkEventScroll* event) {