diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 20:04:46 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-04 20:04:46 +0000 |
commit | f1de3486f3bb4f252b9b5f2384c9e5678d4e1e06 (patch) | |
tree | 96124c50cd89124ec46d7dce70c26e66bd3a5872 /webkit | |
parent | 329f377fccd74bf9623c83b24f9420f2e7cea7b5 (diff) | |
download | chromium_src-f1de3486f3bb4f252b9b5f2384c9e5678d4e1e06.zip chromium_src-f1de3486f3bb4f252b9b5f2384c9e5678d4e1e06.tar.gz chromium_src-f1de3486f3bb4f252b9b5f2384c9e5678d4e1e06.tar.bz2 |
Autocomplete popup should not handle the Home and end key messages, they should be left to the text edit to proceed.
BUG=4874
Review URL: http://codereview.chromium.org/20046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/webview_impl.cc | 40 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 3 |
2 files changed, 31 insertions, 12 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 61fde57..e2a390d 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -79,6 +79,7 @@ MSVC_POP_WARNING(); #undef LOG #include "base/gfx/rect.h" +#include "base/keyboard_codes.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/string_util.h" @@ -152,6 +153,7 @@ class AutocompletePopupMenuClient virtual ~AutocompletePopupMenuClient() { } + // WebCore::PopupMenuClient implementation. virtual void valueChanged(unsigned listIndex, bool fireEvents = true) { text_field_->setValue(suggestions_[listIndex]); } @@ -241,6 +243,7 @@ class AutocompletePopupMenuClient return widget.release(); } + // AutocompletePopupMenuClient specific methods: void SetSuggestions(const std::vector<std::wstring>& suggestions) { suggestions_.clear(); for (std::vector<std::wstring>::const_iterator iter = suggestions.begin(); @@ -463,18 +466,8 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { suppress_next_keypress_event_ = false; // Give autocomplete a chance to consume the key events it is interested in. - if (autocomplete_popup_ && - autocomplete_popup_->isInterestedInEventForKey(event.key_code)) { - if (autocomplete_popup_->handleKeyEvent(MakePlatformKeyboardEvent(event))) { -#if defined(OS_WIN) - // We need to ignore the next CHAR event after this otherwise pressing - // enter when selecting an item in the menu will go to the page. - if (WebInputEvent::KEY_DOWN == event.type) - suppress_next_keypress_event_ = true; -#endif - return true; - } - } + if (AutocompleteHandleKeyEvent(event)) + return true; Frame* frame = GetFocusedWebCoreFrame(); if (!frame) @@ -526,6 +519,29 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { return KeyEventDefault(event); } +bool WebViewImpl::AutocompleteHandleKeyEvent(const WebKeyboardEvent& event) { + if (!autocomplete_popup_ || + // Home and End should be left to the text field to process. + event.key_code == base::VKEY_HOME || event.key_code == base::VKEY_END) { + return false; + } + + if (!autocomplete_popup_->isInterestedInEventForKey(event.key_code)) + return false; + + if (autocomplete_popup_->handleKeyEvent(MakePlatformKeyboardEvent(event))) { +#if defined(OS_WIN) + // We need to ignore the next CHAR event after this otherwise pressing + // enter when selecting an item in the menu will go to the page. + if (WebInputEvent::KEY_DOWN == event.type) + suppress_next_keypress_event_ = true; +#endif + return true; + } + + return false; +} + bool WebViewImpl::CharEvent(const WebKeyboardEvent& event) { DCHECK(event.type == WebInputEvent::CHAR); diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 1f03477..d26c95c 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -248,6 +248,9 @@ class WebViewImpl : public WebView { // Returns true if the event was actually processed. bool KeyEventDefault(const WebKeyboardEvent& event); + // Returns true if the autocomple has consumed the event. + bool AutocompleteHandleKeyEvent(const WebKeyboardEvent& event); + // Returns true if the view was scrolled. bool ScrollViewWithKeyboard(int key_code); |