|
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 #include "JSCSSStyleDeclaration.h" |
|
24 |
|
25 #include <wtf/GetPtr.h> |
|
26 |
|
27 #include "AtomicString.h" |
|
28 #include "CSSRule.h" |
|
29 #include "CSSStyleDeclaration.h" |
|
30 #include "CSSValue.h" |
|
31 #include "ExceptionCode.h" |
|
32 #include "JSCSSRule.h" |
|
33 #include "JSCSSValue.h" |
|
34 #include "PlatformString.h" |
|
35 |
|
36 using namespace KJS; |
|
37 |
|
38 namespace WebCore { |
|
39 |
|
40 /* Hash table */ |
|
41 |
|
42 static const HashEntry JSCSSStyleDeclarationTableEntries[] = |
|
43 { |
|
44 { 0, 0, 0, 0, 0 }, |
|
45 { "cssText", JSCSSStyleDeclaration::CssTextAttrNum, DontDelete, 0, &JSCSSStyleDeclarationTableEntries[4] }, |
|
46 { 0, 0, 0, 0, 0 }, |
|
47 { 0, 0, 0, 0, 0 }, |
|
48 { "length", JSCSSStyleDeclaration::LengthAttrNum, DontDelete|ReadOnly, 0, &JSCSSStyleDeclarationTableEntries[5] }, |
|
49 { "parentRule", JSCSSStyleDeclaration::ParentRuleAttrNum, DontDelete|ReadOnly, 0, &JSCSSStyleDeclarationTableEntries[6] }, |
|
50 { "constructor", JSCSSStyleDeclaration::ConstructorAttrNum, DontDelete|DontEnum|ReadOnly, 0, 0 } |
|
51 }; |
|
52 |
|
53 static const HashTable JSCSSStyleDeclarationTable = |
|
54 { |
|
55 2, 7, JSCSSStyleDeclarationTableEntries, 4 |
|
56 }; |
|
57 |
|
58 /* Hash table for constructor */ |
|
59 |
|
60 static const HashEntry JSCSSStyleDeclarationConstructorTableEntries[] = |
|
61 { |
|
62 { 0, 0, 0, 0, 0 } |
|
63 }; |
|
64 |
|
65 static const HashTable JSCSSStyleDeclarationConstructorTable = |
|
66 { |
|
67 2, 1, JSCSSStyleDeclarationConstructorTableEntries, 1 |
|
68 }; |
|
69 |
|
70 class JSCSSStyleDeclarationConstructor : public DOMObject { |
|
71 public: |
|
72 JSCSSStyleDeclarationConstructor(ExecState* exec) |
|
73 { |
|
74 setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype()); |
|
75 putDirect(exec->propertyNames().prototype, JSCSSStyleDeclarationPrototype::self(exec), None); |
|
76 } |
|
77 virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); |
|
78 JSValue* getValueProperty(ExecState*, int token) const; |
|
79 virtual const ClassInfo* classInfo() const { return &info; } |
|
80 static const ClassInfo info; |
|
81 |
|
82 virtual bool implementsHasInstance() const { return true; } |
|
83 }; |
|
84 |
|
85 const ClassInfo JSCSSStyleDeclarationConstructor::info = { "CSSStyleDeclarationConstructor", 0, &JSCSSStyleDeclarationConstructorTable, 0 }; |
|
86 |
|
87 bool JSCSSStyleDeclarationConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
88 { |
|
89 return getStaticValueSlot<JSCSSStyleDeclarationConstructor, DOMObject>(exec, &JSCSSStyleDeclarationConstructorTable, this, propertyName, slot); |
|
90 } |
|
91 |
|
92 JSValue* JSCSSStyleDeclarationConstructor::getValueProperty(ExecState*, int token) const |
|
93 { |
|
94 // The token is the numeric value of its associated constant |
|
95 return jsNumber(token); |
|
96 } |
|
97 |
|
98 /* Hash table for prototype */ |
|
99 |
|
100 static const HashEntry JSCSSStyleDeclarationPrototypeTableEntries[] = |
|
101 { |
|
102 { "removeProperty", JSCSSStyleDeclaration::RemovePropertyFuncNum, DontDelete|Function, 1, &JSCSSStyleDeclarationPrototypeTableEntries[8] }, |
|
103 { 0, 0, 0, 0, 0 }, |
|
104 { "getPropertyPriority", JSCSSStyleDeclaration::GetPropertyPriorityFuncNum, DontDelete|Function, 1, 0 }, |
|
105 { "getPropertyValue", JSCSSStyleDeclaration::GetPropertyValueFuncNum, DontDelete|Function, 1, 0 }, |
|
106 { 0, 0, 0, 0, 0 }, |
|
107 { "getPropertyShorthand", JSCSSStyleDeclaration::GetPropertyShorthandFuncNum, DontDelete|Function, 1, &JSCSSStyleDeclarationPrototypeTableEntries[9] }, |
|
108 { "getPropertyCSSValue", JSCSSStyleDeclaration::GetPropertyCSSValueFuncNum, DontDelete|Function, 1, 0 }, |
|
109 { "item", JSCSSStyleDeclaration::ItemFuncNum, DontDelete|Function, 1, 0 }, |
|
110 { "setProperty", JSCSSStyleDeclaration::SetPropertyFuncNum, DontDelete|Function, 3, 0 }, |
|
111 { "isPropertyImplicit", JSCSSStyleDeclaration::IsPropertyImplicitFuncNum, DontDelete|Function, 1, 0 } |
|
112 }; |
|
113 |
|
114 static const HashTable JSCSSStyleDeclarationPrototypeTable = |
|
115 { |
|
116 2, 10, JSCSSStyleDeclarationPrototypeTableEntries, 8 |
|
117 }; |
|
118 |
|
119 const ClassInfo JSCSSStyleDeclarationPrototype::info = { "CSSStyleDeclarationPrototype", 0, &JSCSSStyleDeclarationPrototypeTable, 0 }; |
|
120 |
|
121 JSObject* JSCSSStyleDeclarationPrototype::self(ExecState* exec) |
|
122 { |
|
123 return KJS::cacheGlobalObject<JSCSSStyleDeclarationPrototype>(exec, "[[JSCSSStyleDeclaration.prototype]]"); |
|
124 } |
|
125 |
|
126 bool JSCSSStyleDeclarationPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
127 { |
|
128 return getStaticFunctionSlot<JSCSSStyleDeclarationPrototypeFunction, JSObject>(exec, &JSCSSStyleDeclarationPrototypeTable, this, propertyName, slot); |
|
129 } |
|
130 |
|
131 const ClassInfo JSCSSStyleDeclaration::info = { "CSSStyleDeclaration", 0, &JSCSSStyleDeclarationTable, 0 }; |
|
132 |
|
133 JSCSSStyleDeclaration::JSCSSStyleDeclaration(ExecState* exec, CSSStyleDeclaration* impl) |
|
134 : m_impl(impl) |
|
135 { |
|
136 setPrototype(JSCSSStyleDeclarationPrototype::self(exec)); |
|
137 } |
|
138 |
|
139 JSCSSStyleDeclaration::~JSCSSStyleDeclaration() |
|
140 { |
|
141 ScriptInterpreter::forgetDOMObject(m_impl.get()); |
|
142 } |
|
143 |
|
144 bool JSCSSStyleDeclaration::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
145 { |
|
146 const HashEntry* entry = Lookup::findEntry(&JSCSSStyleDeclarationTable, propertyName); |
|
147 if (entry) { |
|
148 slot.setStaticEntry(this, entry, staticValueGetter<JSCSSStyleDeclaration>); |
|
149 return true; |
|
150 } |
|
151 bool ok; |
|
152 unsigned index = propertyName.toUInt32(&ok, false); |
|
153 if (ok && index < static_cast<CSSStyleDeclaration*>(impl())->length()) { |
|
154 slot.setCustomIndex(this, index, indexGetter); |
|
155 return true; |
|
156 } |
|
157 if (canGetItemsForName(exec, static_cast<CSSStyleDeclaration*>(impl()), propertyName)) { |
|
158 slot.setCustom(this, nameGetter); |
|
159 return true; |
|
160 } |
|
161 return KJS::DOMObject::getOwnPropertySlot(exec, propertyName, slot); |
|
162 } |
|
163 |
|
164 JSValue* JSCSSStyleDeclaration::getValueProperty(ExecState* exec, int token) const |
|
165 { |
|
166 switch (token) { |
|
167 case CssTextAttrNum: { |
|
168 CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl()); |
|
169 |
|
170 return jsStringOrNull(imp->cssText()); |
|
171 } |
|
172 case LengthAttrNum: { |
|
173 CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl()); |
|
174 |
|
175 return jsNumber(imp->length()); |
|
176 } |
|
177 case ParentRuleAttrNum: { |
|
178 CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl()); |
|
179 |
|
180 return toJS(exec, WTF::getPtr(imp->parentRule())); |
|
181 } |
|
182 case ConstructorAttrNum: |
|
183 return getConstructor(exec); |
|
184 } |
|
185 return 0; |
|
186 } |
|
187 |
|
188 void JSCSSStyleDeclaration::put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr) |
|
189 { |
|
190 if (customPut(exec, propertyName, value, attr)) |
|
191 return; |
|
192 lookupPut<JSCSSStyleDeclaration, KJS::DOMObject>(exec, propertyName, value, attr, &JSCSSStyleDeclarationTable, this); |
|
193 } |
|
194 |
|
195 void JSCSSStyleDeclaration::putValueProperty(ExecState* exec, int token, JSValue* value, int /*attr*/) |
|
196 { |
|
197 switch (token) { |
|
198 case CssTextAttrNum: { |
|
199 CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(impl()); |
|
200 |
|
201 ExceptionCode ec = 0; |
|
202 imp->setCssText(valueToStringWithNullCheck(exec, value), ec); |
|
203 setDOMException(exec, ec); |
|
204 break; |
|
205 } |
|
206 } |
|
207 } |
|
208 |
|
209 JSValue* JSCSSStyleDeclaration::getConstructor(ExecState* exec) |
|
210 { |
|
211 return KJS::cacheGlobalObject<JSCSSStyleDeclarationConstructor>(exec, "[[CSSStyleDeclaration.constructor]]"); |
|
212 } |
|
213 JSValue* JSCSSStyleDeclarationPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) |
|
214 { |
|
215 if (!thisObj->inherits(&JSCSSStyleDeclaration::info)) |
|
216 return throwError(exec, TypeError); |
|
217 |
|
218 CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(static_cast<JSCSSStyleDeclaration*>(thisObj)->impl()); |
|
219 |
|
220 switch (id) { |
|
221 case JSCSSStyleDeclaration::GetPropertyValueFuncNum: { |
|
222 String propertyName = args[0]->toString(exec); |
|
223 |
|
224 |
|
225 KJS::JSValue* result = jsStringOrNull(imp->getPropertyValue(propertyName)); |
|
226 return result; |
|
227 } |
|
228 case JSCSSStyleDeclaration::GetPropertyCSSValueFuncNum: { |
|
229 String propertyName = args[0]->toString(exec); |
|
230 |
|
231 |
|
232 KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getPropertyCSSValue(propertyName))); |
|
233 return result; |
|
234 } |
|
235 case JSCSSStyleDeclaration::RemovePropertyFuncNum: { |
|
236 ExceptionCode ec = 0; |
|
237 String propertyName = args[0]->toString(exec); |
|
238 |
|
239 |
|
240 KJS::JSValue* result = jsStringOrNull(imp->removeProperty(propertyName, ec)); |
|
241 setDOMException(exec, ec); |
|
242 return result; |
|
243 } |
|
244 case JSCSSStyleDeclaration::GetPropertyPriorityFuncNum: { |
|
245 String propertyName = args[0]->toString(exec); |
|
246 |
|
247 |
|
248 KJS::JSValue* result = jsStringOrNull(imp->getPropertyPriority(propertyName)); |
|
249 return result; |
|
250 } |
|
251 case JSCSSStyleDeclaration::SetPropertyFuncNum: { |
|
252 ExceptionCode ec = 0; |
|
253 String propertyName = args[0]->toString(exec); |
|
254 String value = valueToStringWithNullCheck(exec, args[1]); |
|
255 String priority = args[2]->toString(exec); |
|
256 |
|
257 imp->setProperty(propertyName, value, priority, ec); |
|
258 setDOMException(exec, ec); |
|
259 return jsUndefined(); |
|
260 } |
|
261 case JSCSSStyleDeclaration::ItemFuncNum: { |
|
262 bool indexOk; |
|
263 unsigned index = args[0]->toInt32(exec, indexOk); |
|
264 if (!indexOk) { |
|
265 setDOMException(exec, TYPE_MISMATCH_ERR); |
|
266 return jsUndefined(); |
|
267 } |
|
268 |
|
269 |
|
270 KJS::JSValue* result = jsStringOrNull(imp->item(index)); |
|
271 return result; |
|
272 } |
|
273 case JSCSSStyleDeclaration::GetPropertyShorthandFuncNum: { |
|
274 String propertyName = args[0]->toString(exec); |
|
275 |
|
276 |
|
277 KJS::JSValue* result = jsStringOrNull(imp->getPropertyShorthand(propertyName)); |
|
278 return result; |
|
279 } |
|
280 case JSCSSStyleDeclaration::IsPropertyImplicitFuncNum: { |
|
281 String propertyName = args[0]->toString(exec); |
|
282 |
|
283 |
|
284 KJS::JSValue* result = jsBoolean(imp->isPropertyImplicit(propertyName)); |
|
285 return result; |
|
286 } |
|
287 } |
|
288 return 0; |
|
289 } |
|
290 |
|
291 JSValue* JSCSSStyleDeclaration::indexGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot) |
|
292 { |
|
293 JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(slot.slotBase()); |
|
294 return jsStringOrNull(thisObj->impl()->item(slot.index())); |
|
295 } |
|
296 KJS::JSValue* toJS(KJS::ExecState* exec, CSSStyleDeclaration* obj) |
|
297 { |
|
298 return KJS::cacheDOMObject<CSSStyleDeclaration, JSCSSStyleDeclaration>(exec, obj); |
|
299 } |
|
300 CSSStyleDeclaration* toCSSStyleDeclaration(KJS::JSValue* val) |
|
301 { |
|
302 return val->isObject(&JSCSSStyleDeclaration::info) ? static_cast<JSCSSStyleDeclaration*>(val)->impl() : 0; |
|
303 } |
|
304 |
|
305 } |