tizen beta release
[framework/web/webkit-efl.git] / DerivedSources / WebCore / JSCSSStyleDeclaration.cpp
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 #include "JSCSSStyleDeclaration.h"
23
24 #include "CSSRule.h"
25 #include "CSSStyleDeclaration.h"
26 #include "CSSValue.h"
27 #include "ExceptionCode.h"
28 #include "JSCSSRule.h"
29 #include "JSCSSStyleDeclarationCustom.h"
30 #include "JSDOMBinding.h"
31 #include "KURL.h"
32 #include "wtf/text/AtomicString.h"
33 #include <runtime/Error.h>
34 #include <runtime/JSString.h>
35 #include <runtime/PropertyNameArray.h>
36 #include <wtf/GetPtr.h>
37
38 using namespace JSC;
39
40 namespace WebCore {
41
42 ASSERT_CLASS_FITS_IN_CELL(JSCSSStyleDeclaration);
43
44 /* Hash table */
45 #if ENABLE(JIT)
46 #define THUNK_GENERATOR(generator) , generator
47 #else
48 #define THUNK_GENERATOR(generator)
49 #endif
50 #if ENABLE(DFG_JIT)
51 #define INTRINSIC(intrinsic) , intrinsic
52 #else
53 #define INTRINSIC(intrinsic)
54 #endif
55
56 static const HashTableValue JSCSSStyleDeclarationTableValues[] =
57 {
58     { "cssText", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleDeclarationCssText), (intptr_t)setJSCSSStyleDeclarationCssText THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
59     { "length", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleDeclarationLength), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
60     { "parentRule", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleDeclarationParentRule), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
61     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleDeclarationConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
62     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
63 };
64
65 #undef THUNK_GENERATOR
66 static const HashTable JSCSSStyleDeclarationTable = { 10, 7, JSCSSStyleDeclarationTableValues, 0 };
67 /* Hash table for constructor */
68 #if ENABLE(JIT)
69 #define THUNK_GENERATOR(generator) , generator
70 #else
71 #define THUNK_GENERATOR(generator)
72 #endif
73 #if ENABLE(DFG_JIT)
74 #define INTRINSIC(intrinsic) , intrinsic
75 #else
76 #define INTRINSIC(intrinsic)
77 #endif
78
79 static const HashTableValue JSCSSStyleDeclarationConstructorTableValues[] =
80 {
81     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
82 };
83
84 #undef THUNK_GENERATOR
85 static const HashTable JSCSSStyleDeclarationConstructorTable = { 1, 0, JSCSSStyleDeclarationConstructorTableValues, 0 };
86 const ClassInfo JSCSSStyleDeclarationConstructor::s_info = { "CSSStyleDeclarationConstructor", &DOMConstructorObject::s_info, &JSCSSStyleDeclarationConstructorTable, 0, CREATE_METHOD_TABLE(JSCSSStyleDeclarationConstructor) };
87
88 JSCSSStyleDeclarationConstructor::JSCSSStyleDeclarationConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
89     : DOMConstructorObject(structure, globalObject)
90 {
91 }
92
93 void JSCSSStyleDeclarationConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
94 {
95     Base::finishCreation(exec->globalData());
96     ASSERT(inherits(&s_info));
97     putDirect(exec->globalData(), exec->propertyNames().prototype, JSCSSStyleDeclarationPrototype::self(exec, globalObject), DontDelete | ReadOnly);
98 }
99
100 bool JSCSSStyleDeclarationConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
101 {
102     return getStaticValueSlot<JSCSSStyleDeclarationConstructor, JSDOMWrapper>(exec, &JSCSSStyleDeclarationConstructorTable, static_cast<JSCSSStyleDeclarationConstructor*>(cell), propertyName, slot);
103 }
104
105 bool JSCSSStyleDeclarationConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
106 {
107     return getStaticValueDescriptor<JSCSSStyleDeclarationConstructor, JSDOMWrapper>(exec, &JSCSSStyleDeclarationConstructorTable, static_cast<JSCSSStyleDeclarationConstructor*>(object), propertyName, descriptor);
108 }
109
110 /* Hash table for prototype */
111 #if ENABLE(JIT)
112 #define THUNK_GENERATOR(generator) , generator
113 #else
114 #define THUNK_GENERATOR(generator)
115 #endif
116 #if ENABLE(DFG_JIT)
117 #define INTRINSIC(intrinsic) , intrinsic
118 #else
119 #define INTRINSIC(intrinsic)
120 #endif
121
122 static const HashTableValue JSCSSStyleDeclarationPrototypeTableValues[] =
123 {
124     { "getPropertyValue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionGetPropertyValue), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
125     { "getPropertyCSSValue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionGetPropertyCSSValue), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
126     { "removeProperty", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionRemoveProperty), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
127     { "getPropertyPriority", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionGetPropertyPriority), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
128     { "setProperty", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionSetProperty), (intptr_t)3 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
129     { "item", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionItem), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
130     { "getPropertyShorthand", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionGetPropertyShorthand), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
131     { "isPropertyImplicit", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleDeclarationPrototypeFunctionIsPropertyImplicit), (intptr_t)1 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
132     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
133 };
134
135 #undef THUNK_GENERATOR
136 static const HashTable JSCSSStyleDeclarationPrototypeTable = { 17, 15, JSCSSStyleDeclarationPrototypeTableValues, 0 };
137 const ClassInfo JSCSSStyleDeclarationPrototype::s_info = { "CSSStyleDeclarationPrototype", &JSC::JSNonFinalObject::s_info, &JSCSSStyleDeclarationPrototypeTable, 0, CREATE_METHOD_TABLE(JSCSSStyleDeclarationPrototype) };
138
139 JSObject* JSCSSStyleDeclarationPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
140 {
141     return getDOMPrototype<JSCSSStyleDeclaration>(exec, globalObject);
142 }
143
144 bool JSCSSStyleDeclarationPrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
145 {
146     JSCSSStyleDeclarationPrototype* thisObject = jsCast<JSCSSStyleDeclarationPrototype*>(cell);
147     return getStaticFunctionSlot<JSObject>(exec, &JSCSSStyleDeclarationPrototypeTable, thisObject, propertyName, slot);
148 }
149
150 bool JSCSSStyleDeclarationPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
151 {
152     JSCSSStyleDeclarationPrototype* thisObject = jsCast<JSCSSStyleDeclarationPrototype*>(object);
153     return getStaticFunctionDescriptor<JSObject>(exec, &JSCSSStyleDeclarationPrototypeTable, thisObject, propertyName, descriptor);
154 }
155
156 const ClassInfo JSCSSStyleDeclaration::s_info = { "CSSStyleDeclaration", &JSDOMWrapper::s_info, &JSCSSStyleDeclarationTable, 0 , CREATE_METHOD_TABLE(JSCSSStyleDeclaration) };
157
158 JSCSSStyleDeclaration::JSCSSStyleDeclaration(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<CSSStyleDeclaration> impl)
159     : JSDOMWrapper(structure, globalObject)
160     , m_impl(impl.leakRef())
161 {
162 }
163
164 void JSCSSStyleDeclaration::finishCreation(JSGlobalData& globalData)
165 {
166     Base::finishCreation(globalData);
167     ASSERT(inherits(&s_info));
168 }
169
170 JSObject* JSCSSStyleDeclaration::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
171 {
172     return JSCSSStyleDeclarationPrototype::create(exec->globalData(), globalObject, JSCSSStyleDeclarationPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
173 }
174
175 bool JSCSSStyleDeclaration::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
176 {
177     JSCSSStyleDeclaration* thisObject = jsCast<JSCSSStyleDeclaration*>(cell);
178     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
179     const HashEntry* entry = JSCSSStyleDeclarationTable.entry(exec, propertyName);
180     if (entry) {
181         slot.setCustom(thisObject, entry->propertyGetter());
182         return true;
183     }
184     bool ok;
185     unsigned index = propertyName.toUInt32(ok);
186     if (ok) {
187         slot.setCustomIndex(thisObject, index, indexGetter);
188         return true;
189     }
190     if (canGetItemsForName(exec, static_cast<CSSStyleDeclaration*>(thisObject->impl()), propertyName)) {
191         slot.setCustom(thisObject, thisObject->nameGetter);
192         return true;
193     }
194     return getStaticValueSlot<JSCSSStyleDeclaration, Base>(exec, &JSCSSStyleDeclarationTable, thisObject, propertyName, slot);
195 }
196
197 bool JSCSSStyleDeclaration::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
198 {
199     JSCSSStyleDeclaration* thisObject = jsCast<JSCSSStyleDeclaration*>(object);
200     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
201     const HashEntry* entry = JSCSSStyleDeclarationTable.entry(exec, propertyName);
202     if (entry) {
203         PropertySlot slot;
204         slot.setCustom(thisObject, entry->propertyGetter());
205         descriptor.setDescriptor(slot.getValue(exec, propertyName), entry->attributes());
206         return true;
207     }
208     bool ok;
209     unsigned index = propertyName.toUInt32(ok);
210     if (ok && index < static_cast<CSSStyleDeclaration*>(thisObject->impl())->length()) {
211         PropertySlot slot;
212         slot.setCustomIndex(thisObject, index, indexGetter);
213         descriptor.setDescriptor(slot.getValue(exec, propertyName), DontDelete | ReadOnly);
214         return true;
215     }
216     if (canGetItemsForName(exec, static_cast<CSSStyleDeclaration*>(thisObject->impl()), propertyName)) {
217         PropertySlot slot;
218         slot.setCustom(thisObject, nameGetter);
219         descriptor.setDescriptor(slot.getValue(exec, propertyName), ReadOnly | DontDelete | DontEnum);
220         return true;
221     }
222     return getStaticValueDescriptor<JSCSSStyleDeclaration, Base>(exec, &JSCSSStyleDeclarationTable, thisObject, propertyName, descriptor);
223 }
224
225 bool JSCSSStyleDeclaration::getOwnPropertySlotByIndex(JSCell* cell, ExecState* exec, unsigned propertyName, PropertySlot& slot)
226 {
227     JSCSSStyleDeclaration* thisObject = jsCast<JSCSSStyleDeclaration*>(cell);
228     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
229     if (propertyName < static_cast<CSSStyleDeclaration*>(thisObject->impl())->length()) {
230         slot.setCustomIndex(thisObject, propertyName, thisObject->indexGetter);
231         return true;
232     }
233     return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, Identifier::from(exec, propertyName), slot);
234 }
235
236 JSValue jsCSSStyleDeclarationCssText(ExecState* exec, JSValue slotBase, const Identifier&)
237 {
238     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
239     UNUSED_PARAM(exec);
240     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
241     JSValue result = jsStringOrNull(exec, imp->cssText());
242     return result;
243 }
244
245
246 JSValue jsCSSStyleDeclarationLength(ExecState* exec, JSValue slotBase, const Identifier&)
247 {
248     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
249     UNUSED_PARAM(exec);
250     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
251     JSValue result = jsNumber(imp->length());
252     return result;
253 }
254
255
256 JSValue jsCSSStyleDeclarationParentRule(ExecState* exec, JSValue slotBase, const Identifier&)
257 {
258     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
259     UNUSED_PARAM(exec);
260     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
261     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentRule()));
262     return result;
263 }
264
265
266 JSValue jsCSSStyleDeclarationConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
267 {
268     JSCSSStyleDeclaration* domObject = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
269     return JSCSSStyleDeclaration::getConstructor(exec, domObject->globalObject());
270 }
271
272 void JSCSSStyleDeclaration::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
273 {
274     JSCSSStyleDeclaration* thisObject = jsCast<JSCSSStyleDeclaration*>(cell);
275     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
276     if (thisObject->putDelegate(exec, propertyName, value, slot))
277         return;
278     lookupPut<JSCSSStyleDeclaration, Base>(exec, propertyName, value, &JSCSSStyleDeclarationTable, thisObject, slot);
279 }
280
281 void setJSCSSStyleDeclarationCssText(ExecState* exec, JSObject* thisObject, JSValue value)
282 {
283     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(thisObject);
284     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
285     ExceptionCode ec = 0;
286     imp->setCssText(valueToStringWithNullCheck(exec, value), ec);
287     setDOMException(exec, ec);
288 }
289
290
291 void JSCSSStyleDeclaration::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
292 {
293     JSCSSStyleDeclaration* thisObject = jsCast<JSCSSStyleDeclaration*>(object);
294     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
295     for (unsigned i = 0; i < static_cast<CSSStyleDeclaration*>(thisObject->impl())->length(); ++i)
296         propertyNames.add(Identifier::from(exec, i));
297      Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
298 }
299
300 JSValue JSCSSStyleDeclaration::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
301 {
302     return getDOMConstructor<JSCSSStyleDeclarationConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
303 }
304
305 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyValue(ExecState* exec)
306 {
307     JSValue thisValue = exec->hostThisValue();
308     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
309         return throwVMTypeError(exec);
310     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
311     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
312     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
313     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
314     if (exec->hadException())
315         return JSValue::encode(jsUndefined());
316
317     JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyValue(propertyName));
318     return JSValue::encode(result);
319 }
320
321 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyCSSValue(ExecState* exec)
322 {
323     JSValue thisValue = exec->hostThisValue();
324     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
325         return throwVMTypeError(exec);
326     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
327     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
328     return JSValue::encode(castedThis->getPropertyCSSValue(exec));
329 }
330
331 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionRemoveProperty(ExecState* exec)
332 {
333     JSValue thisValue = exec->hostThisValue();
334     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
335         return throwVMTypeError(exec);
336     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
337     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
338     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
339     ExceptionCode ec = 0;
340     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
341     if (exec->hadException())
342         return JSValue::encode(jsUndefined());
343
344     JSC::JSValue result = jsStringOrNull(exec, imp->removeProperty(propertyName, ec));
345     setDOMException(exec, ec);
346     return JSValue::encode(result);
347 }
348
349 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyPriority(ExecState* exec)
350 {
351     JSValue thisValue = exec->hostThisValue();
352     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
353         return throwVMTypeError(exec);
354     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
355     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
356     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
357     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
358     if (exec->hadException())
359         return JSValue::encode(jsUndefined());
360
361     JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyPriority(propertyName));
362     return JSValue::encode(result);
363 }
364
365 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionSetProperty(ExecState* exec)
366 {
367     JSValue thisValue = exec->hostThisValue();
368     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
369         return throwVMTypeError(exec);
370     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
371     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
372     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
373     ExceptionCode ec = 0;
374     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
375     if (exec->hadException())
376         return JSValue::encode(jsUndefined());
377     const String& value(valueToStringWithNullCheck(exec, MAYBE_MISSING_PARAMETER(exec, 1, MissingIsUndefined)));
378     if (exec->hadException())
379         return JSValue::encode(jsUndefined());
380     const String& priority(ustringToString(MAYBE_MISSING_PARAMETER(exec, 2, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 2, MissingIsUndefined).toString(exec)));
381     if (exec->hadException())
382         return JSValue::encode(jsUndefined());
383     imp->setProperty(propertyName, value, priority, ec);
384     setDOMException(exec, ec);
385     return JSValue::encode(jsUndefined());
386 }
387
388 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionItem(ExecState* exec)
389 {
390     JSValue thisValue = exec->hostThisValue();
391     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
392         return throwVMTypeError(exec);
393     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
394     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
395     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
396     unsigned index(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toUInt32(exec));
397     if (exec->hadException())
398         return JSValue::encode(jsUndefined());
399
400     JSC::JSValue result = jsString(exec, imp->item(index));
401     return JSValue::encode(result);
402 }
403
404 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionGetPropertyShorthand(ExecState* exec)
405 {
406     JSValue thisValue = exec->hostThisValue();
407     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
408         return throwVMTypeError(exec);
409     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
410     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
411     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
412     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
413     if (exec->hadException())
414         return JSValue::encode(jsUndefined());
415
416     JSC::JSValue result = jsStringOrNull(exec, imp->getPropertyShorthand(propertyName));
417     return JSValue::encode(result);
418 }
419
420 EncodedJSValue JSC_HOST_CALL jsCSSStyleDeclarationPrototypeFunctionIsPropertyImplicit(ExecState* exec)
421 {
422     JSValue thisValue = exec->hostThisValue();
423     if (!thisValue.inherits(&JSCSSStyleDeclaration::s_info))
424         return throwVMTypeError(exec);
425     JSCSSStyleDeclaration* castedThis = static_cast<JSCSSStyleDeclaration*>(asObject(thisValue));
426     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSCSSStyleDeclaration::s_info);
427     CSSStyleDeclaration* imp = static_cast<CSSStyleDeclaration*>(castedThis->impl());
428     const String& propertyName(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, MissingIsUndefined).toString(exec)));
429     if (exec->hadException())
430         return JSValue::encode(jsUndefined());
431
432     JSC::JSValue result = jsBoolean(imp->isPropertyImplicit(propertyName));
433     return JSValue::encode(result);
434 }
435
436
437 JSValue JSCSSStyleDeclaration::indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
438 {
439     JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(asObject(slotBase));
440     ASSERT_GC_OBJECT_INHERITS(thisObj, &s_info);
441     return jsStringOrNull(exec, thisObj->impl()->item(index));
442 }
443
444 static inline bool isObservable(JSCSSStyleDeclaration* jsCSSStyleDeclaration)
445 {
446     if (jsCSSStyleDeclaration->hasCustomProperties())
447         return true;
448     return false;
449 }
450
451 bool JSCSSStyleDeclarationOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
452 {
453     JSCSSStyleDeclaration* jsCSSStyleDeclaration = static_cast<JSCSSStyleDeclaration*>(handle.get().asCell());
454     if (!isObservable(jsCSSStyleDeclaration))
455         return false;
456     void* root = WebCore::root(jsCSSStyleDeclaration->impl());
457     return visitor.containsOpaqueRoot(root);
458 }
459
460 void JSCSSStyleDeclarationOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
461 {
462     JSCSSStyleDeclaration* jsCSSStyleDeclaration = static_cast<JSCSSStyleDeclaration*>(handle.get().asCell());
463     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
464     uncacheWrapper(world, jsCSSStyleDeclaration->impl(), jsCSSStyleDeclaration);
465     jsCSSStyleDeclaration->releaseImpl();
466 }
467
468 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, CSSStyleDeclaration* impl)
469 {
470     return wrap<JSCSSStyleDeclaration>(exec, globalObject, impl);
471 }
472
473 CSSStyleDeclaration* toCSSStyleDeclaration(JSC::JSValue value)
474 {
475     return value.inherits(&JSCSSStyleDeclaration::s_info) ? static_cast<JSCSSStyleDeclaration*>(asObject(value))->impl() : 0;
476 }
477
478 }