JSHTMLInputElementBase.cpp [plain text]
#include "config.h"
#include "JSHTMLInputElementBase.h"
#include "HTMLInputElement.h"
#include "JSHTMLInputElementBaseTable.cpp"
using namespace KJS;
namespace WebCore {
KJS_IMPLEMENT_PROTOTYPE("JSHTMLInputElementBase", JSHTMLInputElementBasePrototype)
JSValue* jsHTMLInputElementBaseFunctionSetSelectionRange(ExecState* exec, JSObject* thisObj, const List& args)
{
HTMLInputElement& input = *static_cast<HTMLInputElement*>(static_cast<JSHTMLInputElementBase*>(thisObj)->impl());
input.setSelectionRange(args[0]->toInt32(exec), args[1]->toInt32(exec));
return jsUndefined();
}
const ClassInfo JSHTMLInputElementBase::info = { "JSHTMLInputElementBase", &JSHTMLElement::info, &JSHTMLInputElementBaseTable };
JSHTMLInputElementBase::JSHTMLInputElementBase(KJS::JSObject* prototype, PassRefPtr<HTMLInputElement> e)
: JSHTMLElement(prototype, e.get())
{
}
bool JSHTMLInputElementBase::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
HTMLInputElement& input = *static_cast<HTMLInputElement*>(impl());
if (!input.canHaveSelection())
return JSHTMLElement::getOwnPropertySlot(exec, propertyName, slot);
const HashEntry* entry = Lookup::findEntry(&JSHTMLInputElementBaseFunctionTable, propertyName);
if (entry && (entry->attr & KJS::Function) && entry->value.functionValue == jsHTMLInputElementBaseFunctionSetSelectionRange) {
slot.setStaticEntry(this, entry, staticFunctionGetter);
return true;
}
ASSERT(!entry);
return getStaticValueSlot<JSHTMLInputElementBase, JSHTMLElement>(exec, &JSHTMLInputElementBaseTable, this, propertyName, slot);
}
JSValue* JSHTMLInputElementBase::getValueProperty(ExecState* exec, int token) const
{
HTMLInputElement& input = *static_cast<HTMLInputElement*>(impl());
ASSERT(input.canHaveSelection());
switch (token) {
case SelectionStart:
return jsNumber(input.selectionStart());
case SelectionEnd:
return jsNumber(input.selectionEnd());
}
ASSERT_NOT_REACHED();
return jsUndefined();
}
void JSHTMLInputElementBase::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr)
{
lookupPut<JSHTMLInputElementBase, JSHTMLElement>(exec, propertyName, value, attr, &JSHTMLInputElementBaseTable, this);
}
void JSHTMLInputElementBase::putValueProperty(ExecState* exec, int token, JSValue* value, int )
{
HTMLInputElement& input = *static_cast<HTMLInputElement*>(impl());
ASSERT(input.canHaveSelection());
switch (token) {
case SelectionStart:
input.setSelectionStart(value->toInt32(exec));
return;
case SelectionEnd:
input.setSelectionEnd(value->toInt32(exec));
return;
}
ASSERT_NOT_REACHED();
}
}