diff options
-rw-r--r-- | webkit/glue/webview_impl.cc | 10 | ||||
-rw-r--r-- | webkit/port/platform/chromium/PopupMenuChromium.cpp | 14 | ||||
-rw-r--r-- | webkit/port/platform/chromium/PopupMenuChromium.h | 4 |
3 files changed, 26 insertions, 2 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 9ee599e..34a87ea 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -422,8 +422,15 @@ bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { // 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 (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; } @@ -1508,6 +1515,7 @@ void WebViewImpl::AutofillSuggestionsForNode( autocomplete_popup_ = WebCore::PopupContainer::create(autocomplete_popup_client_.get(), false); + autocomplete_popup_->setTextOnIndexChange(false); autocomplete_popup_->show(focused_node->getRect(), page_->mainFrame()->view(), 0); } diff --git a/webkit/port/platform/chromium/PopupMenuChromium.cpp b/webkit/port/platform/chromium/PopupMenuChromium.cpp index ae9f164..7cb191c 100644 --- a/webkit/port/platform/chromium/PopupMenuChromium.cpp +++ b/webkit/port/platform/chromium/PopupMenuChromium.cpp @@ -130,6 +130,10 @@ public: // Returns whether the popup wants to process events for the passed key. bool isInterestedInEventForKey(int key_code); + // Sets whether the PopupMenuClient should be told to change its text when a + // new item is selected (by using the arrow keys). Default is true. + void setTextOnIndexChange(bool value) { m_setTextOnIndexChange = value; } + private: friend class PopupContainer; friend class RefCounted<PopupListBox>; @@ -158,6 +162,7 @@ private: , m_popupClient(client) , m_repeatingChar(0) , m_lastCharTime(0) + , m_setTextOnIndexChange(true) { setScrollbarModes(ScrollbarAlwaysOff, ScrollbarAlwaysOff); } @@ -251,6 +256,8 @@ private: // The last time the user hit a key. Used for typeAheadFind. TimeStamp m_lastCharTime; + + bool m_setTextOnIndexChange; }; static PlatformMouseEvent constructRelativeMouseEvent(const PlatformMouseEvent& e, @@ -464,6 +471,10 @@ void PopupContainer::show(const IntRect& r, FrameView* v, int index) { showPopup(v); } +void PopupContainer::setTextOnIndexChange(bool value) { + listBox()->setTextOnIndexChange(value); +} + /////////////////////////////////////////////////////////////////////////////// // PopupListBox implementation @@ -602,7 +613,8 @@ bool PopupListBox::handleKeyEvent(const PlatformKeyboardEvent& event) // popup is closed. m_acceptOnAbandon = true; setOriginalIndex(m_selectedIndex); - m_popupClient->setTextFromItem(m_selectedIndex); + if (m_setTextOnIndexChange) + m_popupClient->setTextFromItem(m_selectedIndex); } return true; diff --git a/webkit/port/platform/chromium/PopupMenuChromium.h b/webkit/port/platform/chromium/PopupMenuChromium.h index d419468..0b73774 100644 --- a/webkit/port/platform/chromium/PopupMenuChromium.h +++ b/webkit/port/platform/chromium/PopupMenuChromium.h @@ -60,6 +60,10 @@ public: // Compute size of widget and children. void layout(); + // Sets whether the PopupMenuClient should be told to change its text when a + // new item is selected (by using the arrow keys). Default is true. + void setTextOnIndexChange(bool value); + PopupListBox* listBox() const { return m_listBox.get(); } private: |