summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webview_impl.cc
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 17:56:58 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-24 17:56:58 +0000
commitc8fed0d1f958d14c71aeaddc43bea1b11b5a5328 (patch)
tree1dcbd8bb7ed7e3f7012550facc9c8183861081da /webkit/glue/webview_impl.cc
parent0b45add7a298db2c8e4f07ef6117ebfd0ab30c80 (diff)
downloadchromium_src-c8fed0d1f958d14c71aeaddc43bea1b11b5a5328.zip
chromium_src-c8fed0d1f958d14c71aeaddc43bea1b11b5a5328.tar.gz
chromium_src-c8fed0d1f958d14c71aeaddc43bea1b11b5a5328.tar.bz2
Clicking a text field that is already focused triggers the autofill. However the code triggering this was just checking that the focused element before and after processing the event was the same.
We need to do a hit test to ensure the click is really on the text field, otherwise in cases where clicking somewhere in the page does not change the focus, we would bogusly bring up the autofill popup. BUG=8627 TEST=Ensure autocomplete popup still works as expected: when entering text, when using up/down arrows, when clicking selected text field. Also ensures the scenario from the bug does not trigger the popup. Review URL: http://codereview.chromium.org/50038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12367 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webview_impl.cc')
-rw-r--r--webkit/glue/webview_impl.cc34
1 files changed, 24 insertions, 10 deletions
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 6a0b358..799f0d3 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -87,6 +87,7 @@ MSVC_POP_WARNING();
#include "webkit/glue/chrome_client_impl.h"
#include "webkit/glue/clipboard_conversion.h"
#include "webkit/glue/context_menu_client_impl.h"
+#include "webkit/glue/dom_operations.h"
#include "webkit/glue/dragclient_impl.h"
#include "webkit/glue/editor_client_impl.h"
#include "webkit/glue/event_conversion.h"
@@ -424,21 +425,34 @@ void WebViewImpl::MouseDown(const WebMouseEvent& event) {
return;
last_mouse_down_point_ = gfx::Point(event.x, event.y);
- // We need to remember who has focus, as if the user left-clicks an already
- // focused text-field, we may want to show the auto-fill popup.
- RefPtr<Node> focused_node;
- if (event.button == WebMouseEvent::BUTTON_LEFT)
- focused_node = GetFocusedNode();
+
+ // If a text field that has focus is clicked again, we should display the
+ // autocomplete popup.
+ RefPtr<Node> clicked_node;
+ if (event.button == WebMouseEvent::BUTTON_LEFT) {
+ RefPtr<Node> focused_node = GetFocusedNode();
+ if (focused_node.get() &&
+ webkit_glue::NodeToHTMLInputElement(focused_node.get())) {
+ IntPoint point(event.x, event.y);
+ HitTestResult result(point);
+ result = page_->mainFrame()->eventHandler()->hitTestResultAtPoint(point,
+ false);
+ if (result.innerNonSharedNode() == focused_node) {
+ // Already focused text field was clicked, let's remember this. If
+ // focus has not changed after the mouse event is processed, we'll
+ // trigger the autocomplete.
+ clicked_node = focused_node;
+ }
+ }
+ }
main_frame()->frame()->eventHandler()->handleMousePressEvent(
MakePlatformMouseEvent(main_frame()->frameview(), event));
- if (focused_node.get() && focused_node == GetFocusedNode()) {
- // Already focused node was clicked, ShowAutofillForNode will determine
- // whether to show the autofill (typically, if the node is a text-field and
- // is empty).
+ if (clicked_node.get() && clicked_node == GetFocusedNode()) {
+ // Focus has not changed, show the autocomplete popup.
static_cast<EditorClientImpl*>(page_->editorClient())->
- ShowAutofillForNode(focused_node.get());
+ ShowAutofillForNode(clicked_node.get());
}
}