diff options
-rw-r--r-- | webkit/glue/editor_client_impl.cc | 22 | ||||
-rw-r--r-- | webkit/glue/editor_client_impl.h | 8 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 2 |
3 files changed, 22 insertions, 10 deletions
diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 670bee0..6f2bdf1 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -634,7 +634,13 @@ void EditorClientImpl::handleKeyboardEvent(WebCore::KeyboardEvent* evt) { if (evt->keyCode() == WebCore::VKEY_DOWN || evt->keyCode() == WebCore::VKEY_UP) { DCHECK(evt->target()->toNode()); - ShowAutofillForNode(evt->target()->toNode()); + if (ShowAutofillForNode(evt->target()->toNode())) { + // We will show an autofill popup. Let's return so we don't handle the + // event. The handling could change the caret position, preventing the + // popup from showing (since the actual showing is delayed, see + // DoAutofill). + return; + } } if (handleEditingKeyboardEvent(evt)) @@ -664,14 +670,15 @@ void EditorClientImpl::textDidChangeInTextField(WebCore::Element* element) { Autofill(static_cast<WebCore::HTMLInputElement*>(element), false); } -void EditorClientImpl::ShowAutofillForNode(WebCore::Node* node) { +bool EditorClientImpl::ShowAutofillForNode(WebCore::Node* node) { WebCore::HTMLInputElement* input_element = webkit_glue::NodeToHTMLInputElement(node); if (input_element) - Autofill(input_element, true); + return Autofill(input_element, true); + return false; } -void EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, +bool EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, bool autofill_on_empty_value) { // Cancel any pending DoAutofill calls. autofill_factory_.RevokeAll(); @@ -679,16 +686,16 @@ void EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, // Let's try to trigger autofill for that field, if applicable. if (!input_element->isEnabled() || !input_element->isTextField() || input_element->isPasswordField() || !input_element->autoComplete()) { - return; + return false; } std::wstring name = AutofillForm::GetNameForInputElement(input_element); if (name.empty()) // If the field has no name, then we won't have values. - return; + return false; // Don't attempt to autofill with values that are too large. if (input_element->value().length() > kMaximumTextSizeForAutofill) - return; + return false; // We post a task for doing the autofill as the caret position is not set // properly at this point ( http://bugs.webkit.org/show_bug.cgi?id=16976) @@ -700,6 +707,7 @@ void EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, input_element, autofill_on_empty_value, backspace_pressed_)); + return true; } void EditorClientImpl::DoAutofill(WebCore::HTMLInputElement* input_element, diff --git a/webkit/glue/editor_client_impl.h b/webkit/glue/editor_client_impl.h index 5467470..116dfe9 100644 --- a/webkit/glue/editor_client_impl.h +++ b/webkit/glue/editor_client_impl.h @@ -118,7 +118,9 @@ class EditorClientImpl : public WebCore::EditorClient { // Shows the autofill popup for |node| if it is an HTMLInputElement and it is // empty. This is called when you press the up or down arrow in a text field // or when clicking an already focused text-field. - virtual void ShowAutofillForNode(WebCore::Node* node); + // Returns true if the autofill popup has been scheduled to be shown, false + // otherwise. + virtual bool ShowAutofillForNode(WebCore::Node* node); private: void ModifySelection(WebCore::Frame* frame, @@ -127,7 +129,9 @@ class EditorClientImpl : public WebCore::EditorClient { // Popups an autofill menu for |input_element| is applicable. // |autofill_on_empty_value| indicates whether the autofill should be shown // when the text-field is empty. - void Autofill(WebCore::HTMLInputElement* input_element, + // Returns true if the autofill popup has been scheduled to be shown, false + // otherwise. + bool Autofill(WebCore::HTMLInputElement* input_element, bool autofill_on_empty_value); // This method is invoked later by Autofill() as when Autofill() is invoked diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 799f0d3..98c33fe 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1719,7 +1719,7 @@ void WebViewImpl::DeleteImageResourceFetcher(ImageResourceFetcher* fetcher) { } void WebViewImpl::HideAutoCompletePopup() { - if (autocomplete_popup_) { + if (autocomplete_popup_showing_) { autocomplete_popup_->hidePopup(); autocomplete_popup_showing_ = false; } |