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"
namespace WebCore {
using namespace JSC;
using namespace HTMLNames;
JSValue JSHTMLSelectElement::remove(ExecState& state)
{
HTMLSelectElement& select = wrapped();
if (!state.argumentCount()) {
ExceptionCode ec = 0;
select.remove(ec);
setDOMException(&state, ec);
} else {
if (HTMLOptionElement* option = JSHTMLOptionElement::toWrapped(state.argument(0)))
select.remove(*option);
else
select.removeByIndex(state.argument(0).toInt32(&state));
}
return jsUndefined();
}
void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value)
{
if (value.isUndefinedOrNull())
select->removeByIndex(index);
else {
ExceptionCode ec = 0;
HTMLOptionElement* option = JSHTMLOptionElement::toWrapped(value);
if (!option)
ec = TYPE_MISMATCH_ERR;
else
select->setOption(index, *option, ec);
setDOMException(exec, ec);
}
}
void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value)
{
selectIndexSetter(&wrapped(), exec, index, value);
}
}