本文整理汇总了C++中HTMLFormControlElement::form方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormControlElement::form方法的具体用法?C++ HTMLFormControlElement::form怎么用?C++ HTMLFormControlElement::form使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLFormControlElement
的用法示例。
在下文中一共展示了HTMLFormControlElement::form方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkInvalidControlsAndCollectUnhandled
bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(Vector<RefPtr<FormAssociatedElement> >& unhandledInvalidControls)
{
RefPtr<HTMLFormElement> protector(this);
// Copy m_associatedElements because event handlers called from
// HTMLFormControlElement::checkValidity() might change m_associatedElements.
Vector<RefPtr<FormAssociatedElement> > elements;
elements.reserveCapacity(m_associatedElements.size());
for (unsigned i = 0; i < m_associatedElements.size(); ++i)
elements.append(m_associatedElements[i]);
bool hasInvalidControls = false;
for (unsigned i = 0; i < elements.size(); ++i) {
if (elements[i]->form() == this && elements[i]->isFormControlElement()) {
HTMLFormControlElement* control = static_cast<HTMLFormControlElement*>(elements[i].get());
if (!control->checkValidity(&unhandledInvalidControls) && control->form() == this)
hasInvalidControls = true;
}
}
return hasInvalidControls;
}
示例2: createFromHTMLFormControlElement
// https://html.spec.whatwg.org/multipage/forms.html#processing-model-3
AutofillData AutofillData::createFromHTMLFormControlElement(const HTMLFormControlElement& element)
{
static NeverDestroyed<AtomicString> on("on", AtomicString::ConstructFromLiteral);
static NeverDestroyed<AtomicString> off("off", AtomicString::ConstructFromLiteral);
// Label: Default
// 26. Let the element's IDL-exposed autofill value be the empty string, and its autofill hint set and autofill scope be empty.
// 27. If the element's autocomplete attribute is wearing the autofill anchor mantle, then let the element's autofill field name be the empty string and abort these steps.
// 28. Let form be the element's form owner, if any, or null otherwise.
// 29. If form is not null and form's autocomplete attribute is in the off state, then let the element's autofill field name be "off". Otherwise, let the element's autofill field name be "on".
auto defaultLabel = [&] () -> AutofillData {
if (element.autofillMantle() == AutofillMantle::Anchor)
return { emptyString(), emptyString() };
auto form = element.form();
if (form && form->autocomplete() == off)
return { off, emptyString() };
return { on, emptyString() };
};
const AtomicString& attributeValue = element.attributeWithoutSynchronization(HTMLNames::autocompleteAttr);
// 1. If the element has no autocomplete attribute, then jump to the step labeled default.
if (attributeValue == nullAtom)
return defaultLabel();
// 2. Let tokens be the result of splitting the attribute's value on spaces.
SpaceSplitString tokens(attributeValue, true);
// 3. If tokens is empty, then jump to the step labeled default.
if (tokens.isEmpty())
return defaultLabel();
// 4. Let index be the index of the last token in tokens
unsigned index = tokens.size() - 1;
// 5. If the indexth token in tokens is not an ASCII case-insensitive match for one of the
// tokens given in the first column of the following table, or if the number of tokens in
// tokens is greater than the maximum number given in the cell in the second column of that
// token's row, then jump to the step labeled default. Otherwise, let field be the string given
// in the cell of the first column of the matching row, and let category be the value of the
// cell in the third column of that same row.
auto& map = fieldNameMap();
auto it = map.find(tokens[index]);
if (it == map.end())
return defaultLabel();
auto category = it->value.category;
if (tokens.size() > maxTokensForAutofillFieldCategory(category))
return defaultLabel();
const auto& field = tokens[index];
// 6. If category is Off or Automatic but the element's autocomplete attribute is wearing the
// autofill anchor mantle, then jump to the step labeled default.
auto mantle = element.autofillMantle();
if ((category == AutofillCategory::Off || category == AutofillCategory::Automatic) && mantle == AutofillMantle::Anchor)
return defaultLabel();
// 7. If category is Off, let the element's autofill field name be the string "off", let its
// autofill hint set be empty, and let its IDL-exposed autofill value be the string "off".
// Then, abort these steps.
if (category == AutofillCategory::Off)
return { off, off.get().string() };
// 8. If category is Automatic, let the element's autofill field name be the string "on",
// let its autofill hint set be empty, and let its IDL-exposed autofill value be the string
// "on". Then, abort these steps.
if (category == AutofillCategory::Automatic)
return { on, on.get().string() };
// 9. Let scope tokens be an empty list.
// 10. Let hint tokens be an empty set.
// NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
// 11. Let IDL value have the same value as field.
String idlValue = field;
// 12, If the indexth token in tokens is the first entry, then skip to the step labeled done.
if (index == 0)
return { field, idlValue };
// 13. Decrement index by one
index--;
// 14. If category is Contact and the indexth token in tokens is an ASCII case-insensitive match
// for one of the strings in the following list, then run the substeps that follow:
const auto& contactToken = tokens[index];
if (category == AutofillCategory::Contact && isContactToken(contactToken)) {
// 1. Let contact be the matching string from the list above.
const auto& contact = contactToken;
// 2. Insert contact at the start of scope tokens.
// 3. Add contact to hint tokens.
//.........这里部分代码省略.........