V8HTMLInputElementCustom.cpp [plain text]
#include "config.h"
#include "HTMLInputElement.h"
#include "V8Binding.h"
#include "V8CustomBinding.h"
#include "V8Proxy.h"
namespace WebCore {
ACCESSOR_GETTER(HTMLInputElementSelectionStart)
{
INC_STATS("DOM.HTMLInputElement.selectionStart._get");
v8::Handle<v8::Object> holder = info.Holder();
HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder);
if (!imp->canHaveSelection())
return throwError("Accessing selectionStart on an input element that cannot have a selection.");
int v = imp->selectionStart();
return v8::Integer::New(v);
}
ACCESSOR_SETTER(HTMLInputElementSelectionStart)
{
INC_STATS("DOM.HTMLInputElement.selectionStart._set");
v8::Handle<v8::Object> holder = info.Holder();
HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder);
if (!imp->canHaveSelection()) {
throwError("Accessing selectionStart on an input element that cannot have a selection.");
return;
}
imp->setSelectionStart(value->Int32Value());
}
ACCESSOR_GETTER(HTMLInputElementSelectionEnd)
{
INC_STATS("DOM.HTMLInputElement.selectionEnd._get");
v8::Handle<v8::Object> holder = info.Holder();
HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder);
if (!imp->canHaveSelection())
return throwError("Accessing selectionEnd on an input element that cannot have a selection.");
int v = imp->selectionEnd();
return v8::Integer::New(v);
}
ACCESSOR_SETTER(HTMLInputElementSelectionEnd)
{
INC_STATS("DOM.HTMLInputElement.selectionEnd._set");
v8::Handle<v8::Object> holder = info.Holder();
HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder);
if (!imp->canHaveSelection()) {
throwError("Accessing selectionEnd on an input element that cannot have a selection.");
return;
}
imp->setSelectionEnd(value->Int32Value());
}
CALLBACK_FUNC_DECL(HTMLInputElementSetSelectionRange)
{
INC_STATS("DOM.HTMLInputElement.setSelectionRange");
v8::Handle<v8::Object> holder = args.Holder();
HTMLInputElement* imp = V8DOMWrapper::convertDOMWrapperToNode<HTMLInputElement>(holder);
if (!imp->canHaveSelection())
return throwError("Calling setSelectionRange on an input element that cannot have a selection.");
int start = args[0]->Int32Value();
int end = args[1]->Int32Value();
imp->setSelectionRange(start, end);
return v8::Undefined();
}
}