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

KHTML

  • khtml
  • bindings
  • js
JSSVGPathSegListCustom.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006, 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 "JSSVGPathSegList.h"
25
26#include "Document.h"
27#include "Frame.h"
28#include "JSSVGPathSeg.h"
29#include "SVGDocumentExtensions.h"
30#include "SVGElement.h"
31#include "SVGPathSegList.h"
32
33#include <wtf/Assertions.h>
34
35using namespace KJS;
36using namespace DOM;
37
38namespace khtml {
39
40KJS::JSValue* JSSVGPathSegList::clear(ExecState* exec, const List& args)
41{
42 ExceptionCode ec = 0;
43
44 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
45 imp->clear(ec);
46
47 setDOMException(exec, ec);
48
49 m_context->svgAttributeChanged(imp->associatedAttributeName());
50 return jsUndefined();
51}
52
53KJS::JSValue* JSSVGPathSegList::initialize(ExecState* exec, const List& args)
54{
55 ExceptionCode ec = 0;
56 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
57
58 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
59
60 SVGPathSeg* obj = WTF::getPtr(imp->initialize(newItem, ec));
61
62 KJS::JSValue* result = toJS(exec, obj, m_context.get());
63 setDOMException(exec, ec);
64
65 m_context->svgAttributeChanged(imp->associatedAttributeName());
66 return result;
67}
68
69KJS::JSValue* JSSVGPathSegList::getItem(ExecState* exec, const List& args)
70{
71 ExceptionCode ec = 0;
72
73 bool indexOk;
74 unsigned index = args[0]->toInt32(exec, indexOk);
75 if (!indexOk) {
76 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
77 return jsUndefined();
78 }
79
80 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
81 SVGPathSeg* obj = WTF::getPtr(imp->getItem(index, ec));
82
83 KJS::JSValue* result = toJS(exec, obj, m_context.get());
84 setDOMException(exec, ec);
85 return result;
86}
87
88KJS::JSValue* JSSVGPathSegList::insertItemBefore(ExecState* exec, const List& args)
89{
90 ExceptionCode ec = 0;
91 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
92
93 bool indexOk;
94 unsigned index = args[1]->toInt32(exec, indexOk);
95 if (!indexOk) {
96 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
97 return jsUndefined();
98 }
99
100 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
101
102 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertItemBefore(newItem, index, ec)), m_context.get());
103 setDOMException(exec, ec);
104
105 m_context->svgAttributeChanged(imp->associatedAttributeName());
106 return result;
107}
108
109KJS::JSValue* JSSVGPathSegList::replaceItem(ExecState* exec, const List& args)
110{
111 ExceptionCode ec = 0;
112 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
113
114 bool indexOk;
115 unsigned index = args[1]->toInt32(exec, indexOk);
116 if (!indexOk) {
117 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
118 return jsUndefined();
119 }
120
121 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
122
123 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->replaceItem(newItem, index, ec)), m_context.get());
124 setDOMException(exec, ec);
125
126 m_context->svgAttributeChanged(imp->associatedAttributeName());
127 return result;
128}
129
130KJS::JSValue* JSSVGPathSegList::removeItem(ExecState* exec, const List& args)
131{
132 ExceptionCode ec = 0;
133
134 bool indexOk;
135 unsigned index = args[0]->toInt32(exec, indexOk);
136 if (!indexOk) {
137 setDOMException(exec, DOMException::TYPE_MISMATCH_ERR);
138 return jsUndefined();
139 }
140
141 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
142
143 RefPtr<SVGPathSeg> obj(imp->removeItem(index, ec));
144
145 KJS::JSValue* result = toJS(exec, obj.get(), m_context.get());
146 setDOMException(exec, ec);
147
148 m_context->svgAttributeChanged(imp->associatedAttributeName());
149 return result;
150}
151
152KJS::JSValue* JSSVGPathSegList::appendItem(ExecState* exec, const List& args)
153{
154 ExceptionCode ec = 0;
155 SVGPathSeg* newItem = toSVGPathSeg(args[0]);
156
157 SVGPathSegList* imp = static_cast<SVGPathSegList*>(impl());
158
159 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->appendItem(newItem, ec)), m_context.get());
160 setDOMException(exec, ec);
161
162 m_context->svgAttributeChanged(imp->associatedAttributeName());
163 return result;
164}
165
166}
167
168#endif // ENABLE(SVG)
Frame.h
SVGDocumentExtensions.h
SVGElement.h
SVGPathSegList.h
newItem
QString newItem(const QString &type, const QString &name, const QString &key, const QString &defaultValue, const CfgConfig &cfg, const QString &param=QString())
DOM
This library provides a full-featured HTML parser and widget.
Definition: design.h:55
KJS
Definition: dom_node.h:37
khtml
khtml::ExceptionCode
unsigned short ExceptionCode
Definition: ExceptionCode.h:37
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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