Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Unified Diff: webkit/glue/webview_impl.cc

Issue 20046: Home and End keys should not be processed by the autocomplete popup (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webview_impl.cc
===================================================================
--- webkit/glue/webview_impl.cc (revision 9146)
+++ webkit/glue/webview_impl.cc (working copy)
@@ -78,6 +78,7 @@
#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"
@@ -137,6 +138,7 @@
virtual ~AutocompletePopupMenuClient() {
}
+ // WebCore::PopupMenuClient implementation.
virtual void valueChanged(unsigned listIndex, bool fireEvents = true) {
text_field_->setValue(suggestions_[listIndex]);
}
@@ -230,6 +232,7 @@
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();
@@ -451,18 +454,8 @@
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)
@@ -514,6 +507,29 @@
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);
« no previous file with comments | « webkit/glue/webview_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698