|
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 "JSCSSStyleSheet.h" |
|
23 |
|
24 #include "CSSRule.h" |
|
25 #include "CSSRuleList.h" |
|
26 #include "CSSStyleSheet.h" |
|
27 #include "JSCSSRule.h" |
|
28 #include "JSCSSRuleList.h" |
|
29 #include <runtime/Error.h> |
|
30 #include <runtime/JSNumberCell.h> |
|
31 #include <wtf/GetPtr.h> |
|
32 |
|
33 using namespace JSC; |
|
34 |
|
35 namespace WebCore { |
|
36 |
|
37 ASSERT_CLASS_FITS_IN_CELL(JSCSSStyleSheet); |
|
38 |
|
39 /* Hash table */ |
|
40 #if ENABLE(JIT) |
|
41 #define THUNK_GENERATOR(generator) , generator |
|
42 #else |
|
43 #define THUNK_GENERATOR(generator) |
|
44 #endif |
|
45 |
|
46 static const HashTableValue JSCSSStyleSheetTableValues[5] = |
|
47 { |
|
48 { "ownerRule", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleSheetOwnerRule), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
49 { "cssRules", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleSheetCssRules), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
50 { "rules", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleSheetRules), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
51 { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSStyleSheetConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, |
|
52 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
53 }; |
|
54 |
|
55 #undef THUNK_GENERATOR |
|
56 static JSC_CONST_HASHTABLE HashTable JSCSSStyleSheetTable = { 9, 7, JSCSSStyleSheetTableValues, 0 }; |
|
57 /* Hash table for constructor */ |
|
58 #if ENABLE(JIT) |
|
59 #define THUNK_GENERATOR(generator) , generator |
|
60 #else |
|
61 #define THUNK_GENERATOR(generator) |
|
62 #endif |
|
63 |
|
64 static const HashTableValue JSCSSStyleSheetConstructorTableValues[1] = |
|
65 { |
|
66 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
67 }; |
|
68 |
|
69 #undef THUNK_GENERATOR |
|
70 static JSC_CONST_HASHTABLE HashTable JSCSSStyleSheetConstructorTable = { 1, 0, JSCSSStyleSheetConstructorTableValues, 0 }; |
|
71 class JSCSSStyleSheetConstructor : public DOMConstructorObject { |
|
72 public: |
|
73 JSCSSStyleSheetConstructor(JSC::ExecState*, JSDOMGlobalObject*); |
|
74 |
|
75 virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); |
|
76 virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); |
|
77 virtual const JSC::ClassInfo* classInfo() const { return &s_info; } |
|
78 static const JSC::ClassInfo s_info; |
|
79 static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) |
|
80 { |
|
81 return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); |
|
82 } |
|
83 protected: |
|
84 static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::ImplementsHasInstance | DOMConstructorObject::StructureFlags; |
|
85 }; |
|
86 |
|
87 const ClassInfo JSCSSStyleSheetConstructor::s_info = { "CSSStyleSheetConstructor", 0, &JSCSSStyleSheetConstructorTable, 0 }; |
|
88 |
|
89 JSCSSStyleSheetConstructor::JSCSSStyleSheetConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) |
|
90 : DOMConstructorObject(JSCSSStyleSheetConstructor::createStructure(globalObject->objectPrototype()), globalObject) |
|
91 { |
|
92 putDirect(exec->propertyNames().prototype, JSCSSStyleSheetPrototype::self(exec, globalObject), DontDelete | ReadOnly); |
|
93 } |
|
94 |
|
95 bool JSCSSStyleSheetConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
96 { |
|
97 return getStaticValueSlot<JSCSSStyleSheetConstructor, DOMObject>(exec, &JSCSSStyleSheetConstructorTable, this, propertyName, slot); |
|
98 } |
|
99 |
|
100 bool JSCSSStyleSheetConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
101 { |
|
102 return getStaticValueDescriptor<JSCSSStyleSheetConstructor, DOMObject>(exec, &JSCSSStyleSheetConstructorTable, this, propertyName, descriptor); |
|
103 } |
|
104 |
|
105 /* Hash table for prototype */ |
|
106 #if ENABLE(JIT) |
|
107 #define THUNK_GENERATOR(generator) , generator |
|
108 #else |
|
109 #define THUNK_GENERATOR(generator) |
|
110 #endif |
|
111 |
|
112 static const HashTableValue JSCSSStyleSheetPrototypeTableValues[5] = |
|
113 { |
|
114 { "insertRule", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleSheetPrototypeFunctionInsertRule), (intptr_t)2 THUNK_GENERATOR(0) }, |
|
115 { "deleteRule", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleSheetPrototypeFunctionDeleteRule), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
116 { "addRule", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleSheetPrototypeFunctionAddRule), (intptr_t)3 THUNK_GENERATOR(0) }, |
|
117 { "removeRule", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsCSSStyleSheetPrototypeFunctionRemoveRule), (intptr_t)1 THUNK_GENERATOR(0) }, |
|
118 { 0, 0, 0, 0 THUNK_GENERATOR(0) } |
|
119 }; |
|
120 |
|
121 #undef THUNK_GENERATOR |
|
122 static JSC_CONST_HASHTABLE HashTable JSCSSStyleSheetPrototypeTable = { 8, 7, JSCSSStyleSheetPrototypeTableValues, 0 }; |
|
123 const ClassInfo JSCSSStyleSheetPrototype::s_info = { "CSSStyleSheetPrototype", 0, &JSCSSStyleSheetPrototypeTable, 0 }; |
|
124 |
|
125 JSObject* JSCSSStyleSheetPrototype::self(ExecState* exec, JSGlobalObject* globalObject) |
|
126 { |
|
127 return getDOMPrototype<JSCSSStyleSheet>(exec, globalObject); |
|
128 } |
|
129 |
|
130 bool JSCSSStyleSheetPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
131 { |
|
132 return getStaticFunctionSlot<JSObject>(exec, &JSCSSStyleSheetPrototypeTable, this, propertyName, slot); |
|
133 } |
|
134 |
|
135 bool JSCSSStyleSheetPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
136 { |
|
137 return getStaticFunctionDescriptor<JSObject>(exec, &JSCSSStyleSheetPrototypeTable, this, propertyName, descriptor); |
|
138 } |
|
139 |
|
140 const ClassInfo JSCSSStyleSheet::s_info = { "CSSStyleSheet", &JSStyleSheet::s_info, &JSCSSStyleSheetTable, 0 }; |
|
141 |
|
142 JSCSSStyleSheet::JSCSSStyleSheet(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<CSSStyleSheet> impl) |
|
143 : JSStyleSheet(structure, globalObject, impl) |
|
144 { |
|
145 } |
|
146 |
|
147 JSObject* JSCSSStyleSheet::createPrototype(ExecState* exec, JSGlobalObject* globalObject) |
|
148 { |
|
149 return new (exec) JSCSSStyleSheetPrototype(globalObject, JSCSSStyleSheetPrototype::createStructure(JSStyleSheetPrototype::self(exec, globalObject))); |
|
150 } |
|
151 |
|
152 bool JSCSSStyleSheet::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) |
|
153 { |
|
154 return getStaticValueSlot<JSCSSStyleSheet, Base>(exec, &JSCSSStyleSheetTable, this, propertyName, slot); |
|
155 } |
|
156 |
|
157 bool JSCSSStyleSheet::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) |
|
158 { |
|
159 return getStaticValueDescriptor<JSCSSStyleSheet, Base>(exec, &JSCSSStyleSheetTable, this, propertyName, descriptor); |
|
160 } |
|
161 |
|
162 JSValue jsCSSStyleSheetOwnerRule(ExecState* exec, JSValue slotBase, const Identifier&) |
|
163 { |
|
164 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(slotBase)); |
|
165 UNUSED_PARAM(exec); |
|
166 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
167 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->ownerRule())); |
|
168 return result; |
|
169 } |
|
170 |
|
171 JSValue jsCSSStyleSheetCssRules(ExecState* exec, JSValue slotBase, const Identifier&) |
|
172 { |
|
173 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(slotBase)); |
|
174 UNUSED_PARAM(exec); |
|
175 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
176 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->cssRules())); |
|
177 return result; |
|
178 } |
|
179 |
|
180 JSValue jsCSSStyleSheetRules(ExecState* exec, JSValue slotBase, const Identifier&) |
|
181 { |
|
182 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(slotBase)); |
|
183 UNUSED_PARAM(exec); |
|
184 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
185 JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->rules())); |
|
186 return result; |
|
187 } |
|
188 |
|
189 JSValue jsCSSStyleSheetConstructor(ExecState* exec, JSValue slotBase, const Identifier&) |
|
190 { |
|
191 JSCSSStyleSheet* domObject = static_cast<JSCSSStyleSheet*>(asObject(slotBase)); |
|
192 return JSCSSStyleSheet::getConstructor(exec, domObject->globalObject()); |
|
193 } |
|
194 JSValue JSCSSStyleSheet::getConstructor(ExecState* exec, JSGlobalObject* globalObject) |
|
195 { |
|
196 return getDOMConstructor<JSCSSStyleSheetConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); |
|
197 } |
|
198 |
|
199 EncodedJSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionInsertRule(ExecState* exec) |
|
200 { |
|
201 JSValue thisValue = exec->hostThisValue(); |
|
202 if (!thisValue.inherits(&JSCSSStyleSheet::s_info)) |
|
203 return throwVMTypeError(exec); |
|
204 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(thisValue)); |
|
205 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
206 ExceptionCode ec = 0; |
|
207 const String& rule = ustringToString(exec->argument(0).toString(exec)); |
|
208 unsigned index = exec->argument(1).toInt32(exec); |
|
209 |
|
210 |
|
211 JSC::JSValue result = jsNumber(exec, imp->insertRule(rule, index, ec)); |
|
212 setDOMException(exec, ec); |
|
213 return JSValue::encode(result); |
|
214 } |
|
215 |
|
216 EncodedJSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionDeleteRule(ExecState* exec) |
|
217 { |
|
218 JSValue thisValue = exec->hostThisValue(); |
|
219 if (!thisValue.inherits(&JSCSSStyleSheet::s_info)) |
|
220 return throwVMTypeError(exec); |
|
221 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(thisValue)); |
|
222 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
223 ExceptionCode ec = 0; |
|
224 unsigned index = exec->argument(0).toInt32(exec); |
|
225 |
|
226 imp->deleteRule(index, ec); |
|
227 setDOMException(exec, ec); |
|
228 return JSValue::encode(jsUndefined()); |
|
229 } |
|
230 |
|
231 EncodedJSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionAddRule(ExecState* exec) |
|
232 { |
|
233 JSValue thisValue = exec->hostThisValue(); |
|
234 if (!thisValue.inherits(&JSCSSStyleSheet::s_info)) |
|
235 return throwVMTypeError(exec); |
|
236 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(thisValue)); |
|
237 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
238 ExceptionCode ec = 0; |
|
239 const String& selector = ustringToString(exec->argument(0).toString(exec)); |
|
240 const String& style = ustringToString(exec->argument(1).toString(exec)); |
|
241 |
|
242 int argsCount = exec->argumentCount(); |
|
243 if (argsCount < 3) { |
|
244 |
|
245 JSC::JSValue result = jsNumber(exec, imp->addRule(selector, style, ec)); |
|
246 setDOMException(exec, ec); |
|
247 return JSValue::encode(result); |
|
248 } |
|
249 |
|
250 unsigned index = exec->argument(2).toInt32(exec); |
|
251 |
|
252 |
|
253 JSC::JSValue result = jsNumber(exec, imp->addRule(selector, style, index, ec)); |
|
254 setDOMException(exec, ec); |
|
255 return JSValue::encode(result); |
|
256 } |
|
257 |
|
258 EncodedJSValue JSC_HOST_CALL jsCSSStyleSheetPrototypeFunctionRemoveRule(ExecState* exec) |
|
259 { |
|
260 JSValue thisValue = exec->hostThisValue(); |
|
261 if (!thisValue.inherits(&JSCSSStyleSheet::s_info)) |
|
262 return throwVMTypeError(exec); |
|
263 JSCSSStyleSheet* castedThis = static_cast<JSCSSStyleSheet*>(asObject(thisValue)); |
|
264 CSSStyleSheet* imp = static_cast<CSSStyleSheet*>(castedThis->impl()); |
|
265 ExceptionCode ec = 0; |
|
266 unsigned index = exec->argument(0).toInt32(exec); |
|
267 |
|
268 imp->removeRule(index, ec); |
|
269 setDOMException(exec, ec); |
|
270 return JSValue::encode(jsUndefined()); |
|
271 } |
|
272 |
|
273 |
|
274 } |