This source file includes following definitions.
- addMethodCustom
- lengthAttributeSetterCustom
#include "config.h"
#include "V8HTMLOptionsCollection.h"
#include "V8HTMLOptionElement.h"
#include "V8Node.h"
#include "V8NodeList.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/V8Binding.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NamedNodesCollection.h"
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLOptionsCollection.h"
#include "core/html/HTMLSelectElement.h"
namespace WebCore {
void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTMLOptionsCollection", info.Holder(), info.GetIsolate());
if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate())) {
exceptionState.throwTypeError("The element provided was not an HTMLOptionElement.");
} else {
HTMLOptionsCollection* impl = V8HTMLOptionsCollection::toNative(info.Holder());
HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0])));
if (info.Length() < 2) {
impl->add(option, exceptionState);
} else {
int index = toInt32(info[1], exceptionState);
if (exceptionState.throwIfNeeded())
return;
impl->add(option, index, exceptionState);
}
}
exceptionState.throwIfNeeded();
}
void V8HTMLOptionsCollection::lengthAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
{
HTMLOptionsCollection* impl = 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;
impl->setLength(newLength, exceptionState);
}
}