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 "JSCSSImportRule.h"
23
24#include "JSCSSStyleSheet.h"
25#include "JSDOMAttribute.h"
26#include "JSDOMBinding.h"
27#include "JSDOMConstructorNotConstructable.h"
28#include "JSDOMConvertInterface.h"
29#include "JSDOMConvertNullable.h"
30#include "JSDOMConvertStrings.h"
31#include "JSDOMExceptionHandling.h"
32#include "JSDOMGlobalObject.h"
33#include "JSDOMWrapperCache.h"
34#include "JSMediaList.h"
35#include "ScriptExecutionContext.h"
36#include <JavaScriptCore/HeapSnapshotBuilder.h>
37#include <JavaScriptCore/JSCInlines.h>
38#include <wtf/GetPtr.h>
39#include <wtf/PointerPreparations.h>
40#include <wtf/URL.h>
41
42
43namespace WebCore {
44using namespace JSC;
45
46// Attributes
47
48JSC::EncodedJSValue jsCSSImportRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49bool setJSCSSImportRuleConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50JSC::EncodedJSValue jsCSSImportRuleHref(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
51JSC::EncodedJSValue jsCSSImportRuleMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52JSC::EncodedJSValue jsCSSImportRuleStyleSheet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
53
54class JSCSSImportRulePrototype : public JSC::JSNonFinalObject {
55public:
56 using Base = JSC::JSNonFinalObject;
57 static JSCSSImportRulePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
58 {
59 JSCSSImportRulePrototype* ptr = new (NotNull, JSC::allocateCell<JSCSSImportRulePrototype>(vm.heap)) JSCSSImportRulePrototype(vm, globalObject, structure);
60 ptr->finishCreation(vm);
61 return ptr;
62 }
63
64 DECLARE_INFO;
65 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
66 {
67 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
68 }
69
70private:
71 JSCSSImportRulePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
72 : JSC::JSNonFinalObject(vm, structure)
73 {
74 }
75
76 void finishCreation(JSC::VM&);
77};
78
79using JSCSSImportRuleConstructor = JSDOMConstructorNotConstructable<JSCSSImportRule>;
80
81template<> JSValue JSCSSImportRuleConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
82{
83 return JSCSSRule::getConstructor(vm, &globalObject);
84}
85
86template<> void JSCSSImportRuleConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
87{
88 putDirect(vm, vm.propertyNames->prototype, JSCSSImportRule::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("CSSImportRule"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
90 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
91}
92
93template<> const ClassInfo JSCSSImportRuleConstructor::s_info = { "CSSImportRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSImportRuleConstructor) };
94
95/* Hash table for prototype */
96
97static const HashTableValue JSCSSImportRulePrototypeTableValues[] =
98{
99 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSImportRuleConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSCSSImportRuleConstructor) } },
100 { "href", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSImportRuleHref), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
101 { "media", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSImportRuleMedia), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102 { "styleSheet", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsCSSImportRuleStyleSheet), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103};
104
105const ClassInfo JSCSSImportRulePrototype::s_info = { "CSSImportRulePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSImportRulePrototype) };
106
107void JSCSSImportRulePrototype::finishCreation(VM& vm)
108{
109 Base::finishCreation(vm);
110 reifyStaticProperties(vm, JSCSSImportRule::info(), JSCSSImportRulePrototypeTableValues, *this);
111}
112
113const ClassInfo JSCSSImportRule::s_info = { "CSSImportRule", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCSSImportRule) };
114
115JSCSSImportRule::JSCSSImportRule(Structure* structure, JSDOMGlobalObject& globalObject, Ref<CSSImportRule>&& impl)
116 : JSCSSRule(structure, globalObject, WTFMove(impl))
117{
118}
119
120void JSCSSImportRule::finishCreation(VM& vm)
121{
122 Base::finishCreation(vm);
123 ASSERT(inherits(vm, info()));
124
125}
126
127JSObject* JSCSSImportRule::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
128{
129 return JSCSSImportRulePrototype::create(vm, &globalObject, JSCSSImportRulePrototype::createStructure(vm, &globalObject, JSCSSRule::prototype(vm, globalObject)));
130}
131
132JSObject* JSCSSImportRule::prototype(VM& vm, JSDOMGlobalObject& globalObject)
133{
134 return getDOMPrototype<JSCSSImportRule>(vm, globalObject);
135}
136
137JSValue JSCSSImportRule::getConstructor(VM& vm, const JSGlobalObject* globalObject)
138{
139 return getDOMConstructor<JSCSSImportRuleConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
140}
141
142template<> inline JSCSSImportRule* IDLAttribute<JSCSSImportRule>::cast(ExecState& state, EncodedJSValue thisValue)
143{
144 return jsDynamicCast<JSCSSImportRule*>(state.vm(), JSValue::decode(thisValue));
145}
146
147EncodedJSValue jsCSSImportRuleConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
148{
149 VM& vm = state->vm();
150 auto throwScope = DECLARE_THROW_SCOPE(vm);
151 auto* prototype = jsDynamicCast<JSCSSImportRulePrototype*>(vm, JSValue::decode(thisValue));
152 if (UNLIKELY(!prototype))
153 return throwVMTypeError(state, throwScope);
154 return JSValue::encode(JSCSSImportRule::getConstructor(state->vm(), prototype->globalObject()));
155}
156
157bool setJSCSSImportRuleConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
158{
159 VM& vm = state->vm();
160 auto throwScope = DECLARE_THROW_SCOPE(vm);
161 auto* prototype = jsDynamicCast<JSCSSImportRulePrototype*>(vm, JSValue::decode(thisValue));
162 if (UNLIKELY(!prototype)) {
163 throwVMTypeError(state, throwScope);
164 return false;
165 }
166 // Shadowing a built-in constructor
167 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
168}
169
170static inline JSValue jsCSSImportRuleHrefGetter(ExecState& state, JSCSSImportRule& thisObject, ThrowScope& throwScope)
171{
172 UNUSED_PARAM(throwScope);
173 UNUSED_PARAM(state);
174 auto& impl = thisObject.wrapped();
175 JSValue result = toJS<IDLNullable<IDLDOMString>>(state, throwScope, impl.href());
176 return result;
177}
178
179EncodedJSValue jsCSSImportRuleHref(ExecState* state, EncodedJSValue thisValue, PropertyName)
180{
181 return IDLAttribute<JSCSSImportRule>::get<jsCSSImportRuleHrefGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "href");
182}
183
184static inline JSValue jsCSSImportRuleMediaGetter(ExecState& state, JSCSSImportRule& thisObject, ThrowScope& throwScope)
185{
186 UNUSED_PARAM(throwScope);
187 UNUSED_PARAM(state);
188 auto& impl = thisObject.wrapped();
189 JSValue result = toJS<IDLInterface<MediaList>>(state, *thisObject.globalObject(), throwScope, impl.media());
190 return result;
191}
192
193EncodedJSValue jsCSSImportRuleMedia(ExecState* state, EncodedJSValue thisValue, PropertyName)
194{
195 return IDLAttribute<JSCSSImportRule>::get<jsCSSImportRuleMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media");
196}
197
198static inline JSValue jsCSSImportRuleStyleSheetGetter(ExecState& state, JSCSSImportRule& thisObject, ThrowScope& throwScope)
199{
200 UNUSED_PARAM(throwScope);
201 UNUSED_PARAM(state);
202 auto& impl = thisObject.wrapped();
203 JSValue result = toJS<IDLInterface<CSSStyleSheet>>(state, *thisObject.globalObject(), throwScope, impl.styleSheet());
204 return result;
205}
206
207EncodedJSValue jsCSSImportRuleStyleSheet(ExecState* state, EncodedJSValue thisValue, PropertyName)
208{
209 return IDLAttribute<JSCSSImportRule>::get<jsCSSImportRuleStyleSheetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "styleSheet");
210}
211
212void JSCSSImportRule::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
213{
214 auto* thisObject = jsCast<JSCSSImportRule*>(cell);
215 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
216 if (thisObject->scriptExecutionContext())
217 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
218 Base::heapSnapshot(cell, builder);
219}
220
221
222}
223