本文整理汇总了C++中HTMLFormElement类的典型用法代码示例。如果您正苦于以下问题:C++ HTMLFormElement类的具体用法?C++ HTMLFormElement怎么用?C++ HTMLFormElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTMLFormElement类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nameGetter
JSValue JSHTMLFormElement::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
{
JSHTMLElement* jsForm = static_cast<JSHTMLFormElement*>(asObject(slotBase));
HTMLFormElement* form = static_cast<HTMLFormElement*>(jsForm->impl());
Vector<RefPtr<Node> > namedItems;
form->getNamedElements(identifierToAtomicString(propertyName), namedItems);
if (namedItems.isEmpty())
return jsUndefined();
if (namedItems.size() == 1)
return toJS(exec, jsForm->globalObject(), namedItems[0].get());
// FIXME: HTML5 specifies that this should be a RadioNodeList.
return toJS(exec, jsForm->globalObject(), StaticNodeList::adopt(namedItems).get());
}
示例2: TEST_F
TEST_F(HTMLSelectElementTest, DefaultToolTip) {
document().documentElement()->setInnerHTML(
"<select size=4><option value="
">Placeholder</option><optgroup><option>o2</option></optgroup></select>",
ASSERT_NO_EXCEPTION);
document().view()->updateAllLifecyclePhases();
HTMLSelectElement* select =
toHTMLSelectElement(document().body()->firstChild());
Element* option = toElement(select->firstChild());
Element* optgroup = toElement(option->nextSibling());
EXPECT_EQ(String(), select->defaultToolTip())
<< "defaultToolTip for SELECT without FORM and without required "
"attribute should return null string.";
EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
select->setBooleanAttribute(HTMLNames::requiredAttr, true);
EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip())
<< "defaultToolTip for SELECT without FORM and with required attribute "
"should return a valueMissing message.";
EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
HTMLFormElement* form = HTMLFormElement::create(document());
document().body()->appendChild(form);
form->appendChild(select);
EXPECT_EQ("<<ValidationValueMissingForSelect>>", select->defaultToolTip())
<< "defaultToolTip for SELECT with FORM and required attribute should "
"return a valueMissing message.";
EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
form->setBooleanAttribute(HTMLNames::novalidateAttr, true);
EXPECT_EQ(String(), select->defaultToolTip())
<< "defaultToolTip for SELECT with FORM[novalidate] and required "
"attribute should return null string.";
EXPECT_EQ(select->defaultToolTip(), option->defaultToolTip());
EXPECT_EQ(select->defaultToolTip(), optgroup->defaultToolTip());
option->remove();
optgroup->remove();
EXPECT_EQ(String(), option->defaultToolTip());
EXPECT_EQ(String(), optgroup->defaultToolTip());
}
示例3: throwError
JSValue* JSHTMLFormElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
if (!thisObj->inherits(&JSHTMLFormElement::info))
return throwError(exec, TypeError);
HTMLFormElement* imp = static_cast<HTMLFormElement*>(static_cast<JSHTMLFormElement*>(thisObj)->impl());
switch (id) {
case JSHTMLFormElement::SubmitFuncNum: {
imp->submit();
return jsUndefined();
}
case JSHTMLFormElement::ResetFuncNum: {
imp->reset();
return jsUndefined();
}
}
return 0;
}
示例4: formSignature
static inline String formSignature(const HTMLFormElement& form)
{
URL actionURL = form.getURLAttribute(actionAttr);
// Remove the query part because it might contain volatile parameters such
// as a session key.
actionURL.setQuery(String());
StringBuilder builder;
if (!actionURL.isEmpty())
builder.append(actionURL.string());
recordFormStructure(form, builder);
return builder.toString();
}
示例5: findFormAncestor
void HTMLImageElement::resetFormOwner()
{
m_formWasSetByParser = false;
HTMLFormElement* nearestForm = findFormAncestor();
if (m_form) {
if (nearestForm == m_form.get())
return;
m_form->disassociate(*this);
}
if (nearestForm) {
#if ENABLE(OILPAN)
m_form = nearestForm;
#else
m_form = nearestForm->createWeakPtr();
#endif
m_form->associate(*this);
} else {
#if ENABLE(OILPAN)
m_form = nullptr;
#else
m_form = WeakPtr<HTMLFormElement>();
#endif
}
}
示例6: restoreControlStateIn
void FormController::restoreControlStateIn(HTMLFormElement& form)
{
for (auto& element : form.associatedElements()) {
if (!element->isFormControlElementWithState())
continue;
HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(element);
if (!control->shouldSaveAndRestoreFormControlState())
continue;
if (ownerFormForState(*control) != &form)
continue;
FormControlState state = takeStateForFormElement(*control);
if (state.valueSize() > 0)
control->restoreFormControlState(state);
}
}
示例7: restoreControlStateIn
void FormController::restoreControlStateIn(HTMLFormElement& form)
{
const Vector<FormAssociatedElement*>& elements = form.associatedElements();
for (size_t i = 0; i < elements.size(); ++i) {
if (!elements[i]->isFormControlElementWithState())
continue;
HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(elements[i]);
if (!control->shouldSaveAndRestoreFormControlState())
continue;
if (ownerFormForState(*control) != &form)
continue;
FormControlState state = takeStateForFormElement(*control);
if (state.valueSize() > 0)
control->restoreFormControlState(state);
}
}
示例8: recordFormStructure
static inline void recordFormStructure(const HTMLFormElement& form, StringBuilder& builder)
{
// 2 is enough to distinguish forms in webkit.org/b/91209#c0
const size_t namedControlsToBeRecorded = 2;
const Vector<FormAssociatedElement*>& controls = form.associatedElements();
builder.appendLiteral(" [");
for (size_t i = 0, namedControls = 0; i < controls.size() && namedControls < namedControlsToBeRecorded; ++i) {
if (!controls[i]->isFormControlElementWithState())
continue;
HTMLFormControlElementWithState* control = static_cast<HTMLFormControlElementWithState*>(controls[i]);
if (!ownerFormForState(*control))
continue;
AtomicString name = control->name();
if (name.isEmpty())
continue;
namedControls++;
builder.append(name);
builder.append(' ');
}
builder.append(']');
}
示例9: switch
void JSHTMLFormElement::putValueProperty(ExecState* exec, int token, JSValue* value)
{
switch (token) {
case NameAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setName(valueToStringWithNullCheck(exec, value));
break;
}
case AcceptCharsetAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setAcceptCharset(valueToStringWithNullCheck(exec, value));
break;
}
case ActionAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setAction(valueToStringWithNullCheck(exec, value));
break;
}
case EncodingAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setEncoding(valueToStringWithNullCheck(exec, value));
break;
}
case EnctypeAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setEnctype(valueToStringWithNullCheck(exec, value));
break;
}
case MethodAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setMethod(valueToStringWithNullCheck(exec, value));
break;
}
case TargetAttrNum: {
HTMLFormElement* imp = static_cast<HTMLFormElement*>(impl());
imp->setTarget(valueToStringWithNullCheck(exec, value));
break;
}
}
}
示例10: setJSHTMLFormElementTarget
void setJSHTMLFormElementTarget(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLFormElement* castedThisObj = static_cast<JSHTMLFormElement*>(thisObject);
HTMLFormElement* imp = static_cast<HTMLFormElement*>(castedThisObj->impl());
imp->setTarget(valueToStringWithNullCheck(exec, value));
}
示例11: setJSHTMLFormElementNoValidate
void setJSHTMLFormElementNoValidate(ExecState* exec, JSObject* thisObject, JSValue value)
{
JSHTMLFormElement* castedThisObj = static_cast<JSHTMLFormElement*>(thisObject);
HTMLFormElement* imp = static_cast<HTMLFormElement*>(castedThisObj->impl());
imp->setNoValidate(value.toBoolean(exec));
}
示例12: setJSHTMLFormElementMethod
void setJSHTMLFormElementMethod(ExecState* exec, JSObject* thisObject, JSValue value)
{
HTMLFormElement* imp = static_cast<HTMLFormElement*>(static_cast<JSHTMLFormElement*>(thisObject)->impl());
imp->setMethod(valueToStringWithNullCheck(exec, value));
}