本文整理汇总了C++中HTMLOptionsCollection::setLength方法的典型用法代码示例。如果您正苦于以下问题:C++ HTMLOptionsCollection::setLength方法的具体用法?C++ HTMLOptionsCollection::setLength怎么用?C++ HTMLOptionsCollection::setLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTMLOptionsCollection
的用法示例。
在下文中一共展示了HTMLOptionsCollection::setLength方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setLength
void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue value)
{
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
ExceptionCode ec = 0;
unsigned newLength = 0;
double lengthValue = value.toNumber(exec);
if (!isnan(lengthValue) && !isinf(lengthValue)) {
if (lengthValue < 0.0)
ec = INDEX_SIZE_ERR;
else if (lengthValue > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
newLength = static_cast<unsigned>(lengthValue);
}
if (!ec)
imp->setLength(newLength, ec);
setDOMException(exec, ec);
}
示例2: if
void V8HTMLOptionsCollection::lengthAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
double v = value->NumberValue();
unsigned newLength = 0;
ExceptionCode ec = 0;
if (!std::isnan(v) && !std::isinf(v)) {
if (v < 0.0)
ec = INDEX_SIZE_ERR;
else if (v > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
newLength = static_cast<unsigned>(v);
}
if (!ec)
imp->setLength(newLength, ec);
setDOMException(ec, info.GetIsolate());
}
示例3: if
void V8HTMLOptionsCollection::lengthAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
INC_STATS("DOM.HTMLOptionsCollection.length._set");
HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
double v = value->NumberValue();
unsigned newLength = 0;
ExceptionCode ec = 0;
if (!isnan(v) && !isinf(v)) {
if (v < 0.0)
ec = INDEX_SIZE_ERR;
else if (v > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
newLength = static_cast<unsigned>(v);
}
if (!ec)
imp->setLength(newLength, ec);
setDOMException(ec, info.GetIsolate());
}
示例4: exceptionState
void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
double v = value->NumberValue();
unsigned newLength = 0;
ExceptionState exceptionState(ExceptionState::SetterContext, "length", "HTMLOptionsCollection", info.Holder(), info.GetIsolate());
if (!std::isnan(v) && !std::isinf(v)) {
if (v < 0.0)
exceptionState.throwDOMException(IndexSizeError, "The value provided (" + String::number(v) + ") is negative. Lengths must be greater than or equal to 0.");
else if (v > static_cast<double>(UINT_MAX))
newLength = UINT_MAX;
else
newLength = static_cast<unsigned>(v);
}
if (exceptionState.throwIfNeeded())
return;
imp->setLength(newLength, exceptionState);
}