Пример #1
0
void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
{
    ASSERT(form);
    ASSERT(fields);

    int firstPasswordIndex = 0;
    // First, find the password fields and activated submit button
    const Vector<HTMLFormControlElement*>& formElements = form->associatedElements();
    for (size_t i = 0; i < formElements.size(); i++) {
        HTMLFormControlElement* formElement = formElements[i];
        if (formElement->isActivatedSubmit())
            fields->submit = formElement;

        if (!formElement->hasLocalName(HTMLNames::inputTag))
            continue;

        HTMLInputElement* inputElement = toHTMLInputElement(formElement);
        if (!inputElement->isEnabledFormControl())
            continue;

        if ((fields->passwords.size() < maxPasswords)
            && inputElement->isPasswordField()
            && inputElement->autoComplete()) {
            if (fields->passwords.isEmpty())
                firstPasswordIndex = i;
            fields->passwords.append(inputElement);
        }
    }

    if (!fields->passwords.isEmpty()) {
        // Then, search backwards for the username field
        for (int i = firstPasswordIndex - 1; i >= 0; i--) {
            HTMLFormControlElement* formElement = formElements[i];
            if (!formElement->hasLocalName(HTMLNames::inputTag))
                continue;

            HTMLInputElement* inputElement = toHTMLInputElement(formElement);
            if (!inputElement->isEnabledFormControl())
                continue;

            // Various input types such as text, url, email can be a username field.
            if ((inputElement->isTextField() && !inputElement->isPasswordField())
                && (inputElement->autoComplete())) {
                fields->userName = inputElement;
                break;
            }
        }
    }
}
Пример #2
0
bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame* frame, const QString& elementId)
{
    Frame* coreFrame = QWebFramePrivate::core(frame);
    if (!coreFrame)
        return false;

    Document* doc = coreFrame->document();
    Q_ASSERT(doc);

    Node* coreNode = doc->getElementById(elementId);
    if (!coreNode || !coreNode->renderer())
        return false;

    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(coreNode);

    return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->autoComplete();
}
Пример #3
0
bool WebFrame::elementDoesAutoComplete(DOMElement *element)
{
    if (!element)
        return false;

    HTMLInputElement *inputElement = inputElementFromDOMElement(element);
    if (!inputElement)
        return false;
    else
        return inputElement->isTextField() && inputElement->inputType() != HTMLInputElement::PASSWORD && inputElement->autoComplete();
}