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

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: 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..4ff98a812cba24d15189a6e33b6f5a1051f92a43 100644
--- a/third_party/WebKit/Source/web/WebFormControlElement.cpp
+++ b/third_party/WebKit/Source/web/WebFormControlElement.cpp
@@ -97,6 +97,28 @@ 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)) {
tkent 2016/05/09 01:54:21 - You can unify HTMLInputElement path and HTMLText
sebsg 2016/05/09 22:19:11 Nice! I merged the calls but kept the if more rest
+ unwrap<HTMLInputElement>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
+ unwrap<HTMLInputElement>()->dispatchKeyDownEvent();
+ unwrap<HTMLInputElement>()->setValue(value, DispatchInputAndChangeEvent);
+ unwrap<HTMLInputElement>()->dispatchKeyUpEvent();
+ unwrap<HTMLInputElement>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr);
+ } else if (isHTMLTextAreaElement(*m_private)) {
+ unwrap<HTMLTextAreaElement>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
+ unwrap<HTMLTextAreaElement>()->dispatchKeyDownEvent();
+ unwrap<HTMLTextAreaElement>()->setValue(value, DispatchInputAndChangeEvent);
+ unwrap<HTMLTextAreaElement>()->dispatchKeyUpEvent();
+ unwrap<HTMLTextAreaElement>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr);
+ } else if (isHTMLSelectElement(*m_private)) {
+ unwrap<HTMLSelectElement>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
+ unwrap<HTMLSelectElement>()->setValue(value, true);
+ unwrap<HTMLSelectElement>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, nullptr);
+ }
+}
+
WebString WebFormControlElement::value() const
{
if (isHTMLInputElement(*m_private))

Powered by Google App Engine
This is Rietveld 408576698