Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: third_party/WebKit/Source/web/WebFormControlElement.cpp

Issue 1955963002: [Autofill] Send events to fields being autofilled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added focus check Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/WebFormControlElement.cpp
diff --git a/third_party/WebKit/Source/web/WebFormControlElement.cpp b/third_party/WebKit/Source/web/WebFormControlElement.cpp
index 7dbbea50b4756d937b75e21d3f5366c0421f14e0..64f0c9d2514d5b9f8b1bb74e6c78f0805c18f0e5 100644
--- a/third_party/WebKit/Source/web/WebFormControlElement.cpp
+++ b/third_party/WebKit/Source/web/WebFormControlElement.cpp
@@ -97,6 +97,26 @@ void WebFormControlElement::setValue(const WebString& value, bool sendEvents)
unwrap<HTMLSelectElement>()->setValue(value, sendEvents);
}
+void WebFormControlElement::setAutofillValue(const WebString& value)
+{
+ // The input and change events will be sent in setValue.
+ if (isHTMLInputElement(*m_private) || isHTMLTextAreaElement(*m_private)) {
+ if (!focused())
+ unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
+ unwrap<Element>()->dispatchScopedEvent(Event::createBubble(EventTypeNames::keydown));
+ unwrap<HTMLTextFormControlElement>()->setValue(value, DispatchInputAndChangeEvent);
+ unwrap<Element>()->dispatchScopedEvent(Event::createBubble(EventTypeNames::keyup));
+ if (!focused())
+ unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr);
+ } else if (isHTMLSelectElement(*m_private)) {
+ if (!focused())
+ unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
+ unwrap<HTMLSelectElement>()->setValue(value, true);
+ if (!focused())
+ unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr);
+ }
+}
+
WebString WebFormControlElement::value() const
{
if (isHTMLInputElement(*m_private))
« no previous file with comments | « components/autofill/content/renderer/form_autofill_util.cc ('k') | third_party/WebKit/public/web/WebFormControlElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698