JSHTMLInputElementCustom.cpp [plain text]
#include "config.h"
#include "JSHTMLInputElement.h"
#include "HTMLInputElement.h"
#include <runtime/Error.h>
using namespace JSC;
namespace WebCore {
JSValue JSHTMLInputElement::selectionStart(ExecState* exec) const
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
if (!input->canHaveSelection())
return throwTypeError(exec);
return jsNumber(input->selectionStart());
}
void JSHTMLInputElement::setSelectionStart(ExecState* exec, JSValue value)
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
if (!input->canHaveSelection())
throwTypeError(exec);
input->setSelectionStart(value.toInt32(exec));
}
JSValue JSHTMLInputElement::selectionEnd(ExecState* exec) const
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
if (!input->canHaveSelection())
return throwTypeError(exec);
return jsNumber(input->selectionEnd());
}
void JSHTMLInputElement::setSelectionEnd(ExecState* exec, JSValue value)
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
if (!input->canHaveSelection())
throwTypeError(exec);
input->setSelectionEnd(value.toInt32(exec));
}
JSValue JSHTMLInputElement::setSelectionRange(ExecState* exec)
{
HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
if (!input->canHaveSelection())
return throwTypeError(exec);
int start = exec->argument(0).toInt32(exec);
int end = exec->argument(1).toInt32(exec);
input->setSelectionRange(start, end);
return jsUndefined();
}
}