Пример #1
0
void JSHTMLInputElement::setSelectionEnd(ExecState* exec, JSValue value)
{
    HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
    if (!input->canHaveSelection())
        throwTypeError(exec);

    input->setSelectionEnd(value.toInt32(exec));
}
Пример #2
0
JSValue JSHTMLInputElement::selectionDirection(ExecState* exec) const
{
    HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
    if (!input->canHaveSelection())
        return throwTypeError(exec);

    return jsString(exec, input->selectionDirection());
}
JSValue JSHTMLInputElement::selectionEnd(ExecState* exec) const
{
    HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
    if (!input->canHaveSelection())
        return throwError(exec, TypeError);

    return jsNumber(exec, input->selectionEnd());
}
Пример #4
0
void JSHTMLInputElement::setSelectionDirection(ExecState* exec, JSValue value)
{
    HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
    if (!input->canHaveSelection()) {
        throwTypeError(exec);
        return;
    }

    input->setSelectionDirection(ustringToString(value.toString(exec)));
}
v8::Handle<v8::Value> V8HTMLInputElement::selectionDirectionAttrGetterCustom(v8::Local<v8::String> name, const v8::AccessorInfo& info)
{
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);

    if (!imp->canHaveSelection())
        return throwTypeError("Accessing selectionDirection on an input element that cannot have a selection.", info.GetIsolate());

    return v8String(imp->selectionDirection(), info.GetIsolate());
}
void V8HTMLInputElement::selectionStartAttrSetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    v8::Handle<v8::Object> holder = info.Holder();
    HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);

    if (!imp->canHaveSelection()) {
        throwTypeError("Accessing selectionStart on an input element that cannot have a selection.", info.GetIsolate());
        return;
    }
    imp->setSelectionStart(value->Int32Value());
}
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();
}
JSValue JSHTMLInputElement::setSelectionRange(ExecState* exec, const ArgList& args)
{
    HTMLInputElement* input = static_cast<HTMLInputElement*>(impl());
    if (!input->canHaveSelection())
        return throwError(exec, TypeError);

    int start = args.at(0).toInt32(exec);
    int end = args.at(1).toInt32(exec);

    input->setSelectionRange(start, end);
    return jsUndefined();
}
v8::Handle<v8::Value> V8HTMLInputElement::setSelectionRangeMethodCustom(const v8::Arguments& args)
{
    v8::Handle<v8::Object> holder = args.Holder();
    HTMLInputElement* imp = V8HTMLInputElement::toNative(holder);

    if (!imp->canHaveSelection())
        return throwTypeError("Calling setSelectionRange on an input element that cannot have a selection.", args.GetIsolate());

    int start = args[0]->Int32Value();
    int end = args[1]->Int32Value();
    String direction = toWebCoreString(args[2]);

    imp->setSelectionRange(start, end, direction);
    return v8::Undefined();
}
v8::Handle<v8::Value> V8HTMLInputElement::setSelectionRangeCallback(const v8::Arguments& args)
{
    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();
}