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)) |