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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void WebFormControlElement::setValue(const WebString& value, bool sendEvents) 90 void WebFormControlElement::setValue(const WebString& value, bool sendEvents)
91 { 91 {
92 if (isHTMLInputElement(*m_private)) 92 if (isHTMLInputElement(*m_private))
93 unwrap<HTMLInputElement>()->setValue(value, sendEvents ? DispatchInputAn dChangeEvent : DispatchNoEvent); 93 unwrap<HTMLInputElement>()->setValue(value, sendEvents ? DispatchInputAn dChangeEvent : DispatchNoEvent);
94 else if (isHTMLTextAreaElement(*m_private)) 94 else if (isHTMLTextAreaElement(*m_private))
95 unwrap<HTMLTextAreaElement>()->setValue(value, sendEvents ? DispatchInpu tAndChangeEvent : DispatchNoEvent); 95 unwrap<HTMLTextAreaElement>()->setValue(value, sendEvents ? DispatchInpu tAndChangeEvent : DispatchNoEvent);
96 else if (isHTMLSelectElement(*m_private)) 96 else if (isHTMLSelectElement(*m_private))
97 unwrap<HTMLSelectElement>()->setValue(value, sendEvents); 97 unwrap<HTMLSelectElement>()->setValue(value, sendEvents);
98 } 98 }
99 99
100 void WebFormControlElement::setAutofillValue(const WebString& value)
101 {
102 // The input and change events will be sent in setValue.
103 if (isHTMLInputElement(*m_private) || isHTMLTextAreaElement(*m_private)) {
104 if (!focused())
105 unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
106 unwrap<Element>()->dispatchScopedEvent(Event::createBubble(EventTypeName s::keydown));
107 unwrap<HTMLTextFormControlElement>()->setValue(value, DispatchInputAndCh angeEvent);
108 unwrap<Element>()->dispatchScopedEvent(Event::createBubble(EventTypeName s::keyup));
109 if (!focused())
110 unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, n ullptr);
111 } else if (isHTMLSelectElement(*m_private)) {
112 if (!focused())
113 unwrap<Element>()->dispatchFocusEvent(nullptr, WebFocusTypeForward, nullptr);
114 unwrap<HTMLSelectElement>()->setValue(value, true);
115 if (!focused())
116 unwrap<Element>()->dispatchBlurEvent(nullptr, WebFocusTypeForward, n ullptr);
117 }
118 }
119
100 WebString WebFormControlElement::value() const 120 WebString WebFormControlElement::value() const
101 { 121 {
102 if (isHTMLInputElement(*m_private)) 122 if (isHTMLInputElement(*m_private))
103 return constUnwrap<HTMLInputElement>()->value(); 123 return constUnwrap<HTMLInputElement>()->value();
104 if (isHTMLTextAreaElement(*m_private)) 124 if (isHTMLTextAreaElement(*m_private))
105 return constUnwrap<HTMLTextAreaElement>()->value(); 125 return constUnwrap<HTMLTextAreaElement>()->value();
106 if (isHTMLSelectElement(*m_private)) 126 if (isHTMLSelectElement(*m_private))
107 return constUnwrap<HTMLSelectElement>()->value(); 127 return constUnwrap<HTMLSelectElement>()->value();
108 return WebString(); 128 return WebString();
109 } 129 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 m_private = elem; 208 m_private = elem;
189 return *this; 209 return *this;
190 } 210 }
191 211
192 WebFormControlElement::operator HTMLFormControlElement*() const 212 WebFormControlElement::operator HTMLFormControlElement*() const
193 { 213 {
194 return toHTMLFormControlElement(m_private.get()); 214 return toHTMLFormControlElement(m_private.get());
195 } 215 }
196 216
197 } // namespace blink 217 } // namespace blink
OLDNEW
« 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