|
1 /* |
|
2 This file is part of the WebKit open source project. |
|
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
|
4 |
|
5 This library is free software; you can redistribute it and/or |
|
6 modify it under the terms of the GNU Library General Public |
|
7 License as published by the Free Software Foundation; either |
|
8 version 2 of the License, or (at your option) any later version. |
|
9 |
|
10 This library is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 Library General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU Library General Public License |
|
16 along with this library; see the file COPYING.LIB. If not, write to |
|
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 |
|
23 |
|
24 #if ENABLE(SVG) |
|
25 |
|
26 #include "Document.h" |
|
27 #include "Frame.h" |
|
28 #include "SVGDocumentExtensions.h" |
|
29 #include "SVGElement.h" |
|
30 #include "SVGAnimatedTemplate.h" |
|
31 #include "JSSVGPaint.h" |
|
32 |
|
33 #include <wtf/GetPtr.h> |
|
34 |
|
35 #include "PlatformString.h" |
|
36 #include "SVGPaint.h" |
|
37 |
|
38 using namespace KJS; |
|
39 |
|
40 namespace WebCore { |
|
41 |
|
42 /* Hash table */ |
|
43 |
|
44 static const HashEntry JSSVGPaintTableEntries[] = |
|
45 { |
|
46 { "paintType", JSSVGPaint::PaintTypeAttrNum, DontDelete|ReadOnly, 0, &JSSVGPaintTableEntries[3] }, |
|
47 { 0, 0, 0, 0, 0 }, |
|
48 { "uri", JSSVGPaint::UriAttrNum, DontDelete|ReadOnly, 0, 0 }, |
|
49 { "constructor", JSSVGPaint::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
50 }; |
|
51 |
|
52 static const HashTable JSSVGPaintTable = |
|
53 { |
|
54 2, 4, JSSVGPaintTableEntries, 3 |
|
55 }; |
|
56 |
|
57 /* Hash table for constructor */ |
|
58 |
|
59 static const HashEntry JSSVGPaintConstructorTableEntries[] = |
|
60 { |
|
61 { "SVG_PAINTTYPE_URI_CURRENTCOLOR", SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
62 { "SVG_PAINTTYPE_NONE", SVGPaint::SVG_PAINTTYPE_NONE, DontDelete|ReadOnly, 0, 0 }, |
|
63 { "SVG_PAINTTYPE_RGBCOLOR", SVGPaint::SVG_PAINTTYPE_RGBCOLOR, DontDelete|ReadOnly, 0, &JSSVGPaintConstructorTableEntries[10] }, |
|
64 { 0, 0, 0, 0, 0 }, |
|
65 { "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR", SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
66 { "SVG_PAINTTYPE_UNKNOWN", SVGPaint::SVG_PAINTTYPE_UNKNOWN, DontDelete|ReadOnly, 0, 0 }, |
|
67 { 0, 0, 0, 0, 0 }, |
|
68 { "SVG_PAINTTYPE_URI_NONE", SVGPaint::SVG_PAINTTYPE_URI_NONE, DontDelete|ReadOnly, 0, 0 }, |
|
69 { "SVG_PAINTTYPE_URI_RGBCOLOR", SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR, DontDelete|ReadOnly, 0, &JSSVGPaintConstructorTableEntries[11] }, |
|
70 { "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR", SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
71 { "SVG_PAINTTYPE_CURRENTCOLOR", SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
72 { "SVG_PAINTTYPE_URI", SVGPaint::SVG_PAINTTYPE_URI, DontDelete|ReadOnly, 0, 0 } |
|
73 }; |
|
74 |
|
75 static const HashTable JSSVGPaintConstructorTable = |
|
76 { |
|
77 2, 12, JSSVGPaintConstructorTableEntries, 10 |
|
78 }; |
|
79 |
|
80 class JSSVGPaintConstructor : public DOMObject { |
|
81 public: |
|
82 JSSVGPaintConstructor(ExecState* exec) |
|
83 { |
|
84 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
85 putDirect(exec->propertyNames().prototype, JSSVGPaintPrototype::self(exec), None); |
|
86 } |
|
87 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
88 JSValue* getValueProperty(ExecState*, int token) const; |
|
89 virtual const ClassInfo* classInfo() const { return &info; } |
|
90 static const ClassInfo info; |
|
91 |
|
92 virtual bool implementsHasInstance() const { return true; } |
|
93 }; |
|
94 |
|
95 const ClassInfo JSSVGPaintConstructor::info = { "SVGPaintConstructor", 0, &JSSVGPaintConstructorTable, 0 }; |
|
96 |
|
97 bool JSSVGPaintConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
98 { |
|
99 return getStaticValueSlot<JSSVGPaintConstructor, DOMObject>(exec, &JSSVGPaintConstructorTable, this, propertyName, slot); |
|
100 } |
|
101 |
|
102 JSValue* JSSVGPaintConstructor::getValueProperty(ExecState*, int token) const |
|
103 { |
|
104 // The token is the numeric value of its associated constant |
|
105 return jsNumber(token); |
|
106 } |
|
107 |
|
108 /* Hash table for prototype */ |
|
109 |
|
110 static const HashEntry JSSVGPaintPrototypeTableEntries[] = |
|
111 { |
|
112 { "SVG_PAINTTYPE_URI_CURRENTCOLOR", SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
113 { "SVG_PAINTTYPE_NONE", SVGPaint::SVG_PAINTTYPE_NONE, DontDelete|ReadOnly, 0, 0 }, |
|
114 { "SVG_PAINTTYPE_CURRENTCOLOR", SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
115 { "setUri", JSSVGPaint::SetUriFuncNum, DontDelete|Function, 1, 0 }, |
|
116 { "SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR", SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR, DontDelete|ReadOnly, 0, &JSSVGPaintPrototypeTableEntries[13] }, |
|
117 { 0, 0, 0, 0, 0 }, |
|
118 { "SVG_PAINTTYPE_RGBCOLOR", SVGPaint::SVG_PAINTTYPE_RGBCOLOR, DontDelete|ReadOnly, 0, &JSSVGPaintPrototypeTableEntries[12] }, |
|
119 { "SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR", SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
120 { 0, 0, 0, 0, 0 }, |
|
121 { "SVG_PAINTTYPE_UNKNOWN", SVGPaint::SVG_PAINTTYPE_UNKNOWN, DontDelete|ReadOnly, 0, 0 }, |
|
122 { 0, 0, 0, 0, 0 }, |
|
123 { "SVG_PAINTTYPE_URI_NONE", SVGPaint::SVG_PAINTTYPE_URI_NONE, DontDelete|ReadOnly, 0, 0 }, |
|
124 { "SVG_PAINTTYPE_URI_RGBCOLOR", SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR, DontDelete|ReadOnly, 0, 0 }, |
|
125 { "SVG_PAINTTYPE_URI", SVGPaint::SVG_PAINTTYPE_URI, DontDelete|ReadOnly, 0, &JSSVGPaintPrototypeTableEntries[14] }, |
|
126 { "setPaint", JSSVGPaint::SetPaintFuncNum, DontDelete|Function, 4, 0 } |
|
127 }; |
|
128 |
|
129 static const HashTable JSSVGPaintPrototypeTable = |
|
130 { |
|
131 2, 15, JSSVGPaintPrototypeTableEntries, 12 |
|
132 }; |
|
133 |
|
134 const ClassInfo JSSVGPaintPrototype::info = { "SVGPaintPrototype", 0, &JSSVGPaintPrototypeTable, 0 }; |
|
135 |
|
136 JSObject* JSSVGPaintPrototype::self(ExecState* exec) |
|
137 { |
|
138 return KJS::cacheGlobalObject<JSSVGPaintPrototype>(exec, "[[JSSVGPaint.prototype]]"); |
|
139 } |
|
140 |
|
141 bool JSSVGPaintPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
142 { |
|
143 return getStaticPropertySlot<JSSVGPaintPrototypeFunction, JSSVGPaintPrototype, JSObject>(exec, &JSSVGPaintPrototypeTable, this, propertyName, slot); |
|
144 } |
|
145 |
|
146 JSValue* JSSVGPaintPrototype::getValueProperty(ExecState*, int token) const |
|
147 { |
|
148 // The token is the numeric value of its associated constant |
|
149 return jsNumber(token); |
|
150 } |
|
151 |
|
152 const ClassInfo JSSVGPaint::info = { "SVGPaint", &JSSVGColor::info, &JSSVGPaintTable, 0 }; |
|
153 |
|
154 JSSVGPaint::JSSVGPaint(ExecState* exec, SVGPaint* impl) |
|
155 : JSSVGColor(exec, impl) |
|
156 { |
|
157 setPrototype(JSSVGPaintPrototype::self(exec)); |
|
158 } |
|
159 |
|
160 bool JSSVGPaint::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
161 { |
|
162 return getStaticValueSlot<JSSVGPaint, JSSVGColor>(exec, &JSSVGPaintTable, this, propertyName, slot); |
|
163 } |
|
164 |
|
165 JSValue* JSSVGPaint::getValueProperty(ExecState* exec, int token) const |
|
166 { |
|
167 switch (token) { |
|
168 case PaintTypeAttrNum: { |
|
169 SVGPaint* imp = static_cast<SVGPaint*>(impl()); |
|
170 |
|
171 return jsNumber(imp->paintType()); |
|
172 } |
|
173 case UriAttrNum: { |
|
174 SVGPaint* imp = static_cast<SVGPaint*>(impl()); |
|
175 |
|
176 return jsString(imp->uri()); |
|
177 } |
|
178 case ConstructorAttrNum: |
|
179 return getConstructor(exec); |
|
180 } |
|
181 return 0; |
|
182 } |
|
183 |
|
184 JSValue* JSSVGPaint::getConstructor(ExecState* exec) |
|
185 { |
|
186 return KJS::cacheGlobalObject<JSSVGPaintConstructor>(exec, "[[SVGPaint.constructor]]"); |
|
187 } |
|
188 JSValue* JSSVGPaintPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
189 { |
|
190 if (!thisObj->inherits(&JSSVGPaint::info)) |
|
191 return throwError(exec, TypeError); |
|
192 |
|
193 SVGPaint* imp = static_cast<SVGPaint*>(static_cast<JSSVGPaint*>(thisObj)->impl()); |
|
194 |
|
195 switch (id) { |
|
196 case JSSVGPaint::SetUriFuncNum: { |
|
197 String uri = args[0]->toString(exec); |
|
198 |
|
199 imp->setUri(uri); |
|
200 return jsUndefined(); |
|
201 } |
|
202 case JSSVGPaint::SetPaintFuncNum: { |
|
203 ExceptionCode ec = 0; |
|
204 SVGPaint::SVGPaintType paintType = static_cast<SVGPaint::SVGPaintType>(args[0]->toInt32(exec)); |
|
205 String uri = args[1]->toString(exec); |
|
206 String rgbColor = args[2]->toString(exec); |
|
207 String iccColor = args[3]->toString(exec); |
|
208 |
|
209 imp->setPaint(paintType, uri, rgbColor, iccColor, ec); |
|
210 setDOMException(exec, ec); |
|
211 return jsUndefined(); |
|
212 } |
|
213 } |
|
214 return 0; |
|
215 } |
|
216 |
|
217 } |
|
218 |
|
219 #endif // ENABLE(SVG) |