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 "JSMutationEvent.h" |
23 | |
24 | #include "JSDOMAttribute.h" |
25 | #include "JSDOMBinding.h" |
26 | #include "JSDOMConstructorNotConstructable.h" |
27 | #include "JSDOMConvertBoolean.h" |
28 | #include "JSDOMConvertInterface.h" |
29 | #include "JSDOMConvertNullable.h" |
30 | #include "JSDOMConvertNumbers.h" |
31 | #include "JSDOMConvertStrings.h" |
32 | #include "JSDOMExceptionHandling.h" |
33 | #include "JSDOMGlobalObject.h" |
34 | #include "JSDOMOperation.h" |
35 | #include "JSDOMWrapperCache.h" |
36 | #include "JSNode.h" |
37 | #include "ScriptExecutionContext.h" |
38 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
39 | #include <JavaScriptCore/JSCInlines.h> |
40 | #include <wtf/GetPtr.h> |
41 | #include <wtf/PointerPreparations.h> |
42 | #include <wtf/URL.h> |
43 | |
44 | |
45 | namespace WebCore { |
46 | using namespace JSC; |
47 | |
48 | // Functions |
49 | |
50 | JSC::EncodedJSValue JSC_HOST_CALL jsMutationEventPrototypeFunctionInitMutationEvent(JSC::ExecState*); |
51 | |
52 | // Attributes |
53 | |
54 | JSC::EncodedJSValue jsMutationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
55 | bool setJSMutationEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
56 | JSC::EncodedJSValue jsMutationEventRelatedNode(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
57 | JSC::EncodedJSValue jsMutationEventPrevValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
58 | JSC::EncodedJSValue jsMutationEventNewValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
59 | JSC::EncodedJSValue jsMutationEventAttrName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
60 | JSC::EncodedJSValue jsMutationEventAttrChange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
61 | |
62 | class JSMutationEventPrototype : public JSC::JSNonFinalObject { |
63 | public: |
64 | using Base = JSC::JSNonFinalObject; |
65 | static JSMutationEventPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
66 | { |
67 | JSMutationEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSMutationEventPrototype>(vm.heap)) JSMutationEventPrototype(vm, globalObject, structure); |
68 | ptr->finishCreation(vm); |
69 | return ptr; |
70 | } |
71 | |
72 | DECLARE_INFO; |
73 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
74 | { |
75 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
76 | } |
77 | |
78 | private: |
79 | JSMutationEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
80 | : JSC::JSNonFinalObject(vm, structure) |
81 | { |
82 | } |
83 | |
84 | void finishCreation(JSC::VM&); |
85 | }; |
86 | |
87 | using JSMutationEventConstructor = JSDOMConstructorNotConstructable<JSMutationEvent>; |
88 | |
89 | /* Hash table for constructor */ |
90 | |
91 | static const HashTableValue JSMutationEventConstructorTableValues[] = |
92 | { |
93 | { "MODIFICATION" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
94 | { "ADDITION" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
95 | { "REMOVAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
96 | }; |
97 | |
98 | static_assert(MutationEvent::MODIFICATION == 1, "MODIFICATION in MutationEvent does not match value from IDL" ); |
99 | static_assert(MutationEvent::ADDITION == 2, "ADDITION in MutationEvent does not match value from IDL" ); |
100 | static_assert(MutationEvent::REMOVAL == 3, "REMOVAL in MutationEvent does not match value from IDL" ); |
101 | |
102 | template<> JSValue JSMutationEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
103 | { |
104 | return JSEvent::getConstructor(vm, &globalObject); |
105 | } |
106 | |
107 | template<> void JSMutationEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
108 | { |
109 | putDirect(vm, vm.propertyNames->prototype, JSMutationEvent::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
110 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("MutationEvent"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
111 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
112 | reifyStaticProperties(vm, JSMutationEvent::info(), JSMutationEventConstructorTableValues, *this); |
113 | } |
114 | |
115 | template<> const ClassInfo JSMutationEventConstructor::s_info = { "MutationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationEventConstructor) }; |
116 | |
117 | /* Hash table for prototype */ |
118 | |
119 | static const HashTableValue JSMutationEventPrototypeTableValues[] = |
120 | { |
121 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMutationEventConstructor) } }, |
122 | { "relatedNode" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventRelatedNode), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
123 | { "prevValue" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventPrevValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
124 | { "newValue" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventNewValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
125 | { "attrName" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
126 | { "attrChange" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMutationEventAttrChange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
127 | { "initMutationEvent" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMutationEventPrototypeFunctionInitMutationEvent), (intptr_t) (0) } }, |
128 | { "MODIFICATION" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
129 | { "ADDITION" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
130 | { "REMOVAL" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
131 | }; |
132 | |
133 | const ClassInfo JSMutationEventPrototype::s_info = { "MutationEventPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationEventPrototype) }; |
134 | |
135 | void JSMutationEventPrototype::finishCreation(VM& vm) |
136 | { |
137 | Base::finishCreation(vm); |
138 | reifyStaticProperties(vm, JSMutationEvent::info(), JSMutationEventPrototypeTableValues, *this); |
139 | } |
140 | |
141 | const ClassInfo JSMutationEvent::s_info = { "MutationEvent" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMutationEvent) }; |
142 | |
143 | JSMutationEvent::JSMutationEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MutationEvent>&& impl) |
144 | : JSEvent(structure, globalObject, WTFMove(impl)) |
145 | { |
146 | } |
147 | |
148 | void JSMutationEvent::finishCreation(VM& vm) |
149 | { |
150 | Base::finishCreation(vm); |
151 | ASSERT(inherits(vm, info())); |
152 | |
153 | } |
154 | |
155 | JSObject* JSMutationEvent::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
156 | { |
157 | return JSMutationEventPrototype::create(vm, &globalObject, JSMutationEventPrototype::createStructure(vm, &globalObject, JSEvent::prototype(vm, globalObject))); |
158 | } |
159 | |
160 | JSObject* JSMutationEvent::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
161 | { |
162 | return getDOMPrototype<JSMutationEvent>(vm, globalObject); |
163 | } |
164 | |
165 | JSValue JSMutationEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
166 | { |
167 | return getDOMConstructor<JSMutationEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
168 | } |
169 | |
170 | template<> inline JSMutationEvent* IDLAttribute<JSMutationEvent>::cast(ExecState& state, EncodedJSValue thisValue) |
171 | { |
172 | return jsDynamicCast<JSMutationEvent*>(state.vm(), JSValue::decode(thisValue)); |
173 | } |
174 | |
175 | template<> inline JSMutationEvent* IDLOperation<JSMutationEvent>::cast(ExecState& state) |
176 | { |
177 | return jsDynamicCast<JSMutationEvent*>(state.vm(), state.thisValue()); |
178 | } |
179 | |
180 | EncodedJSValue jsMutationEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
181 | { |
182 | VM& vm = state->vm(); |
183 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
184 | auto* prototype = jsDynamicCast<JSMutationEventPrototype*>(vm, JSValue::decode(thisValue)); |
185 | if (UNLIKELY(!prototype)) |
186 | return throwVMTypeError(state, throwScope); |
187 | return JSValue::encode(JSMutationEvent::getConstructor(state->vm(), prototype->globalObject())); |
188 | } |
189 | |
190 | bool setJSMutationEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
191 | { |
192 | VM& vm = state->vm(); |
193 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
194 | auto* prototype = jsDynamicCast<JSMutationEventPrototype*>(vm, JSValue::decode(thisValue)); |
195 | if (UNLIKELY(!prototype)) { |
196 | throwVMTypeError(state, throwScope); |
197 | return false; |
198 | } |
199 | // Shadowing a built-in constructor |
200 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
201 | } |
202 | |
203 | static inline JSValue jsMutationEventRelatedNodeGetter(ExecState& state, JSMutationEvent& thisObject, ThrowScope& throwScope) |
204 | { |
205 | UNUSED_PARAM(throwScope); |
206 | UNUSED_PARAM(state); |
207 | auto& impl = thisObject.wrapped(); |
208 | JSValue result = toJS<IDLNullable<IDLInterface<Node>>>(state, *thisObject.globalObject(), throwScope, impl.relatedNode()); |
209 | return result; |
210 | } |
211 | |
212 | EncodedJSValue jsMutationEventRelatedNode(ExecState* state, EncodedJSValue thisValue, PropertyName) |
213 | { |
214 | return IDLAttribute<JSMutationEvent>::get<jsMutationEventRelatedNodeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "relatedNode" ); |
215 | } |
216 | |
217 | static inline JSValue jsMutationEventPrevValueGetter(ExecState& state, JSMutationEvent& thisObject, ThrowScope& throwScope) |
218 | { |
219 | UNUSED_PARAM(throwScope); |
220 | UNUSED_PARAM(state); |
221 | auto& impl = thisObject.wrapped(); |
222 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.prevValue()); |
223 | return result; |
224 | } |
225 | |
226 | EncodedJSValue jsMutationEventPrevValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
227 | { |
228 | return IDLAttribute<JSMutationEvent>::get<jsMutationEventPrevValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "prevValue" ); |
229 | } |
230 | |
231 | static inline JSValue jsMutationEventNewValueGetter(ExecState& state, JSMutationEvent& thisObject, ThrowScope& throwScope) |
232 | { |
233 | UNUSED_PARAM(throwScope); |
234 | UNUSED_PARAM(state); |
235 | auto& impl = thisObject.wrapped(); |
236 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.newValue()); |
237 | return result; |
238 | } |
239 | |
240 | EncodedJSValue jsMutationEventNewValue(ExecState* state, EncodedJSValue thisValue, PropertyName) |
241 | { |
242 | return IDLAttribute<JSMutationEvent>::get<jsMutationEventNewValueGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "newValue" ); |
243 | } |
244 | |
245 | static inline JSValue jsMutationEventAttrNameGetter(ExecState& state, JSMutationEvent& thisObject, ThrowScope& throwScope) |
246 | { |
247 | UNUSED_PARAM(throwScope); |
248 | UNUSED_PARAM(state); |
249 | auto& impl = thisObject.wrapped(); |
250 | JSValue result = toJS<IDLDOMString>(state, throwScope, impl.attrName()); |
251 | return result; |
252 | } |
253 | |
254 | EncodedJSValue jsMutationEventAttrName(ExecState* state, EncodedJSValue thisValue, PropertyName) |
255 | { |
256 | return IDLAttribute<JSMutationEvent>::get<jsMutationEventAttrNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attrName" ); |
257 | } |
258 | |
259 | static inline JSValue jsMutationEventAttrChangeGetter(ExecState& state, JSMutationEvent& thisObject, ThrowScope& throwScope) |
260 | { |
261 | UNUSED_PARAM(throwScope); |
262 | UNUSED_PARAM(state); |
263 | auto& impl = thisObject.wrapped(); |
264 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.attrChange()); |
265 | return result; |
266 | } |
267 | |
268 | EncodedJSValue jsMutationEventAttrChange(ExecState* state, EncodedJSValue thisValue, PropertyName) |
269 | { |
270 | return IDLAttribute<JSMutationEvent>::get<jsMutationEventAttrChangeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "attrChange" ); |
271 | } |
272 | |
273 | static inline JSC::EncodedJSValue jsMutationEventPrototypeFunctionInitMutationEventBody(JSC::ExecState* state, typename IDLOperation<JSMutationEvent>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
274 | { |
275 | UNUSED_PARAM(state); |
276 | UNUSED_PARAM(throwScope); |
277 | auto& impl = castedThis->wrapped(); |
278 | auto type = convert<IDLDOMString>(*state, state->argument(0)); |
279 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
280 | auto canBubble = convert<IDLBoolean>(*state, state->argument(1)); |
281 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
282 | auto cancelable = convert<IDLBoolean>(*state, state->argument(2)); |
283 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
284 | auto relatedNode = convert<IDLNullable<IDLInterface<Node>>>(*state, state->argument(3), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 3, "relatedNode" , "MutationEvent" , "initMutationEvent" , "Node" ); }); |
285 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
286 | auto prevValue = convert<IDLDOMString>(*state, state->argument(4)); |
287 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
288 | auto newValue = convert<IDLDOMString>(*state, state->argument(5)); |
289 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
290 | auto attrName = convert<IDLDOMString>(*state, state->argument(6)); |
291 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
292 | auto attrChange = convert<IDLUnsignedShort>(*state, state->argument(7)); |
293 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
294 | impl.initMutationEvent(WTFMove(type), WTFMove(canBubble), WTFMove(cancelable), WTFMove(relatedNode), WTFMove(prevValue), WTFMove(newValue), WTFMove(attrName), WTFMove(attrChange)); |
295 | return JSValue::encode(jsUndefined()); |
296 | } |
297 | |
298 | EncodedJSValue JSC_HOST_CALL jsMutationEventPrototypeFunctionInitMutationEvent(ExecState* state) |
299 | { |
300 | return IDLOperation<JSMutationEvent>::call<jsMutationEventPrototypeFunctionInitMutationEventBody>(*state, "initMutationEvent" ); |
301 | } |
302 | |
303 | void JSMutationEvent::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
304 | { |
305 | auto* thisObject = jsCast<JSMutationEvent*>(cell); |
306 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
307 | if (thisObject->scriptExecutionContext()) |
308 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
309 | Base::heapSnapshot(cell, builder); |
310 | } |
311 | |
312 | |
313 | } |
314 | |