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 "JSCSSKeyframesRule.h"
23
24#include "JSCSSKeyframeRule.h"
25#include "JSCSSRuleList.h"
26#include "JSDOMAttribute.h"
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertInterface.h"
30#include "JSDOMConvertNullable.h"
31#include "JSDOMConvertStrings.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMOperation.h"
35#include "JSDOMWrapperCache.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <JavaScriptCore/PropertyNameArray.h>
40#include <wtf/GetPtr.h>
41#include <wtf/PointerPreparations.h>
42#include <wtf/URL.h>
43
44
45namespace WebCore {
46using namespace JSC;
47
48// Functions
49
50JSC::EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionInsertRule(JSC::ExecState*);
51JSC::EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionAppendRule(JSC::ExecState*);
52JSC::EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionDeleteRule(JSC::ExecState*);
53JSC::EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionFindRule(JSC::ExecState*);
54
55// Attributes
56
57JSC::EncodedJSValue jsCSSKeyframesRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58bool setJSCSSKeyframesRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
59JSC::EncodedJSValue jsCSSKeyframesRuleName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
60bool setJSCSSKeyframesRuleName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
61JSC::EncodedJSValue jsCSSKeyframesRuleCssRules(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62
63class JSCSSKeyframesRulePrototype : public JSC::JSNonFinalObject {
64public:
65 using Base = JSC::JSNonFinalObject;
66 static JSCSSKeyframesRulePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
67 {
68 JSCSSKeyframesRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSKeyframesRulePrototype>(vm.heap)) JSCSSKeyframesRulePrototype(vm, globalObject, structure);
69 ptr->finishCreation(vm);
70 return ptr;
71 }
72
73 DECLARE_INFO;
74 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
75 {
76 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
77 }
78
79private:
80 JSCSSKeyframesRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
81 : JSC::JSNonFinalObject(vm, structure)
82 {
83 }
84
85 void finishCreation(JSC::VM&);
86};
87
88using JSCSSKeyframesRuleConstructor = JSDOMConstructorNotConstructable<JSCSSKeyframesRule>;
89
90template<> JSValue JSCSSKeyframesRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
91{
92 return JSCSSRule::getConstructor(vm, &globalObject);
93}
94
95template<> void JSCSSKeyframesRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
96{
97 putDirect(vm, vm.propertyNames->prototype, JSCSSKeyframesRule::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSKeyframesRule"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
99 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
100}
101
102template<> const ClassInfo JSCSSKeyframesRuleConstructor::s_info = { "CSSKeyframesRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSKeyframesRuleConstructor) };
103
104/* Hash table for prototype */
105
106static const HashTableValue JSCSSKeyframesRulePrototypeTableValues[] =
107{
108 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSKeyframesRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSKeyframesRuleConstructor) } },
109 { "name", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSKeyframesRuleName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSKeyframesRuleName) } },
110 { "cssRules", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSKeyframesRuleCssRules), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
111 { "insertRule", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCSSKeyframesRulePrototypeFunctionInsertRule), (intptr_t) (1) } },
112 { "appendRule", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCSSKeyframesRulePrototypeFunctionAppendRule), (intptr_t) (1) } },
113 { "deleteRule", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCSSKeyframesRulePrototypeFunctionDeleteRule), (intptr_t) (1) } },
114 { "findRule", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsCSSKeyframesRulePrototypeFunctionFindRule), (intptr_t) (1) } },
115};
116
117const ClassInfo JSCSSKeyframesRulePrototype::s_info = { "CSSKeyframesRulePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSKeyframesRulePrototype) };
118
119void JSCSSKeyframesRulePrototype::finishCreation(VM& vm)
120{
121 Base::finishCreation(vm);
122 reifyStaticProperties(vm, JSCSSKeyframesRule::info(), JSCSSKeyframesRulePrototypeTableValues, *this);
123}
124
125const ClassInfo JSCSSKeyframesRule::s_info = { "CSSKeyframesRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSKeyframesRule) };
126
127JSCSSKeyframesRule::JSCSSKeyframesRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSKeyframesRule>&& impl)
128 : JSCSSRule(structure, globalObject, WTFMove(impl))
129{
130}
131
132void JSCSSKeyframesRule::finishCreation(VM& vm)
133{
134 Base::finishCreation(vm);
135 ASSERT(inherits(vm, info()));
136
137}
138
139JSObject* JSCSSKeyframesRule::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
140{
141 return JSCSSKeyframesRulePrototype::create(vm, &globalObject, JSCSSKeyframesRulePrototype::createStructure(vm, &globalObject, JSCSSRule::prototype(vm, globalObject)));
142}
143
144JSObject* JSCSSKeyframesRule::prototype(VM& vm, JSDOMGlobalObject& globalObject)
145{
146 return getDOMPrototype<JSCSSKeyframesRule>(vm, globalObject);
147}
148
149JSValue JSCSSKeyframesRule::getConstructor(VM& vm, const JSGlobalObject* globalObject)
150{
151 return getDOMConstructor<JSCSSKeyframesRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
152}
153
154bool JSCSSKeyframesRule::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
155{
156 auto* thisObject = jsCast<JSCSSKeyframesRule*>(object);
157 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
158 if (auto index = parseIndex(propertyName)) {
159 if (index.value() < thisObject->wrapped().length()) {
160 auto value = toJS<IDLInterface<CSSKeyframeRule>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index.value()));
161 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
162 return true;
163 }
164 }
165 return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
166}
167
168bool JSCSSKeyframesRule::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
169{
170 auto* thisObject = jsCast<JSCSSKeyframesRule*>(object);
171 ASSERT_GC_OBJECT_INHERITS(thisObject, info());
172 if (LIKELY(index <= MAX_ARRAY_INDEX)) {
173 if (index < thisObject->wrapped().length()) {
174 auto value = toJS<IDLInterface<CSSKeyframeRule>>(*state, *thisObject->globalObject(), thisObject->wrapped().item(index));
175 slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), value);
176 return true;
177 }
178 }
179 return JSObject::getOwnPropertySlotByIndex(object, state, index, slot);
180}
181
182void JSCSSKeyframesRule::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
183{
184 auto* thisObject = jsCast<JSCSSKeyframesRule*>(object);
185 ASSERT_GC_OBJECT_INHERITS(object, info());
186 for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
187 propertyNames.add(Identifier::from(state, i));
188 JSObject::getOwnPropertyNames(object, state, propertyNames, mode);
189}
190
191template<> inline JSCSSKeyframesRule* IDLAttribute<JSCSSKeyframesRule>::cast(ExecState& state, EncodedJSValue thisValue)
192{
193 return jsDynamicCast<JSCSSKeyframesRule*>(state.vm(), JSValue::decode(thisValue));
194}
195
196template<> inline JSCSSKeyframesRule* IDLOperation<JSCSSKeyframesRule>::cast(ExecState& state)
197{
198 return jsDynamicCast<JSCSSKeyframesRule*>(state.vm(), state.thisValue());
199}
200
201EncodedJSValue jsCSSKeyframesRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
202{
203 VM& vm = state->vm();
204 auto throwScope = DECLARE_THROW_SCOPE(vm);
205 auto* prototype = jsDynamicCast<JSCSSKeyframesRulePrototype*>(vm, JSValue::decode(thisValue));
206 if (UNLIKELY(!prototype))
207 return throwVMTypeError(state, throwScope);
208 return JSValue::encode(JSCSSKeyframesRule::getConstructor(state->vm(), prototype->globalObject()));
209}
210
211bool setJSCSSKeyframesRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
212{
213 VM& vm = state->vm();
214 auto throwScope = DECLARE_THROW_SCOPE(vm);
215 auto* prototype = jsDynamicCast<JSCSSKeyframesRulePrototype*>(vm, JSValue::decode(thisValue));
216 if (UNLIKELY(!prototype)) {
217 throwVMTypeError(state, throwScope);
218 return false;
219 }
220 // Shadowing a built-in constructor
221 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
222}
223
224static inline JSValue jsCSSKeyframesRuleNameGetter(ExecState& state, JSCSSKeyframesRule& thisObject, ThrowScope& throwScope)
225{
226 UNUSED_PARAM(throwScope);
227 UNUSED_PARAM(state);
228 auto& impl = thisObject.wrapped();
229 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name());
230 return result;
231}
232
233EncodedJSValue jsCSSKeyframesRuleName(ExecState* state, EncodedJSValue thisValue, PropertyName)
234{
235 return IDLAttribute<JSCSSKeyframesRule>::get<jsCSSKeyframesRuleNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name");
236}
237
238static inline bool setJSCSSKeyframesRuleNameSetter(ExecState& state, JSCSSKeyframesRule& thisObject, JSValue value, ThrowScope& throwScope)
239{
240 UNUSED_PARAM(throwScope);
241 auto& impl = thisObject.wrapped();
242 auto nativeValue = convert<IDLDOMString>(state, value);
243 RETURN_IF_EXCEPTION(throwScope, false);
244 AttributeSetter::call(state, throwScope, [&] {
245 return impl.setName(WTFMove(nativeValue));
246 });
247 return true;
248}
249
250bool setJSCSSKeyframesRuleName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
251{
252 return IDLAttribute<JSCSSKeyframesRule>::set<setJSCSSKeyframesRuleNameSetter>(*state, thisValue, encodedValue, "name");
253}
254
255static inline JSValue jsCSSKeyframesRuleCssRulesGetter(ExecState& state, JSCSSKeyframesRule& thisObject, ThrowScope& throwScope)
256{
257 UNUSED_PARAM(throwScope);
258 UNUSED_PARAM(state);
259 auto& impl = thisObject.wrapped();
260 JSValue result = toJS<IDLInterface<CSSRuleList>>(state, *thisObject.globalObject(), throwScope, impl.cssRules());
261 return result;
262}
263
264EncodedJSValue jsCSSKeyframesRuleCssRules(ExecState* state, EncodedJSValue thisValue, PropertyName)
265{
266 return IDLAttribute<JSCSSKeyframesRule>::get<jsCSSKeyframesRuleCssRulesGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "cssRules");
267}
268
269static inline JSC::EncodedJSValue jsCSSKeyframesRulePrototypeFunctionInsertRuleBody(JSC::ExecState* state, typename IDLOperation<JSCSSKeyframesRule>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
270{
271 UNUSED_PARAM(state);
272 UNUSED_PARAM(throwScope);
273 auto& impl = castedThis->wrapped();
274 if (UNLIKELY(state->argumentCount() < 1))
275 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
276 auto rule = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
277 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
278 impl.insertRule(WTFMove(rule));
279 return JSValue::encode(jsUndefined());
280}
281
282EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionInsertRule(ExecState* state)
283{
284 return IDLOperation<JSCSSKeyframesRule>::call<jsCSSKeyframesRulePrototypeFunctionInsertRuleBody>(*state, "insertRule");
285}
286
287static inline JSC::EncodedJSValue jsCSSKeyframesRulePrototypeFunctionAppendRuleBody(JSC::ExecState* state, typename IDLOperation<JSCSSKeyframesRule>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
288{
289 UNUSED_PARAM(state);
290 UNUSED_PARAM(throwScope);
291 auto& impl = castedThis->wrapped();
292 if (UNLIKELY(state->argumentCount() < 1))
293 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
294 auto rule = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
295 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
296 impl.appendRule(WTFMove(rule));
297 return JSValue::encode(jsUndefined());
298}
299
300EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionAppendRule(ExecState* state)
301{
302 return IDLOperation<JSCSSKeyframesRule>::call<jsCSSKeyframesRulePrototypeFunctionAppendRuleBody>(*state, "appendRule");
303}
304
305static inline JSC::EncodedJSValue jsCSSKeyframesRulePrototypeFunctionDeleteRuleBody(JSC::ExecState* state, typename IDLOperation<JSCSSKeyframesRule>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
306{
307 UNUSED_PARAM(state);
308 UNUSED_PARAM(throwScope);
309 auto& impl = castedThis->wrapped();
310 if (UNLIKELY(state->argumentCount() < 1))
311 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
312 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
313 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
314 impl.deleteRule(WTFMove(key));
315 return JSValue::encode(jsUndefined());
316}
317
318EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionDeleteRule(ExecState* state)
319{
320 return IDLOperation<JSCSSKeyframesRule>::call<jsCSSKeyframesRulePrototypeFunctionDeleteRuleBody>(*state, "deleteRule");
321}
322
323static inline JSC::EncodedJSValue jsCSSKeyframesRulePrototypeFunctionFindRuleBody(JSC::ExecState* state, typename IDLOperation<JSCSSKeyframesRule>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
324{
325 UNUSED_PARAM(state);
326 UNUSED_PARAM(throwScope);
327 auto& impl = castedThis->wrapped();
328 if (UNLIKELY(state->argumentCount() < 1))
329 return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
330 auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
331 RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
332 return JSValue::encode(toJS<IDLNullable<IDLInterface<CSSKeyframeRule>>>(*state, *castedThis->globalObject(), impl.findRule(WTFMove(key))));
333}
334
335EncodedJSValue JSC_HOST_CALL jsCSSKeyframesRulePrototypeFunctionFindRule(ExecState* state)
336{
337 return IDLOperation<JSCSSKeyframesRule>::call<jsCSSKeyframesRulePrototypeFunctionFindRuleBody>(*state, "findRule");
338}
339
340void JSCSSKeyframesRule::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
341{
342 auto* thisObject = jsCast<JSCSSKeyframesRule*>(cell);
343 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
344 if (thisObject->scriptExecutionContext())
345 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
346 Base::heapSnapshot(cell, builder);
347}
348
349
350}
351