2
* Copyright (C) 2006 Apple Computer, Inc.
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
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.
21
#include "JSHTMLOptionsCollection.h"
23
#include "ExceptionCode.h"
24
#include "HTMLNames.h"
25
#include "HTMLOptionElement.h"
26
#include "HTMLOptionsCollection.h"
27
#include "HTMLSelectElement.h"
28
#include "JSHTMLOptionElement.h"
29
#include "JSHTMLSelectElementCustom.h"
31
#include <kjs/operations.h>
37
JSValue* JSHTMLOptionsCollection::length(ExecState* exec) const
39
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
40
return jsNumber(imp->length());
43
void JSHTMLOptionsCollection::setLength(ExecState* exec, JSValue* value)
45
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
47
unsigned newLength = 0;
48
double lengthValue = value->getNumber();
49
if (!isNaN(lengthValue) && !isInf(lengthValue)) {
50
if (lengthValue < 0.0)
52
else if (lengthValue > static_cast<double>(UINT_MAX))
55
newLength = static_cast<unsigned>(lengthValue);
58
imp->setLength(newLength, ec);
59
setDOMException(exec, ec);
62
void JSHTMLOptionsCollection::indexSetter(KJS::ExecState* exec, unsigned index, KJS::JSValue* value, int attr)
64
HTMLOptionsCollection* imp = static_cast<HTMLOptionsCollection*>(impl());
65
HTMLSelectElement* base = static_cast<HTMLSelectElement*>(imp->base());
66
selectIndexSetter(base, exec, index, value);