| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 , m_event(event) | 155 , m_event(event) |
| 156 { | 156 { |
| 157 } | 157 } |
| 158 | 158 |
| 159 inline FormSubmission::FormSubmission(const String& result) | 159 inline FormSubmission::FormSubmission(const String& result) |
| 160 : m_method(DialogMethod) | 160 : m_method(DialogMethod) |
| 161 , m_result(result) | 161 , m_result(result) |
| 162 { | 162 { |
| 163 } | 163 } |
| 164 | 164 |
| 165 FormSubmission* FormSubmission::create(HTMLFormElement* form, const Attributes&
attributes, Event* event) | 165 FormSubmission* FormSubmission::create(HTMLFormElement* form, const Attributes&
attributes, Event* event, HTMLFormControlElement* submitButton) |
| 166 { | 166 { |
| 167 DCHECK(form); | 167 DCHECK(form); |
| 168 | 168 |
| 169 HTMLFormControlElement* submitButton = 0; | |
| 170 if (event && event->target()) { | |
| 171 for (Node* node = event->target()->toNode(); node; node = node->parentOr
ShadowHostNode()) { | |
| 172 if (node->isElementNode() && toElement(node)->isFormControlElement()
) { | |
| 173 submitButton = toHTMLFormControlElement(node); | |
| 174 break; | |
| 175 } | |
| 176 } | |
| 177 } | |
| 178 | |
| 179 FormSubmission::Attributes copiedAttributes; | 169 FormSubmission::Attributes copiedAttributes; |
| 180 copiedAttributes.copyFrom(attributes); | 170 copiedAttributes.copyFrom(attributes); |
| 181 if (submitButton) { | 171 if (submitButton) { |
| 182 AtomicString attributeValue; | 172 AtomicString attributeValue; |
| 183 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i
sNull()) | 173 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i
sNull()) |
| 184 copiedAttributes.parseAction(attributeValue); | 174 copiedAttributes.parseAction(attributeValue); |
| 185 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)).
isNull()) | 175 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)).
isNull()) |
| 186 copiedAttributes.updateEncodingType(attributeValue); | 176 copiedAttributes.updateEncodingType(attributeValue); |
| 187 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i
sNull()) | 177 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i
sNull()) |
| 188 copiedAttributes.updateMethodType(attributeValue); | 178 copiedAttributes.updateMethodType(attributeValue); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 213 if (copiedAttributes.method() == PostMethod) { | 203 if (copiedAttributes.method() == PostMethod) { |
| 214 isMultiPartForm = copiedAttributes.isMultiPartForm(); | 204 isMultiPartForm = copiedAttributes.isMultiPartForm(); |
| 215 if (isMultiPartForm && isMailtoForm) { | 205 if (isMultiPartForm && isMailtoForm) { |
| 216 encodingType = AtomicString("application/x-www-form-urlencoded"); | 206 encodingType = AtomicString("application/x-www-form-urlencoded"); |
| 217 isMultiPartForm = false; | 207 isMultiPartForm = false; |
| 218 } | 208 } |
| 219 } | 209 } |
| 220 WTF::TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataEnc
oder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document.encod
ing()); | 210 WTF::TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataEnc
oder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document.encod
ing()); |
| 221 FormData* domFormData = FormData::create(dataEncoding.encodingForFormSubmiss
ion()); | 211 FormData* domFormData = FormData::create(dataEncoding.encodingForFormSubmiss
ion()); |
| 222 | 212 |
| 213 if (submitButton) |
| 214 submitButton->setActivatedSubmit(true); |
| 223 bool containsPasswordData = false; | 215 bool containsPasswordData = false; |
| 224 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { | 216 for (unsigned i = 0; i < form->associatedElements().size(); ++i) { |
| 225 FormAssociatedElement* control = form->associatedElements()[i]; | 217 FormAssociatedElement* control = form->associatedElements()[i]; |
| 226 DCHECK(control); | 218 DCHECK(control); |
| 227 HTMLElement& element = toHTMLElement(*control); | 219 HTMLElement& element = toHTMLElement(*control); |
| 228 if (!element.isDisabledFormControl()) | 220 if (!element.isDisabledFormControl()) |
| 229 control->appendToFormData(*domFormData); | 221 control->appendToFormData(*domFormData); |
| 230 if (isHTMLInputElement(element)) { | 222 if (isHTMLInputElement(element)) { |
| 231 HTMLInputElement& input = toHTMLInputElement(element); | 223 HTMLInputElement& input = toHTMLInputElement(element); |
| 232 if (input.type() == InputTypeNames::password && !input.value().isEmp
ty()) | 224 if (input.type() == InputTypeNames::password && !input.value().isEmp
ty()) |
| 233 containsPasswordData = true; | 225 containsPasswordData = true; |
| 234 } | 226 } |
| 235 } | 227 } |
| 228 if (submitButton) |
| 229 submitButton->setActivatedSubmit(false); |
| 236 | 230 |
| 237 RefPtr<EncodedFormData> formData; | 231 RefPtr<EncodedFormData> formData; |
| 238 String boundary; | 232 String boundary; |
| 239 | 233 |
| 240 if (isMultiPartForm) { | 234 if (isMultiPartForm) { |
| 241 formData = domFormData->encodeMultiPartFormData(); | 235 formData = domFormData->encodeMultiPartFormData(); |
| 242 boundary = formData->boundary().data(); | 236 boundary = formData->boundary().data(); |
| 243 } else { | 237 } else { |
| 244 formData = domFormData->encodeFormData(attributes.method() == GetMethod
? EncodedFormData::FormURLEncoded : EncodedFormData::parseEncodingType(encodingT
ype)); | 238 formData = domFormData->encodeFormData(attributes.method() == GetMethod
? EncodedFormData::FormURLEncoded : EncodedFormData::parseEncodingType(encodingT
ype)); |
| 245 if (copiedAttributes.method() == PostMethod && isMailtoForm) { | 239 if (copiedAttributes.method() == PostMethod && isMailtoForm) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 285 |
| 292 frameRequest.resourceRequest().setURL(requestURL()); | 286 frameRequest.resourceRequest().setURL(requestURL()); |
| 293 | 287 |
| 294 frameRequest.setTriggeringEvent(m_event); | 288 frameRequest.setTriggeringEvent(m_event); |
| 295 frameRequest.setForm(m_form); | 289 frameRequest.setForm(m_form); |
| 296 | 290 |
| 297 return frameRequest; | 291 return frameRequest; |
| 298 } | 292 } |
| 299 | 293 |
| 300 } // namespace blink | 294 } // namespace blink |
| OLD | NEW |