summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 21:29:45 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-25 21:29:45 +0000
commit39ee8f7a3096c37b18fa65047b88643b376f1cc3 (patch)
treee5fb2f163332a11cb7a936c11ddbc9fecea9710d /chrome
parent86baff29bae1a00012aad5f360b75c2066abc8f4 (diff)
downloadchromium_src-39ee8f7a3096c37b18fa65047b88643b376f1cc3.zip
chromium_src-39ee8f7a3096c37b18fa65047b88643b376f1cc3.tar.gz
chromium_src-39ee8f7a3096c37b18fa65047b88643b376f1cc3.tar.bz2
Changes table_view to get position for context menu from the current
position of the mose. I've no idea why, but it seems when RTL the position passed to OnContextMenu is wrong in weird inconsistent ways. I thought it was interted, but that isn't always the case. I'm also changing the anchor position to top_right when RTL. BUG=4750 TEST=see bug Review URL: http://codereview.chromium.org/12447 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5996 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/bookmarks/bookmark_context_menu.cc6
-rw-r--r--chrome/views/table_view.cc15
-rw-r--r--chrome/views/table_view.h3
3 files changed, 22 insertions, 2 deletions
diff --git a/chrome/browser/bookmarks/bookmark_context_menu.cc b/chrome/browser/bookmarks/bookmark_context_menu.cc
index a4a1607..4da52e1 100644
--- a/chrome/browser/bookmarks/bookmark_context_menu.cc
+++ b/chrome/browser/bookmarks/bookmark_context_menu.cc
@@ -313,8 +313,10 @@ void BookmarkContextMenu::RunMenuAt(int x, int y) {
return;
}
// width/height don't matter here.
- menu_->RunMenuAt(hwnd_, gfx::Rect(x, y, 0, 0), views::MenuItemView::TOPLEFT,
- true);
+ views::MenuItemView::AnchorPosition anchor =
+ (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ?
+ views::MenuItemView::TOPRIGHT : views::MenuItemView::TOPLEFT;
+ menu_->RunMenuAt(hwnd_, gfx::Rect(x, y, 0, 0), anchor, true);
}
void BookmarkContextMenu::ExecuteCommand(int id) {
diff --git a/chrome/views/table_view.cc b/chrome/views/table_view.cc
index 61d70388..208a38b 100644
--- a/chrome/views/table_view.cc
+++ b/chrome/views/table_view.cc
@@ -1076,6 +1076,21 @@ void TableView::OnDestroy() {
}
}
+void TableView::OnContextMenu(const CPoint& location) {
+ if (!GetContextMenuController())
+ return;
+
+ if (!UILayoutIsRightToLeft() || (location.x == -1 && location.y == -1)) {
+ NativeControl::OnContextMenu(location);
+ return;
+ }
+ // For some reason context menu gestures when rtl have the wrong coordinates;
+ // get the position of the cursor and use it.
+ CPoint cursor_point;
+ GetCursorPos(&cursor_point);
+ NativeControl::OnContextMenu(cursor_point);
+}
+
// Returns result, unless ascending is false in which case -result is returned.
static int SwapCompareResult(int result, bool ascending) {
return ascending ? result : -result;
diff --git a/chrome/views/table_view.h b/chrome/views/table_view.h
index b02ec24..69ad4d4 100644
--- a/chrome/views/table_view.h
+++ b/chrome/views/table_view.h
@@ -472,6 +472,9 @@ class TableView : public NativeControl,
// Overriden to destroy the image list.
virtual void OnDestroy();
+ // Overriden to work around bug when RTL.
+ virtual void OnContextMenu(const CPoint& location);
+
// Used to sort the two rows. Returns a value < 0, == 0 or > 0 indicating
// whether the row2 comes before row1, row2 is the same as row1 or row1 comes
// after row2. This invokes CompareValues on the model with the sorted column.