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 "JSHTMLStyleElement.h"
23
24#include "CustomElementReactionQueue.h"
25#include "HTMLNames.h"
26#include "JSDOMAttribute.h"
27#include "JSDOMBinding.h"
28#include "JSDOMConstructorNotConstructable.h"
29#include "JSDOMConvertBoolean.h"
30#include "JSDOMConvertInterface.h"
31#include "JSDOMConvertStrings.h"
32#include "JSDOMExceptionHandling.h"
33#include "JSDOMGlobalObject.h"
34#include "JSDOMWrapperCache.h"
35#include "JSStyleSheet.h"
36#include "ScriptExecutionContext.h"
37#include <JavaScriptCore/HeapSnapshotBuilder.h>
38#include <JavaScriptCore/JSCInlines.h>
39#include <wtf/GetPtr.h>
40#include <wtf/PointerPreparations.h>
41#include <wtf/URL.h>
42
43
44namespace WebCore {
45using namespace JSC;
46
47// Attributes
48
49JSC::EncodedJSValue jsHTMLStyleElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
50bool setJSHTMLStyleElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
51JSC::EncodedJSValue jsHTMLStyleElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
52bool setJSHTMLStyleElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
53JSC::EncodedJSValue jsHTMLStyleElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
54bool setJSHTMLStyleElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
55JSC::EncodedJSValue jsHTMLStyleElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
56bool setJSHTMLStyleElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
57JSC::EncodedJSValue jsHTMLStyleElementSheet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
58JSC::EncodedJSValue jsHTMLStyleElementNonce(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59bool setJSHTMLStyleElementNonce(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60
61class JSHTMLStyleElementPrototype : public JSC::JSNonFinalObject {
62public:
63 using Base = JSC::JSNonFinalObject;
64 static JSHTMLStyleElementPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
65 {
66 JSHTMLStyleElementPrototype* ptr = new (NotNull, JSC::allocateCell<JSHTMLStyleElementPrototype>(vm.heap)) JSHTMLStyleElementPrototype(vm, globalObject, structure);
67 ptr->finishCreation(vm);
68 return ptr;
69 }
70
71 DECLARE_INFO;
72 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
73 {
74 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
75 }
76
77private:
78 JSHTMLStyleElementPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
79 : JSC::JSNonFinalObject(vm, structure)
80 {
81 }
82
83 void finishCreation(JSC::VM&);
84};
85
86using JSHTMLStyleElementConstructor = JSDOMConstructorNotConstructable<JSHTMLStyleElement>;
87
88template<> JSValue JSHTMLStyleElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
89{
90 return JSHTMLElement::getConstructor(vm, &globalObject);
91}
92
93template<> void JSHTMLStyleElementConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
94{
95 putDirect(vm, vm.propertyNames->prototype, JSHTMLStyleElement::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
96 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("HTMLStyleElement"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
97 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
98}
99
100template<> const ClassInfo JSHTMLStyleElementConstructor::s_info = { "HTMLStyleElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElementConstructor) };
101
102/* Hash table for prototype */
103
104static const HashTableValue JSHTMLStyleElementPrototypeTableValues[] =
105{
106 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLStyleElementConstructor) } },
107 { "disabled", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementDisabled), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLStyleElementDisabled) } },
108 { "media", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementMedia), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLStyleElementMedia) } },
109 { "type", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLStyleElementType) } },
110 { "sheet", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementSheet), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
111 { "nonce", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsHTMLStyleElementNonce), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSHTMLStyleElementNonce) } },
112};
113
114const ClassInfo JSHTMLStyleElementPrototype::s_info = { "HTMLStyleElementPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElementPrototype) };
115
116void JSHTMLStyleElementPrototype::finishCreation(VM& vm)
117{
118 Base::finishCreation(vm);
119 reifyStaticProperties(vm, JSHTMLStyleElement::info(), JSHTMLStyleElementPrototypeTableValues, *this);
120}
121
122const ClassInfo JSHTMLStyleElement::s_info = { "HTMLStyleElement", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElement) };
123
124JSHTMLStyleElement::JSHTMLStyleElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLStyleElement>&& impl)
125 : JSHTMLElement(structure, globalObject, WTFMove(impl))
126{
127}
128
129void JSHTMLStyleElement::finishCreation(VM& vm)
130{
131 Base::finishCreation(vm);
132 ASSERT(inherits(vm, info()));
133
134}
135
136JSObject* JSHTMLStyleElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
137{
138 return JSHTMLStyleElementPrototype::create(vm, &globalObject, JSHTMLStyleElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject)));
139}
140
141JSObject* JSHTMLStyleElement::prototype(VM& vm, JSDOMGlobalObject& globalObject)
142{
143 return getDOMPrototype<JSHTMLStyleElement>(vm, globalObject);
144}
145
146JSValue JSHTMLStyleElement::getConstructor(VM& vm, const JSGlobalObject* globalObject)
147{
148 return getDOMConstructor<JSHTMLStyleElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
149}
150
151template<> inline JSHTMLStyleElement* IDLAttribute<JSHTMLStyleElement>::cast(ExecState& state, EncodedJSValue thisValue)
152{
153 return jsDynamicCast<JSHTMLStyleElement*>(state.vm(), JSValue::decode(thisValue));
154}
155
156EncodedJSValue jsHTMLStyleElementConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
157{
158 VM& vm = state->vm();
159 auto throwScope = DECLARE_THROW_SCOPE(vm);
160 auto* prototype = jsDynamicCast<JSHTMLStyleElementPrototype*>(vm, JSValue::decode(thisValue));
161 if (UNLIKELY(!prototype))
162 return throwVMTypeError(state, throwScope);
163 return JSValue::encode(JSHTMLStyleElement::getConstructor(state->vm(), prototype->globalObject()));
164}
165
166bool setJSHTMLStyleElementConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
167{
168 VM& vm = state->vm();
169 auto throwScope = DECLARE_THROW_SCOPE(vm);
170 auto* prototype = jsDynamicCast<JSHTMLStyleElementPrototype*>(vm, JSValue::decode(thisValue));
171 if (UNLIKELY(!prototype)) {
172 throwVMTypeError(state, throwScope);
173 return false;
174 }
175 // Shadowing a built-in constructor
176 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
177}
178
179static inline JSValue jsHTMLStyleElementDisabledGetter(ExecState& state, JSHTMLStyleElement& thisObject, ThrowScope& throwScope)
180{
181 UNUSED_PARAM(throwScope);
182 UNUSED_PARAM(state);
183 auto& impl = thisObject.wrapped();
184 JSValue result = toJS<IDLBoolean>(state, throwScope, impl.disabled());
185 return result;
186}
187
188EncodedJSValue jsHTMLStyleElementDisabled(ExecState* state, EncodedJSValue thisValue, PropertyName)
189{
190 return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementDisabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "disabled");
191}
192
193static inline bool setJSHTMLStyleElementDisabledSetter(ExecState& state, JSHTMLStyleElement& thisObject, JSValue value, ThrowScope& throwScope)
194{
195 UNUSED_PARAM(throwScope);
196 auto& impl = thisObject.wrapped();
197 auto nativeValue = convert<IDLBoolean>(state, value);
198 RETURN_IF_EXCEPTION(throwScope, false);
199 AttributeSetter::call(state, throwScope, [&] {
200 return impl.setDisabled(WTFMove(nativeValue));
201 });
202 return true;
203}
204
205bool setJSHTMLStyleElementDisabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
206{
207 return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementDisabledSetter>(*state, thisValue, encodedValue, "disabled");
208}
209
210static inline JSValue jsHTMLStyleElementMediaGetter(ExecState& state, JSHTMLStyleElement& thisObject, ThrowScope& throwScope)
211{
212 UNUSED_PARAM(throwScope);
213 UNUSED_PARAM(state);
214 auto& impl = thisObject.wrapped();
215 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::mediaAttr));
216 return result;
217}
218
219EncodedJSValue jsHTMLStyleElementMedia(ExecState* state, EncodedJSValue thisValue, PropertyName)
220{
221 return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media");
222}
223
224static inline bool setJSHTMLStyleElementMediaSetter(ExecState& state, JSHTMLStyleElement& thisObject, JSValue value, ThrowScope& throwScope)
225{
226 UNUSED_PARAM(throwScope);
227 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
228 auto& impl = thisObject.wrapped();
229 auto nativeValue = convert<IDLDOMString>(state, value);
230 RETURN_IF_EXCEPTION(throwScope, false);
231 AttributeSetter::call(state, throwScope, [&] {
232 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::mediaAttr, WTFMove(nativeValue));
233 });
234 return true;
235}
236
237bool setJSHTMLStyleElementMedia(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
238{
239 return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementMediaSetter>(*state, thisValue, encodedValue, "media");
240}
241
242static inline JSValue jsHTMLStyleElementTypeGetter(ExecState& state, JSHTMLStyleElement& thisObject, ThrowScope& throwScope)
243{
244 UNUSED_PARAM(throwScope);
245 UNUSED_PARAM(state);
246 auto& impl = thisObject.wrapped();
247 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::typeAttr));
248 return result;
249}
250
251EncodedJSValue jsHTMLStyleElementType(ExecState* state, EncodedJSValue thisValue, PropertyName)
252{
253 return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type");
254}
255
256static inline bool setJSHTMLStyleElementTypeSetter(ExecState& state, JSHTMLStyleElement& thisObject, JSValue value, ThrowScope& throwScope)
257{
258 UNUSED_PARAM(throwScope);
259 CustomElementReactionDisallowedScope customElementReactionDisallowedScope;
260 auto& impl = thisObject.wrapped();
261 auto nativeValue = convert<IDLDOMString>(state, value);
262 RETURN_IF_EXCEPTION(throwScope, false);
263 AttributeSetter::call(state, throwScope, [&] {
264 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::typeAttr, WTFMove(nativeValue));
265 });
266 return true;
267}
268
269bool setJSHTMLStyleElementType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
270{
271 return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementTypeSetter>(*state, thisValue, encodedValue, "type");
272}
273
274static inline JSValue jsHTMLStyleElementSheetGetter(ExecState& state, JSHTMLStyleElement& thisObject, ThrowScope& throwScope)
275{
276 UNUSED_PARAM(throwScope);
277 UNUSED_PARAM(state);
278 auto& impl = thisObject.wrapped();
279 JSValue result = toJS<IDLInterface<StyleSheet>>(state, *thisObject.globalObject(), throwScope, impl.sheet());
280 return result;
281}
282
283EncodedJSValue jsHTMLStyleElementSheet(ExecState* state, EncodedJSValue thisValue, PropertyName)
284{
285 return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementSheetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sheet");
286}
287
288static inline JSValue jsHTMLStyleElementNonceGetter(ExecState& state, JSHTMLStyleElement& thisObject, ThrowScope& throwScope)
289{
290 UNUSED_PARAM(throwScope);
291 UNUSED_PARAM(state);
292 auto& impl = thisObject.wrapped();
293 JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attributeWithoutSynchronization(WebCore::HTMLNames::nonceAttr));
294 return result;
295}
296
297EncodedJSValue jsHTMLStyleElementNonce(ExecState* state, EncodedJSValue thisValue, PropertyName)
298{
299 return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementNonceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "nonce");
300}
301
302static inline bool setJSHTMLStyleElementNonceSetter(ExecState& state, JSHTMLStyleElement& thisObject, JSValue value, ThrowScope& throwScope)
303{
304 UNUSED_PARAM(throwScope);
305 auto& impl = thisObject.wrapped();
306 auto nativeValue = convert<IDLDOMString>(state, value);
307 RETURN_IF_EXCEPTION(throwScope, false);
308 AttributeSetter::call(state, throwScope, [&] {
309 return impl.setAttributeWithoutSynchronization(WebCore::HTMLNames::nonceAttr, WTFMove(nativeValue));
310 });
311 return true;
312}
313
314bool setJSHTMLStyleElementNonce(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
315{
316 return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementNonceSetter>(*state, thisValue, encodedValue, "nonce");
317}
318
319void JSHTMLStyleElement::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
320{
321 auto* thisObject = jsCast<JSHTMLStyleElement*>(cell);
322 builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
323 if (thisObject->scriptExecutionContext())
324 builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
325 Base::heapSnapshot(cell, builder);
326}
327
328
329}
330