• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • bindings
  • js
JSSVGTransformListCustom.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
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 "config.h"
21 #include "wtf/Platform.h"
22 
23 #if ENABLE(SVG)
24 #include "JSSVGTransformList.h"
25 
26 #include "Document.h"
27 #include "Frame.h"
28 #include "JSSVGTransform.h"
29 #include "SVGDocumentExtensions.h"
30 #include "SVGTransformList.h"
31 #include "SVGStyledElement.h"
32 
33 #include <wtf/Assertions.h>
34 
35 using namespace KJS;
36 using namespace WebCore;
37 
38 namespace khtml {
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)
Frame.h
SVGStyledElement.h
SVGTransformList.h
SVGDocumentExtensions.h
newItem
QString newItem(const QString &type, const QString &name, const QString &key, const QString &defaultValue, const CfgConfig &cfg, const QString &param=QString())
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal