summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/gtk/PopupMenuGtk.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/platform/gtk/PopupMenuGtk.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/platform/gtk/PopupMenuGtk.cpp')
-rw-r--r--WebCore/platform/gtk/PopupMenuGtk.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/WebCore/platform/gtk/PopupMenuGtk.cpp b/WebCore/platform/gtk/PopupMenuGtk.cpp
index b4689f6..85c5aa0 100644
--- a/WebCore/platform/gtk/PopupMenuGtk.cpp
+++ b/WebCore/platform/gtk/PopupMenuGtk.cpp
@@ -1,8 +1,9 @@
/*
* This file is part of the popup menu implementation for <select> elements in WebCore.
*
- * Copyright (C) 2006, 2007 Apple Inc.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2008 Collabora Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,6 +27,7 @@
#include "CString.h"
#include "FrameView.h"
+#include "HostWindow.h"
#include "NotImplemented.h"
#include "PlatformString.h"
#include <gtk/gtk.h>
@@ -61,7 +63,7 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
gtk_container_foreach(GTK_CONTAINER(m_popup), reinterpret_cast<GtkCallback>(menuRemoveItem), this);
int x, y;
- gdk_window_get_origin(GTK_WIDGET(view->containingWindow())->window, &x, &y);
+ gdk_window_get_origin(GTK_WIDGET(view->hostWindow()->platformWindow())->window, &x, &y);
m_menuPosition = view->contentsToWindow(rect.location());
m_menuPosition = IntPoint(m_menuPosition.x() + x, m_menuPosition.y() + y + rect.height());
m_indexMap.clear();
@@ -77,7 +79,7 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
m_indexMap.add(item, i);
g_signal_connect(item, "activate", G_CALLBACK(menuItemActivated), this);
- // FIXME: Apply the RenderStyle from client()->itemStyle(i)
+ // FIXME: Apply the PopupMenuStyle from client()->itemStyle(i)
gtk_widget_set_sensitive(item, client()->itemIsEnabled(i));
gtk_menu_shell_append(GTK_MENU_SHELL(m_popup), item);
gtk_widget_show(item);
@@ -91,6 +93,24 @@ void PopupMenu::show(const IntRect& rect, FrameView* view, int index)
gtk_widget_set_size_request(GTK_WIDGET(m_popup), -1, -1);
gtk_widget_size_request(GTK_WIDGET(m_popup), &requisition);
gtk_widget_set_size_request(GTK_WIDGET(m_popup), MAX(rect.width(), requisition.width), -1);
+
+ GList* children = GTK_MENU_SHELL(m_popup)->children;
+ if (size)
+ for (int i = 0; i < size; i++) {
+ if (i > index)
+ break;
+
+ GtkWidget* item = reinterpret_cast<GtkWidget*>(children->data);
+ GtkRequisition itemRequisition;
+ gtk_widget_get_child_requisition(item, &itemRequisition);
+ m_menuPosition.setY(m_menuPosition.y() - itemRequisition.height);
+
+ children = g_list_next(children);
+ }
+ else
+ // Center vertically the empty popup in the combo box area
+ m_menuPosition.setY(m_menuPosition.y() - rect.height() / 2);
+
gtk_menu_popup(m_popup, NULL, NULL, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, 0, gtk_get_current_event_time());
}
@@ -127,7 +147,7 @@ void PopupMenu::menuPositionFunction(GtkMenu*, gint* x, gint* y, gboolean* pushI
{
*x = that->m_menuPosition.x();
*y = that->m_menuPosition.y();
- pushIn = false;
+ *pushIn = true;
}
void PopupMenu::menuRemoveItem(GtkWidget* widget, PopupMenu* that)