diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 17:56:58 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-24 17:56:58 +0000 |
commit | c8fed0d1f958d14c71aeaddc43bea1b11b5a5328 (patch) | |
tree | 1dcbd8bb7ed7e3f7012550facc9c8183861081da /webkit/glue/dom_operations.cc | |
parent | 0b45add7a298db2c8e4f07ef6117ebfd0ab30c80 (diff) | |
download | chromium_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/dom_operations.cc')
-rw-r--r-- | webkit/glue/dom_operations.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 4773812..f0adc1a 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -312,14 +312,6 @@ static bool FillFormImpl(FormElements* fe, const FormData& data, bool submit) { return false; } -// Helper function to cast a Node as an HTMLInputElement. -static WebCore::HTMLInputElement* GetNodeAsInputElement(WebCore::Node* node) { - DCHECK(node->nodeType() == WebCore::Node::ELEMENT_NODE); - DCHECK(static_cast<WebCore::Element*>(node)->hasTagName( - WebCore::HTMLNames::inputTag)); - return static_cast<WebCore::HTMLInputElement*>(node); -} - // Helper to search the given form element for the specified input elements // in |data|, and add results to |result|. static bool FindFormInputElements(WebCore::HTMLFormElement* fe, @@ -346,7 +338,8 @@ static bool FindFormInputElements(WebCore::HTMLFormElement* fe, // matching elements it can get at them through the FormElement*. // Note: This assignment adds a reference to the InputElement. result->input_elements[data.elements[j]] = - GetNodeAsInputElement(temp_elements[0].get()); + NodeToHTMLInputElement(temp_elements[0].get()); + DCHECK(result->input_elements[data.elements[j]].get()); } return true; } @@ -874,4 +867,17 @@ int NumberOfActiveAnimations(WebView* view) { return controller->numberOfActiveAnimations(); } +WebCore::HTMLInputElement* ElementToHTMLInputElement( + WebCore::Element* element) { + if (!element->hasLocalName(WebCore::HTMLNames::inputTag)) + return NULL; + return static_cast<WebCore::HTMLInputElement*>(element); +} + +WebCore::HTMLInputElement* NodeToHTMLInputElement(WebCore::Node* node) { + if (node->nodeType() != WebCore::Node::ELEMENT_NODE) + return NULL; + return ElementToHTMLInputElement(static_cast<WebCore::Element*>(node)); +} + } // webkit_glue |