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 | |
44 | namespace WebCore { |
45 | using namespace JSC; |
46 | |
47 | // Attributes |
48 | |
49 | JSC::EncodedJSValue jsHTMLStyleElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
50 | bool setJSHTMLStyleElementConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
51 | JSC::EncodedJSValue jsHTMLStyleElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
52 | bool setJSHTMLStyleElementDisabled(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
53 | JSC::EncodedJSValue jsHTMLStyleElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | bool setJSHTMLStyleElementMedia(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
55 | JSC::EncodedJSValue jsHTMLStyleElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
56 | bool setJSHTMLStyleElementType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
57 | JSC::EncodedJSValue jsHTMLStyleElementSheet(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
58 | JSC::EncodedJSValue jsHTMLStyleElementNonce(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | bool setJSHTMLStyleElementNonce(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
60 | |
61 | class JSHTMLStyleElementPrototype : public JSC::JSNonFinalObject { |
62 | public: |
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 | |
77 | private: |
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 | |
86 | using JSHTMLStyleElementConstructor = JSDOMConstructorNotConstructable<JSHTMLStyleElement>; |
87 | |
88 | template<> JSValue JSHTMLStyleElementConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
89 | { |
90 | return JSHTMLElement::getConstructor(vm, &globalObject); |
91 | } |
92 | |
93 | template<> 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 | |
100 | template<> const ClassInfo JSHTMLStyleElementConstructor::s_info = { "HTMLStyleElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElementConstructor) }; |
101 | |
102 | /* Hash table for prototype */ |
103 | |
104 | static 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 | |
114 | const ClassInfo JSHTMLStyleElementPrototype::s_info = { "HTMLStyleElementPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElementPrototype) }; |
115 | |
116 | void JSHTMLStyleElementPrototype::finishCreation(VM& vm) |
117 | { |
118 | Base::finishCreation(vm); |
119 | reifyStaticProperties(vm, JSHTMLStyleElement::info(), JSHTMLStyleElementPrototypeTableValues, *this); |
120 | } |
121 | |
122 | const ClassInfo JSHTMLStyleElement::s_info = { "HTMLStyleElement" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSHTMLStyleElement) }; |
123 | |
124 | JSHTMLStyleElement::JSHTMLStyleElement(Structure* structure, JSDOMGlobalObject& globalObject, Ref<HTMLStyleElement>&& impl) |
125 | : JSHTMLElement(structure, globalObject, WTFMove(impl)) |
126 | { |
127 | } |
128 | |
129 | void JSHTMLStyleElement::finishCreation(VM& vm) |
130 | { |
131 | Base::finishCreation(vm); |
132 | ASSERT(inherits(vm, info())); |
133 | |
134 | } |
135 | |
136 | JSObject* JSHTMLStyleElement::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
137 | { |
138 | return JSHTMLStyleElementPrototype::create(vm, &globalObject, JSHTMLStyleElementPrototype::createStructure(vm, &globalObject, JSHTMLElement::prototype(vm, globalObject))); |
139 | } |
140 | |
141 | JSObject* JSHTMLStyleElement::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
142 | { |
143 | return getDOMPrototype<JSHTMLStyleElement>(vm, globalObject); |
144 | } |
145 | |
146 | JSValue JSHTMLStyleElement::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
147 | { |
148 | return getDOMConstructor<JSHTMLStyleElementConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
149 | } |
150 | |
151 | template<> inline JSHTMLStyleElement* IDLAttribute<JSHTMLStyleElement>::cast(ExecState& state, EncodedJSValue thisValue) |
152 | { |
153 | return jsDynamicCast<JSHTMLStyleElement*>(state.vm(), JSValue::decode(thisValue)); |
154 | } |
155 | |
156 | EncodedJSValue 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 | |
166 | bool 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 | |
179 | static 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 | |
188 | EncodedJSValue jsHTMLStyleElementDisabled(ExecState* state, EncodedJSValue thisValue, PropertyName) |
189 | { |
190 | return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementDisabledGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "disabled" ); |
191 | } |
192 | |
193 | static 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 | |
205 | bool setJSHTMLStyleElementDisabled(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
206 | { |
207 | return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementDisabledSetter>(*state, thisValue, encodedValue, "disabled" ); |
208 | } |
209 | |
210 | static 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 | |
219 | EncodedJSValue jsHTMLStyleElementMedia(ExecState* state, EncodedJSValue thisValue, PropertyName) |
220 | { |
221 | return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementMediaGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "media" ); |
222 | } |
223 | |
224 | static 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 | |
237 | bool setJSHTMLStyleElementMedia(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
238 | { |
239 | return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementMediaSetter>(*state, thisValue, encodedValue, "media" ); |
240 | } |
241 | |
242 | static 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 | |
251 | EncodedJSValue jsHTMLStyleElementType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
252 | { |
253 | return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
254 | } |
255 | |
256 | static 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 | |
269 | bool setJSHTMLStyleElementType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
270 | { |
271 | return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementTypeSetter>(*state, thisValue, encodedValue, "type" ); |
272 | } |
273 | |
274 | static 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 | |
283 | EncodedJSValue jsHTMLStyleElementSheet(ExecState* state, EncodedJSValue thisValue, PropertyName) |
284 | { |
285 | return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementSheetGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "sheet" ); |
286 | } |
287 | |
288 | static 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 | |
297 | EncodedJSValue jsHTMLStyleElementNonce(ExecState* state, EncodedJSValue thisValue, PropertyName) |
298 | { |
299 | return IDLAttribute<JSHTMLStyleElement>::get<jsHTMLStyleElementNonceGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "nonce" ); |
300 | } |
301 | |
302 | static 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 | |
314 | bool setJSHTMLStyleElementNonce(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
315 | { |
316 | return IDLAttribute<JSHTMLStyleElement>::set<setJSHTMLStyleElementNonceSetter>(*state, thisValue, encodedValue, "nonce" ); |
317 | } |
318 | |
319 | void 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 | |