void EditorClientImpl::textFieldDidEndEditing(Element* element) { HTMLInputElement* inputElement = toHTMLInputElement(element); if (m_webView->autoFillClient() && inputElement) m_webView->autoFillClient()->textFieldDidEndEditing(WebInputElement(inputElement)); // Notification that focus was lost. Be careful with this, it's also sent // when the page is being closed. // Cancel any pending DoAutofill call. m_autofillArgs.clear(); m_autofillTimer.stop(); // Hide any showing popup. m_webView->hideAutoFillPopup(); if (!m_webView->client()) return; // The page is getting closed, don't fill the password. // Notify any password-listener of the focus change. if (!inputElement) return; WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); if (!webframe) return; WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); if (!listener) return; listener->didBlurInputElement(inputElement->value()); }
void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer) { OwnPtr<AutofillArgs> args(m_autofillArgs.release()); HTMLInputElement* inputElement = args->inputElement.get(); const String& value = inputElement->value(); // Enforce autofill_on_empty_value and caret_at_end. bool isCaretAtEnd = true; if (args->requireCaretAtEnd) isCaretAtEnd = inputElement->selectionStart() == inputElement->selectionEnd() && inputElement->selectionEnd() == static_cast<int>(value.length()); if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) { m_webView->hideAutoFillPopup(); return; } // First let's see if there is a password listener for that element. // We won't trigger form autofill in that case, as having both behavior on // a node would be confusing. WebFrameImpl* webframe = WebFrameImpl::fromFrame(inputElement->document()->frame()); if (!webframe) return; WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(inputElement); if (listener) { if (args->autofillFormOnly) return; listener->performInlineAutocomplete(value, args->backspaceOrDeletePressed, true); return; } // Then trigger form autofill. WebString name = WebInputElement(inputElement).nameForAutofill(); ASSERT(static_cast<int>(name.length()) > 0); if (m_webView->client()) m_webView->client()->queryAutofillSuggestions(WebNode(inputElement), name, WebString(value)); }