KHTML
JSSVGPathSegListCustom.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "config.h"
00021 #include "wtf/Platform.h"
00022
00023 #if ENABLE(SVG)
00024 #include "JSSVGPathSegList.h"
00025
00026 #include "Document.h"
00027 #include "Frame.h"
00028 #include "JSSVGPathSeg.h"
00029 #include "SVGDocumentExtensions.h"
00030 #include "SVGElement.h"
00031 #include "SVGPathSegList.h"
00032
00033 #include <wtf/Assertions.h>
00034
00035 using namespace KJS;
00036 using namespace DOM;
00037
00038 namespace khtml {
00039
00040 KJS::JSValue* JSSVGPathSegList::clear(ExecState* exec, const List& args)
00041 {
00042 ExceptionCode ec = 0;
00043
00044 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00045 imp->clear(ec);
00046
00047 setDOMException(exec, ec);
00048
00049 m_context->svgAttributeChanged(imp->associatedAttributeName());
00050 return jsUndefined();
00051 }
00052
00053 KJS::JSValue* JSSVGPathSegList::initialize(ExecState* exec, const List& args)
00054 {
00055 ExceptionCode ec = 0;
00056 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
00057
00058 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00059
00060 SVGPathSeg* obj = WTF::getPtr(imp->initialize(newItem, ec));
00061
00062 KJS::JSValue* result = toJS(exec, obj, m_context.get());
00063 setDOMException(exec, ec);
00064
00065 m_context->svgAttributeChanged(imp->associatedAttributeName());
00066 return result;
00067 }
00068
00069 KJS::JSValue* JSSVGPathSegList::getItem(ExecState* exec, const List& args)
00070 {
00071 ExceptionCode ec = 0;
00072
00073 bool indexOk;
00074 unsigned index = args[0]->toInt32(exec, indexOk);
00075 if (!indexOk) {
00076 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
00077 return jsUndefined();
00078 }
00079
00080 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00081 SVGPathSeg* obj = WTF::getPtr(imp->getItem(index, ec));
00082
00083 KJS::JSValue* result = toJS(exec, obj, m_context.get());
00084 setDOMException(exec, ec);
00085 return result;
00086 }
00087
00088 KJS::JSValue* JSSVGPathSegList::insertItemBefore(ExecState* exec, const List& args)
00089 {
00090 ExceptionCode ec = 0;
00091 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
00092
00093 bool indexOk;
00094 unsigned index = args[1]->toInt32(exec, indexOk);
00095 if (!indexOk) {
00096 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
00097 return jsUndefined();
00098 }
00099
00100 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00101
00102 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertItemBefore(newItem, index, ec)), m_context.get());
00103 setDOMException(exec, ec);
00104
00105 m_context->svgAttributeChanged(imp->associatedAttributeName());
00106 return result;
00107 }
00108
00109 KJS::JSValue* JSSVGPathSegList::replaceItem(ExecState* exec, const List& args)
00110 {
00111 ExceptionCode ec = 0;
00112 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
00113
00114 bool indexOk;
00115 unsigned index = args[1]->toInt32(exec, indexOk);
00116 if (!indexOk) {
00117 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
00118 return jsUndefined();
00119 }
00120
00121 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00122
00123 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->replaceItem(newItem, index, ec)), m_context.get());
00124 setDOMException(exec, ec);
00125
00126 m_context->svgAttributeChanged(imp->associatedAttributeName());
00127 return result;
00128 }
00129
00130 KJS::JSValue* JSSVGPathSegList::removeItem(ExecState* exec, const List& args)
00131 {
00132 ExceptionCode ec = 0;
00133
00134 bool indexOk;
00135 unsigned index = args[0]->toInt32(exec, indexOk);
00136 if (!indexOk) {
00137 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
00138 return jsUndefined();
00139 }
00140
00141 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00142
00143 RefPtr<SVGPathSeg> obj(imp->removeItem(index, ec));
00144
00145 KJS::JSValue* result = toJS(exec, obj.get(), m_context.get());
00146 setDOMException(exec, ec);
00147
00148 m_context->svgAttributeChanged(imp->associatedAttributeName());
00149 return result;
00150 }
00151
00152 KJS::JSValue* JSSVGPathSegList::appendItem(ExecState* exec, const List& args)
00153 {
00154 ExceptionCode ec = 0;
00155 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
00156
00157 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
00158
00159 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get());
00160 setDOMException(exec, ec);
00161
00162 m_context->svgAttributeChanged(imp->associatedAttributeName());
00163 return result;
00164 }
00165
00166 }
00167
00168 #endif // ENABLE(SVG)