| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 { | 135 { |
| 136 m_method = other.m_method; | 136 m_method = other.m_method; |
| 137 m_isMultiPartForm = other.m_isMultiPartForm; | 137 m_isMultiPartForm = other.m_isMultiPartForm; |
| 138 | 138 |
| 139 m_action = other.m_action; | 139 m_action = other.m_action; |
| 140 m_target = other.m_target; | 140 m_target = other.m_target; |
| 141 m_encodingType = other.m_encodingType; | 141 m_encodingType = other.m_encodingType; |
| 142 m_acceptCharset = other.m_acceptCharset; | 142 m_acceptCharset = other.m_acceptCharset; |
| 143 } | 143 } |
| 144 | 144 |
| 145 inline FormSubmission::FormSubmission(SubmitMethod method, const KURL& action, c
onst AtomicString& target, const AtomicString& contentType, HTMLFormElement* for
m, PassRefPtr<EncodedFormData> data, const String& boundary, PassRefPtrWillBeRaw
Ptr<Event> event) | 145 inline FormSubmission::FormSubmission(SubmitMethod method, const KURL& action, c
onst AtomicString& target, const AtomicString& contentType, HTMLFormElement* for
m, PassRefPtr<EncodedFormData> data, const String& boundary, RawPtr<Event> event
) |
| 146 : m_method(method) | 146 : m_method(method) |
| 147 , m_action(action) | 147 , m_action(action) |
| 148 , m_target(target) | 148 , m_target(target) |
| 149 , m_contentType(contentType) | 149 , m_contentType(contentType) |
| 150 , m_form(form) | 150 , m_form(form) |
| 151 , m_formData(data) | 151 , m_formData(data) |
| 152 , m_boundary(boundary) | 152 , m_boundary(boundary) |
| 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 PassRefPtrWillBeRawPtr<FormSubmission> FormSubmission::create(HTMLFormElement* f
orm, const Attributes& attributes, PassRefPtrWillBeRawPtr<Event> event) | 163 RawPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attri
butes& attributes, RawPtr<Event> event) |
| 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(attributeValue); | 182 copiedAttributes.parseAction(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 adoptRefWillBeNoop(new FormSubmission(submitButton->resultFor
DialogSubmit())); | 193 return new FormSubmission(submitButton->resultForDialogSubmit()); |
| 194 return adoptRefWillBeNoop(new FormSubmission("")); | 194 return new FormSubmission(""); |
| 195 } | 195 } |
| 196 | 196 |
| 197 Document& document = form->document(); | 197 Document& document = form->document(); |
| 198 KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ?
document.url().getString() : copiedAttributes.action()); | 198 KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ?
document.url().getString() : copiedAttributes.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 = EncodedFormData::create(); | 238 formData = EncodedFormData::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 adoptRefWillBeNoop(new FormSubmission(copiedAttributes.method(), acti
onURL, targetOrBaseTarget, encodingType, form, formData.release(), boundary, eve
nt)); | 245 return new FormSubmission(copiedAttributes.method(), actionURL, targetOrBase
Target, encodingType, form, formData.release(), boundary, event); |
| 246 } | 246 } |
| 247 | 247 |
| 248 DEFINE_TRACE(FormSubmission) | 248 DEFINE_TRACE(FormSubmission) |
| 249 { | 249 { |
| 250 visitor->trace(m_form); | 250 visitor->trace(m_form); |
| 251 visitor->trace(m_event); | 251 visitor->trace(m_event); |
| 252 } | 252 } |
| 253 | 253 |
| 254 KURL FormSubmission::requestURL() const | 254 KURL FormSubmission::requestURL() const |
| 255 { | 255 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 274 if (m_boundary.isEmpty()) | 274 if (m_boundary.isEmpty()) |
| 275 frameRequest.resourceRequest().setHTTPContentType(m_contentType); | 275 frameRequest.resourceRequest().setHTTPContentType(m_contentType); |
| 276 else | 276 else |
| 277 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); | 277 frameRequest.resourceRequest().setHTTPContentType(m_contentType + ";
boundary=" + m_boundary); |
| 278 } | 278 } |
| 279 | 279 |
| 280 frameRequest.resourceRequest().setURL(requestURL()); | 280 frameRequest.resourceRequest().setURL(requestURL()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace blink | 283 } // namespace blink |
| OLD | NEW |