KHtml

JSSVGTransformListCustom.cpp
1 /*
2  * Copyright (C) 2007, 2008 Nikolas Zimmermann <[email protected]>
3  *
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.
8  *
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.
13  *
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.
18  */
19 
20 #include "wtf/Platform.h"
21 
22 #if ENABLE(SVG)
23 #include "JSSVGTransformList.h"
24 
25 #include "Document.h"
26 #include "Frame.h"
27 #include "JSSVGTransform.h"
28 #include "SVGDocumentExtensions.h"
29 #include "SVGTransformList.h"
30 #include "SVGStyledElement.h"
31 
32 #include <wtf/Assertions.h>
33 
34 using namespace KJS;
35 using namespace WebCore;
36 
37 namespace khtml
38 {
39 
40 JSValue *JSSVGTransformList::clear(ExecState *exec, const List &)
41 {
42  ExceptionCode ec = 0;
43 
44  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
45  imp->clear(ec);
46  setDOMException(exec, ec);
47 
48  m_context->svgAttributeChanged(imp->associatedAttributeName());
49 
50  return jsUndefined();
51 }
52 
53 JSValue *JSSVGTransformList::initialize(ExecState *exec, const List &args)
54 {
55  ExceptionCode ec = 0;
56  SVGTransform newItem = toSVGTransform(args[0]);
57 
58  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
59  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
60 
61  SVGPODListItem<SVGTransform> *listItem = listImp->initialize(SVGPODListItem<SVGTransform>::copy(newItem), ec).get();
62  JSSVGPODTypeWrapperCreatorForList<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
63 
64  KJS::JSValue *result = toJS(exec, obj, m_context.get());
65  setDOMException(exec, ec);
66 
67  m_context->svgAttributeChanged(imp->associatedAttributeName());
68 
69  return result;
70 }
71 
72 JSValue *JSSVGTransformList::getItem(ExecState *exec, const List &args)
73 {
74  ExceptionCode ec = 0;
75 
76  bool indexOk;
77  unsigned index = args[0]->toInt32(exec, indexOk);
78  if (!indexOk) {
79  setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
80  return jsUndefined();
81  }
82 
83  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
84  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
85 
86  SVGPODListItem<SVGTransform> *listItem = listImp->getItem(index, ec).get();
87  JSSVGPODTypeWrapperCreatorForList<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
88 
89  KJS::JSValue *result = toJS(exec, obj, m_context.get());
90  setDOMException(exec, ec);
91  return result;
92 }
93 
94 JSValue *JSSVGTransformList::insertItemBefore(ExecState *exec, const List &args)
95 {
96  ExceptionCode ec = 0;
97  SVGTransform newItem = toSVGTransform(args[0]);
98 
99  bool indexOk;
100  unsigned index = args[1]->toInt32(exec, indexOk);
101  if (!indexOk) {
102  setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
103  return jsUndefined();
104  }
105 
106  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
107  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
108 
109  SVGPODListItem<SVGTransform> *listItem = listImp->insertItemBefore(SVGPODListItem<SVGTransform>::copy(newItem), index, ec).get();
110  JSSVGPODTypeWrapperCreatorForList<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
111 
112  KJS::JSValue *result = toJS(exec, obj, m_context.get());
113  setDOMException(exec, ec);
114 
115  m_context->svgAttributeChanged(imp->associatedAttributeName());
116 
117  return result;
118 }
119 
120 JSValue *JSSVGTransformList::replaceItem(ExecState *exec, const List &args)
121 {
122  ExceptionCode ec = 0;
123  SVGTransform newItem = toSVGTransform(args[0]);
124 
125  bool indexOk;
126  unsigned index = args[1]->toInt32(exec, indexOk);
127  if (!indexOk) {
128  setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
129  return jsUndefined();
130  }
131 
132  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
133  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
134 
135  SVGPODListItem<SVGTransform> *listItem = listImp->replaceItem(SVGPODListItem<SVGTransform>::copy(newItem), index, ec).get();
136  JSSVGPODTypeWrapperCreatorForList<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
137 
138  KJS::JSValue *result = toJS(exec, obj, m_context.get());
139  setDOMException(exec, ec);
140 
141  m_context->svgAttributeChanged(imp->associatedAttributeName());
142 
143  return result;
144 }
145 
146 JSValue *JSSVGTransformList::removeItem(ExecState *exec, const List &args)
147 {
148  ExceptionCode ec = 0;
149 
150  bool indexOk;
151  unsigned index = args[0]->toInt32(exec, indexOk);
152  if (!indexOk) {
153  setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
154  return jsUndefined();
155  }
156 
157  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
158  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
159 
160  RefPtr<SVGPODListItem<SVGTransform> > listItem(listImp->removeItem(index, ec));
161  JSSVGPODTypeWrapper<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorReadOnly<SVGTransform>(*listItem.get());
162 
163  KJS::JSValue *result = toJS(exec, obj, m_context.get());
164  setDOMException(exec, ec);
165 
166  m_context->svgAttributeChanged(imp->associatedAttributeName());
167 
168  return result;
169 }
170 
171 JSValue *JSSVGTransformList::appendItem(ExecState *exec, const List &args)
172 {
173  ExceptionCode ec = 0;
174  SVGTransform newItem = toSVGTransform(args[0]);
175 
176  SVGTransformList *imp = static_cast<SVGTransformList *>(impl());
177  SVGList<RefPtr<SVGPODListItem<SVGTransform> > > *listImp = imp;
178 
179  SVGPODListItem<SVGTransform> *listItem = listImp->appendItem(SVGPODListItem<SVGTransform>::copy(newItem), ec).get();
180  JSSVGPODTypeWrapperCreatorForList<SVGTransform> *obj = new JSSVGPODTypeWrapperCreatorForList<SVGTransform>(listItem, imp->associatedAttributeName());
181 
182  KJS::JSValue *result = toJS(exec, obj, m_context.get());
183  setDOMException(exec, ec);
184 
185  m_context->svgAttributeChanged(imp->associatedAttributeName());
186 
187  return result;
188 }
189 
190 }
191 
192 #endif // ENABLE(SVG)
This file is part of the HTML rendering engine for KDE.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 16 2021 22:47:55 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.