2 * Copyright (C) 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
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., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
21 #include "wtf/Platform.h"
24 #include "JSSVGPathSegList.h"
28 #include "JSSVGPathSeg.h"
29 #include "SVGDocumentExtensions.h"
30 #include "SVGElement.h"
31 #include "SVGPathSegList.h"
33 #include <wtf/Assertions.h>
40 KJS::JSValue
* JSSVGPathSegList::clear(ExecState
* exec
, const List
& args
)
44 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
47 setDOMException(exec
, ec
);
49 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
53 KJS::JSValue
* JSSVGPathSegList::initialize(ExecState
* exec
, const List
& args
)
56 SVGPathSeg
* newItem
= toSVGPathSeg(args
[0]);
58 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
60 SVGPathSeg
* obj
= WTF::getPtr(imp
->initialize(newItem
, ec
));
62 KJS::JSValue
* result
= toJS(exec
, obj
, m_context
.get());
63 setDOMException(exec
, ec
);
65 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
69 KJS::JSValue
* JSSVGPathSegList::getItem(ExecState
* exec
, const List
& args
)
74 unsigned index
= args
[0]->toInt32(exec
, indexOk
);
76 setDOMException(exec
, DOMException::TYPE_MISMATCH_ERR
);
80 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
81 SVGPathSeg
* obj
= WTF::getPtr(imp
->getItem(index
, ec
));
83 KJS::JSValue
* result
= toJS(exec
, obj
, m_context
.get());
84 setDOMException(exec
, ec
);
88 KJS::JSValue
* JSSVGPathSegList::insertItemBefore(ExecState
* exec
, const List
& args
)
91 SVGPathSeg
* newItem
= toSVGPathSeg(args
[0]);
94 unsigned index
= args
[1]->toInt32(exec
, indexOk
);
96 setDOMException(exec
, DOMException::TYPE_MISMATCH_ERR
);
100 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
102 KJS::JSValue
* result
= toJS(exec
, WTF::getPtr(imp
->insertItemBefore(newItem
, index
, ec
)), m_context
.get());
103 setDOMException(exec
, ec
);
105 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
109 KJS::JSValue
* JSSVGPathSegList::replaceItem(ExecState
* exec
, const List
& args
)
111 ExceptionCode ec
= 0;
112 SVGPathSeg
* newItem
= toSVGPathSeg(args
[0]);
115 unsigned index
= args
[1]->toInt32(exec
, indexOk
);
117 setDOMException(exec
, DOMException::TYPE_MISMATCH_ERR
);
118 return jsUndefined();
121 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
123 KJS::JSValue
* result
= toJS(exec
, WTF::getPtr(imp
->replaceItem(newItem
, index
, ec
)), m_context
.get());
124 setDOMException(exec
, ec
);
126 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
130 KJS::JSValue
* JSSVGPathSegList::removeItem(ExecState
* exec
, const List
& args
)
132 ExceptionCode ec
= 0;
135 unsigned index
= args
[0]->toInt32(exec
, indexOk
);
137 setDOMException(exec
, DOMException::TYPE_MISMATCH_ERR
);
138 return jsUndefined();
141 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
143 RefPtr
<SVGPathSeg
> obj(imp
->removeItem(index
, ec
));
145 KJS::JSValue
* result
= toJS(exec
, obj
.get(), m_context
.get());
146 setDOMException(exec
, ec
);
148 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
152 KJS::JSValue
* JSSVGPathSegList::appendItem(ExecState
* exec
, const List
& args
)
154 ExceptionCode ec
= 0;
155 SVGPathSeg
* newItem
= toSVGPathSeg(args
[0]);
157 SVGPathSegList
* imp
= static_cast<SVGPathSegList
*>(impl());
159 KJS::JSValue
* result
= toJS(exec
, WTF::getPtr(imp
->appendItem(newItem
, ec
)), m_context
.get());
160 setDOMException(exec
, ec
);
162 m_context
->svgAttributeChanged(imp
->associatedAttributeName());
168 #endif // ENABLE(SVG)