JSHTMLSelectElementCustom.cpp [plain text]
#include "config.h"
#include "JSHTMLSelectElementCustom.h"
#include "ExceptionCode.h"
#include "HTMLNames.h"
#include "HTMLOptionElement.h"
#include "HTMLSelectElement.h"
#include "JSHTMLOptionElement.h"
#include "kjs_html.h"
namespace WebCore {
using namespace KJS;
using namespace HTMLNames;
JSValue* JSHTMLSelectElement::remove(ExecState* exec, const List& args)
{
HTMLSelectElement& select = *static_cast<HTMLSelectElement*>(impl());
HTMLElement* element = toHTMLElement(args[0]);
if (element && element->hasTagName(optionTag))
select.remove(static_cast<HTMLOptionElement*>(element)->index());
else
select.remove(args[0]->toInt32(exec));
return jsUndefined();
}
void selectIndexSetter(HTMLSelectElement* select, KJS::ExecState* exec, unsigned index, KJS::JSValue* value)
{
if (value->isUndefinedOrNull())
select->remove(index);
else {
ExceptionCode ec = 0;
HTMLOptionElement* option = toHTMLOptionElement(value);
if (!option)
ec = TYPE_MISMATCH_ERR;
else
select->setOption(index, option, ec);
setDOMException(exec, ec);
}
}
void JSHTMLSelectElement::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value, int attr)
{
selectIndexSetter(static_cast<HTMLSelectElement*>(impl()), exec, index, value);
}
}