本文整理汇总了C++中HTMLFormControlElement::resultForDialogSubmit方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormControlElement::resultForDialogSubmit方法的具体用法?C++ HTMLFormControlElement::resultForDialogSubmit怎么用?C++ HTMLFormControlElement::resultForDialogSubmit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLFormControlElement
的用法示例。
在下文中一共展示了HTMLFormControlElement::resultForDialogSubmit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adoptRefWillBeNoop
PassRefPtrWillBeRawPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtrWillBeRawPtr<Event> event)
{
ASSERT(form);
HTMLFormControlElement* submitButton = 0;
if (event && event->target()) {
for (Node* node = event->target()->toNode(); node; node = node->parentOrShadowHostNode()) {
if (node->isElementNode() && toElement(node)->isFormControlElement()) {
submitButton = toHTMLFormControlElement(node);
break;
}
}
}
FormSubmission::Attributes copiedAttributes;
copiedAttributes.copyFrom(attributes);
if (submitButton) {
AtomicString attributeValue;
if (!(attributeValue = submitButton->fastGetAttribute(formactionAttr)).isNull())
copiedAttributes.parseAction(attributeValue);
if (!(attributeValue = submitButton->fastGetAttribute(formenctypeAttr)).isNull())
copiedAttributes.updateEncodingType(attributeValue);
if (!(attributeValue = submitButton->fastGetAttribute(formmethodAttr)).isNull())
copiedAttributes.updateMethodType(attributeValue);
if (!(attributeValue = submitButton->fastGetAttribute(formtargetAttr)).isNull())
copiedAttributes.setTarget(attributeValue);
}
if (copiedAttributes.method() == DialogMethod) {
if (submitButton)
return adoptRefWillBeNoop(new FormSubmission(submitButton->resultForDialogSubmit()));
return adoptRefWillBeNoop(new FormSubmission(""));
}
Document& document = form->document();
KURL actionURL = document.completeURL(copiedAttributes.action().isEmpty() ? document.url().string() : copiedAttributes.action());
bool isMailtoForm = actionURL.protocolIs("mailto");
bool isMultiPartForm = false;
AtomicString encodingType = copiedAttributes.encodingType();
if (copiedAttributes.method() == PostMethod) {
isMultiPartForm = copiedAttributes.isMultiPartForm();
if (isMultiPartForm && isMailtoForm) {
encodingType = AtomicString("application/x-www-form-urlencoded", AtomicString::ConstructFromLiteral);
isMultiPartForm = false;
}
}
WTF::TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataEncoder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document.encoding());
FormData* domFormData = FormData::create(dataEncoding.encodingForFormSubmission());
bool containsPasswordData = false;
for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
FormAssociatedElement* control = form->associatedElements()[i];
ASSERT(control);
HTMLElement& element = toHTMLElement(*control);
if (!element.isDisabledFormControl())
control->appendToFormData(*domFormData);
if (isHTMLInputElement(element)) {
HTMLInputElement& input = toHTMLInputElement(element);
if (input.type() == InputTypeNames::password && !input.value().isEmpty())
containsPasswordData = true;
}
}
RefPtr<EncodedFormData> formData;
String boundary;
if (isMultiPartForm) {
formData = domFormData->encodeMultiPartFormData();
boundary = formData->boundary().data();
} else {
formData = domFormData->encodeFormData(attributes.method() == GetMethod ? EncodedFormData::FormURLEncoded : EncodedFormData::parseEncodingType(encodingType));
if (copiedAttributes.method() == PostMethod && isMailtoForm) {
// Convert the form data into a string that we put into the URL.
appendMailtoPostFormDataToURL(actionURL, *formData, encodingType);
formData = EncodedFormData::create();
}
}
formData->setIdentifier(generateFormDataIdentifier());
formData->setContainsPasswordData(containsPasswordData);
AtomicString targetOrBaseTarget = copiedAttributes.target().isEmpty() ? document.baseTarget() : copiedAttributes.target();
return adoptRefWillBeNoop(new FormSubmission(copiedAttributes.method(), actionURL, targetOrBaseTarget, encodingType, form, formData.release(), boundary, event));
}