2
* Copyright (C) 2006 Apple Computer, Inc.
2
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4
4
* This library is free software; you can redistribute it and/or
5
5
* modify it under the terms of the GNU Library General Public
14
14
* You should have received a copy of the GNU Library General Public License
15
15
* along with this library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
16
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
20
#include "config.h"
26
26
#include "HTMLOptionsCollection.h"
27
27
#include "HTMLSelectElement.h"
28
28
#include "JSHTMLOptionElement.h"
29
#include "JSHTMLSelectElement.h"
29
30
#include "JSHTMLSelectElementCustom.h"
31
#include <kjs/operations.h>
32
#include <wtf/MathExtras.h>
33
34
using namespace KJS;
45
46
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
46
47
ExceptionCode ec = 0;
47
48
unsigned newLength = 0;
48
double lengthValue = value->getNumber();
49
if (!isNaN(lengthValue) && !isInf(lengthValue)) {
49
double lengthValue = value->toNumber(exec);
50
if (!isnan(lengthValue) && !isinf(lengthValue)) {
50
51
if (lengthValue < 0.0)
51
52
ec = INDEX_SIZE_ERR;
52
53
else if (lengthValue > static_cast<double>(UINT_MAX))
59
60
setDOMException(exec, ec);
62
void JSHTMLOptionsCollection::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value, int attr)
63
void JSHTMLOptionsCollection::indexSetter(ExecState* exec, unsigned index, JSValue* value)
64
65
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
65
66
HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
66
67
selectIndexSetter(base, exec, index, value);
70
JSValue* JSHTMLOptionsCollection::add(ExecState* exec, const List& args)
72
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
73
HTMLOptionElement* option = toHTMLOptionElement(args[0]);
79
int index = args[1]->toInt32(exec, ok);
80
if (exec->hadException())
83
ec = TYPE_MISMATCH_ERR;
85
imp->add(option, index, ec);
87
setDOMException(exec, ec);
91
JSValue* JSHTMLOptionsCollection::remove(ExecState* exec, const List& args)
93
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
94
JSHTMLSelectElement* base = static_cast<JSHTMLSelectElement*>(toJS(exec, imp->base()));
95
return base->remove(exec, args);