/* * Copyright (C) 2006 Nikolas Zimmermann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "config.h" #if ENABLE(SVG) #include "JSSVGPointList.h" #include "Document.h" #include "Frame.h" #include "JSSVGPoint.h" #include "SVGDocumentExtensions.h" #include "SVGPointList.h" #include "SVGStyledElement.h" #include using namespace KJS; namespace WebCore { JSValue* JSSVGPointList::clear(ExecState* exec, const List&) { ExceptionCode ec = 0; SVGPointList* imp = static_cast(impl()); imp->clear(ec); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return jsUndefined(); } JSValue* JSSVGPointList::initialize(ExecState* exec, const List& args) { ExceptionCode ec = 0; FloatPoint newItem = toSVGPoint(args[0]); SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; SVGPODListItem* listItem = listImp->initialize(new SVGPODListItem(newItem), ec).get(); JSSVGPODTypeWrapperCreatorForList* obj = new JSSVGPODTypeWrapperCreatorForList(listItem, imp); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return result; } JSValue* JSSVGPointList::getItem(ExecState* exec, const List& args) { ExceptionCode ec = 0; bool indexOk; unsigned index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; SVGPODListItem* listItem = listImp->getItem(index, ec).get(); JSSVGPODTypeWrapperCreatorForList* obj = new JSSVGPODTypeWrapperCreatorForList(listItem, imp); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); return result; } JSValue* JSSVGPointList::insertItemBefore(ExecState* exec, const List& args) { ExceptionCode ec = 0; FloatPoint newItem = toSVGPoint(args[0]); bool indexOk; unsigned index = args[1]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; SVGPODListItem* listItem = listImp->insertItemBefore(new SVGPODListItem(newItem), index, ec).get(); JSSVGPODTypeWrapperCreatorForList* obj = new JSSVGPODTypeWrapperCreatorForList(listItem, imp); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return result; } JSValue* JSSVGPointList::replaceItem(ExecState* exec, const List& args) { ExceptionCode ec = 0; FloatPoint newItem = toSVGPoint(args[0]); bool indexOk; unsigned index = args[1]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; SVGPODListItem* listItem = listImp->replaceItem(new SVGPODListItem(newItem), index, ec).get(); JSSVGPODTypeWrapperCreatorForList* obj = new JSSVGPODTypeWrapperCreatorForList(listItem, imp); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return result; } JSValue* JSSVGPointList::removeItem(ExecState* exec, const List& args) { ExceptionCode ec = 0; bool indexOk; unsigned index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; RefPtr > listItem(listImp->removeItem(index, ec)); JSSVGPODTypeWrapper* obj = new JSSVGPODTypeWrapper((FloatPoint&) *listItem.get()); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return result; } JSValue* JSSVGPointList::appendItem(ExecState* exec, const List& args) { ExceptionCode ec = 0; FloatPoint newItem = toSVGPoint(args[0]); SVGPointList* imp = static_cast(impl()); SVGList > >* listImp = imp; SVGPODListItem* listItem = listImp->appendItem(new SVGPODListItem(newItem), ec).get(); JSSVGPODTypeWrapperCreatorForList* obj = new JSSVGPODTypeWrapperCreatorForList(listItem, imp); KJS::JSValue* result = toJS(exec, obj); setDOMException(exec, ec); ASSERT(imp->context()); imp->context()->notifyAttributeChange(); return result; } } #endif // ENABLE(SVG) // vim:ts=4:noet