tizen beta release
[framework/web/webkit-efl.git] / DerivedSources / WebCore / JSStyleSheet.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 "JSStyleSheet.h"
23
24 #include "JSMediaList.h"
25 #include "JSNode.h"
26 #include "JSStyleSheet.h"
27 #include "KURL.h"
28 #include "MediaList.h"
29 #include "Node.h"
30 #include "StyleSheet.h"
31 #include <wtf/GetPtr.h>
32
33 using namespace JSC;
34
35 namespace WebCore {
36
37 ASSERT_CLASS_FITS_IN_CELL(JSStyleSheet);
38
39 /* Hash table */
40 #if ENABLE(JIT)
41 #define THUNK_GENERATOR(generator) , generator
42 #else
43 #define THUNK_GENERATOR(generator)
44 #endif
45 #if ENABLE(DFG_JIT)
46 #define INTRINSIC(intrinsic) , intrinsic
47 #else
48 #define INTRINSIC(intrinsic)
49 #endif
50
51 static const HashTableValue JSStyleSheetTableValues[] =
52 {
53     { "type", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetType), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
54     { "disabled", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetDisabled), (intptr_t)setJSStyleSheetDisabled THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
55     { "ownerNode", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetOwnerNode), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
56     { "parentStyleSheet", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetParentStyleSheet), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
57     { "href", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetHref), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
58     { "title", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetTitle), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
59     { "media", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetMedia), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
60     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsStyleSheetConstructor), (intptr_t)0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) },
61     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
62 };
63
64 #undef THUNK_GENERATOR
65 static const HashTable JSStyleSheetTable = { 17, 15, JSStyleSheetTableValues, 0 };
66 /* Hash table for constructor */
67 #if ENABLE(JIT)
68 #define THUNK_GENERATOR(generator) , generator
69 #else
70 #define THUNK_GENERATOR(generator)
71 #endif
72 #if ENABLE(DFG_JIT)
73 #define INTRINSIC(intrinsic) , intrinsic
74 #else
75 #define INTRINSIC(intrinsic)
76 #endif
77
78 static const HashTableValue JSStyleSheetConstructorTableValues[] =
79 {
80     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
81 };
82
83 #undef THUNK_GENERATOR
84 static const HashTable JSStyleSheetConstructorTable = { 1, 0, JSStyleSheetConstructorTableValues, 0 };
85 const ClassInfo JSStyleSheetConstructor::s_info = { "StyleSheetConstructor", &DOMConstructorObject::s_info, &JSStyleSheetConstructorTable, 0, CREATE_METHOD_TABLE(JSStyleSheetConstructor) };
86
87 JSStyleSheetConstructor::JSStyleSheetConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
88     : DOMConstructorObject(structure, globalObject)
89 {
90 }
91
92 void JSStyleSheetConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
93 {
94     Base::finishCreation(exec->globalData());
95     ASSERT(inherits(&s_info));
96     putDirect(exec->globalData(), exec->propertyNames().prototype, JSStyleSheetPrototype::self(exec, globalObject), DontDelete | ReadOnly);
97 }
98
99 bool JSStyleSheetConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
100 {
101     return getStaticValueSlot<JSStyleSheetConstructor, JSDOMWrapper>(exec, &JSStyleSheetConstructorTable, static_cast<JSStyleSheetConstructor*>(cell), propertyName, slot);
102 }
103
104 bool JSStyleSheetConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
105 {
106     return getStaticValueDescriptor<JSStyleSheetConstructor, JSDOMWrapper>(exec, &JSStyleSheetConstructorTable, static_cast<JSStyleSheetConstructor*>(object), propertyName, descriptor);
107 }
108
109 /* Hash table for prototype */
110 #if ENABLE(JIT)
111 #define THUNK_GENERATOR(generator) , generator
112 #else
113 #define THUNK_GENERATOR(generator)
114 #endif
115 #if ENABLE(DFG_JIT)
116 #define INTRINSIC(intrinsic) , intrinsic
117 #else
118 #define INTRINSIC(intrinsic)
119 #endif
120
121 static const HashTableValue JSStyleSheetPrototypeTableValues[] =
122 {
123     { 0, 0, 0, 0 THUNK_GENERATOR(0) INTRINSIC(DFG::NoIntrinsic) }
124 };
125
126 #undef THUNK_GENERATOR
127 static const HashTable JSStyleSheetPrototypeTable = { 1, 0, JSStyleSheetPrototypeTableValues, 0 };
128 const ClassInfo JSStyleSheetPrototype::s_info = { "StyleSheetPrototype", &JSC::JSNonFinalObject::s_info, &JSStyleSheetPrototypeTable, 0, CREATE_METHOD_TABLE(JSStyleSheetPrototype) };
129
130 JSObject* JSStyleSheetPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
131 {
132     return getDOMPrototype<JSStyleSheet>(exec, globalObject);
133 }
134
135 const ClassInfo JSStyleSheet::s_info = { "StyleSheet", &JSDOMWrapper::s_info, &JSStyleSheetTable, 0 , CREATE_METHOD_TABLE(JSStyleSheet) };
136
137 JSStyleSheet::JSStyleSheet(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<StyleSheet> impl)
138     : JSDOMWrapper(structure, globalObject)
139     , m_impl(impl.leakRef())
140 {
141 }
142
143 void JSStyleSheet::finishCreation(JSGlobalData& globalData)
144 {
145     Base::finishCreation(globalData);
146     ASSERT(inherits(&s_info));
147 }
148
149 JSObject* JSStyleSheet::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
150 {
151     return JSStyleSheetPrototype::create(exec->globalData(), globalObject, JSStyleSheetPrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
152 }
153
154 bool JSStyleSheet::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
155 {
156     JSStyleSheet* thisObject = jsCast<JSStyleSheet*>(cell);
157     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
158     return getStaticValueSlot<JSStyleSheet, Base>(exec, &JSStyleSheetTable, thisObject, propertyName, slot);
159 }
160
161 bool JSStyleSheet::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
162 {
163     JSStyleSheet* thisObject = jsCast<JSStyleSheet*>(object);
164     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
165     return getStaticValueDescriptor<JSStyleSheet, Base>(exec, &JSStyleSheetTable, thisObject, propertyName, descriptor);
166 }
167
168 JSValue jsStyleSheetType(ExecState* exec, JSValue slotBase, const Identifier&)
169 {
170     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
171     UNUSED_PARAM(exec);
172     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
173     JSValue result = jsStringOrNull(exec, imp->type());
174     return result;
175 }
176
177
178 JSValue jsStyleSheetDisabled(ExecState* exec, JSValue slotBase, const Identifier&)
179 {
180     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
181     UNUSED_PARAM(exec);
182     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
183     JSValue result = jsBoolean(imp->disabled());
184     return result;
185 }
186
187
188 JSValue jsStyleSheetOwnerNode(ExecState* exec, JSValue slotBase, const Identifier&)
189 {
190     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
191     UNUSED_PARAM(exec);
192     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
193     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->ownerNode()));
194     return result;
195 }
196
197
198 JSValue jsStyleSheetParentStyleSheet(ExecState* exec, JSValue slotBase, const Identifier&)
199 {
200     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
201     UNUSED_PARAM(exec);
202     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
203     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->parentStyleSheet()));
204     return result;
205 }
206
207
208 JSValue jsStyleSheetHref(ExecState* exec, JSValue slotBase, const Identifier&)
209 {
210     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
211     UNUSED_PARAM(exec);
212     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
213     JSValue result = jsStringOrNull(exec, imp->href());
214     return result;
215 }
216
217
218 JSValue jsStyleSheetTitle(ExecState* exec, JSValue slotBase, const Identifier&)
219 {
220     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
221     UNUSED_PARAM(exec);
222     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
223     JSValue result = jsStringOrNull(exec, imp->title());
224     return result;
225 }
226
227
228 JSValue jsStyleSheetMedia(ExecState* exec, JSValue slotBase, const Identifier&)
229 {
230     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(asObject(slotBase));
231     UNUSED_PARAM(exec);
232     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
233     JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->media()));
234     return result;
235 }
236
237
238 JSValue jsStyleSheetConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
239 {
240     JSStyleSheet* domObject = static_cast<JSStyleSheet*>(asObject(slotBase));
241     return JSStyleSheet::getConstructor(exec, domObject->globalObject());
242 }
243
244 void JSStyleSheet::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
245 {
246     JSStyleSheet* thisObject = jsCast<JSStyleSheet*>(cell);
247     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
248     lookupPut<JSStyleSheet, Base>(exec, propertyName, value, &JSStyleSheetTable, thisObject, slot);
249 }
250
251 void setJSStyleSheetDisabled(ExecState* exec, JSObject* thisObject, JSValue value)
252 {
253     JSStyleSheet* castedThis = static_cast<JSStyleSheet*>(thisObject);
254     StyleSheet* imp = static_cast<StyleSheet*>(castedThis->impl());
255     imp->setDisabled(value.toBoolean(exec));
256 }
257
258
259 JSValue JSStyleSheet::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
260 {
261     return getDOMConstructor<JSStyleSheetConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
262 }
263
264 static inline bool isObservable(JSStyleSheet* jsStyleSheet)
265 {
266     if (jsStyleSheet->hasCustomProperties())
267         return true;
268     return false;
269 }
270
271 bool JSStyleSheetOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
272 {
273     JSStyleSheet* jsStyleSheet = static_cast<JSStyleSheet*>(handle.get().asCell());
274     if (!isObservable(jsStyleSheet))
275         return false;
276     void* root = WebCore::root(jsStyleSheet->impl());
277     return visitor.containsOpaqueRoot(root);
278 }
279
280 void JSStyleSheetOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
281 {
282     JSStyleSheet* jsStyleSheet = static_cast<JSStyleSheet*>(handle.get().asCell());
283     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
284     uncacheWrapper(world, jsStyleSheet->impl(), jsStyleSheet);
285     jsStyleSheet->releaseImpl();
286 }
287
288 StyleSheet* toStyleSheet(JSC::JSValue value)
289 {
290     return value.inherits(&JSStyleSheet::s_info) ? static_cast<JSStyleSheet*>(asObject(value))->impl() : 0;
291 }
292
293 }