Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)) { | |
|
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
| |
| 104 unwrap<HTMLInputElement>()->dispatchFocusEvent(nullptr, WebFocusTypeForw ard, nullptr); | |
| 105 unwrap<HTMLInputElement>()->dispatchKeyDownEvent(); | |
| 106 unwrap<HTMLInputElement>()->setValue(value, DispatchInputAndChangeEvent) ; | |
| 107 unwrap<HTMLInputElement>()->dispatchKeyUpEvent(); | |
| 108 unwrap<HTMLInputElement>()->dispatchBlurEvent(nullptr, WebFocusTypeForwa rd, nullptr); | |
| 109 } else if (isHTMLTextAreaElement(*m_private)) { | |
| 110 unwrap<HTMLTextAreaElement>()->dispatchFocusEvent(nullptr, WebFocusTypeF orward, nullptr); | |
| 111 unwrap<HTMLTextAreaElement>()->dispatchKeyDownEvent(); | |
| 112 unwrap<HTMLTextAreaElement>()->setValue(value, DispatchInputAndChangeEve nt); | |
| 113 unwrap<HTMLTextAreaElement>()->dispatchKeyUpEvent(); | |
| 114 unwrap<HTMLTextAreaElement>()->dispatchBlurEvent(nullptr, WebFocusTypeFo rward, nullptr); | |
| 115 } else if (isHTMLSelectElement(*m_private)) { | |
| 116 unwrap<HTMLSelectElement>()->dispatchFocusEvent(nullptr, WebFocusTypeFor ward, nullptr); | |
| 117 unwrap<HTMLSelectElement>()->setValue(value, true); | |
| 118 unwrap<HTMLSelectElement>()->dispatchBlurEvent(nullptr, WebFocusTypeForw ard, nullptr); | |
| 119 } | |
| 120 } | |
| 121 | |
| 100 WebString WebFormControlElement::value() const | 122 WebString WebFormControlElement::value() const |
| 101 { | 123 { |
| 102 if (isHTMLInputElement(*m_private)) | 124 if (isHTMLInputElement(*m_private)) |
| 103 return constUnwrap<HTMLInputElement>()->value(); | 125 return constUnwrap<HTMLInputElement>()->value(); |
| 104 if (isHTMLTextAreaElement(*m_private)) | 126 if (isHTMLTextAreaElement(*m_private)) |
| 105 return constUnwrap<HTMLTextAreaElement>()->value(); | 127 return constUnwrap<HTMLTextAreaElement>()->value(); |
| 106 if (isHTMLSelectElement(*m_private)) | 128 if (isHTMLSelectElement(*m_private)) |
| 107 return constUnwrap<HTMLSelectElement>()->value(); | 129 return constUnwrap<HTMLSelectElement>()->value(); |
| 108 return WebString(); | 130 return WebString(); |
| 109 } | 131 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 m_private = elem; | 210 m_private = elem; |
| 189 return *this; | 211 return *this; |
| 190 } | 212 } |
| 191 | 213 |
| 192 WebFormControlElement::operator HTMLFormControlElement*() const | 214 WebFormControlElement::operator HTMLFormControlElement*() const |
| 193 { | 215 { |
| 194 return toHTMLFormControlElement(m_private.get()); | 216 return toHTMLFormControlElement(m_private.get()); |
| 195 } | 217 } |
| 196 | 218 |
| 197 } // namespace blink | 219 } // namespace blink |
| OLD | NEW |