summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/location_bar_view.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 04:28:07 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 04:28:07 +0000
commitca13d804c304a61711352044022971ec39f9d4f8 (patch)
tree81e2f1039a317a4ba5177ec98d18a545c0ff9c94 /chrome/browser/views/location_bar_view.cc
parent921515182691bf105b404862bf80ae7dfc0e151e (diff)
downloadchromium_src-ca13d804c304a61711352044022971ec39f9d4f8.zip
chromium_src-ca13d804c304a61711352044022971ec39f9d4f8.tar.gz
chromium_src-ca13d804c304a61711352044022971ec39f9d4f8.tar.bz2
Clean-up of the accelerator code.
The View::CanProcessTabKeyEvents and View::ShouldLookUpAccelerator have both been replaced with a new method, SkipDefaultKeyEventProcessing. This new method provides for a view that has focus a way to prevent a key event from being processed for tab traversal or accelerators. Also, fixed a regression where the Ctrl-Tab accelerator was not working anymore when the omnibox was focused. BUG=11538 TEST=Thoroughly test accelerators, making sure they work when the page, the omnibox and the find-bar text-field have focus. Also test that tab traversal still work as expected in the browser and in the option dialog. Review URL: http://codereview.chromium.org/113307 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/location_bar_view.cc')
-rw-r--r--chrome/browser/views/location_bar_view.cc34
1 files changed, 18 insertions, 16 deletions
diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc
index c53a7e9..2f22fd2 100644
--- a/chrome/browser/views/location_bar_view.cc
+++ b/chrome/browser/views/location_bar_view.cc
@@ -33,6 +33,7 @@
#include "grit/theme_resources.h"
#include "views/background.h"
#include "views/border.h"
+#include "views/focus/focus_manager.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
@@ -238,11 +239,6 @@ void LocationBarView::Paint(ChromeCanvas* canvas) {
std::max(height() - top_margin - kVertMargin, 0));
}
-bool LocationBarView::CanProcessTabKeyEvents() {
- // We want to receive tab key events when the hint is showing.
- return keyword_hint_view_.IsVisible();
-}
-
void LocationBarView::VisibleBoundsInRootChanged() {
location_entry_->ClosePopup();
}
@@ -851,42 +847,48 @@ void LocationBarView::KeywordHintView::Layout() {
}
}
-bool LocationBarView::ShouldLookupAccelerators(const views::KeyEvent& e) {
+bool LocationBarView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
+ if (keyword_hint_view_.IsVisible() &&
+ views::FocusManager::IsTabTraversalKeyEvent(e)) {
+ // We want to receive tab key events when the hint is showing.
+ return true;
+ }
+
int c = e.GetCharacter();
- // We don't translate accelerators for ALT + numpad digit, they are used for
+ // We don't process ALT + numpad digit as accelerators, they are used for
// entering special characters.
if (e.IsAltDown() && win_util::IsNumPadDigit(c, e.IsExtendedKey()))
- return false;
+ return true;
// Skip accelerators for key combinations omnibox wants to crack. This list
// should be synced with AutocompleteEditViewWin::OnKeyDownOnlyWritable().
+ // (but for tab which is dealt with above).
//
- // We cannot return false for all keys because we still need to handle some
+ // We cannot return true for all keys because we still need to handle some
// accelerators (e.g., F5 for reload the page should work even when the
// Omnibox gets focused).
switch (c) {
case VK_RETURN:
- return false;
+ return true;
case VK_UP:
case VK_DOWN:
- return e.IsAltDown();
+ return !e.IsAltDown();
case VK_DELETE:
case VK_INSERT:
- return e.IsAltDown() || !e.IsShiftDown();
+ return !e.IsAltDown() && e.IsShiftDown();
case 'X':
case 'V':
- return e.IsAltDown() || !e.IsControlDown();
+ return !e.IsAltDown() && e.IsControlDown();
case VK_BACK:
- case VK_TAB:
case 0xbb:
- return false;
+ return true;
default:
- return true;
+ return false;
}
}