当前位置: 首页>>代码示例>>C++>>正文


C++ HTMLFormControlElement::disabled方法代码示例

本文整理汇总了C++中HTMLFormControlElement::disabled方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormControlElement::disabled方法的具体用法?C++ HTMLFormControlElement::disabled怎么用?C++ HTMLFormControlElement::disabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLFormControlElement的用法示例。


在下文中一共展示了HTMLFormControlElement::disabled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: adoptRef

PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, bool lockHistory, FormSubmissionTrigger trigger)
{
    ASSERT(form);
    Document* document = form->document();
    KURL actionURL = document->completeURL(attributes.action().isEmpty() ? document->url().string() : attributes.action());
    bool isMailtoForm = actionURL.protocolIs("mailto");
    bool isMultiPartForm = false;
    String encodingType = attributes.encodingType();

    if (attributes.method() == PostMethod) {
        isMultiPartForm = attributes.isMultiPartForm();
        if (isMultiPartForm && isMailtoForm) {
            encodingType = "application/x-www-form-urlencoded";
            isMultiPartForm = false;
        }
    }

    TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(attributes.acceptCharset(), document);
    RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding.encodingForFormSubmission());
    Vector<pair<String, String> > formValues;

    for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
        HTMLFormControlElement* control = form->associatedElements()[i];
        if (!control->disabled())
            control->appendFormData(*domFormData, isMultiPartForm);
        if (control->hasLocalName(inputTag)) {
            HTMLInputElement* input = static_cast<HTMLInputElement*>(control);
            if (input->isTextField()) {
                formValues.append(pair<String, String>(input->name(), input->value()));
                if (input->isSearchField())
                    input->addSearchResult();
            }
        }
    }

    RefPtr<FormData> formData;
    String boundary;

    if (isMultiPartForm) {
        formData = FormData::createMultiPart(*(static_cast<FormDataList*>(domFormData.get())), domFormData->encoding(), document);
        boundary = formData->boundary().data();
    } else {
        formData = FormData::create(*(static_cast<FormDataList*>(domFormData.get())), domFormData->encoding());
        if (attributes.method() == PostMethod && isMailtoForm) {
            // Convert the form data into a string that we put into the URL.
            appendMailtoPostFormDataToURL(actionURL, *formData, encodingType);
            formData = FormData::create();
        }
    }

    formData->setIdentifier(generateFormDataIdentifier());
    String targetOrBaseTarget = attributes.target().isEmpty() ? document->baseTarget() : attributes.target();
    RefPtr<FormState> formState = FormState::create(form, formValues, document->frame(), trigger);
    return adoptRef(new FormSubmission(attributes.method(), actionURL, targetOrBaseTarget, encodingType, formState.release(), formData.release(), boundary, lockHistory, event));
}
开发者ID:,项目名称:,代码行数:55,代码来源:

示例2: setEnctype

PassRefPtr<FormData> HTMLFormElement::prepareFormData()
{
    if (m_formDataBuilder.isPostMethod()) {
        if (m_formDataBuilder.isMultiPartForm() && isMailtoForm()) {
            // FIXME: This may fire a DOM Mutation Event. Do we really want this here?
            setEnctype("application/x-www-form-urlencoded");
            ASSERT(!m_formDataBuilder.isMultiPartForm());
        }
    } else
        m_formDataBuilder.setIsMultiPartForm(false);

    RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding().encodingForFormSubmission());
    for (unsigned i = 0; i < m_associatedElements.size(); ++i) {
        HTMLFormControlElement* control = m_associatedElements[i];
        if (!control->disabled())
            control->appendFormData(*domFormData, m_formDataBuilder.isMultiPartForm());
    }

    RefPtr<FormData> result;

    if (m_formDataBuilder.isMultiPartForm())
        result = FormData::createMultiPart(domFormData->items(), domFormData->encoding(), document());
    else {
        result = FormData::create(domFormData->items(), domFormData->encoding());
        if (m_formDataBuilder.isPostMethod() && isMailtoForm()) {
            // Convert the form data into a string that we put into the URL.
            KURL url = document()->completeURL(m_url);
            appendMailtoPostFormDataToURL(url, *result, m_formDataBuilder.encodingType());
            m_url = url.string();

            result = FormData::create();
        }
    }

    result->setIdentifier(generateFormDataIdentifier());
    return result.release();
}
开发者ID:mikedougherty,项目名称:webkit,代码行数:37,代码来源:HTMLFormElement.cpp

示例3: list

PassRefPtr<FormData> HTMLFormElement::createFormData(const CString& boundary)
{
    Vector<char> encodedData;
    TextEncoding encoding = dataEncoding().encodingForFormSubmission();

    RefPtr<FormData> result = FormData::create();

    for (unsigned i = 0; i < formElements.size(); ++i) {
        HTMLFormControlElement* control = formElements[i];
        FormDataList list(encoding);

        if (!control->disabled() && control->appendFormData(list, m_formDataBuilder.isMultiPartForm())) {
            size_t formDataListSize = list.list().size();
            ASSERT(formDataListSize % 2 == 0);
            for (size_t j = 0; j < formDataListSize; j += 2) {
                const FormDataList::Item& key = list.list()[j];
                const FormDataList::Item& value = list.list()[j + 1];
                if (!m_formDataBuilder.isMultiPartForm()) {
                    // Omit the name "isindex" if it's the first form data element.
                    // FIXME: Why is this a good rule? Is this obsolete now?
                    if (encodedData.isEmpty() && key.data() == "isindex")
                        FormDataBuilder::encodeStringAsFormData(encodedData, value.data());
                    else
                        m_formDataBuilder.addKeyValuePairAsFormData(encodedData, key.data(), value.data());
                } else {
                    Vector<char> header;
                    m_formDataBuilder.beginMultiPartHeader(header, boundary, key.data());

                    bool shouldGenerateFile = false;
                    // if the current type is FILE, then we also need to include the filename
                    if (value.file()) {
                        const String& path = value.file()->path();
                        String fileName = value.file()->fileName();

                        // Let the application specify a filename if it's going to generate a replacement file for the upload.
                        if (!path.isEmpty()) {
                            if (Page* page = document()->page()) {
                                String generatedFileName;
                                shouldGenerateFile = page->chrome()->client()->shouldReplaceWithGeneratedFileForUpload(path, generatedFileName);
                                if (shouldGenerateFile)
                                    fileName = generatedFileName;
                            }
                        }

                        // We have to include the filename=".." part in the header, even if the filename is empty
                        m_formDataBuilder.addFilenameToMultiPartHeader(header, encoding, fileName);

                        if (!fileName.isEmpty()) {
                            // FIXME: The MIMETypeRegistry function's name makes it sound like it takes a path,
                            // not just a basename. But filename is not the path. But note that it's not safe to
                            // just use path instead since in the generated-file case it will not reflect the
                            // MIME type of the generated file.
                            String mimeType = MIMETypeRegistry::getMIMETypeForPath(fileName);
                            if (!mimeType.isEmpty())
                                m_formDataBuilder.addContentTypeToMultiPartHeader(header, mimeType.latin1());
                        }
                    }

                    m_formDataBuilder.finishMultiPartHeader(header);

                    // Append body
                    result->appendData(header.data(), header.size());
                    if (size_t dataSize = value.data().length())
                        result->appendData(value.data().data(), dataSize);
                    else if (value.file() && !value.file()->path().isEmpty())
                        result->appendFile(value.file()->path(), shouldGenerateFile);

                    result->appendData("\r\n", 2);
                }
            }
        }
    }

    if (m_formDataBuilder.isMultiPartForm())
        m_formDataBuilder.addBoundaryToMultiPartHeader(encodedData, boundary, true);

    result->appendData(encodedData.data(), encodedData.size());

    result->setIdentifier(generateFormDataIdentifier());
    return result;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:81,代码来源:HTMLFormElement.cpp


注:本文中的HTMLFormControlElement::disabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。