本文整理汇总了C++中HTMLSelectElement::add方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLSelectElement::add方法的具体用法?C++ HTMLSelectElement::add怎么用?C++ HTMLSelectElement::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLSelectElement
的用法示例。
在下文中一共展示了HTMLSelectElement::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: add
void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index, ExceptionState& exceptionState)
{
HTMLOptionElement* newOption = element.get();
if (!newOption) {
exceptionState.throwTypeError("The element provided was not an HTMLOptionElement.");
return;
}
if (index < -1) {
exceptionState.throwDOMException(IndexSizeError, "The index provided (" + String::number(index) + ") is less than -1.");
return;
}
HTMLSelectElement* select = toHTMLSelectElement(ownerNode());
if (index == -1 || unsigned(index) >= length())
select->add(newOption, 0, exceptionState);
else
select->add(newOption, toHTMLOptionElement(item(index)), exceptionState);
ASSERT(!exceptionState.hadException());
}
示例2: add
void HTMLOptionsCollection::add(PassRefPtr<HTMLOptionElement> element, int index, ExceptionCode &ec)
{
HTMLOptionElement* newOption = element.get();
if (!newOption) {
ec = TYPE_MISMATCH_ERR;
return;
}
if (index < -1) {
ec = INDEX_SIZE_ERR;
return;
}
ec = 0;
HTMLSelectElement* select = static_cast<HTMLSelectElement*>(m_base.get());
if (index == -1 || unsigned(index) >= length())
select->add(newOption, 0, ec);
else
select->add(newOption, static_cast<HTMLOptionElement*>(item(index)), ec);
ASSERT(ec == 0);
}
示例3: addCallback
static v8::Handle<v8::Value> addCallback(const v8::Arguments& args)
{
INC_STATS("DOM.HTMLSelectElement.add");
HTMLSelectElement* imp = V8HTMLSelectElement::toNative(args.Holder());
ExceptionCode ec = 0;
{
EXCEPTION_BLOCK(HTMLElement*, element, V8HTMLElement::HasInstance(args[0]) ? V8HTMLElement::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0);
EXCEPTION_BLOCK(HTMLElement*, before, V8HTMLElement::HasInstance(args[1]) ? V8HTMLElement::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
imp->add(element, before, ec);
if (UNLIKELY(ec))
goto fail;
return v8::Handle<v8::Value>();
}
fail:
V8Proxy::setDOMException(ec);
return v8::Handle<v8::Value>();
}
示例4: jsHTMLSelectElementPrototypeFunctionAdd
EncodedJSValue JSC_HOST_CALL jsHTMLSelectElementPrototypeFunctionAdd(ExecState* exec)
{
JSValue thisValue = exec->hostThisValue();
if (!thisValue.inherits(&JSHTMLSelectElement::s_info))
return throwVMTypeError(exec);
JSHTMLSelectElement* castedThis = static_cast<JSHTMLSelectElement*>(asObject(thisValue));
HTMLSelectElement* imp = static_cast<HTMLSelectElement*>(castedThis->impl());
ExceptionCode ec = 0;
HTMLElement* element(toHTMLElement(exec->argument(0)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
HTMLElement* before(toHTMLElement(exec->argument(1)));
if (exec->hadException())
return JSValue::encode(jsUndefined());
imp->add(element, before, ec);
setDOMException(exec, ec);
return JSValue::encode(jsUndefined());
}