summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 21:24:20 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-06 21:24:20 +0000
commit535e9640458af3ddbf13339b706b589d7b3e945e (patch)
tree5efb722f14b48b0c6c05db18f929a0c154b9b136 /chrome/browser/tab_contents
parentf89aa1d84880734cd0f6afec2197a89ff0ec85c2 (diff)
downloadchromium_src-535e9640458af3ddbf13339b706b589d7b3e945e.zip
chromium_src-535e9640458af3ddbf13339b706b589d7b3e945e.tar.gz
chromium_src-535e9640458af3ddbf13339b706b589d7b3e945e.tar.bz2
GTK: Fix context menu positioning.
There are still some issues with context menus. The context menu doesn't respect links, for example. That is, if you tab to a link and hit the menu button, it will act as if you right clicked on the upper left pixel of the web page (both in content and position of the menu). This seems to be a webkit bug/missing feature as safari 4 on windows does the same. However, some cases do work as expected, for example if you select text and hit the menu button. Anyway, I'll do the webkit side of this fix as some later patch. BUG=26811 Review URL: http://codereview.chromium.org/371033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31301 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_gtk.cc4
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_gtk.h5
-rw-r--r--chrome/browser/tab_contents/tab_contents_view_gtk.cc7
3 files changed, 11 insertions, 5 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
index 70381be..e94575d 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
@@ -28,10 +28,10 @@ void RenderViewContextMenuGtk::DoInit() {
gtk_menu_.reset(new MenuGtk(this, menu_.data(), NULL));
}
-void RenderViewContextMenuGtk::Popup() {
+void RenderViewContextMenuGtk::Popup(const gfx::Point& point) {
if (source_tab_contents_->render_widget_host_view())
source_tab_contents_->render_widget_host_view()->ShowingContextMenu(true);
- gtk_menu_->PopupAsContext(triggering_event_time_);
+ gtk_menu_->PopupAsContextAt(triggering_event_time_, point);
}
bool RenderViewContextMenuGtk::IsCommandEnabled(int id) const {
diff --git a/chrome/browser/tab_contents/render_view_context_menu_gtk.h b/chrome/browser/tab_contents/render_view_context_menu_gtk.h
index 8d7a5d0..c972855 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_gtk.h
+++ b/chrome/browser/tab_contents/render_view_context_menu_gtk.h
@@ -9,6 +9,7 @@
#include <string>
#include <vector>
+#include "base/gfx/point.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/gtk/standard_menus.h"
@@ -27,8 +28,8 @@ class RenderViewContextMenuGtk : public RenderViewContextMenu,
~RenderViewContextMenuGtk();
- // Show the menu at the current cursor location.
- void Popup();
+ // Show the menu at the given location.
+ void Popup(const gfx::Point& point);
// Menu::Delegate implementation ---------------------------------------------
virtual bool IsCommandEnabled(int id) const;
diff --git a/chrome/browser/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
index ede66bb..332c7cd 100644
--- a/chrome/browser/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/tab_contents_view_gtk.cc
@@ -368,7 +368,12 @@ void TabContentsViewGtk::ShowContextMenu(const ContextMenuParams& params) {
context_menu_.reset(new RenderViewContextMenuGtk(tab_contents(), params,
last_mouse_down_.time));
context_menu_->Init();
- context_menu_->Popup();
+
+ gfx::Rect bounds;
+ GetContainerBounds(&bounds);
+ gfx::Point point = bounds.origin();
+ point.Offset(params.x, params.y);
+ context_menu_->Popup(point);
}
// Render view DnD -------------------------------------------------------------