| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 , m_event(event) | 153 , m_event(event) |
| 154 { | 154 { |
| 155 } | 155 } |
| 156 | 156 |
| 157 inline FormSubmission::FormSubmission(const String& result) | 157 inline FormSubmission::FormSubmission(const String& result) |
| 158 : m_method(DialogMethod) | 158 : m_method(DialogMethod) |
| 159 , m_result(result) | 159 , m_result(result) |
| 160 { | 160 { |
| 161 } | 161 } |
| 162 | 162 |
| 163 PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const A
ttributes& attributes, PassRefPtrWillBeRawPtr<Event> event, FormSubmissionTrigge
r trigger) | 163 PassRefPtrWillBeRawPtr<FormSubmission> FormSubmission::create(HTMLFormElement* f
orm, const Attributes& attributes, PassRefPtrWillBeRawPtr<Event> event, FormSubm
issionTrigger trigger) |
| 164 { | 164 { |
| 165 ASSERT(form); | 165 ASSERT(form); |
| 166 | 166 |
| 167 HTMLFormControlElement* submitButton = 0; | 167 HTMLFormControlElement* submitButton = 0; |
| 168 if (event && event->target()) { | 168 if (event && event->target()) { |
| 169 for (Node* node = event->target()->toNode(); node; node = node->parentOr
ShadowHostNode()) { | 169 for (Node* node = event->target()->toNode(); node; node = node->parentOr
ShadowHostNode()) { |
| 170 if (node->isElementNode() && toElement(node)->isFormControlElement()
) { | 170 if (node->isElementNode() && toElement(node)->isFormControlElement()
) { |
| 171 submitButton = toHTMLFormControlElement(node); | 171 submitButton = toHTMLFormControlElement(node); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 FormSubmission::Attributes copiedAttributes; | 177 FormSubmission::Attributes copiedAttributes; |
| 178 copiedAttributes.copyFrom(attributes); | 178 copiedAttributes.copyFrom(attributes); |
| 179 if (submitButton) { | 179 if (submitButton) { |
| 180 AtomicString attributeValue; | 180 AtomicString attributeValue; |
| 181 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i
sNull()) | 181 if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).i
sNull()) |
| 182 copiedAttributes.parseAction(form->document(), attributeValue); | 182 copiedAttributes.parseAction(form->document(), attributeValue); |
| 183 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)).
isNull()) | 183 if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)).
isNull()) |
| 184 copiedAttributes.updateEncodingType(attributeValue); | 184 copiedAttributes.updateEncodingType(attributeValue); |
| 185 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i
sNull()) | 185 if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).i
sNull()) |
| 186 copiedAttributes.updateMethodType(attributeValue); | 186 copiedAttributes.updateMethodType(attributeValue); |
| 187 if (!(attributeValue = submitButton->fastGetAttribute(formtargetAttr)).i
sNull()) | 187 if (!(attributeValue = submitButton->fastGetAttribute(formtargetAttr)).i
sNull()) |
| 188 copiedAttributes.setTarget(attributeValue); | 188 copiedAttributes.setTarget(attributeValue); |
| 189 } | 189 } |
| 190 | 190 |
| 191 if (copiedAttributes.method() == DialogMethod) { | 191 if (copiedAttributes.method() == DialogMethod) { |
| 192 if (submitButton) | 192 if (submitButton) |
| 193 return adoptRef(new FormSubmission(submitButton->resultForDialogSubm
it())); | 193 return adoptRefWillBeNoop(new FormSubmission(submitButton->resultFor
DialogSubmit())); |
| 194 return adoptRef(new FormSubmission("")); | 194 return adoptRefWillBeNoop(new FormSubmission("")); |
| 195 } | 195 } |
| 196 | 196 |
| 197 Document& document = form->document(); | 197 Document& document = form->document(); |
| 198 KURL actionURL = copiedAttributes.action().isEmpty() ? document.url() : copi
edAttributes.action(); | 198 KURL actionURL = copiedAttributes.action().isEmpty() ? document.url() : copi
edAttributes.action(); |
| 199 bool isMailtoForm = actionURL.protocolIs("mailto"); | 199 bool isMailtoForm = actionURL.protocolIs("mailto"); |
| 200 bool isMultiPartForm = false; | 200 bool isMultiPartForm = false; |
| 201 AtomicString encodingType = copiedAttributes.encodingType(); | 201 AtomicString encodingType = copiedAttributes.encodingType(); |
| 202 | 202 |
| 203 if (copiedAttributes.method() == PostMethod) { | 203 if (copiedAttributes.method() == PostMethod) { |
| 204 isMultiPartForm = copiedAttributes.isMultiPartForm(); | 204 isMultiPartForm = copiedAttributes.isMultiPartForm(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 235 if (copiedAttributes.method() == PostMethod && isMailtoForm) { | 235 if (copiedAttributes.method() == PostMethod && isMailtoForm) { |
| 236 // Convert the form data into a string that we put into the URL. | 236 // Convert the form data into a string that we put into the URL. |
| 237 appendMailtoPostFormDataToURL(actionURL, *formData, encodingType); | 237 appendMailtoPostFormDataToURL(actionURL, *formData, encodingType); |
| 238 formData = FormData::create(); | 238 formData = FormData::create(); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 formData->setIdentifier(generateFormDataIdentifier()); | 242 formData->setIdentifier(generateFormDataIdentifier()); |
| 243 formData->setContainsPasswordData(containsPasswordData); | 243 formData->setContainsPasswordData(containsPasswordData); |
| 244 AtomicString targetOrBaseTarget = copiedAttributes.target().isEmpty() ? docu
ment.baseTarget() : copiedAttributes.target(); | 244 AtomicString targetOrBaseTarget = copiedAttributes.target().isEmpty() ? docu
ment.baseTarget() : copiedAttributes.target(); |
| 245 return adoptRef(new FormSubmission(copiedAttributes.method(), actionURL, tar
getOrBaseTarget, encodingType, FormState::create(*form, trigger), formData.relea
se(), boundary, event)); | 245 return adoptRefWillBeNoop(new FormSubmission(copiedAttributes.method(), acti
onURL, targetOrBaseTarget, encodingType, FormState::create(*form, trigger), form
Data.release(), boundary, event)); |
| 246 } |
| 247 |
| 248 void FormSubmission::trace(Visitor* visitor) |
| 249 { |
| 250 visitor->trace(m_formState); |
| 251 visitor->trace(m_event); |
| 246 } | 252 } |
| 247 | 253 |
| 248 KURL FormSubmission::requestURL() const | 254 KURL FormSubmission::requestURL() const |
| 249 { | 255 { |
| 250 if (m_method == FormSubmission::PostMethod) | 256 if (m_method == FormSubmission::PostMethod) |
| 251 return m_action; | 257 return m_action; |
| 252 | 258 |
| 253 KURL requestURL(m_action); | 259 KURL requestURL(m_action); |
| 254 requestURL.setQuery(m_formData->flattenToString()); | 260 requestURL.setQuery(m_formData->flattenToString()); |
| 255 return requestURL; | 261 return requestURL; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 272 frameRequest.resourceRequest().setHTTPContentType(m_contentType); | 278 frameRequest.resourceRequest().setHTTPContentType(m_contentType); |
| 273 else | 279 else |
| 274 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); | 280 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); |
| 275 } | 281 } |
| 276 | 282 |
| 277 frameRequest.resourceRequest().setURL(requestURL()); | 283 frameRequest.resourceRequest().setURL(requestURL()); |
| 278 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), AtomicStr
ing(m_origin)); | 284 FrameLoader::addHTTPOriginIfNeeded(frameRequest.resourceRequest(), AtomicStr
ing(m_origin)); |
| 279 } | 285 } |
| 280 | 286 |
| 281 } | 287 } |
| OLD | NEW |