summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_contents_view_win.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 18:57:31 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-21 18:57:31 +0000
commit50e12183260c4b94ce3ee3316b27b998af5b7926 (patch)
tree4ab8c00c2c8214fce88844a047bf3895a9520651 /chrome/browser/web_contents_view_win.cc
parentc04b6367950900e19ced8d89393d3b870fd837b8 (diff)
downloadchromium_src-50e12183260c4b94ce3ee3316b27b998af5b7926.zip
chromium_src-50e12183260c4b94ce3ee3316b27b998af5b7926.tar.gz
chromium_src-50e12183260c4b94ce3ee3316b27b998af5b7926.tar.bz2
Discard CHAR events if their corresponding KEY_DOWN events triggered accelerators.
Original patch by Alex Mendes de Costa (alexmdac@gmail.com) on http://codereview.chromium.org/11268, r=me. BUG=91 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5832 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/web_contents_view_win.cc')
-rw-r--r--chrome/browser/web_contents_view_win.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc
index 30665ea..4a15e62 100644
--- a/chrome/browser/web_contents_view_win.cc
+++ b/chrome/browser/web_contents_view_win.cc
@@ -42,7 +42,8 @@ BOOL CALLBACK DetachPluginWindowsCallback(HWND window, LPARAM param) {
WebContentsViewWin::WebContentsViewWin(WebContents* web_contents)
: web_contents_(web_contents),
error_info_bar_message_(NULL),
- info_bar_visible_(false) {
+ info_bar_visible_(false),
+ ignore_next_char_event_(false) {
}
WebContentsViewWin::~WebContentsViewWin() {
@@ -293,6 +294,15 @@ void WebContentsViewWin::TakeFocus(bool reverse) {
}
void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) {
+ // Previous calls to TranslateMessage can generate CHAR events as well as
+ // KEY_DOWN events, even if the latter triggered an accelerator. In these
+ // cases, we discard the CHAR events.
+ if (event.type == WebInputEvent::CHAR && ignore_next_char_event_) {
+ ignore_next_char_event_ = false;
+ return;
+ }
+ ignore_next_char_event_ = false;
+
// The renderer returned a keyboard event it did not process. This may be
// a keyboard shortcut that we have to process.
if (event.type == WebInputEvent::KEY_DOWN) {
@@ -308,8 +318,10 @@ void WebContentsViewWin::HandleKeyboardEvent(const WebKeyboardEvent& event) {
WebInputEvent::CTRL_KEY,
(event.modifiers & WebInputEvent::ALT_KEY) ==
WebInputEvent::ALT_KEY);
- if (focus_manager->ProcessAccelerator(accelerator, false))
+ if (focus_manager->ProcessAccelerator(accelerator, false)) {
+ ignore_next_char_event_ = true;
return;
+ }
}
}