summaryrefslogtreecommitdiffstats
path: root/webkit/port
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 00:50:44 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-11 00:50:44 +0000
commit621af4ffdbeeaee2785750258d90b096eb6c7551 (patch)
treebc894d6f5d2dc501977c81ac2c8918195d10a5f7 /webkit/port
parent5c150741a8d3db36f80fbc805e0e5bc7266fef9d (diff)
downloadchromium_src-621af4ffdbeeaee2785750258d90b096eb6c7551.zip
chromium_src-621af4ffdbeeaee2785750258d90b096eb6c7551.tar.gz
chromium_src-621af4ffdbeeaee2785750258d90b096eb6c7551.tar.bz2
This CL makes the form autofill popup menu behave like the Firefox's one, we only set the text field text when the user presses enter or click on an item.
It also prevents the WM_CHAR events to make it to the page after a WM_KEYDOWN has been processed by the menu (that would typically cause forms to proceed when you pressed enter in the form popup). BUG=4145 TEST=Type something in a form to have the autofill popup showing. Use the down/up arrow to move around. The text should not change in the text field. Press enter, the selection should be set. Try again clicking this time. Review URL: http://codereview.chromium.org/9621 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5149 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port')
-rw-r--r--webkit/port/platform/chromium/PopupMenuChromium.cpp14
-rw-r--r--webkit/port/platform/chromium/PopupMenuChromium.h4
2 files changed, 17 insertions, 1 deletions
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: