Beispiel #1
0
bool LayoutTheme::isReadOnlyControl(const LayoutObject& o)
{
    Node* node = o.node();
    if (!node || !node->isElementNode() || !toElement(node)->isFormControlElement())
        return false;
    HTMLFormControlElement* element = toHTMLFormControlElement(node);
    return element->isReadOnly();
}
bool HTMLFieldSetElement::isValidElement()
{
    const FormAssociatedElement::List& elements = associatedElements();
    for (unsigned i = 0; i < elements.size(); ++i) {
        if (elements[i]->isFormControlElement()) {
            HTMLFormControlElement* control = toHTMLFormControlElement(elements[i].get());
            if (!control->checkValidity(0, CheckValidityDispatchNoEvent))
                return false;
        }
    }
    return true;
}
void WebFormElement::getFormControlElements(WebVector<WebFormControlElement>& result) const
{
    const HTMLFormElement* form = constUnwrap<HTMLFormElement>();
    Vector<RefPtr<HTMLFormControlElement> > formControlElements;

    const Vector<FormAssociatedElement*>& associatedElements = form->associatedElements();
    for (Vector<FormAssociatedElement*>::const_iterator it = associatedElements.begin(); it != associatedElements.end(); ++it) {
        if ((*it)->isFormControlElement())
            formControlElements.append(toHTMLFormControlElement(*it));
    }
    result.assign(formControlElements);
}
void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
{
    ASSERT(form);
    ASSERT(fields);

    HTMLInputElement* latestInputElement = 0;
    const Vector<FormAssociatedElement*>& formElements = form->associatedElements();
    for (size_t i = 0; i < formElements.size(); i++) {
        if (!formElements[i]->isFormControlElement())
            continue;
        HTMLFormControlElement* control = toHTMLFormControlElement(formElements[i]);
        if (control->isActivatedSubmit())
            fields->submit = control;

        if (!control->hasTagName(HTMLNames::inputTag))
            continue;

        HTMLInputElement* inputElement = toHTMLInputElement(control);
        if (inputElement->isDisabledFormControl())
            continue;

        if ((fields->passwords.size() < maxPasswords)
                && inputElement->isPasswordField()) {
            // We assume that the username is the input element before the
            // first password element.
            if (fields->passwords.isEmpty() && latestInputElement) {
                fields->userName = latestInputElement;
                // Remove the selected username from alternateUserNames.
                if (!fields->alternateUserNames.isEmpty() && !latestInputElement->value().isEmpty())
                    fields->alternateUserNames.removeLast();
            }
            fields->passwords.append(inputElement);
        }

        // Various input types such as text, url, email can be a username field.
        if (inputElement->isTextField() && !inputElement->isPasswordField()) {
            latestInputElement = inputElement;
            // We ignore elements that have no value. Unlike userName, alternateUserNames
            // is used only for autofill, not for form identification, and blank autofill
            // entries are not useful.
            if (!inputElement->value().isEmpty())
                fields->alternateUserNames.append(inputElement->value());
        }
    }
}
void HTMLFieldSetElement::refreshElementsIfNeeded() const
{
    uint64_t docVersion = document().domTreeVersion();
    if (m_documentVersion == docVersion)
        return;

    m_documentVersion = docVersion;

    m_associatedElements.clear();

    for (Element* element = ElementTraversal::firstWithin(*this); element; element = ElementTraversal::next(*element, this)) {
        if (element->hasTagName(objectTag)) {
            m_associatedElements.append(toHTMLObjectElement(element));
            continue;
        }

        if (!element->isFormControlElement())
            continue;

        m_associatedElements.append(toHTMLFormControlElement(element));
    }
}
void HTMLFieldSetElement::refreshElementsIfNeeded() const
{
    uint64_t docVersion = document().domTreeVersion();
    if (m_documentVersion == docVersion)
        return;

    m_documentVersion = docVersion;

    m_associatedElements.clear();

    for (HTMLElement& element : Traversal<HTMLElement>::descendantsOf(*this)) {
        if (isHTMLObjectElement(element)) {
            m_associatedElements.append(toHTMLObjectElement(&element));
            continue;
        }

        if (!element.isFormControlElement())
            continue;

        m_associatedElements.append(toHTMLFormControlElement(&element));
    }
}
WebFormControlElement::operator PassRefPtr<HTMLFormControlElement>() const
{
    return toHTMLFormControlElement(m_private.get());
}
WebFormControlElement::operator HTMLFormControlElement*() const {
  return toHTMLFormControlElement(m_private.get());
}